main.js: unfuck dynamic captcha support

This commit is contained in:
Zankaria 2024-07-29 21:24:14 +02:00
parent 8f98665a1c
commit 6097849ea2

View file

@ -231,7 +231,7 @@ function init_stylechooser() {
} }
function get_cookie(cookie_name) { function get_cookie(cookie_name) {
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
if (results) if (results)
return (unescape(results[2])); return (unescape(results[2]));
else else
@ -241,7 +241,7 @@ function get_cookie(cookie_name) {
{% endraw %} {% endraw %}
{% if config.dynamic_captcha %} {% if config.dynamic_captcha %}
function is_dynamic_captcha_enabled() { function is_dynamic_captcha_enabled() {
let cookie = get_cookie('require-captcha'); let cookie = get_cookie('captcha-required');
return cookie === '1'; return cookie === '1';
} }
@ -254,7 +254,7 @@ function get_captcha_pub_key() {
} }
function init_dynamic_captcha() { function init_dynamic_captcha() {
if (!is_dynamic_captcha_enabled()) { if (is_dynamic_captcha_enabled()) {
let pub_key = get_captcha_pub_key(); let pub_key = get_captcha_pub_key();
if (!pub_key) { if (!pub_key) {
console.error("Missing public captcha key!"); console.error("Missing public captcha key!");
@ -265,6 +265,8 @@ function init_dynamic_captcha() {
captcha_hook.style = ""; captcha_hook.style = "";
} }
} }
{% else %}
function init_dynamic_captcha() {}
{% endif %} {% endif %}
{% raw %} {% raw %}
@ -420,6 +422,7 @@ var script_settings = function(script_name) {
function init() { function init() {
init_stylechooser(); init_stylechooser();
init_dynamic_captcha();
{% endraw %} {% endraw %}
{% if config.allow_delete %} {% if config.allow_delete %}