phpBB

Code Changes

File: assets/javascript/core.js

  Unmodified   Added   Modified   Removed
Line 948Line 948
	var minutes = offset % 60;
var hours = (offset - minutes) / 60;


	var minutes = offset % 60;
var hours = (offset - minutes) / 60;


	if (hours < 10) {




	if (hours === 0) {
hours = '00';
sign = '+';
} else if (hours < 10) {

		hours = '0' + hours.toString();
} else {
hours = hours.toString();

		hours = '0' + hours.toString();
} else {
hours = hours.toString();

Line 1745Line 1748
	});
};


	});
};


var recaptchaForm = $('.g-recaptcha').parents('form');
var submitButton = null;
var programaticallySubmitted = false;

phpbb.recaptcha = {
button: null,
ready: false,





phpbb.recaptchaOnLoad = function () {
// Listen to submit buttons in order to know which one was pressed
$('input[type="submit"]').each(function () {
$(this).on('click', function () {
submitButton = this;
});








	token: $('input[name="recaptcha_token"]'),
form: $('.g-recaptcha').parents('form'),
v3: $('[data-recaptcha-v3]'),

load: function() {
phpbb.recaptcha.bindButton();
phpbb.recaptcha.bindForm();
},
bindButton: function() {
phpbb.recaptcha.form.find('input[type="submit"]').on('click', function() {
// Listen to all the submit buttons for the form that has reCAPTCHA protection,
// and store it so we can click the exact same button later on when we are ready.
phpbb.recaptcha.button = this;

	});

	});

 
	},
bindForm: function() {
phpbb.recaptcha.form.on('submit', function(e) {
// If ready is false, it means the user pressed a submit button.
// And the form was not submitted by us, after the token was loaded.
if (!phpbb.recaptcha.ready) {
// If version 3 is used, we need to make a different execution,
// including the action and the site key.
if (phpbb.recaptcha.v3.length) {
grecaptcha.execute(
phpbb.recaptcha.v3.data('recaptcha-v3'),
{action: phpbb.recaptcha.v3.val()}
).then(function(token) {
// Place the token inside the form
phpbb.recaptcha.token.val(token);





	recaptchaForm.on('submit', function (e) {
if (!programaticallySubmitted) {




						// And now we submit the form.
phpbb.recaptcha.submitForm();
});
} else {
// Regular version 2 execution

			grecaptcha.execute();

			grecaptcha.execute();

 
				}

// Do not submit the form

			e.preventDefault();
}
});

			e.preventDefault();
}
});

}





	},
submitForm: function() {
// Now we are ready, so set it to true.
// so the 'submit' event doesn't run multiple times.
phpbb.recaptcha.ready = true;





phpbb.recaptchaOnSubmit = function () {
programaticallySubmitted = true;
// If concrete button was clicked (e.g. preview instead of submit),
// let's trigger the same action
if (submitButton) {
submitButton.click();

		if (phpbb.recaptcha.button) {
// If there was a specific button pressed initially, trigger the same button
phpbb.recaptcha.button.click();




	} else {

	} else {

 
			if (typeof phpbb.recaptcha.form.submit !== 'function') {

		// Rename input[name="submit"] so that we can submit the form

		// Rename input[name="submit"] so that we can submit the form

		if (typeof recaptchaForm.submit !== 'function') {
recaptchaForm.submit.name = 'submit_btn';

				phpbb.recaptcha.form.submit.name = 'submit_btn';


		}

		}

		recaptchaForm.submit();



phpbb.recaptcha.form.submit();

	}
}

	}
}

 
};





// reCAPTCHA doesn't accept callback functions nested inside objects

// reCAPTCHA v2 doesn't accept callback functions nested inside objects

// so we need to make this helper functions here
window.phpbbRecaptchaOnLoad = function() {

// so we need to make this helper functions here
window.phpbbRecaptchaOnLoad = function() {

	phpbb.recaptchaOnLoad();
}


	phpbb.recaptcha.load();
};


window.phpbbRecaptchaOnSubmit = function() {

window.phpbbRecaptchaOnSubmit = function() {

	phpbb.recaptchaOnSubmit();
}

	phpbb.recaptcha.submitForm();
};


$(window).on('load', phpbb.lazyLoadAvatars);



$(window).on('load', phpbb.lazyLoadAvatars);


Line 1795Line 1830
* Apply code editor to all textarea elements with data-bbcode attribute
*/
$(function() {

* Apply code editor to all textarea elements with data-bbcode attribute
*/
$(function() {

 
	// reCAPTCHA v3 needs to be initialized
if (phpbb.recaptcha.v3.length) {
phpbb.recaptcha.load();
}


	$('textarea[data-bbcode]').each(function() {
phpbb.applyCodeEditor(this);
});

	$('textarea[data-bbcode]').each(function() {
phpbb.applyCodeEditor(this);
});