1(function () { 2var customNewsletterCounter2 = 0; // Add this if not defined elsewhere 3 4function loadMore(totalRe) { 5 jQuery(".moreorless").slice(0, 4).removeClass("moreorless"); 6 jQuery(".moreorless2").slice(0, 4).removeClass("moreorless2"); 7 customNewsletterCounter2 += 4; 8 if (customNewsletterCounter2 + 4 >= totalRe) { 9 jQuery("#load_more").css("display", "none"); 10 } 11} 12jQuery(document).ready(function () { 13 /*jQuery("#load_more").click(function() { 14 jQuery(".moreorless").removeClass('moreorless'); 15 //jQuery("#load_more").removeClass('moreorless'); 16 }); */ 17 //click on see more display all newsletter 18 jQuery("#tag-box-button").click(function () { 19 jQuery(".moreorless").removeClass("moreorless"); 20 jQuery(".moreorless2").removeClass("moreorless2"); 21 jQuery("#load_more").css("display", "none"); 22 }); 23 24 //this is for count newsletter 25 var $checkboxes = jQuery( 26 '.checkbox-wrap.newsletter-item__subscribe-box input[type="checkbox"]' 27 ); 28 29 $checkboxes.change(function () { 30 var countCheckedCheckboxes = $checkboxes.filter(":checked").length; 31 jQuery("#selected-newsletters").text(countCheckedCheckboxes); 32 33 if (countCheckedCheckboxes < 1) { 34 jQuery("#modal-two").hide(); 35 } else { 36 jQuery("#modal-two").show(); 37 } 38 }); 39}); 40 41//get paradot url and related newsletter 42let allnewsletters = document.querySelectorAll(".checkboxinput"); 43var pardot_wrapper = document.querySelector("#pardot_data"); 44var pardotCollection = []; 45allnewsletters.forEach(function (newsletter) { 46 newsletter.addEventListener("change", function () { 47 let inptVal = this.value; 48 let newletterName, pardot_id; 49 let newsletterNameID = inptVal.split("|"); 50 newletterName = newsletterNameID[0]; 51 pardot_id = newsletterNameID[1]; 52 let wrapper = this.parentNode.parentNode.parentNode.parentNode.parentNode; 53 let pardotElement = pardot_id ? wrapper.querySelector("#pardot_" + pardot_id) : null; 54 let pardotUrl = pardotElement ? pardotElement.value : ""; 55 let temp = pardot_id; 56 57 if (this.checked) { 58 let collElement = pardot_wrapper ? pardot_wrapper.querySelector("#coll_" + pardot_id) : null; 59 let existidata = collElement ? collElement.value : ""; 60 if (existidata == "") { 61 existidata = newletterName; 62 } else { 63 existidata = existidata + "$$" + newletterName; 64 } 65 if (collElement) collElement.value = existidata; 66 } else { 67 let result = ""; 68 let collElement2 = pardot_wrapper ? pardot_wrapper.querySelector("#coll_" + pardot_id) : null; 69 let existidata = collElement2 ? collElement2.value : ""; 70 if (existidata != "") { 71 let existingcoll = existidata.split("$$"); 72 let result = arrayRemove(existingcoll, newletterName); 73 let formating = ""; 74 let separation = ""; 75 for (var i = 0; i < result.length; i++) { 76 formating = formating + separation + result[i]; 77 separation = "$$"; 78 //Do something 79 } 80 if (collElement2) collElement2.value = formating; 81 } 82 //pardotCollection = arrayRemove( pardotCollection, newletterName ); 83 //pardot_wrapper.querySelector('#coll_'+pardot_id).value = pardotCollection.toString(); 84 } 85 }); 86}); 87 88function arrayRemove(arr, value) { 89 return arr.filter(function (ele) { 90 return ele != value; 91 }); 92} 93 94// this function returns true if the user input is empty 95const isRequired_3 = (value) => (value === "" ? false : true); 96 97const showError_3 = (input, message) => { 98 // get the form-field element 99 const formField = input.closest(".form-group"); 100 const error = formField.querySelector("small"); 101 error.textContent = message; 102 103 input.children.forEach((child) => { 104 // console.log(child.tagName) 105 106 if (child.tagName === "SELECT") { 107 child.style.border = "1px solid #EB0000"; 108 } else { 109 input.style.border = "1px solid #EB0000"; 110 } 111 }); 112}; 113 114const showSuccess_3 = (input) => { 115 // get the form-field element 116 const formField = input.closest(".form-group"); 117 const error = formField.querySelector("small"); 118 error.textContent = ""; 119
120 input.children.forEach((child) => { 121 // console.log(child.tagName) 122 123 if (child.tagName === "SELECT") { 124 child.style.border = "1px solid #373997"; 125 } else if (child.tagName === "INPUT") { 126 input.style.border = "1px solid #373997"; 127 } 128 }); 129}; 130 131//form validation and submit form using ajax 132//email validation on keyup 133function checkNewslettersEmail(email) { 134 useFetchedNewslettersEmails(email); 135 //console.log(chkmail); 136} 137const urlToFetchNewslettersEmails = 138 "/wp-content/plugins/nsmg-newsletter-settings/free-disposable-email-providers.csv"; 139var reg = 140 /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!yahoo.co.in)(?!aol.com)(?!abc.com)(?!xyz.com)(?!pqr.com)(?!rediffmail.com)(?!live.com)(?!outlook.com)(?!me.com)(?!msn.com)(?!ymail.com)([\w-]+\.)+[\w-]{2,4})?$/; 141 142async function fetchingNewslettersEmails() { 143 const res = await fetch(urlToFetchNewslettersEmails); 144 const data = res.text(); 145 return data; 146} 147async function useFetchedNewslettersEmails(email) { 148 let data = await fetchingNewslettersEmails(); 149 data = data.replace(/\n/g, ""); 150 151 const excludedEmailsArr = data.split(","); 152 excludedEmailsArr.shift(); 153 154 let valid = false; 155 const ea = email.value.trim(); 156 let emailDomain = ea.split("@"); 157 const matches = excludedEmailsArr.filter((element) => { 158 if (element.indexOf(emailDomain[1]) !== -1) { 159 //valid = true; 160 jQuery("#temp_email").val("true"); 161 return true; 162 } 163 }); 164 165 if (matches.length > 0) { 166 //valid = false; 167 jQuery("#temp_email").val("false"); 168 showError_3(email, "Please enter a work/business email address"); 169 } else if (!isRequired_3(ea)) { 170 jQuery("#temp_email").val("false"); 171 // valid = false; 172 showError_3(email, "This field is mandatory"); 173 } else if (!isEmailValid_3(ea)) { 174 //valid = false; 175 jQuery("#temp_email").val("false"); 176 177 showError_3(email, "Email is not valid"); 178 } else { 179 jQuery("#temp_email").val("true"); 180 showSuccess_3(email); 181 valid = true; 182 } 183 //return valid; 184} 185 186let customNewsletterFormValid = false; 187function checkEmail(email) { 188 let valid = false; 189 const ea = email.value.trim(); 190 191 useFetchedNewslettersEmails(email).then((value) => { 192 if (email) { 193 if (!value) { 194 return false; 195 } else { 196 valid = true; 197 return true; 198 } 199 } 200 }); 201 return true; 202} 203 204function checkFirstName(firstname) { 205 let valid = false; 206 const fn = firstname.value.trim(); 207 if (!isRequired_3(fn)) { 208 showError_3(firstname, "This field is mandatory"); 209 } else if (firstname.value.length < 2) { 210 showError_3(firstname, "First name has to be more than 2 characters"); 211 } else { 212 showSuccess_3(firstname); 213 valid = true; 214 } 215 return valid; 216} 217 218function checkLastName(lastname) { 219 let valid = false; 220 const ln = lastname.value.trim(); 221 if (!isRequired_3(ln)) { 222 showError_3(lastname, "This field is mandatory"); 223 } else { 224 showSuccess_3(lastname); 225 valid = true; 226 } 227 return valid; 228} 229 230function checkCompany(company) { 231 let valid = false; 232 const comp = company.value.trim(); 233 if (!isRequired_3(comp)) { 234 showError_3(company, "This field is mandatory"); 235 } else { 236 showSuccess_3(company); 237 valid = true; 238 } 239 return valid; 240} 241 242function checkIndustry(industry) { 243 /*let valid = false; 244 const ind = industry.value.trim(); 245 if (!isRequired_3(ind)) { 246 showError_3(industry.parentElement, "This field is mandatory"); 247 } else { 248 showSuccess_3(industry.parentElement); 249 valid = true; 250 } 251 return valid;*/ 252 let valid = false; 253 const ind = industry.value.trim(); 254 if (!isRequired_3(ind)) { 255 showError_3(industry.parentElement, "Please pick an industry"); 256 } else if (ind == "0") { 257 showError_3(industry.parentElement, "Please pick an industry"); 258 valid = false; 259 return valid; 260 } else { 261 showSuccess_3(industry.parentElement); 262 valid = true; 263 } 264 return valid; 265} 266 267function checkJobTitle(jobtitle) { 268 let valid = false; 269 const jt = jobtitle.value.trim(); 270 if (!isRequired_3(jt)) { 271 showError_3(jobtitle, "This field is mandatory"); 272 } else { 273 showSuccess_3(jobtitle); 274 valid = true; 275 } 276 return valid; 277} 278 279function checkFunction(jobfunction) { 280 let valid = false;
281 const jf = jobfunction.value.trim(); 282 if (!isRequired_3(jf)) { 283 showError_3(jobfunction.parentElement, "This field is mandatory"); 284 } else { 285 showSuccess_3(jobfunction.parentElement); 286 valid = true; 287 } 288 return valid; 289} 290 291function checkCountry(country) { 292 let valid = false; 293 const co = country.value.trim(); 294 if (!isRequired_3(co)) { 295 showError_3(country.parentElement, "Please pick a country"); 296 } else if (co == "0") { 297 showError_3(country.parentElement, "Please pick a country"); 298 valid = false; 299 return valid; 300 } else { 301 showSuccess_3(country.parentElement); 302 valid = true; 303 } 304 return valid; 305} 306 307function checkSelect(sel) { 308 let valid = false; 309 const co = sel.value.trim(); 310 if (!isRequired_3(co)) { 311 showError_3(sel.parentElement, "Please pick a country"); 312 } else if (co == "0") { 313 showError_3(sel.parentElement, "Please pick a country"); 314 valid = false; 315 return valid; 316 } else { 317 showSuccess_3(sel.parentElement); 318 valid = true; 319 } 320 return valid; 321} 322 323function checkPhone(phone) { 324 let valid = false; 325 const ph = phone.value.trim(); 326 if (!isRequired_3(ph)) { 327 showError_3(phone, "This field is mandatory"); 328 } else if (phone.value.length <= 3) { 329 showError_3(phone, "Please enter more characters"); 330 } else { 331 showSuccess_3(phone); 332 valid = true; 333 } 334 return valid; 335} 336 337function checkMessage(enquiry) { 338 let valid = false; 339 const msg = enquiry.value.trim(); 340 if (!isRequired_3(msg)) { 341 showError_3(enquiry, "This field is mandatory"); 342 } else if (enquiry.value.length < 10) { 343 showError_3(enquiry, "Please enter more characters"); 344 } else { 345 showSuccess_3(enquiry); 346 valid = true; 347 } 348 return valid; 349} 350 351// Check at least one newsletter checkbox is checked 352// let newsletterCheckboxes = document.querySelectorAll( 353// ".newsletter-checkboxes .Verdict_Privacy_opt_in input[type=checkbox]" 354// ); 355 356// const checkNewsletterCheckboxes = () => { 357// const isValid = [...newsletterCheckboxes].some( 358// (checkbox) => checkbox.checked 359// ); 360 361// const displayErrorState = () => { 362// const errorEl = document.createElement("small"); 363// errorEl.classList.add("checkbox-error-message"); 364// errorEl.textContent = "Please select at least one newsletter"; 365// !document.querySelector(".checkbox-error-message") 366// ? document 367// .querySelector(".newsletter-checkboxes") 368// .insertAdjacentElement("afterend", errorEl) 369// : ""; 370// [...newsletterCheckboxes].forEach((checkbox) => 371// checkbox.classList.add("error") 372// ); 373// }; 374// const removeErrorState = () => { 375// const errorEl = document.querySelector(".checkbox-error-message"); 376// errorEl ? errorEl.remove() : ""; 377// [...newsletterCheckboxes].forEach((checkbox) => 378// checkbox.classList.remove("error") 379// ); 380// }; 381// !isValid ? displayErrorState() : removeErrorState(); 382// return isValid; 383// }; 384 385// if (newsletterCheckboxes[0]) { 386// checkNewsletterCheckboxes(); 387// document 388// .querySelector("#formSubmit") && document 389// .querySelector("#formSubmit").addEventListener("click", checkNewsletterCheckboxes.bind(this)); 390// } 391// var checkGdpr = function checkGdpr() { 392function checkGdpr4(consent) { 393 let valid = false; 394 const vali = consent.checked; 395 if (vali) { 396 showSuccess_3(consent); 397 valid = true; 398 } else { 399 showError_3(consent, "The field is required"); 400 } 401 return valid; 402} 403 404function validate(evt) { 405 var theEvent = evt || window.event; 406 // Handle paste 407 if (theEvent.type === "paste") { 408 key = event.clipboardData.getData("text/plain"); 409 } else { 410 // Handle key press 411 var key = theEvent.keyCode || theEvent.which; 412 key = String.fromCharCode(key); 413 } 414 var regex = /[0-9]|\./; 415 if (!regex.test(key)) { 416 theEvent.returnValue = false; 417 if (theEvent.preventDefault) theEvent.preventDefault(); 418 } 419} 420 421function isEmailValid_3(email) { 422 const re = 423 /^(([^<>()\[\]\\.,;:\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,}))$/; 424 return re.test(email); 425} 426
427let inputCheck = document.querySelectorAll(".form-group input"); 428const selectBoxes = document.querySelectorAll(".form-group select"); 429 430var newsletterSubmitBtn = document.getElementById("formSubmitBtn"); 431 432// Check if all fields are correct to make button active 433const customNewsletterFormValidFunction = () => { 434 let forms = document.querySelectorAll( 435 "#newsletterForm_1", 436 "#newsletterForm", 437 "#newsletterForm_2", 438 '.gdm-form' 439 ); 440 [...forms].forEach((form) => { 441 let valueCount = 0; 442 let fieldsToValidate = form.querySelectorAll(".form-group").length + 1; 443 444 Array.from(form.elements).forEach((element) => { 445 if (element.value !== "" && element.checkValidity()) { 446 valueCount++; 447 } else { 448 return; 449 } 450 }); 451 452 if ( 453 valueCount >= fieldsToValidate && 454 newsletterSubmitBtn.classList.contains("disabled") 455 ) { 456 newsletterSubmitBtn.classList.remove("disabled"); 457 } else if ( 458 valueCount < fieldsToValidate && 459 !newsletterSubmitBtn.classList.contains("disabled") 460 ) { 461 newsletterSubmitBtn.classList.add("disabled"); 462 } 463 }); 464}; 465 466inputCheck.forEach((el) => { 467 el.addEventListener("keyup", () => { 468 const elId = el.id.toString(); 469 window[elId](el); 470 customNewsletterFormValidFunction(); 471 }); 472}); 473 474selectBoxes.forEach((el) => { 475 el.addEventListener("change", function (e) { 476 checkSelect(el); 477 customNewsletterFormValidFunction(); 478 }); 479}); 480 481// Catfish uses this 482function validateMyForm( 483 form, 484 email, 485 firstname, 486 lastname, 487 company, 488 jobtitle, 489 industry, 490 country, 491 //jobfunction, 492 consent = false 493) { 494 // input on change check 495 496 var necolldata = ""; 497 /*var chkEmail = jQuery("#temp_email").val(); 498 499 var finalEmailCheck = true; 500 if (chkEmail == false || chkEmail == "false") { 501 finalEmailCheck = false; 502 }*/ 503 var allCollection = jQuery('input[name="news_form_key_name[]"]:checked') 504 .map(function () { 505 if (this.value != "") { 506 let singleitem = this.value; 507 return singleitem; 508 } 509 }) 510 .get(); 511 512 var blogids = jQuery('input[name="blogids"]').val(); 513 514 checkEmail(email); 515 checkFirstName(firstname); 516 checkLastName(lastname); 517 checkCompany(company); 518 checkIndustry(industry); 519 checkCountry(country); 520 checkJobTitle(jobtitle); 521 //checkFunction(jobfunction); 522 checkGdpr4(consent); 523 524 customNewsletterFormValid = 525 //finalEmailCheck && 526 checkEmail(email) && 527 checkFirstName(firstname) && 528 checkLastName(lastname) && 529 checkCompany(company) && 530 checkIndustry(industry) && 531 checkJobTitle(jobtitle) && 532 //checkFunction(jobfunction) && 533 checkCountry(country); 534 checkGdpr4(consent); 535 // checkPhone(phone) && 536 // checkMessage(enquiry) && 537 // checkGdpr(consent); 538 539 // if form is valid then submit 540 541 if (customNewsletterFormValid) { 542 var news_form_key_name = new Array(); 543 var news_form_key_paradot_name = new Array(); 544 var news_form_key_pardontlink = new Array(); 545 546 var form_Id = form.id; 547 548 // newsletterSubmitBtn.classList.remove("disabled"); 549 var recaptcha = document.getElementById("recaptch_secret_key").value; 550 551 if (recaptcha != "") { 552 jQuery.ajax({ 553 url: "/wp-content/plugins/vms-automation-gd/captcha.php", 554 data: jQuery("form#" + form_Id).serialize(), 555 type: "POST", 556 complete: function (response) { 557 let data_captcha = JSON.parse(response.responseText); 558 559 if (data_captcha.status == "success") { 560 jQuery.ajax({ 561 url: "/wp-content/plugins/nsmg-newsletter-settings/newsletter-ajaxcall.php", 562 data: 563 jQuery("form#" + form_Id).serialize() + 564 "&news_form_key_name=" + 565 allCollection + 566 "&blogids=" + 567 blogids, 568 type: "POST", 569 beforeSend: function () { 570 //jQuery('.button').attr("disabled","disabled"); 571 //jQuery('.modal-full').css('opacity', '.5'); 572 }, 573 success: function (data) { 574 if (data != 1 || data != "1") { 575 jQuery(".leaderrormsg").html( 576 "Your request has not been submitted! please try again." 577 ); 578 } else { 579 // Success start 580 const removeLineBreaksAndEmptyStrings = (text) => 581 text.replace(/[\n\r]+/g, "").replace(/\s{2,10}/g, " "); 582 const qnOrAnd = () => 583 window.location.href.includes("?") ? "&" : "?"; 584 585 history.pushState( 586 "", 587 "", 588 `${window.location.href}${qnOrAnd()}cf-form-submission` 589 ); 590 591 // Track which newsletter checkboxes were selected 592 // Take the text content from the label next to each checkbox and make it a URL param if the checkbox is checked when the form is submitted 593 594 [ 595 ...document.querySelectorAll( 596 ".newsletter-checkboxes .Verdict_Privacy_opt_in input[type=checkbox]" 597 ), 598 ].forEach((box) => { 599 box.checked 600 ? history.pushState( 601 "", 602 "", 603 `${ 604 window.location.href 605 }${qnOrAnd()}${removeLineBreaksAndEmptyStrings( 606 box.nextElementSibling 607 ? box.nextElementSibling.textContent 608 : "" 609 )}=true` 610 ) 611 : history.pushState( 612 "", 613 "", 614 `${ 615 window.location.href 616 }${qnOrAnd()}${removeLineBreaksAndEmptyStrings( 617 box.nextElementSibling 618 ? box.nextElementSibling.textContent 619 : "" 620 )}=false` 621 ); 622 }); 623 624 document.body.classList.remove( 625 "catfish-slide-up", 626 "open-full-form", 627 "modal-taller-than-viewport", 628 "freeze-element" 629 ); 630 631 document.body.classList.add("form-submitted"); 632 localStorage.setItem("doNotShowCatFishAgain", "true"); 633 634 location.reload(); 635 636 // Success end 637 } 638 //jQuery('.leadsucessmsg').html("Your request has been submitted successfully"); 639 }, 640 error: function (ex) { 641 jQuery(".leaderrormsg").html( 642 "Your request has not been submitted! please try again error." 643 ); 644 }, 645 }); 646 } else { 647 document.getElementById("captcha").innerHTML = "Invalid Captcha"; 648 } 649 }, 650 error: function (ex) { 651 document.getElementById("captcha").innerHTML = 652 "form not submitted to curl"; 653 }, 654 }); 655 } else { 656 document.getElementById("captcha").innerHTML = "Please select Captcha"; 657 } 658 //tracking 659 if ( 660 window.location.hostname == "www.pharmaceutical-technology.com" || 661 window.location.hostname == "www.power-technology.com" || 662 window.location.hostname == "www.offshore-technology.com" 663 ) { 664 window._uxa = window._uxa || []; 665 if (typeof CS_CONF === "undefined") { 666 window._uxa.push([ 667 "setPath", 668 window.location.pathname + window.location.hash.replace("#", "?__"), 669 ]); 670 var mt = document.createElement("script"); 671 mt.type = "text/javascript"; 672 mt.async = true; 673 mt.src = "//t.contentsquare.net/uxa/70aab1561db23.js"; 674 document.getElementsByTagName("head")[0].appendChild(mt); 675 } else { 676 window._uxa.push([ 677 "setPath", 678 window.location.pathname + "?catfish_newsletter_subscribe", 679 ]); 680 window._uxa.push(["trackPageview"]); 681 window._uxa.push(["trackPageEvent", " Catfish banner shown "]); 682 } 683 } 684 } else { 685 if (!newsletterSubmitBtn.classList.contains("disabled")) { 686 newsletterSubmitBtn.classList && newsletterSubmitBtn.classList.add("disabled"); 687 } 688 return false;
689 } 690 691 const debounce = (fn, delay = 500) => { 692 let timeoutId; 693 return (...args) => { 694 // cancel the previous timer 695 if (timeoutId) { 696 clearTimeout(timeoutId); 697 } 698 // setup a new timer 699 timeoutId = setTimeout(() => { 700 fn.apply(null, args); 701 }, delay); 702 }; 703 }; 704 705 form.addEventListener( 706 "input", 707 debounce(function (e) { 708 switch (e.target.id) { 709 case "enq-email": 710 checkEmail(email); 711 break; 712 case "enq-first-name": 713 checkFirstName(firstname); 714 break; 715 case "enq-last-name": 716 checkLastName(lastname); 717 break; 718 case "enq-company": 719 checkCompany(company); 720 break; 721 case "enq-industry": 722 checkCompany(industry); 723 break; 724 case "enq-job-title": 725 checkJobTitle(jobtitle); 726 break; 727 case "enq-job-function": 728 checkJobTitle(jobfunction); 729 break; 730 case "enq-country": 731 checkCountry(country); 732 break; 733 case "enq-phone": 734 checkPhone(phone); 735 break; 736 case "enq-message": 737 checkMessage(enquiry); 738 break; 739 // case "enq-gdpr": 740 // checkGdpr4(consent); 741 // break; 742 } 743 }) 744 ); 745} 746 747// Expose functions to global scope for HTML event handlers 748window.checkNewslettersEmail = checkNewslettersEmail; 749window.validateMyForm = validateMyForm; 750window.validateNewForm = validateNewForm; 751window.checkEmail = checkEmail; 752window.checkFirstName = checkFirstName; 753window.checkLastName = checkLastName; 754window.checkCompany = checkCompany; 755window.checkIndustry = checkIndustry; 756window.checkJobTitle = checkJobTitle; 757window.checkFunction = checkFunction; 758window.checkCountry = checkCountry; 759window.checkSelect = checkSelect; 760window.checkPhone = checkPhone; 761window.checkMessage = checkMessage; 762window.checkGdpr4 = checkGdpr4; 763window.validate = validate; 764window.isEmailValid_3 = isEmailValid_3; 765 766})(); 767 768// Activate submit button after validate the form 769 770 771 772function validateNewForm( 773 form, 774 email, 775 firstname, 776 lastname, 777 company, 778 //industry, 779 //country, 780 jobtitle, 781 //jobfunction, 782 consent = false 783) { 784 // input on change check 785 786 var necolldata = ""; 787 /*var chkEmail = jQuery("#temp_email").val(); 788 789 var finalEmailCheck = true; 790 if (chkEmail == false || chkEmail == "false") { 791 finalEmailCheck = false; 792 }*/ 793 var allCollection = jQuery('input[name="news_form_key_name[]"]:checked') 794 .map(function () { 795 if (this.value != "") { 796 let singleitem = this.value; 797 return singleitem; 798 } 799 }) 800 .get(); 801 802 checkEmail(email); 803 checkFirstName(firstname); 804 checkLastName(lastname); 805 checkCompany(company); 806 //checkIndustry(industry); 807 //checkCountry(country); 808 checkJobTitle(jobtitle); 809 //checkFunction(jobfunction); 810 checkGdpr4(consent); 811 812 formValid = 813 //finalEmailCheck && 814 checkEmail(email) && 815 checkFirstName(firstname) && 816 checkLastName(lastname) && 817 checkCompany(company) && 818 //checkIndustry(industry) && 819 checkJobTitle(jobtitle) 820 //checkFunction(jobfunction) && 821 //checkCountry(country); 822 // checkNewsletterCheckboxes() && 823 // checkGdpr4(consent); 824 // checkPhone(phone) && 825 // checkMessage(enquiry) && 826 // checkGdpr3(consent); 827 828 // if form is valid then submit 829 830 if (formValid) { 831 var news_form_key_name = new Array(); 832 var news_form_key_paradot_name = new Array(); 833 var news_form_key_pardontlink = new Array(); 834 835 var form_Id = form.id; 836 837 // newsletterSubmitBtn.classList.remove("disabled"); 838 var recaptcha = document.getElementById("recaptch_secret_key").value; 839 840 if (recaptcha != "") { 841 jQuery.ajax({ 842 url: "/wp-content/plugins/vms-automation-gd/captcha.php", 843 data: jQuery("form#" + form_Id).serialize(), 844 type: "POST", 845 complete: function (response) { 846 let data_captcha = JSON.parse(response.responseText); 847 if (data_captcha.status == "success") { 848 jQuery.ajax({ 849 url: "/wp-content/plugins/nsmg-newsletter-settings/newsletter-ajaxcall.php", 850 data: 851 jQuery("form#newsletterForm_2").serialize() + 852 "&news_form_key_name=" + 853 allCollection, 854 type: "POST", 855 beforeSend: function () { 856 //jQuery('.button').attr("disabled","disabled");
857 //jQuery('.modal-full').css('opacity', '.5'); 858 }, 859 success: function (data) { 860 if (data != 1 || data != "1") { 861 jQuery(".leaderrormsg").html( 862 "Your request has not been submitted! please try again." 863 ); 864 } else { 865 /*document.body.classList.remove('catfish-slide-up', 'open-full-form', 'modal-taller-than-viewport', 'freeze-element'); 866 document.body.classList.add('form-submitted'); 867 localStorage.setItem('doNotShowCatFishAgain', 'true');*/ 868 869 jQuery("#thank-you-message").css("display", "block"); 870 jQuery("#submitted-form").hide(); 871 872 // Track which newsletter checkboxes were selected 873 // Take the text content from the label next to each checkbox and make it a URL param if the checkbox is checked when the form is submitted 874 875 const removeLineBreaksAndEmptyStrings = (text) => 876 text.replace(/[\n\r]+/g, "").replace(/\s{2,10}/g, " "); 877 const qnOrAnd = () => 878 window.location.href.includes("?") ? "&" : "?"; 879 const newsletterCheckboxes = document.querySelectorAll( 880 ".newsletter-checkboxes .Verdict_Privacy_opt_in" 881 ); 882 history.pushState( 883 "", 884 "", 885 `${window.location.href}${this.qnOrAnd()}cf-form-submission` 886 ); 887 888 if (newsletterCheckboxes[0]) 889 [...newsletterCheckBoxes].forEach((box) => 890 box.checked 891 ? history.pushState( 892 "", 893 "", 894 `${ 895 window.location.href 896 }${qnOrAnd()}${removeLineBreaksAndEmptyStrings( 897 box.nextElementSibling.textContent 898 )}=true` 899 ) 900 : history.pushState( 901 "", 902 "", 903 `${ 904 window.location.href 905 }${qnOrAnd()}${removeLineBreaksAndEmptyStrings( 906 box.nextElementSibling.textContent 907 )}=false` 908 ) 909 ); 910 911 //jQuery("#newsletterForm_2").trigger("reset"); 912 /*const successMoadal = 913 document.querySelector("#successs-modal"); 914 document.querySelector("#modal-two").classList.remove("open"); 915 successMoadal.classList.add("open"); 916 document 917 .querySelector("#successs-modal .close-modal") 918 .addEventListener("click", () => { 919 successMoadal.classList.remove("open"); 920 921 });*/ 922 } 923 //jQuery('.leadsucessmsg').html("Your request has been submitted successfully"); 924 }, 925 error: function (ex) { 926 jQuery(".leaderrormsg").html( 927 "Your request has not been submitted! please try again error." 928 ); 929 }, 930 }); 931 } else { 932 document.getElementById("captcha").innerHTML = "Invalid Captcha"; 933 } 934 }, 935 error: function (ex) { 936 document.getElementById("captcha").innerHTML = 937 "form not submitted to curl"; 938 }, 939 }); 940 } else { 941 //document.getElementById("captcha").innerHTML = "Please select Captcha"; 942 jQuery.ajax({ 943 url: "/wp-content/plugins/nsmg-newsletter-settings/newsletter-ajaxcall.php", 944 data: 945 jQuery("form#newsletterForm_2").serialize() + 946 "&news_form_key_name=" + 947 allCollection, 948 type: "POST", 949 beforeSend: function () { 950 //jQuery('.button').attr("disabled","disabled");
951 //jQuery('.modal-full').css('opacity', '.5'); 952 }, 953 success: function (data) { 954 if (data != 1 || data != "1") { 955 jQuery(".leaderrormsg").html( 956 "Your request has not been submitted! please try again." 957 ); 958 } else { 959 /*document.body.classList.remove('catfish-slide-up', 'open-full-form', 'modal-taller-than-viewport', 'freeze-element'); 960 document.body.classList.add('form-submitted'); 961 localStorage.setItem('doNotShowCatFishAgain', 'true');*/ 962 jQuery("#thank-you-message").css("display", "block"); 963 jQuery("#submitted-form").hide(); 964 965 //jQuery("#newsletterForm_2").trigger("reset"); 966 /*const successMoadal = 967 document.querySelector("#successs-modal"); 968 document.querySelector("#modal-two").classList.remove("open"); 969 successMoadal.classList.add("open"); 970 document 971 .querySelector("#successs-modal .close-modal") 972 .addEventListener("click", () => { 973 successMoadal.classList.remove("open"); 974 975 });*/ 976 } 977 }, 978 error: function (ex) { 979 document.getElementById("captcha").innerHTML = 980 "form not submitted to curl"; 981 }, 982 }); 983 } 984 //tracking 985 if ( 986 window.location.hostname == "www.pharmaceutical-technology.com" || 987 window.location.hostname == "www.power-technology.com" || 988 window.location.hostname == "www.offshore-technology.com" 989 ) { 990 window._uxa = window._uxa || []; 991 if (typeof CS_CONF === "undefined") { 992 window._uxa.push([ 993 "setPath", 994 window.location.pathname + window.location.hash.replace("#", "?__"), 995 ]); 996 var mt = document.createElement("script"); 997 mt.type = "text/javascript"; 998 mt.async = true; 999 mt.src = "//t.contentsquare.net/uxa/70aab1561db23.js"; 1000 document.getElementsByTagName("head")[0].appendChild(mt); 1001 } else { 1002 window._uxa.push([ 1003 "setPath", 1004 window.location.pathname + "?daily_newsletter_subscribe", 1005 ]); 1006 window._uxa.push(["trackPageview"]); 1007 window._uxa.push(["trackPageEvent", "Daily News Letter Susbscribe "]); 1008 } 1009 } 1010 } else { 1011 if (!newsletterSubmitBtn.classList.contains("disabled")) { 1012 newsletterSubmitBtn.classList.add("disabled"); 1013 } 1014 return false; 1015 } 1016 1017 const debounce = (fn, delay = 500) => { 1018 let timeoutId; 1019 return (...args) => { 1020 // cancel the previous timer 1021 if (timeoutId) { 1022 clearTimeout(timeoutId); 1023 } 1024 // setup a new timer 1025 timeoutId = setTimeout(() => { 1026 fn.apply(null, args); 1027 }, delay); 1028 }; 1029 }; 1030 1031 form.addEventListener( 1032 "input", 1033 debounce(function (e) { 1034 switch (e.target.id) { 1035 case "enq-email": 1036 checkEmail(email); 1037 break; 1038 case "enq-first-name": 1039 checkFirstName(firstname); 1040 break; 1041 case "enq-last-name": 1042 checkLastName(lastname); 1043 break; 1044 case "enq-company": 1045 checkCompany(company); 1046 break; 1047 case "enq-industry": 1048 checkCompany(industry); 1049 break; 1050 case "enq-job-title": 1051 checkJobTitle(jobtitle); 1052 break; 1053 case "enq-job-function": 1054 checkJobTitle(jobfunction); 1055 break; 1056 case "enq-country": 1057 checkCountry(country); 1058 break; 1059 case "enq-phone": 1060 checkPhone(phone); 1061 break; 1062 case "enq-message": 1063 checkMessage(enquiry); 1064 break; 1065 // case "enq-gdpr": 1066 // checkGdpr4(consent); 1067 // break; 1068 } 1069 }) 1070 ); 1071}
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.