Skip to content
Snippets Groups Projects
Commit d627e73b authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Formalize grecaptcha checks.

parent c4d44be3
No related merge requests found
......@@ -163,7 +163,7 @@ function phoneNumberFormHandler(numID, regionCode) {
// Setup captchas after Google script loads
function recaptchaOnLoad() {
if (grecaptcha) {
if (typeof grecaptcha !== 'undefined') {
var captchas = $('.g-recaptcha:empty');
for (var i = 0; i < captchas.length; i++) {
captchas[i].dataset.captchaId = grecaptcha.render(captchas[i], captchas[i].dataset);
......
......@@ -226,7 +226,7 @@ VuFind.register('lightbox', function Lightbox() {
var form = event.target;
var data = $(form).serializeArray();
// Check for recaptcha
if (grecaptcha) {
if (typeof grecaptcha !== 'undefined') {
var recaptcha = $(form).find('.g-recaptcha');
if (recaptcha.length > 0) {
data.push({ name: 'g-recaptcha-response', value: grecaptcha.getResponse(recaptcha.data('captchaId')) });
......@@ -277,7 +277,7 @@ VuFind.register('lightbox', function Lightbox() {
method: $(form).attr('method') || 'GET',
data: data
}).done(function recaptchaReset() {
if (grecaptcha) {
if (typeof grecaptcha !== 'undefined') {
grecaptcha.reset($(form).find('.g-recaptcha').data('captchaId'));
}
});
......
......@@ -96,7 +96,7 @@ function registerAjaxCommentRecord() {
id: id,
source: recordSource
};
if (grecaptcha) {
if (typeof grecaptcha !== 'undefined') {
var recaptcha = $(form).find('.g-recaptcha');
if (recaptcha.length > 0) {
data['g-recaptcha-response'] = grecaptcha.getResponse(recaptcha.data('captchaId'));
......@@ -113,7 +113,7 @@ function registerAjaxCommentRecord() {
refreshCommentList($tab, id, recordSource);
$(form).find('textarea[name="comment"]').val('');
$(form).find('input[type="submit"]').button('loading');
if (grecaptcha) {
if (typeof grecaptcha !== 'undefined') {
grecaptcha.reset($(form).find('.g-recaptcha').data('captchaId'));
}
})
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment