1document.addEventListener("DOMContentLoaded", function () { 2 const form = document.getElementById("bookdemoform"); 3 function handleSubmit(event, formId) { 4 event.preventDefault(); 5 // Opt-in consent is mandatory before a lead is sent to the CRM (#642). 6 // The checkbox is also `required` in the markup; this is a defensive guard 7 // so the lead call can never fire without an explicit opt-in. 8 const consent = document.getElementById("consent"); 9 if (consent && !consent.checked) { 10 if (typeof consent.reportValidity === "function") { 11 consent.reportValidity(); 12 } 13 return; 14 } 15 const formData = new FormData(formId); 16 const formDataObject = {}; 17 formData.forEach((value, key) => { 18 formDataObject[key] = value; 19 }); 20 // Neo Trader CRM (via server-side proxy). Never call the CRM directly 21 // from the browser -- the API key must stay on the server. 22 var url = "/api/crm/demo-register/" 23 var payload = JSON.stringify({ 24 full_name: formDataObject.name, 25 email: formDataObject.email, 26 phone: formDataObject.countryCode + "" + formDataObject.phone, 27 notes: formDataObject["time-slot"], 28 // Marketing opt-in (#642). The server records this against the lead. 29 consent: !!(consent && consent.checked), 30 }) 31 $.ajax({
32 url: url, 33 type: "POST", 34 data: payload, 35 contentType: "application/json", 36 success: function (response) { 37 }, 38 error: function (xhr, status, error) {}, 39 }); 40 } 41 if (form) { 42 form.addEventListener("submit", function (event) { 43 handleSubmit(event, form); 44 }); 45 } 46 47 // The marketing funnel popup ("Submit & Watch Demo") uses its own global 48 // handleSubmit() that validates and redirects to /Watch-a-Live-Demo. Wrap it 49 // so the redirect can't proceed without an explicit opt-in (#642). This keeps 50 // the consent gate in one place instead of editing every page's inline JS. 51 if (typeof window.handleSubmit === "function") { 52 var originalHandleSubmit = window.handleSubmit; 53 window.handleSubmit = function () { 54 var consent = document.getElementById("consent"); 55 if (consent && !consent.checked) { 56 var alertBox = document.getElementById("formAlert"); 57 if (alertBox) { 58 alertBox.textContent = 59 "â ï¸ Please agree to receive messages before continuing."; 60 } 61 if (typeof consent.reportValidity === "function") { 62 consent.reportValidity(); 63 } 64 return false; 65 } 66 return originalHandleSubmit.apply(this, arguments); 67 }; 68 } 69 70 // Some pages (book_demo, Watch-a-Live-Demo, most blog posts) submit via a 71 // global validateForm() that shows the "slot booked" popup. Wrap it too so 72 // that popup can't appear without an explicit opt-in (#642) -- gated here in 73 // one place instead of editing every page's inline validateForm(). 74 if (typeof window.validateForm === "function") { 75 var originalValidateForm = window.validateForm; 76 window.validateForm = function () { 77 var consent = document.getElementById("consent"); 78 if (consent && !consent.checked) { 79 var alertBox = document.getElementById("formAlert"); 80 if (alertBox) { 81 alertBox.textContent = 82 "â ï¸ Please agree to receive messages before continuing."; 83 } 84 if (typeof consent.reportValidity === "function") { 85 consent.reportValidity(); 86 } 87 return false; 88 } 89 return originalValidateForm.apply(this, arguments); 90 }; 91 } 92});
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.