1/** 2 * Client-side functionality for recaptcha forms. 3 * 4 * @author Rutger Speksnijder 5 */ 6 (function(window) { 7 // Constructor 8 var RecaptchaForm = function() {}; 9 10 RecaptchaForm.siteKey = ''; 11 12 /** 13 * Submits a recaptcha form. 14 * @param {Event} event 15 * @param {HTMLFormElement} form 16 * @returns {void} 17 */ 18 RecaptchaForm.submit = function(event, form) { 19 // Prevent default behaviour 20 event.preventDefault(); 21 22 // Check if the form is valid 23 var validator = $(form).validate(window.validationRules); 24 if (!validator.form()) { 25 return; 26 } 27 28 // Wait until recaptcha is ready 29 grecaptcha.ready(function() { 30 grecaptcha.execute(RecaptchaForm.siteKey, {action: 'submit'}).then(function(token) { 31 $(form).find('input[name="recaptcha-token"]').val(token); 32 form.submit(); 33 }).catch(function() { 34 form.submit(); 35 }); 36 }); 37 }; 38 39 // Expose to the window 40 window.RecaptchaForm = RecaptchaForm; 41})(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.