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
|
{% if config.dynamic_captcha %} // If dynamic captcha
|
||||||
|
var captchaMode = 'dynamic';
|
||||||
|
|
||||||
function isDynamicCaptchaEnabled() {
|
function isDynamicCaptchaEnabled() {
|
||||||
let cookie = getCookie('captcha-required');
|
let cookie = getCookie('captcha-required');
|
||||||
return cookie === '1';
|
return cookie === '1';
|
||||||
|
@ -370,8 +372,15 @@ function initCaptcha() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{% else %}
|
||||||
|
var captchaMode = 'static';
|
||||||
{% endif %} // End if dynamic captcha
|
{% endif %} // End if dynamic captcha
|
||||||
{% else %} // Else if any captcha
|
{% else %} // Else if any captcha
|
||||||
|
var captchaMode = 'none';
|
||||||
|
|
||||||
|
function isDynamicCaptchaEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// No-op for `init()`.
|
// No-op for `init()`.
|
||||||
function initCaptcha() {}
|
function initCaptcha() {}
|
||||||
{% endif %} // End if any captcha
|
{% endif %} // End if any captcha
|
||||||
|
@ -427,9 +436,11 @@ function doPost(form) {
|
||||||
saved[document.location] = form.elements['body'].value;
|
saved[document.location] = form.elements['body'].value;
|
||||||
sessionStorage.body = JSON.stringify(saved);
|
sessionStorage.body = JSON.stringify(saved);
|
||||||
|
|
||||||
if (captcha_renderer && postCaptchaId && !captcha_renderer.hasResponse(postCaptchaId)) {
|
if (captchaMode === 'static' || (captchaMode === 'dynamic' && isDynamicCaptchaEnabled())) {
|
||||||
captcha_renderer.execute(postCaptchaId);
|
if (captcha_renderer && postCaptchaId && !captcha_renderer.hasResponse(postCaptchaId)) {
|
||||||
return false;
|
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.
|
// 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