forked from leftypol/leftypol
Add dynamic captcha support
This commit is contained in:
parent
81f5c70681
commit
483d553fc0
4 changed files with 60 additions and 7 deletions
|
@ -238,6 +238,36 @@ function get_cookie(cookie_name) {
|
|||
return null;
|
||||
}
|
||||
|
||||
{% endraw %}
|
||||
{% if config.dynamic_captcha %}
|
||||
function is_dynamic_captcha_enabled() {
|
||||
let cookie = get_cookie('require-captcha');
|
||||
return cookie === '1';
|
||||
}
|
||||
|
||||
function get_captcha_pub_key() {
|
||||
{% if config.recaptcha %}
|
||||
return "{{ config.recaptcha_public }}";
|
||||
{% else %}
|
||||
return null;
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
function init_dynamic_captcha() {
|
||||
if (!is_dynamic_captcha_enabled()) {
|
||||
let pub_key = get_captcha_pub_key();
|
||||
if (!pub_key) {
|
||||
console.error("Missing public captcha key!");
|
||||
return;
|
||||
}
|
||||
|
||||
let captcha_hook = document.getElementById('captcha');
|
||||
captcha_hook.style = "";
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
{% raw %}
|
||||
|
||||
function highlightReply(id) {
|
||||
if (typeof window.event != "undefined" && event.which == 2) {
|
||||
// don't highlight on middle click
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue