1document.addEventListener("DOMContentLoaded", () => { 2 const formSubmission = document.getElementById("newsletter"); 3 const submitBtn = document.querySelector("form .newsletter-btn"); 4 const email = document.getElementById('email'); 5 6 const inputFields = [email]; 7 8 let shouldValidate = false; 9 let isFormValid = false; 10 11 function resetElm(elm) { 12 elm.classList.remove("invalid-input"); 13 } 14 15 function invalidateElm(elm) { 16 elm.classList.add("invalid-input"); 17 } 18 19 const validateInputs = () => { 20 isFormValid = true; 21 resetElm(email); 22 23 if (!email.value || email.value.indexOf("@") == -1 || email.value.length < 5) { 24 isFormValid = false; 25 invalidateElm(email); 26 } 27 }; 28 29 function showThankYouMessage() { 30 if (formSubmission) { 31 formSubmission.innerHTML = "<h4 class='submitted-message'>Thank you!</h4>"; 32 } 33 } 34 35 function handleSubmit(e) { 36 e.preventDefault(); 37 38 if (submitBtn) { 39 submitBtn.disabled = true; 40 } 41 42 const formData = new FormData(); 43 formData.append( 44 'email', 45 `${email.value === "" ? "n/a" : email.value}` 46 ); 47 48 formData.append( 49 'subscriptions', 50 'all' 51 ); 52 53 54 showThankYouMessage(); 55 56 57 try { 58 if (typeof grecaptcha !== 'undefined') { 59 grecaptcha.ready(function() { 60 try { 61 grecaptcha.execute('6LcC8qMfAAAAAKQvHTUiJyxB_DO3nXwei4BFktyg', {action: 'contact'}) 62 .then(function(token) { 63 formData.append('g-recaptcha-response', token); 64 return fetch("https://getform.io/f/5f1f20be-e019-4bcf-a218-dd770809b977", { 65 method: "POST", 66 body: formData, 67 }); 68 }) 69 .catch(error => { 70 console.log("reCAPTCHA or fetch error:", error); 71 }); 72 } catch (error) { 73 console.log("Error in grecaptcha execute:", error); 74 } 75 }); 76 } else { 77 fetch("https://getform.io/f/5f1f20be-e019-4bcf-a218-dd770809b977", { 78 method: "POST", 79 body: formData, 80 }) 81 .catch(error => { 82 console.log("Fetch error:", error); 83 }); 84 } 85 } catch (error) { 86 console.log("General submission error:", error); 87 } 88 } 89 90 if (submitBtn) { 91 submitBtn.addEventListener("click", (e) => { 92 e.preventDefault(); 93 shouldValidate = true; 94 validateInputs(); 95 if (isFormValid) { 96 handleSubmit(e); 97 } 98 }); 99 } 100 101 inputFields.forEach((input) => { 102 if (input) { 103 input.addEventListener("input", () => { 104 validateInputs(); 105 }); 106 } 107 }); 108});
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.