1//var mxformCallback = function() { 2// $('head meta[name^=mx_]').each(function(){ 3// var _captchaForm=$("#"+$(this).attr('name') + " form"), _formName=$(this).attr('name'),_captchaKey=$(this).attr('content'),_captchaSubmit,_execute=true; 4// grecaptcha.execute(_captchaKey, {action: _formName}).then(function(token) { 5// $(_captchaForm).prepend('<input type="hidden" name="g-recaptcha-response" value="' + token + '">'); 6// }); 7// }); 8//}; 9 10document.addEventListener('DOMContentLoaded', function() { 11 // Find all meta tags for reCAPTCHA enabled forms 12 const metaTags = document.querySelectorAll('meta[name^="mx_contact_"]'); 13 metaTags.forEach(function(metaTag, index) { 14 const formNumber = 1; 15 const formSelector = `form[action*="mx_contact_form=${formNumber}"]`; 16 17 // Check if form with this selector exists 18 const form = document.querySelector(formSelector); 19 if (!form) { 20 console.warn(`No form found with action containing "mx_contact_form=${formNumber}"`); 21 return; 22 } 23 24 // Make the class name unique by appending the index 25 const newid = form.className + '_' + index; 26 form.setAttribute('id', newid); 27 28 // Attach handler only to forms that need reCAPTCHA 29 document.querySelector(`#${newid}`).addEventListener('submit', function(e) { 30 e.preventDefault(); 31 const captchaKey = document.querySelector(`meta[name="mx_contact_form"]`).getAttribute('content'); 32 33 if (!captchaKey) { 34 console.error(`No reCAPTCHA key found for form ${formNumber}`); 35 return; 36 } 37 38 // Disable submit button while processing 39 const submitButton = form.querySelector('input[type="submit"]'); 40 submitButton.disabled = true; 41 42 // Generate new token 43 grecaptcha.ready(function() { 44 grecaptcha.execute(captchaKey, { action: `mx_contact_form_${formNumber}` }) 45 .then(function(token) { 46 // Remove any existing token and add new one 47 const existingRecaptchaInput = form.querySelector('input[name="g-recaptcha-response"]'); 48 if (existingRecaptchaInput) { 49 existingRecaptchaInput.remove(); 50 } 51 52 const hiddenInput = document.createElement('input'); 53 hiddenInput.type = 'hidden'; 54 hiddenInput.name = 'g-recaptcha-response'; 55 hiddenInput.value = token; 56 form.prepend(hiddenInput); 57 58 // Submit the form using native submit 59 HTMLFormElement.prototype.submit.call(form); 60 }) 61 .catch(function(error) { 62 console.error('reCAPTCHA token generation failed:', error); 63 submitButton.disabled = false; 64 }); 65 }); 66 }); 67 }); 68});
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.