forked from leftypol/leftypol
main.js: use unified captcha-response
This commit is contained in:
parent
2319a7b74e
commit
93e37b0c42
1 changed files with 9 additions and 3 deletions
|
@ -273,8 +273,9 @@ var captcha_renderer = null;
|
|||
function onCaptchaLoadHcaptcha() {
|
||||
if (captcha_renderer === null && (active_page === 'index' || active_page === 'catalog' || active_page === 'thread')) {
|
||||
let renderer = {
|
||||
renderOn: (container) => hcaptcha.render(container, {
|
||||
applyOn: (container, params) => hcaptcha.render(container, {
|
||||
sitekey: "{{ config.hcaptcha_public }}",
|
||||
callback: params['on-success'],
|
||||
}),
|
||||
remove: (widgetId) => { /* Not supported */ },
|
||||
reset: (widgetId) => hcaptcha.reset(widgetId)
|
||||
|
@ -300,10 +301,11 @@ window.onCaptchaLoadTurnstile_post_thread = function() {
|
|||
function onCaptchaLoadTurnstile(action) {
|
||||
if (captcha_renderer === null && (active_page === 'index' || active_page === 'catalog' || active_page === 'thread')) {
|
||||
let renderer = {
|
||||
renderOn: function(container) {
|
||||
applyOn: function(container, params) {
|
||||
let widgetId = turnstile.render('#' + container, {
|
||||
sitekey: "{{ config.turnstile_public }}",
|
||||
action: action,
|
||||
callback: params['on-success'],
|
||||
});
|
||||
if (widgetId === undefined) {
|
||||
return null;
|
||||
|
@ -322,7 +324,11 @@ function onCaptchaLoadTurnstile(action) {
|
|||
function onCaptchaLoad(renderer) {
|
||||
captcha_renderer = renderer;
|
||||
|
||||
let widgetId = renderer.renderOn('captcha-container');
|
||||
let widgetId = renderer.applyOn('captcha-container', {
|
||||
'on-success': function(token) {
|
||||
document.getElementById('captcha-response').value = token;
|
||||
}
|
||||
});
|
||||
if (widgetId === null) {
|
||||
console.error('Could not render captcha!');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue