1var zf_DateRegex = new RegExp("^(([0][1-9])|([1-2][0-9])|([3][0-1]))[-](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[-](?:(?:19|20)[0-9]{2})$"); 2var zf_MandArray = ["Dropdown3", "SingleLine", "SingleLine1", "Email", "DecisionBox2", "Dropdown1"]; 3var zf_FieldArray = ["submitButtonClickCounter","Dropdown3", "Dropdown", "Dropdown2", "DecisionBox1", "MultiLine","MultiLine2", "SingleLine1", "SingleLine", "Dropdown1", "PhoneNumber_countrycode", "PhoneNumber_countrycodeval", "Email", "DecisionBox", "DecisionBox2", "Dropdown4", "SingleLine2", "SingleLine3", "MultiLine1","DeviceInfo","BrowserInfo","IPAddressInfo","SingleLine7","SingleLine8"]; 4var isSalesIQIntegrationEnabled = true; 5var salesIQFieldsArray = [{ 6 "formFieldName": "Email", 7 "formFieldType": 9, 8 "salesIQFieldName": "Email" 9}, { "formFieldName": "SingleLine", "formFieldType": 1, "salesIQFieldName": "Name" }, { 10 "formFieldName": "PhoneNumber", 11 "formFieldType": 11, 12 "salesIQFieldName": "Phone" 13}, { "formFieldName": "SingleLine7", "formFieldType": 1, "salesIQFieldName": "How_do_we_contact_you" }]; 14 15var isSubmitingLeadForm = false; 16 17function getDeviceInfo() { 18 const ua = navigator.userAgent; 19 let device = "Desktop"; 20 if (/Mobi|Android/i.test(ua)) { 21 device = "Mobile"; 22 } else if (/Tablet|iPad/i.test(ua)) { 23 device = "Tablet"; 24 } 25 return { 26 device: device, 27 browser: navigator.userAgent 28 }; 29} 30 31const zohoIframe = document.querySelector('iframe[name="zoho_iframe"]'); 32 33if (zohoIframe) { 34 zohoIframe.onload = function () { 35 36 let existing = localStorage.getItem("ftc_form_saver") 37 ? JSON.parse(atob(localStorage.getItem("ftc_form_saver"))) 38 : {}; 39 40 try { 41 let iframeDoc = this.contentDocument || this.contentWindow.document; 42 let bodyText = iframeDoc.body.innerText; 43 44 if (bodyText.includes("duplicate") || bodyText.includes("already exists")) { 45 existing.submission_status = "server_error"; 46 existing.server_error = "409_conflict_duplicate"; 47 } 48 else if (bodyText.includes("error")) { 49 existing.submission_status = "server_error"; 50 existing.server_error = bodyText.substring(0, 200); 51 } 52 else { 53 existing.submission_status = "success"; 54 existing.server_error = "none"; 55 } 56 57 } catch (e) { 58 existing.submission_status = "unknown"; 59 existing.server_error = "cross_origin_blocked"; 60 } 61 62 localStorage.setItem("ftc_form_saver", btoa(JSON.stringify(existing))); 63 64 // â Send final API update 65 if (window.matomoInstance) { 66 window.matomoInstance.post_form_saver(); 67 } 68 69 // â Redirect after tracking completes 70 /*setTimeout(() => { 71 window.location.href = document.getElementById("zfredirection").value; 72 }, 700);*/ 73 }; 74} 75 76 77 78function zf_addDataToSalesIQ(form) { 79 var visitorinfo = {}; 80 var elements = form.elements; 81 for (var elmIdx = 0; elmIdx < elements.length; elmIdx++) { 82 var inpElem = elements[elmIdx]; 83 var fieldLinkName = inpElem.getAttribute("name"); 84 var fieldType = inpElem.getAttribute("fieldType"); 85 if (fieldType === "1" || fieldType === "7" || fieldType === "9" || fieldType === "11") { 86 for (var idx = 0; idx < salesIQFieldsArray.length; idx++) { 87 var salesIQObj = salesIQFieldsArray[idx]; 88 var zfFieldName = salesIQObj.formFieldName; 89 if (fieldType === "1") { 90 if (fieldLinkName === zfFieldName) { 91 var salesIQValue = inpElem.value; 92 var salesIQFieldName = salesIQObj.salesIQFieldName; 93 if (salesIQFieldName === "Phone") { 94 visitorinfo.contactnumber = salesIQValue; 95 } 96 if (salesIQFieldName === "Name") { 97 visitorinfo.name = salesIQValue; 98 } 99 } 100 } 101 if (fieldType === "7") { 102 var zfFldCompLinkName = salesIQObj.fieldCompLinkName; 103 if (fieldLinkName === zfFldCompLinkName) { 104 var salesIQValue = inpElem.value; 105 visitorinfo.name = salesIQValue; 106 } 107 } 108 if (fieldType === "9") { 109 if (fieldLinkName === zfFieldName) { 110 var salesIQValue = inpElem.value; 111 visitorinfo.email = salesIQValue; 112 } 113 } 114 if (fieldType === "11") { 115 fieldLinkName = inpElem.getAttribute("compname"); 116 if (fieldLinkName === zfFieldName) { 117 var phoneFormat = inpElem.getAttribute("phoneFormat"); 118 var salesIQValue = ""; 119 if (phoneFormat === "1") { 120 var isCodeEnabled = inpElem.getAttribute("isCountryCodeEnabled"); 121 salesIQValue = form.querySelector("#international_" + fieldLinkName + "_countrycode").value; 122 if (salesIQValue != null && salesIQValue != "" && isCodeEnabled === "true") { 123 salesIQValue = 124 125 form.querySelector("#" + fieldLinkName + "_countrycodeval").value + salesIQValue; 126 } 127 } else if (phoneFormat === "2") { 128 var countryCode = form.querySelector("#" + fieldLinkName + "_countrycode").value; 129 var first = form.querySelector("#" + fieldLinkName + "_first").value; 130 var last = form.querySelector("#" + fieldLinkName + "_second").value; 131 salesIQValue = countryCode + first + last; 132 } 133 visitorinfo.contactnumber = salesIQValue; 134 } 135 } 136 } 137 } 138 } 139 parent.postMessage(JSON.stringify({ type: 'zoho.salesiq.apimessage', visitor: visitorinfo }), '*'); 140} 141 142function zf_ValidateAndSubmit(form) { 143 144 // First Name 145 let firstName = form.querySelector('[name="SingleLine1"]'); 146 if (firstName) { 147 firstName.value = firstName.value 148 .replace(/[^a-zA-Z\s]/g, '') 149 .replace(/\s{2,}/g, ' ') 150 .trim(); 151 } 152 153 // Last Name 154 let lastName = form.querySelector('[name="SingleLine"]'); 155 if (lastName) { 156 lastName.value = lastName.value 157 .replace(/[^a-zA-Z\s]/g, '') 158 .replace(/\s{2,}/g, ' ') 159 .trim(); 160 } 161 162 // Phone Number 163 let phoneField = form.querySelector('[name="PhoneNumber_countrycode"]'); 164 if (phoneField) { 165 phoneField.value = phoneField.value.replace(/[^0-9]/g, ''); 166 } 167 168 169 if (zf_CheckMandatory(form)) { 170 if (zf_ValidCheck(form)) { 171 172 let elements = document.querySelectorAll('.custom_tour_form .lf-error');
173 elements.forEach((element) => { 174 element.classList.remove('lf-error'); 175 }); 176 if (isSalesIQIntegrationEnabled) { 177 zf_addDataToSalesIQ(form); 178 } 179 180 181 if (!isSubmitingLeadForm) { 182 183 let existing = localStorage.getItem("ftc_form_saver") 184 ? JSON.parse(atob(localStorage.getItem("ftc_form_saver"))) 185 : {}; 186 187 // â Mark attempt 188 existing.submission_status = "attempting_submit"; 189 existing.attempt_time = new Date().toISOString(); 190 191 localStorage.setItem("ftc_form_saver", btoa(JSON.stringify(existing))); 192 193 if (window.matomoInstance) { 194 window.matomoInstance.post_form_saver(); 195 } 196 197 // =============================== 198 // Set Pages Visited (Zoho field) 199 // =============================== 200 let pageCount = sessionStorage.getItem('page_count') || 0; 201 202 // Set into Zoho field 203 let pageField = form.querySelector('[name="SingleLine8"]'); 204 if (pageField) { 205 pageField.value = pageCount; 206 } 207 208 populateWishlistLf(form); 209 isSubmitingLeadForm = true; 210 211 const submitBtn = form.querySelector('button[type="submit"]'); 212 if (submitBtn) { 213 submitBtn.disabled = true; 214 submitBtn.innerText = "Submitting..."; 215 } 216 217 // â DELAY SUBMIT (important for tracking) 218 219 220 setTimeout(() => { 221 form.submit(); 222 }, 600); // increased delay for API reliability 223 224 setTimeout(() => { 225 window.location.href = document.getElementById("zfredirection").value; 226 }, 5000); 227 } 228 return false; 229 } else { 230 return false; 231 } 232 } else { 233 alert("Form field required"); 234 return false; 235 } 236} 237 238function zf_CheckMandatory(form) { 239 let fieldsNotOk = []; 240 zf_ClearErrorMsg(form) 241 for (i = 0; i < zf_MandArray.length; i++) { 242 var fieldObj = form[zf_MandArray[i]]; 243 if (fieldObj) { 244 if (fieldObj.nodeName != null) { 245 if (fieldObj.nodeName == 'OBJECT') { 246 if (!zf_MandatoryCheckSignature(fieldObj)) { 247 fieldsNotOk.push(i); 248 } 249 } else if (((fieldObj.value).replace(/^\s+|\s+$/g, '')).length == 0) { 250 if (fieldObj.type == 'file') { 251 fieldObj.focus(); 252 fieldsNotOk.push(i); 253 } 254 fieldObj.focus(); 255 fieldsNotOk.push(i); 256 } else if (fieldObj.nodeName == 'SELECT') { 257 if (fieldObj.options[fieldObj.selectedIndex].value == '-Select-') { 258 fieldObj.focus(); 259 fieldsNotOk.push(i); 260 } 261 } else if (fieldObj.type == 'checkbox' || fieldObj.type == 'radio') { 262 if (fieldObj.checked == false) { 263 fieldObj.focus(); 264 fieldsNotOk.push(i); 265 } 266 } 267 } else { 268 var checkedValsCount = 0; 269 var inpChoiceElems = fieldObj; 270 for (var ii = 0; ii < inpChoiceElems.length; ii++) { 271 if (inpChoiceElems[ii].checked === true) { 272 checkedValsCount++; 273 } 274 } 275 if (checkedValsCount == 0) { 276 inpChoiceElems[0].focus(); 277 fieldsNotOk.push(i); 278 } 279 } 280 } 281 } 282 283 let checkStatus = true; 284 if (fieldsNotOk.length > 0) { 285 fieldsNotOk.forEach(index => { 286 zf_ShowErrorMsg(zf_MandArray[index], form); 287 }); 288 checkStatus = false; 289 } 290 291 if (!checkSelectedDateValidity(form)) { 292 checkStatus = false; 293 } 294 295 // ======================================================= 296 // Validate "How should we contact you" radio selection 297 // ======================================================= 298 var contactRadios = form.querySelectorAll("input[name='contact_you']"); 299 var contactHidden = form.querySelector("input[name='SingleLine7']"); 300 var isContactSelected = false;
301 302 contactRadios.forEach(function(radio){ 303 if (radio.checked) { 304 isContactSelected = true; 305 } 306 }); 307 308 // If no radio selected OR hidden field empty â error 309 if (!isContactSelected || !contactHidden.value.trim()) { 310 checkStatus = false; 311 312 contactRadios.forEach(function(radio){ 313 radio.closest(".zf-tempContDiv").classList.add("lf-error"); 314 }); 315 } else { 316 contactRadios.forEach(function(radio){ 317 radio.closest(".zf-tempContDiv").classList.remove("lf-error"); 318 }); 319 } 320 321 return checkStatus; 322} 323 324 325function zf_ClearErrorMsg(form) { 326 form.querySelectorAll('.custom_tour_form .lf-error').forEach((element) => { 327 element.classList.remove('lf-error'); 328 }); 329 330 form.querySelectorAll('.custom_tour_form .lf-error-message').forEach((element) => { 331 element.style.display = 'none'; 332 }); 333} 334 335function jsonIsEmptyArray(item) { 336 let parsedItem; 337 try { 338 parsedItem = JSON.parse(item); 339 } catch (e) { 340 return false; 341 } 342 return Array.isArray(parsedItem) && parsedItem.length === 0; 343} 344 345function populateWishlistLf(form) { 346 var guestWishlistFullName = localStorage.getItem('guest_wishlist_full_name'); 347 if (guestWishlistFullName && !jsonIsEmptyArray(guestWishlistFullName)) { 348 var inputField = form['MultiLine2']; 349 if (inputField) { 350 inputField.value = guestWishlistFullName; 351 } 352 } 353} 354 355function checkSelectedDateValidity(form) { 356 if (form['Dropdown2'].options[form['Dropdown2'].selectedIndex].value == new Date().getFullYear()) {
357 const month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; 358 var curMonthIndex = new Date().getMonth(); 359 var selectMonthIndex = month.findIndex(x => x == form['Dropdown'].options[form['Dropdown'].selectedIndex].value); 360 if (curMonthIndex > selectMonthIndex) { 361 form['Dropdown2'].classList.add("lf-error"); 362 form['Dropdown'].classList.add("lf-error"); 363 form['Dropdown2'].focus(); 364 return false; 365 } 366 } 367 if ( 368 form['Dropdown2'].selectedIndex > 0 && 369 form['Dropdown'].selectedIndex > 0 || 370 form['DecisionBox1'].checked 371 ) { 372 return true; 373 } else { 374 form['Dropdown2'].classList.add("lf-error"); 375 form['Dropdown'].classList.add("lf-error"); 376 form['DecisionBox1'].classList.add("lf-error"); 377 form['Dropdown2'].focus(); 378 return false; 379 } 380} 381 382 383function zf_ValidCheck(form) { 384 var isValid = true; 385 let fieldsNotOk = []; 386 for (ind = 0; ind < zf_FieldArray.length; ind++) { 387 var fieldObj = form[zf_FieldArray[ind]]; 388 if (fieldObj) { 389 if (fieldObj.nodeName != null) { 390 var checkType = fieldObj.getAttribute("fieldType"); 391 if (checkType == "c2") { 392 if (!zf_ValidateNumber(fieldObj)) { 393 isValid = false; 394 fieldObj.focus(); 395 zf_ShowErrorMsg(zf_FieldArray[ind], form); 396 fieldsNotOk.push(ind); 397 } 398 } else if (checkType == "c3") { 399 if (!zf_ValidateCurrency(fieldObj) || !zf_ValidateDecimalLength(fieldObj, 10)) { 400 isValid = false; 401 fieldObj.focus(); 402 zf_ShowErrorMsg(zf_FieldArray[ind], form); 403 fieldsNotOk.push(ind); 404 } 405 } else if (checkType == "c4") { 406 if (!zf_ValidateDateFormat(fieldObj)) { 407 isValid = false; 408 fieldObj.focus(); 409 zf_ShowErrorMsg(zf_FieldArray[ind], form); 410 fieldsNotOk.push(ind); 411 } 412 } else if (checkType == "9") { 413 if (!zf_ValidateEmailID(fieldObj)) { 414 isValid = false; 415 fieldObj.focus(); 416 zf_ShowErrorMsg(zf_FieldArray[ind], form); 417 fieldsNotOk.push(ind); 418 } 419 } else if (checkType == "c6") { 420 if (!zf_ValidateLiveUrl(fieldObj)) { 421 isValid = false; 422 fieldObj.focus(); 423 zf_ShowErrorMsg(zf_FieldArray[ind], form); 424 fieldsNotOk.push(ind); 425 } 426 } else if (checkType == "11") { 427 if (fieldObj.value!='' && !zf_ValidatePhone(fieldObj)) { 428 isValid = false; 429 fieldObj.focus(); 430 zf_ShowErrorMsg(zf_FieldArray[ind], form); 431 fieldsNotOk.push(ind); 432 } 433 } else if (checkType == "c8") { 434 zf_ValidateSignature(fieldObj); 435 } 436 } 437 } 438 } 439 if (fieldsNotOk.length > 0) { 440 fieldsNotOk.forEach(index => { 441 console.log(zf_FieldArray[index]); 442 zf_ShowErrorMsg(zf_FieldArray[index], form); 443 }); 444 } 445 return isValid; 446} 447 448 449function zf_ShowErrorMsg(uniqName, form) { 450 451 var elval = form[uniqName]; 452 453 if (elval) { 454 if (uniqName == "Dropdown3" || elval.type == 'checkbox' || elval.type == 'radio') { 455 elval.parentNode.parentNode.classList.add("lf-error"); 456 } else { 457 elval.classList.add("lf-error"); 458 } 459 460 form.querySelectorAll('.custom_tour_form .lf-error-message').forEach((element) => { 461 element.style.display = 'block'; 462 }); 463 } 464 465 // â Extract EXACT error message 466 let errorMsg = ""; 467 let errorEl = elval?.closest('.zf-field')?.querySelector('.lf-error-message'); 468 469 if (!errorEl) { 470 errorEl = form.querySelector('.lf-error-message'); 471 } 472 473 if (errorEl) { 474 errorMsg = errorEl.innerText.trim(); 475 } 476 477 let existing = localStorage.getItem("ftc_form_saver") 478 ? JSON.parse(atob(localStorage.getItem("ftc_form_saver"))) 479 : {}; 480 481 if (!existing.client_errors) existing.client_errors = {}; 482 483 existing.client_errors[uniqName] = { 484 message: errorMsg || "Validation failed", 485 time: new Date().toISOString() 486 }; 487 488 existing.submission_status = "validation_error"; 489 490 localStorage.setItem("ftc_form_saver", btoa(JSON.stringify(existing))); 491} 492 493function zf_ValidateNumber(elem) {
494 var validChars = "-0123456789"; 495 var numValue = elem.value.replace(/^\s+|\s+$/g, ''); 496 if (numValue != null && !numValue == "") { 497 var strChar; 498 var result = true; 499 if (numValue.charAt(0) == "-" && numValue.length == 1) { 500 return false; 501 } 502 for (i = 0; i < numValue.length && result == true; i++) { 503 strChar = numValue.charAt(i); 504 if ((strChar == "-") && (i != 0)) { 505 return false; 506 } 507 if (validChars.indexOf(strChar) == -1) { 508 result = false; 509 } 510 } 511 return result; 512 } else { 513 return true; 514 } 515} 516 517function zf_ValidateDateFormat(inpElem) { 518 var dateValue = inpElem.value.replace(/^\s+|\s+$/g, ''); 519 if (dateValue == "") { 520 return true; 521 } else { 522 return (zf_DateRegex.test(dateValue)); 523 } 524} 525 526function zf_ValidateCurrency(elem) { 527 var validChars = "0123456789."; 528 var numValue = elem.value.replace(/^\s+|\s+$/g, ''); 529 if (numValue.charAt(0) == '-') { 530 numValue = numValue.substring(1, numValue.length); 531 } 532 if (numValue != null && !numValue == "") { 533 var strChar; 534 var result = true; 535 for (i = 0; i < numValue.length && result == true; i++) { 536 strChar = numValue.charAt(i); 537 if (validChars.indexOf(strChar) == -1) { 538 result = false;
539 } 540 } 541 return result; 542 } else { 543 return true; 544 } 545} 546 547function zf_ValidateDecimalLength(elem, decimalLen) { 548 var numValue = elem.value; 549 if (numValue.indexOf('.') >= 0) { 550 var decimalLength = numValue.substring(numValue.indexOf('.') + 1).length; 551 if (decimalLength > decimalLen) { 552 return false; 553 } else { 554 return true; 555 } 556 } 557 return true; 558} 559 560function zf_ValidateEmailID(elem) { 561 var check = 0; 562 var emailValue = elem.value; 563 if (emailValue != null && !emailValue == "") { 564 var emailArray = emailValue.split(","); 565 for (i = 0; i < emailArray.length; i++) { 566 var emailExp = /^[\w]([\w\-.+&'/]*)@([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,22}$/; 567 if (!emailExp.test(emailArray[i].replace(/^\s+|\s+$/g, ''))) { 568 check = 1; 569 } 570 } 571 if (check == 0) { 572 return true; 573 } else { 574 return false; 575 } 576 } else { 577 return true; 578 } 579} 580 581function zf_ValidateLiveUrl(elem) { 582 var urlValue = elem.value; 583 if (urlValue !== null && typeof (urlValue) !== "undefined") { 584 urlValue = urlValue.replace(/^\s+|\s+$/g, ''); 585 if (urlValue !== "") { 586 var urlregex = new RegExp("^((((h|H)(t|T)|(f|F))(t|T)(p|P)((s|S)?)://[-.\\w]*)|(((w|W){3}\\.)[-.\\w]+)|((\\w+)([-\\w]*)(\\.([-\\w]+))+))(/?)([-\\w.?,:'/\\\\+=&;%$#@()!~]*)?$"); 587 return (urlregex.test(urlValue)); 588 } 589 } 590 return true; 591} 592 593function zf_ValidatePhone(inpElem) { 594 595 var ZFPhoneRegex = { 596 PHONE_INTE_ALL_REG: /^[+]{0,1}[()0-9-. ]+$/, 597 PHONE_INTE_NUMERIC_REG: /^[0-9]+$/, 598 PHONE_INTE_CONT_CODE_ENABLED_REG: /^[(0-9-.][()0-9-. ]*$/, 599 PHONE_USA_REG: /^[0-9]+$/, 600 PHONE_CONT_CODE_REG: /^[+][0-9]{1,4}$/ 601 } 602 var phoneFormat = parseInt(inpElem.getAttribute("phoneFormat")); 603 var fieldInpVal = inpElem.value.replace(/^\s+|\s+$/g, ''); 604 var toReturn = true; 605 if (phoneFormat === 1) { 606 if (inpElem.getAttribute("valType") == 'code') { 607 var codeRexp = ZFPhoneRegex.PHONE_CONT_CODE_REG; 608 if (fieldInpVal != "" && !codeRexp.test(fieldInpVal)) { 609 return false; 610 } 611 } else { 612 var IRexp = ZFPhoneRegex.PHONE_INTE_ALL_REG; 613 if (inpElem.getAttribute("phoneFormatType") == '2') { 614 IRexp = ZFPhoneRegex.PHONE_INTE_NUMERIC_REG; 615 } 616 if (fieldInpVal != "" && !IRexp.test(fieldInpVal)) { 617 toReturn = false; 618 return toReturn; 619 } 620 } 621 if (fieldInpVal.length < 5) { 622 toReturn = false; 623 } 624 return toReturn; 625 } else if (phoneFormat === 2) { 626 var InpMaxlength = inpElem.getAttribute("maxlength"); 627 var USARexp = ZFPhoneRegex.PHONE_USA_REG; 628 if (fieldInpVal != "" && USARexp.test(fieldInpVal) && fieldInpVal.length == InpMaxlength) { 629 toReturn = true; 630 } else if (fieldInpVal == "") { 631 toReturn = true; 632 } else { 633 toReturn = false; 634 } 635 return toReturn; 636 } 637} 638 639function zf_ValidateSignature(objElem) { 640 var linkName = objElem.getAttribute("compname"); 641 var canvasElem = document.getElementById("drawingCanvas-" + linkName); 642 var isValidSign = zf_IsSignaturePresent(objElem, linkName, canvasElem); 643 var hiddenSignInputElem = document.getElementById("hiddenSignInput-" + linkName); 644 if (isValidSign) { 645 hiddenSignInputElem.value = canvasElem.toDataURL(); 646 } else { 647 hiddenSignInputElem.value = ""; 648 } 649 return isValidSign; 650} 651 652function zf_MandatoryCheckSignature(objElem) { 653 var linkName = objElem.getAttribute("compname"); 654 var canvasElem = document.getElementById("drawingCanvas-" + linkName); 655 var isValid = zf_IsSignaturePresent(objElem, linkName, canvasElem); 656 return isValid; 657} 658 659function zf_IsSignaturePresent(objElem, linkName, canvasElem) { 660 var context = canvasElem.getContext('2d'); 661 var canvasWidth = canvasElem.width; 662 var canvasHeight = canvasElem.height; 663 var canvasData = context.getImageData(0, 0, canvasWidth, canvasHeight); 664 var signLen = canvasData.data.length; 665 var flag = false;
666 for (var index = 0; index < signLen; index++) { 667 if (!canvasData.data[index]) { 668 flag = false; 669 } else if (canvasData.data[index]) { 670 flag = true; 671 break; 672 } 673 } 674 return flag; 675} 676 677function zf_setCountryCode(form, prefix, countryName) { 678 var select = form['PhoneNumber_countrycodeval']; 679 var options = select.options; 680 for (var i = 0; i < options.length; i++) { 681 if (options[i].value == prefix && options[i].getAttribute('data-country-name').includes(countryName)) { 682 select.selectedIndex = i; 683 } 684 } 685} 686 687document.getElementsByName('DecisionBox1').forEach(x => x.addEventListener('change', function () { 688 if (this.checked) { 689 document.getElementsByName('Dropdown').forEach(function (x) { 690 x.selectedIndex = 0; 691 x.disabled = true 692 }) 693 document.getElementsByName('Dropdown2').forEach(function (x) { 694 x.selectedIndex = 0; 695 x.disabled = true 696 }) 697 } else { 698 document.getElementsByName('Dropdown').forEach(function (x) { 699 x.disabled = false 700 }) 701 document.getElementsByName('Dropdown2').forEach(function (x) { 702 x.disabled = false 703 }) 704 } 705})) 706 707document.getElementsByName('Dropdown4').forEach(x => x.addEventListener('change', function () { 708 let textInputField = this.parentNode.nextElementSibling.querySelector('input[name="SingleLine2"]'); 709 textInputField.value = this.value; 710})); 711 712 713document.querySelectorAll('.custom_tour_form [name=MultiLine]').forEach(x => x.addEventListener('input', function () { 714 var text = this.value; 715 // Match sequences of non-space characters (\S+ matches anything that is not a whitespace character) 716 var words = text.match(/\S+/g); 717 718 if (words && words.length > 0) { 719 720 this.nextElementSibling.querySelector('.comment-progress').hidden = false; 721 this.nextElementSibling.querySelectorAll('.comment-rating').forEach(x => { x.hidden = true }); 722 if (words.length <= 10) { 723 this.nextElementSibling.querySelector('.comment-progress .comment-progress-bar').style.backgroundColor = "#FF9100"; 724 this.nextElementSibling.querySelector('.comment-rating.good').hidden = false; 725 } 726 else if (words.length > 10 && words.length < 25) { 727 this.nextElementSibling.querySelector('.comment-progress .comment-progress-bar').style.backgroundColor = "#2979FF"; 728 this.nextElementSibling.querySelector('.comment-rating.great').hidden = false; 729 } 730 else { 731 this.nextElementSibling.querySelector('.comment-progress .comment-progress-bar').style.backgroundColor = "#25D366"; 732 this.nextElementSibling.querySelector('.comment-rating.fantastic').hidden = false; 733 } 734 } 735 else { 736 this.nextElementSibling.querySelector('.comment-progress').hidden = true; 737 } 738})); 739 740document.getElementsByName('SingleLine3').forEach(x => x.value = Intl.DateTimeFormat().resolvedOptions().timeZone); 741document.getElementsByName('MultiLine1').forEach(x => x.value = document.URL); 742 743//MATOMO LEAD FORM 744$ = jQuery; 745//We instianciate only if we never did before to avoid concurency 746if (typeof matomoFormSaver == 'undefined') { 747 matomoFormSaver = function () { 748 749 var matomo_visitor_var = localStorage.getItem("ftc_form_saver") == null ? {} : JSON.parse(atob(localStorage.getItem("ftc_form_saver"))); 750 var matomo_visitor_email = null; 751 var matomo_visitor_id = null; 752 753 var post_form_saver = function () { 754 if (matomo_visitor_id == null) { 755 matomo_visitor_id = getVisitorId(); 756 } 757 if (Object.keys(matomo_visitor_var).length > 0 && matomo_visitor_email != null && typeof $("#ftc_api_url").val() !== 'undefined') { 758 759 const deviceInfo = getDeviceInfo(); 760 var ipAddress = $('#visitorIPAd').val(); 761 matomo_visitor_var.device = deviceInfo.device; 762 matomo_visitor_var.browser = deviceInfo.browser; 763 matomo_visitor_var.ipAddress = ipAddress; 764 765 $.ajax({ 766 url: $("#ftc_api_url").val() + "/wordpress/lead_form_backup", 767 type: "POST", 768 data: JSON.stringify({ 769 matomo_visitor_email, 770 matomo_visitor_var: JSON.stringify(matomo_visitor_var), 771 matomo_visitor_id 772 }), 773 contentType: "application/json" 774 }); 775 } 776 } 777 778 // â IMPORTANT: expose function 779 this.post_form_saver = post_form_saver; 780 781 var set_visitor_email = function (email) { 782 if (validate_email(email)) { 783 matomo_visitor_email = email 784 } 785 } 786
787 var validate_email = function (email) { 788 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 789 return re.test(email); 790 }; 791 792 var getVisitorId = function () { 793 var visitor_id = null; 794 if (typeof Matomo !== 'undefined' && Matomo != null) { 795 var tracker = Matomo.getTracker(); 796 if (tracker != null) { 797 visitor_id = tracker.getVisitorId(); 798 } 799 } 800 return visitor_id; 801 } 802 803 $(document).ready(function () { 804 805 (async function myLoop(i) { 806 while (--i) { 807 await new Promise(resolve => setTimeout(resolve, 1000)); 808 matomo_visitor_id = getVisitorId(); 809 if (matomo_visitor_id == null) { 810 continue; 811 } else { 812 break; 813 } 814 } 815 })(10); 816 817 document.querySelectorAll('.custom_tour_form').forEach(function (form) { 818 819 $(form).on("change", "input,textarea,select", function () { 820 821 let harvestedData = {}; 822 823 zf_FieldArray.forEach(fieldName => { 824 let element = form.querySelector('[name="' + fieldName + '"]'); 825 if (element) { 826 harvestedData[fieldName] = element.value; 827 828 if (element.getAttribute("type") == "checkbox") { 829 harvestedData[fieldName] = element.checked; 830 } 831 832 if (element.getAttribute("type") == "email") { 833 set_visitor_email(element.value); 834 } 835 } 836 }); 837 838 let existing = localStorage.getItem("ftc_form_saver") 839 ? JSON.parse(atob(localStorage.getItem("ftc_form_saver"))) 840 : {}; 841 842 harvestedData.server_error = existing.server_error || "none"; 843 harvestedData.submission_status = existing.submission_status || "filling"; 844 harvestedData.client_errors = existing.client_errors || {}; 845 846 let pageCount = sessionStorage.getItem('page_count') || 0; 847 // Add to tracking JSON 848 harvestedData.page_count = pageCount; 849 850 matomo_visitor_var = harvestedData; 851 852 localStorage.setItem("ftc_form_saver", btoa(JSON.stringify(matomo_visitor_var))); 853 854 post_form_saver(); 855 }); 856 }); 857 }); 858 } 859 860 // â IMPORTANT: global instance 861 window.matomoInstance = new matomoFormSaver(); 862} 863 864function checkTimeInIreland() { 865 // Create a Date object for current time in Ireland 866 let dateInIreland = new Date().toLocaleString("en-US", { timeZone: "Europe/Dublin" }); 867 dateInIreland = new Date(dateInIreland); 868 869 // Get the day of the week (0 = Sunday, 1 = Monday, etc.) 870 let dayOfWeek = dateInIreland.getDay(); 871 872 // Get the current hours and minutes 873 let hours = dateInIreland.getHours(); 874 let minutes = dateInIreland.getMinutes(); 875 876 // Check if the current day is Monday to Friday and the current time is between 8 AM and 7.30 PM 877 return dayOfWeek >= 1 && dayOfWeek <= 5 && (hours > 8 || (hours == 8 && minutes >= 0)) && (hours < 19 || (hours == 19 && minutes < 30)); 878} 879 880 881document.addEventListener("DOMContentLoaded", function () { 882 883 if (checkTimeInIreland() == false) { 884 document.querySelectorAll('.call-us-lf').forEach(function (callUsElement) { 885 callUsElement.style.display = 'none'; 886 }) 887 } 888}); 889 890function incrementSubmitButtonClickCounterValue(form){ 891 try{ 892 var input = form.querySelector("#submitButtonClickCounter") 893 input.value = parseInt(input.value, 10) + 1; 894 895 // create a new 'change' event 896 var event = new Event('change', { 897 'bubbles': true, 898 'cancelable': true 899 }); 900 901 // dispatch the event 902 input.dispatchEvent(event); 903 } 904 catch(e){ 905 console.error("Failed to increment submitButtonClickCounter"); 906 } 907} 908 909 910 911jQuery(document).ready(function ($) { 912 913 const form = $('.custom_tour_form'); 914 if (!form.length) return; 915 916 const hiddenField = form.find("input[name='SingleLine7']"); 917 918 // Set value if already selected (important for reload/edit cases) 919 const checkedRadio = form.find("input[name='contact_you']:checked"); 920 if (checkedRadio.length) { 921 hiddenField.val(checkedRadio.val()); 922 } 923 924 // Use delegated event (works for dynamic DOM like Zoho) 925 form.on('change', "input[name='contact_you']", function () { 926 console.log("Radio clicked:", $(this).val()); 927 hiddenField.val($(this).val()); 928 console.log("Hidden value:", hiddenField.val()); 929 }); 930 931}); 932 933 934document.addEventListener('input', function(e){ 935 936 // First Name + Last Name 937 if ( 938 e.target.name === 'SingleLine1' || 939 e.target.name === 'SingleLine' 940 ) { 941 e.target.value = e.target.value.replace(/[^a-zA-Z\s]/g, ''); 942 e.target.value = e.target.value.replace(/\s{2,}/g, ' '); 943 } 944 945 // Phone Number 946 if (e.target.name === 'PhoneNumber_countrycode') { 947 e.target.value = e.target.value.replace(/[^0-9]/g, ''); 948 } 949 950});
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.