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