mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/15564] Use es2015
PHPBB3-15564
This commit is contained in:
parent
760a03fffc
commit
0f3559528a
1 changed files with 19 additions and 27 deletions
|
@ -1650,47 +1650,39 @@ phpbb.lazyLoadAvatars = function loadAvatars() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// reCAPTCHA-related variables
|
const recaptchaForm = $('.g-recaptcha').parents('form');
|
||||||
var recaptcha_form = $('.g-recaptcha').parents('form'),
|
let submitButton = null;
|
||||||
submit_button = null,
|
let programaticallySubmitted = false;
|
||||||
programatically_submitted = false;
|
|
||||||
|
|
||||||
/**
|
phpbb.recaptchaOnLoad = function () {
|
||||||
* Function is called when reCAPTCHA code is loaded
|
|
||||||
*/
|
|
||||||
phpbb.recaptchaOnLoad = function() {
|
|
||||||
console.log('ahoj');
|
console.log('ahoj');
|
||||||
// listen to submit buttons in order to know which one was pressed
|
// Listen to submit buttons in order to know which one was pressed
|
||||||
$('input[type="submit"]').each(function() {
|
$('input[type="submit"]').each(() => {
|
||||||
$(this).on('click', function() {
|
$(this).on('click', () => {
|
||||||
submit_button = this;
|
submitButton = this;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
recaptcha_form.on('submit', function(e) {
|
recaptchaForm.on('submit', e => {
|
||||||
if (!programatically_submitted) {
|
if (!programaticallySubmitted) {
|
||||||
grecaptcha.execute();
|
grecaptcha.execute();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
phpbb.recaptchaOnSubmit = function () {
|
||||||
* Function is called after successful solving of reCAPTCHA
|
programaticallySubmitted = true;
|
||||||
*/
|
// If concrete button was clicked (e.g. preview instead of submit),
|
||||||
phpbb.recaptchaOnSubmit = function() {
|
|
||||||
console.log('submit');
|
|
||||||
programatically_submitted = true;
|
|
||||||
// if concrete button was clicked (e.g. preview instead of submit),
|
|
||||||
// let's trigger the same action
|
// let's trigger the same action
|
||||||
if (submit_button) {
|
if (submitButton) {
|
||||||
submit_button.click();
|
submitButton.click();
|
||||||
} else {
|
} else {
|
||||||
// rename input[name="submit"] so that we can submit the form
|
// Rename input[name="submit"] so that we can submit the form
|
||||||
if (typeof recaptcha_form.submit !== 'function') {
|
if (typeof recaptchaForm.submit !== 'function') {
|
||||||
recaptcha_form.submit.name = 'submit_btn';
|
recaptchaForm.submit.name = 'submit_btn';
|
||||||
}
|
}
|
||||||
recaptcha_form.submit();
|
recaptchaForm.submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue