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 %}
|
||||
|
||||
/* BEGIN CAPTCHA REGION */
|
||||
|
||||
{% if config.turnstile %}
|
||||
// Global captcha object. Assigned by `onCaptchaLoad()`.
|
||||
var captcha_renderer = null;
|
||||
|
||||
// Wrapper function to be called from thread.html
|
||||
window.onCaptchaLoadTurnstile_post_reply = function() {
|
||||
onCaptchaLoadTurnstile('post-reply');
|
||||
|
@ -277,9 +283,25 @@ function onCaptchaLoadTurnstile(action) {
|
|||
|
||||
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 %}
|
||||
|
||||
function onCaptchaLoad(renderer) {
|
||||
captcha_renderer = renderer;
|
||||
|
||||
let widgetId = renderer.renderOn('#captcha-container');
|
||||
if (widgetId === null) {
|
||||
console.error('Could not render captcha!');
|
||||
|
@ -300,11 +322,16 @@ function initDynamicCaptcha() {
|
|||
if (isDynamicCaptchaEnabled()) {
|
||||
let captcha_hook = document.getElementById('captcha');
|
||||
captcha_hook.style = "";
|
||||
initCaptchaImpl();
|
||||
}
|
||||
}
|
||||
{% else %}
|
||||
// No-op for `init()`.
|
||||
function initDynamicCaptcha() {}
|
||||
{% endif %}
|
||||
|
||||
/* END CAPTCHA REGION */
|
||||
|
||||
{% raw %}
|
||||
|
||||
function highlightReply(id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue