main.js: use new config style

This commit is contained in:
Zankaria 2025-02-08 18:15:07 +01:00
parent 4eb12479ec
commit a70b6e6ec9

View file

@ -243,13 +243,13 @@ function getCookie(cookie_name) {
{% endraw %} {% endraw %}
/* BEGIN CAPTCHA REGION */ /* BEGIN CAPTCHA REGION */
{% if config.hcaptcha or config.turnstile %} // If any captcha {% if config.captcha.mode == 'hcaptcha' or config.captcha.mode == 'turnstile' %} // If any captcha
// Global captcha object. Assigned by `onCaptchaLoad()`. // Global captcha object. Assigned by `onCaptchaLoad()`.
var captcha_renderer = null; var captcha_renderer = null;
// Captcha widget id of the post form. // Captcha widget id of the post form.
var postCaptchaId = null; var postCaptchaId = null;
{% if config.hcaptcha %} // If hcaptcha {% if config.captcha.mode == 'hcaptcha' %} // If hcaptcha
function onCaptchaLoadHcaptcha() { function onCaptchaLoadHcaptcha() {
if (captcha_renderer === null && (active_page === 'index' || active_page === 'catalog' || active_page === 'thread')) { if (captcha_renderer === null && (active_page === 'index' || active_page === 'catalog' || active_page === 'thread')) {
let renderer = { let renderer = {
@ -257,7 +257,7 @@ function onCaptchaLoadHcaptcha() {
* @returns {object} Opaque widget id. * @returns {object} Opaque widget id.
*/ */
applyOn: (container, params) => hcaptcha.render(container, { applyOn: (container, params) => hcaptcha.render(container, {
sitekey: "{{ config.hcaptcha_public }}", sitekey: "{{ config.captcha.hcaptcha.public }}",
callback: params['on-success'], callback: params['on-success'],
}), }),
/** /**
@ -282,7 +282,7 @@ function onCaptchaLoadHcaptcha() {
} }
} }
{% endif %} // End if hcaptcha {% endif %} // End if hcaptcha
{% if config.turnstile %} // If turnstile {% if config.captcha.mode == 'turnstile' %} // If turnstile
// Wrapper function to be called from thread.html // Wrapper function to be called from thread.html
window.onCaptchaLoadTurnstile_post_reply = function() { window.onCaptchaLoadTurnstile_post_reply = function() {
@ -303,7 +303,7 @@ function onCaptchaLoadTurnstile(action) {
*/ */
applyOn: function(container, params) { applyOn: function(container, params) {
let widgetId = turnstile.render('#' + container, { let widgetId = turnstile.render('#' + container, {
sitekey: "{{ config.turnstile_public }}", sitekey: "{{ config.captcha.turnstile.public }}",
action: action, action: action,
callback: params['on-success'], callback: params['on-success'],
}); });