forked from leftypol/leftypol
main.js: store captcha mode
This commit is contained in:
parent
d48ba6113a
commit
262e8971bd
1 changed files with 14 additions and 3 deletions
|
@ -357,6 +357,8 @@ function onCaptchaLoad(renderer) {
|
|||
}
|
||||
|
||||
{% if config.dynamic_captcha %} // If dynamic captcha
|
||||
var captchaMode = 'dynamic';
|
||||
|
||||
function isDynamicCaptchaEnabled() {
|
||||
let cookie = getCookie('captcha-required');
|
||||
return cookie === '1';
|
||||
|
@ -370,8 +372,15 @@ function initCaptcha() {
|
|||
}
|
||||
}
|
||||
}
|
||||
{% else %}
|
||||
var captchaMode = 'static';
|
||||
{% endif %} // End if dynamic captcha
|
||||
{% else %} // Else if any captcha
|
||||
var captchaMode = 'none';
|
||||
|
||||
function isDynamicCaptchaEnabled() {
|
||||
return false;
|
||||
}
|
||||
// No-op for `init()`.
|
||||
function initCaptcha() {}
|
||||
{% endif %} // End if any captcha
|
||||
|
@ -427,9 +436,11 @@ function doPost(form) {
|
|||
saved[document.location] = form.elements['body'].value;
|
||||
sessionStorage.body = JSON.stringify(saved);
|
||||
|
||||
if (captcha_renderer && postCaptchaId && !captcha_renderer.hasResponse(postCaptchaId)) {
|
||||
captcha_renderer.execute(postCaptchaId);
|
||||
return false;
|
||||
if (captchaMode === 'static' || (captchaMode === 'dynamic' && isDynamicCaptchaEnabled())) {
|
||||
if (captcha_renderer && postCaptchaId && !captcha_renderer.hasResponse(postCaptchaId)) {
|
||||
captcha_renderer.execute(postCaptchaId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Needs to be delayed by at least 1 frame, otherwise it may reset the form (read captcha) fields before they're sent.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue