1$(document).ready(function(){ 2 $('.mx_form input[type=radio][value="-1"], .mx_form input[type=checkbox][value="-1"]').each(function(){ 3 // Change 4 $(this).change(function(){ 5 if($(this).is(':checked')){ 6 $(this).parents('.mx_form_input_option').find('.mx_form_input_other').show(); 7 }else{ 8 $(this).parents('.mx_form_input_option').find('.mx_form_input_other').hide(); 9 } 10 }); 11 12 // Load 13 if($(this).is(':checked')){ 14 $(this).parents('.mx_form_input_option').find('.mx_form_input_other').show(); 15 }else{ 16 $(this).parents('.mx_form_input_option').find('.mx_form_input_other').hide(); 17 } 18 }); 19 20 $('.mx_form input[type=radio][value!="-1"]').each(function(){ 21 // Change 22 $(this).change(function(){ 23 if($(this).is(':checked')){ 24 $(this).parents('.mx_form_row').find('.mx_form_input_other').hide(); 25 }else{ 26 $(this).parents('.mx_form_row').find('.mx_form_input_other').show(); 27 } 28 }); 29 }); 30 31 $('.mx_form .mx_newsletter').each(function(){ 32 if ($(this).is(':checked')) { 33 if ($(this).val() == 1) { 34 $('.mx_form .mx_newsletter_other').show(); 35 } else { 36 $('.mx_form .mx_newsletter_other').hide(); 37 } 38 } 39 40 // Change 41 $(this).change(function(){ 42 if($(this).val() == 1){ 43 $('.mx_form .mx_newsletter_other').show(); 44 }else{ 45 $('.mx_form .mx_newsletter_other').hide(); 46 } 47 }); 48 }); 49}); 50 51var mxformCallback = function() { 52 var c = 0; 53 $('head meta[name^=mx_]').each(function(){ 54 var _captchaForm=$("#"+$(this).attr('name') + " form"), _formName=$(this).attr('name'),_captchaKey=$(this).attr('content'); 55 grecaptcha.execute(_captchaKey, {action: _formName}).then(function(token) { 56 $(_captchaForm).prepend('<input type="hidden" name="g-recaptcha-response" value="' + token + '">'); 57 }); 58 59 setInterval(function () { 60 if (c < 5) { 61 grecaptcha.ready(function () { 62 grecaptcha.execute(_captchaKey, { action: _formName }).then(function (e) { 63 $('input[name=g-recaptcha-response').val(e); 64 }); 65 }); 66 } else { 67 alert('form has expired!'); 68 location.reload(); 69 } 70 c++; 71 }, 90 * 1000); 72 }); 73}; 74 75document.addEventListener('DOMContentLoaded', function() { 76 const forms = document.querySelectorAll('form.mx_form'); 77 forms.forEach(function(form, index) { 78 // Make the class name unique by appending the index 79 const newid = form.className + '_' + index; 80 form.setAttribute('id', newid); 81 82 // Extract the mx_form number from the form action 83 const action = form.getAttribute('action'); 84 const mxFormMatch = action.match(/mx_form=(\d+)/); 85 86 if (!mxFormMatch) { 87 console.warn(`No mx_form number found in the form action: ${action}`); 88 return; 89 } 90 91 const formNumber = mxFormMatch[1]; 92 const metaElement = document.querySelector(`meta[name="mx_form_${formNumber}"]`); 93 94 if (!metaElement) { 95 console.warn(`No meta element found for mx_form_${formNumber}`); 96 return; 97 } 98 99 const captchaKey = metaElement.getAttribute('content'); 100 if (!captchaKey) { 101 console.warn(`No captcha key found for mx_form_${formNumber}`); 102 return; 103 } 104 105 // No need to use querySelector here since we already have the form element 106 form.addEventListener('submit', function(e) { 107 e.preventDefault(); 108 109 // Update selector to find either input[type="submit"] or button[type="submit"] 110 const submitButton = form.querySelector('button[type="submit"], input[type="submit"]'); 111 if (!submitButton) { 112 console.warn('No submit button found in form'); 113 return; 114 } 115 submitButton.disabled = true; 116 117 // Generate reCAPTCHA token 118 grecaptcha.ready(function() { 119 grecaptcha.execute(captchaKey, { action: `mx_form_${formNumber}` }) 120 .then(function(token) { 121 // Remove any existing token and add new one 122 const existingRecaptchaInput = form.querySelector('input[name="g-recaptcha-response"]'); 123 if (existingRecaptchaInput) { 124 existingRecaptchaInput.remove(); 125 } 126 const hiddenInput = document.createElement('input'); 127 hiddenInput.type = 'hidden'; 128 hiddenInput.name = 'g-recaptcha-response'; 129 hiddenInput.value = token; 130 form.prepend(hiddenInput); 131 132 // Submit the form using native submit 133 HTMLFormElement.prototype.submit.call(form); 134 }) 135 .catch(function(error) { 136 console.error('reCAPTCHA token generation failed:', error); 137 submitButton.disabled = false;
138 }); 139 }); 140 }); 141 }); 142});
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.