forked from leftypol/leftypol
Reviewed-on: https://git.leftypol.org/leftypol/leftypol/pulls/165
This commit is contained in:
parent
17f92344e9
commit
eb6649b260
1 changed files with 27 additions and 0 deletions
|
@ -243,7 +243,13 @@ function getCookie(cookie_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
/* BEGIN CAPTCHA REGION */
|
||||||
|
|
||||||
{% if config.turnstile %}
|
{% if config.turnstile %}
|
||||||
|
// Global captcha object. Assigned by `onCaptchaLoad()`.
|
||||||
|
var captcha_renderer = null;
|
||||||
|
|
||||||
// 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() {
|
||||||
onCaptchaLoadTurnstile('post-reply');
|
onCaptchaLoadTurnstile('post-reply');
|
||||||
|
@ -277,9 +283,25 @@ function onCaptchaLoadTurnstile(action) {
|
||||||
|
|
||||||
onCaptchaLoad(renderer);
|
onCaptchaLoad(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initCaptchaImpl() {
|
||||||
|
/*
|
||||||
|
* Turnstile is set but the captcha_renderer is null? Turnstile loaded before main.js could set up the callbacks.
|
||||||
|
* Init now.
|
||||||
|
*/
|
||||||
|
if (turnstile && captcha_renderer === null) {
|
||||||
|
if (active_page === 'index' || active_page === 'catalog') {
|
||||||
|
onCaptchaLoadTurnstile('post-thread');
|
||||||
|
} else if (active_page === 'thread') {
|
||||||
|
onCaptchaLoadTurnstile('post-reply');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
function onCaptchaLoad(renderer) {
|
function onCaptchaLoad(renderer) {
|
||||||
|
captcha_renderer = renderer;
|
||||||
|
|
||||||
let widgetId = renderer.renderOn('#captcha-container');
|
let widgetId = renderer.renderOn('#captcha-container');
|
||||||
if (widgetId === null) {
|
if (widgetId === null) {
|
||||||
console.error('Could not render captcha!');
|
console.error('Could not render captcha!');
|
||||||
|
@ -300,11 +322,16 @@ function initDynamicCaptcha() {
|
||||||
if (isDynamicCaptchaEnabled()) {
|
if (isDynamicCaptchaEnabled()) {
|
||||||
let captcha_hook = document.getElementById('captcha');
|
let captcha_hook = document.getElementById('captcha');
|
||||||
captcha_hook.style = "";
|
captcha_hook.style = "";
|
||||||
|
initCaptchaImpl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
// No-op for `init()`.
|
||||||
function initDynamicCaptcha() {}
|
function initDynamicCaptcha() {}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
/* END CAPTCHA REGION */
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
function highlightReply(id) {
|
function highlightReply(id) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue