1 2 3if(typeof jQuery === 'undefined'){ 4 var startingTime = new Date().getTime(); 5 // Load the script 6 var script = document.createElement("SCRIPT"); 7 script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js'; 8 script.type = 'text/javascript'; 9 document.getElementsByTagName("head")[0].appendChild(script); 10} 11 12// make sure that jquery is always present 13var isJqueryReady = function(callback) { 14 if (window.jQuery) { 15 callback(jQuery.noConflict()); 16 var $ = jQuery; 17 } 18 else { 19 window.setTimeout(function() { isJqueryReady(callback); }, 20); 20 } 21}; 22 23 24isJqueryReady(function($jqueryInstance) { 25 $jqueryInstance(function() { 26 var endingTime = new Date().getTime(); 27 var tookTime = endingTime - startingTime; 28 $jqueryInstance('body').append('<!-- jquery version: ' + $jqueryInstance.fn.jquery + ' -->'); 29 var cmApp_element=''; 30 var cmApp_formType=''; 31 32 var CM_BASE_SITE_URL = ""; 33 34 window.cmApp_validateForm = function() 35 { 36 37 var signupContainerElem=$jqueryInstance("#cmApp_signupContainer"); 38 39 var errorElem = $jqueryInstance("#cmApp_emailError"); 40 var errorElemDOB = $jqueryInstance("#cmApp_dobError"); 41 var formElem = signupContainerElem.find("form"); 42 var processingMsgElem = signupContainerElem.find("div.cmApp_processingMsg"); 43 var successMsgElem = signupContainerElem.find("div.cmApp_successMsg"); 44 45 46 var errorMsgAr=[]; 47 var errorFieldSelectorAr=[]; 48 49 var errorMsg=""; 50 51 formElem.hide(); 52 errorElem.html("").hide(); 53 errorElemDOB.html("").hide(); 54 successMsgElem.hide(); 55 56 cmApp_showProcessing(); 57 58 signupContainerElem.find("input,select").css("outline","none"); 59 60 // validate the email field. make sure it is not empty and that it is valid. if invalid, add to the error array and outline the field in red 61 var email = $jqueryInstance("#cmApp_signupEmail").val(); 62 63 if (email.length < 1) { 64 errorMsg = "Email address is required"; 65 errorMsgAr[errorMsgAr.length]="Email address is required"; 66 $jqueryInstance("#cmApp_signupEmail").focus().css("outline","1px solid #FF0000"); 67 } 68 else { 69 if (!cmApp_validateEmail(email)) { 70 errorMsgAr[errorMsgAr.length]="Email address is invalid"; 71 errorFieldSelectorAr[errorFieldSelectorAr.length]="#cmApp_signupEmail"; 72 $jqueryInstance("#cmApp_signupEmail").focus().css("outline","1px solid #FF0000"); 73 } 74 } 75 76 // make sure that all required inputs and selects (dropdown) have values. if invalid, add to the error array and outline the field in red 77 $jqueryInstance(".cm-required").find("input").css("outline","none"); 78 var elems=$jqueryInstance(".cm-required").find("input,select"); 79 for (var x=0; x<elems.length;x++) 80 { 81 var elem=$jqueryInstance(elems[x]); 82 if (elem) 83 { 84 var val=elem.val(); 85 if (val.length<1) 86 { 87 // the field is empty. 88 var elemId=elem.attr("name"); 89 var tempElem=$jqueryInstance("#cmApp_signupContainer").find("label[for='"+elemId+"']"); 90 var fieldLabel="Field"; 91 if (tempElem.length>0) 92 { 93 // the field has a label. use the label as the field name 94 fieldLabel=tempElem.html(); 95 } 96 else 97 { 98 if (elem.attr("placeholder")) 99 { 100 // the field has a placeholder. use the placeholder as the field name 101 fieldLabel=elem.attr("placeholder"); 102 } 103 } 104 errorMsgAr[errorMsgAr.length]= fieldLabel.replace(" *","")+" is required"; 105 elem.focus().css("outline","1px solid #FF0000"); 106 } 107 } 108 } 109 110 // make sure that all required multi select many inputs (checkboxes) have at least 1 checked field. if invalid, add to the error array and outline all checkboxes in red 111 $jqueryInstance(".cm-checkboxes-required").find("input").css("outline","none"); 112 var elems=$jqueryInstance(".cm-checkboxes-required"); 113 114 for (var x=0; x<elems.length;x++) 115 {
116 var elem=$jqueryInstance(elems[x]).find("input:checked"); 117 if (elem.length<1) 118 { 119 // there are no checked inputs in the container 120 var fieldLabel=elems.find("label:eq(0)").html(); 121 errorMsgAr[errorMsgAr.length]= fieldLabel.replace(" *","")+" is required"; 122 elems.find("input").focus().css("outline","1px solid #FF0000"); 123 } 124 } 125 126 127 if (errorMsgAr.length > 0 ) { 128 // at least 1 error was found. loop through all error and display them. 129 cmApp_hideProcessing(); 130 formElem.show(); 131 var errorMsg=""; 132 for (var x=0;x<errorMsgAr.length;x++) 133 { 134 errorMsg+="<div>"+errorMsgAr[x]+"</div>"; 135 } 136 $jqueryInstance("#cmApp_errorAll").html(errorMsg).slideDown(200); 137 successMsgElem.hide(); 138 //return false; 139 } 140 141 142 143 var errorMsgDOB=""; 144 145 if (cmApp_validateDOB() == true){ 146 //errorMsgDOB = ""; 147 } else { 148 //console.log("DOB NOT valid"); 149 errorMsgDOB = "Please enter a valid date (MM/DD/YYYY)"; 150 cmApp_hideProcessing(); 151 formElem.show(); 152 errorElemDOB.html(errorMsgDOB).slideDown(200); 153 successMsgElem.hide(); 154 //return false; 155 } 156 157 if (errorMsg.length > 0 || errorMsgDOB.length>0) 158 { 159 return false; 160 } 161 return true; 162 163 }; 164 165 166 window.cmApp_signup_writeCookie = function(var1, val1) 167 { 168 document.cookie = var1 + "=" + encodeURIComponent(val1) + "; path=/"; 169 }; 170 171 window.cmApp_signup_removeCookie = function(var1) 172 { 173 document.cookie = var1 + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/"; 174 }; 175 176 window.cmApp_signup_readCookie = function(var1) 177 { 178 var nameEQ = var1 + "="; 179 var cookieAr = document.cookie.split(';'); 180 for (var i = 0; i < cookieAr.length; i++) { 181 var curCookie = cookieAr[i].trim(); 182 if (curCookie.indexOf(nameEQ) == 0) { 183 return decodeURIComponent(curCookie.substring(nameEQ.length, curCookie.length)); 184 } 185 } 186 return ""; 187 }; 188 189 190 window.cmApp_validateEmail = function(email) 191 { 192 // simple test to determine that there are character(s), the @ symbol, character(s), period, character(s) 193 // this will still allow some invalid emails (ex: "a@[email protected]"), these can be checked by campaign monitor. 194 var emailReg = /^[^\s]+@[^\s@]+\.[^\s@]+$/; 195 return emailReg.test(email); 196 }; 197 198 window.cmApp_validateDOB = function() 199 { 200 var dobNode = $jqueryInstance("#cmApp_signupDateOfBirth"); 201 if (dobNode.length == 0){ // there is no date of birth field in the form. no error. 202 return true; 203 } 204 205 var dob = dobNode.val(); 206 if (dob.length == 0){ // date of birth field is blank. it is not required, so there is no error. 207 return true; 208 } 209 210 211 dob = dob.replace(/\/|-| |\.|,/g, '-'); 212 var dateAR=dob.split("-"); 213 if (dateAR.length!=3) 214 { // there should be 3 values: day, month, and year. Otherwise there is a date error. 215 return false; 216 } 217 218 // Parse the date parts to integers 219 var day = parseInt(dateAR[1]); 220 var month = parseInt(dateAR[0]); 221 var year = parseInt(dateAR[2]); 222 223 224 if(isNaN(day) || isNaN(month) || isNaN(year)) { 225 // day, month, or year is not a numeric. 226 return false; 227 } 228 229 var currentYear=new Date().getFullYear(); 230 231 // Check the ranges of month and year 232 if (year < 1900 || year >
232 currentYear || month == 0 || month > 12) { 233 // the month or year is invalid 234 return false; 235 } 236 237 var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 238 239 // Adjust for leap years 240 if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) { 241 monthLength[1] = 29; 242 } 243 244 // Check the range of the day 245 if (day <= 0 || day > monthLength[month - 1]) { 246 // the number of days is not valid for the specified month. 247 return false; 248 } 249 250 return true; 251 }; 252 253 window.cmApp_showProcessing = function() { 254 var statusContainer = document.getElementById('cmApp_statusContainer'); 255 var processingElem = statusContainer.querySelector('.cmApp_processingMsg'); 256 257 statusContainer.classList.add('cmApp_processing'); 258 statusContainer.classList.remove('cmApp_hidden'); 259 }; 260 261 window.cmApp_hideProcessing = function() { 262 var statusContainer = document.getElementById('cmApp_statusContainer'); 263 var processingElem = statusContainer.querySelector('.cmApp_processingMsg'); 264 265 statusContainer.classList.remove('cmApp_processing'); 266 statusContainer.classList.add('cmApp_hidden'); 267 }; 268 269 window.showSuccess = function() { 270 var statusContainer = document.getElementById('cmApp_statusContainer'); 271 var processingElem = statusContainer.querySelector('.cmApp_processingMsg'); 272 273 statusContainer.classList.remove('cmApp_hidden'); 274 statusContainer.classList.remove('cmApp_processing'); 275 }; 276 277 window.cmApp_showError = function() { 278 var statusContainer = document.getElementById('cmApp_statusContainer'); 279 }; 280 281 var cmApp_formIsDisplayed=0; 282 283 window.cmApp_initForm = function(forceLoadForm) 284 { 285 // cmApp_formType = $jqueryInstance('#cmApp_formType').val(); 286 // cmApp_element 287 288 if (cmApp_formIsDisplayed && $jqueryInstance("#noAutoOpen").val()!="1") 289 { 290 return false; 291 } 292 293 if (cmApp_formType=="lightbox" && !forceLoadForm) 294 { 295 var percentScroll=0; 296 297 var elem=$jqueryInstance('#noAutoOpen'); 298 if (elem.length>0) 299 { 300 var noAutoOpen=parseInt(elem.val()); 301 if (noAutoOpen>0) 302 { 303 //alert("load form in "+delaySeconds+" sec"); 304 //setTimeout(function(){ cmApp_initForm(1); }, (delaySeconds*1000)); 305 cmApp_button(); 306 return false; 307 } 308 } 309 310 elem=$jqueryInstance('#lightboxSeconds'); 311 if (elem.length>0) 312 { 313 //alert("c"); 314 var delaySeconds=parseInt(elem.val()); 315 if (delaySeconds>0) 316 { 317 //alert("load form in "+delaySeconds+" sec"); 318 setTimeout(function(){ cmApp_initForm(1); }, (delaySeconds*1000)); 319 return false; 320 } 321 } 322 323 elem=$jqueryInstance('#lightboxScrollPercent'); 324 if (elem.length>0) 325 { 326 327 var percentScroll=parseInt(elem.val()); 328 if (percentScroll>0) 329 { 330 331 //console.log("load form in "+percentScroll+" % scroll"); 332 333 function checkPageScroll(percentScroll) 334 { 335 var wintop = $jqueryInstance(window).scrollTop(); 336 var docheight = $jqueryInstance(document).height(); 337 var winheight = $jqueryInstance(window).height(); 338 //var scrolltrigger = event.data.percentScroll/100; 339 var scrolltrigger = percentScroll/100; 340 //console.log("A "+((wintop/(docheight-winheight))+" > "+(scrolltrigger))); 341 //console.log("b +(("+wintop+"/("+docheight+"-"+winheight+")) > ("+scrolltrigger+"))"); 342 if ((wintop/(docheight-winheight)) > scrolltrigger) 343 { 344 cmApp_initForm(1); 345 } 346 } 347 348 $jqueryInstance(document).on("scroll", { percentScroll:percentScroll }, function(event){ 349 checkPageScroll(event.data.percentScroll); 350 }); 351 //console.log("checkPageScroll("+percentScroll+")"); 352 checkPageScroll(percentScroll); 353 return false; 354 } 355 } 356 } 357 358 359 var campaignMonitorFormId = $jqueryInstance("#cmApp_FormId").val(); 360 var campaignMonitorViewedIds = cmApp_signup_readCookie("campaignMonitorViewedIds"); 361 362 // get $ reference to form 363 var el = $jqueryInstance('#' + cmApp_element); 364 365 cmApp_formIsDisplayed=1; 366 367 // add form id to cookie 368 if (campaignMonitorFormId) { 369 370 if (campaignMonitorViewedIds.indexOf("(" + campaignMonitorFormId + ")") < 0) { 371 cmApp_signup_writeCookie("campaignMonitorViewedIds", 372 campaignMonitorViewedIds + "(" + campaignMonitorFormId + ")"); 373 } 374 } 375 376 if (cmApp_formType == 'lightbox') { 377 //cmApp_lightboxForm(el); 378 setTimeout(function(){ 379 cmApp_lightboxForm(el); 380 }, 1000); 381 } else { 382 if (cmApp_formType == 'slideoutTab') { 383 cmApp_slideoutForm(el); 384 } else { 385 if (cmApp_formType == 'embedded') { 386 cmApp_embedForm(el); 387 } else { 388 el.removeClass('cmApp_hidden'); 389 } 390 } 391 } 392 393 394 // bind close button click handler 395 el.find('.cmApp_closeFormButton').on('click', function (event) 396 { 397 event.preventDefault(); 398 cmApp_closeForm(cmApp_element); 399 }); 400 401 402 cmPreviewFormHeightUpdate(); 403 404 405 }; 406 407 window.cmApp_closeForm = function(element) 408 {
409 var modalBackground = $jqueryInstance('#cmApp_modalBackground'); 410 element = $jqueryInstance('#' + element); 411 modalBackground.fadeOut( 300, function() { 412 element.addClass('cmApp_hidden'); 413 }); 414 415 }; 416 417 window.cmApp_embedForm = function(el) 418 { 419 var markup = el.html(); 420 421 var main = $jqueryInstance('.cmApp_embedFormContainer').first(); 422 423 if (main.length >= 0) 424 { 425 $jqueryInstance('.cmApp_embedFormContainer').css("display","block"); 426 } 427 else { 428 var main = $jqueryInstance('main').first(); 429 430 if (main.length < 1) { 431 main = $jqueryInstance('[role="main"]').first(); 432 } 433 } 434 435 if (main.length >= 1) { 436 el.appendTo(main); 437 } 438 el.removeClass('cmApp_hidden'); 439 440 }; 441 442 window.cmApp_button = function() 443 { 444 445 var main = $jqueryInstance('.cmApp_FormButtonContainer').first(); 446 447 if (main.length > 0) 448 { 449 $jqueryInstance('.cmApp_FormButtonContainer').css("display","block"); 450 } 451 else { 452 var main = $jqueryInstance('main').first(); 453 454 if (main.length < 1) { 455 main = $jqueryInstance('[role="main"]').first(); 456 } 457 if (main.length < 1) { 458 main = $jqueryInstance('body').first(); 459 } 460 } 461 462 if (main.length >= 1) { 463 //el.appendTo(main); 464 main.append('<a href="javascript:void(0);" onclick="cmApp_initForm(1);" class="cmFormElemButton">Click Here</a>'); 465 466 var elem=$jqueryInstance(".cmApp_formSubmitButton"); 467 var elemNew=$jqueryInstance(".cmFormElemButton"); 468 elemNew.css("background-color", elem.css("background-color")); 469 elemNew.css("color", elem.css("color")); 470 elemNew.html(elem.val()); 471 472 } 473 }; 474 475 window.cmApp_lightboxForm = function(el) 476 { 477 478 $jqueryInstance('#cmApp_modalBackground').removeClass("cmApp_hidden").css("display", "block"); 479 el.removeClass('cmApp_hidden'); 480 }; 481 482 window.cmApp_slideoutForm = function(el) 483 { 484 $jqueryInstance('#cmApp_slideoutButton').on('click', function (event) 485 { 486 event.preventDefault(); 487 cmApp_toggleSlideout(el); 488 }); 489 }; 490 491 window.cmApp_toggleSlideout = function(el) 492 { 493 if (el.is('.cmApp_hidden')) { 494 el.removeClass('cmApp_hidden'); 495 } else { 496 el.addClass('cmApp_hidden'); 497 } 498 }; 499 500 window.cmApp_toggleModal = function(hideBackground) { 501 var modal = $jqueryInstance('#cmApp_modalBackground'); 502 503 if (typeof hideBackground == "undefined") { 504 if (modal.is('.cmApp_hidden')) { 505 hideBackground = 0; 506 } 507 else { 508 hideBackground = 1; 509 } 510 } 511 512 if (hideBackground) { 513 modal.addClass('cmApp_hidden'); 514 } else { 515 modal.removeClass('cmApp_hidden'); 516 } 517 }; 518 519 window.cmPreviewFormHeightUpdate = function() 520 { 521 var windowHeight = $jqueryInstance( window ).height(); 522 523 /*var maxHeightInner=windowHeight-300; 524 if (maxHeightInner<120) 525 { 526 maxHeightInner=120; 527 }*/ 528 529 var maxHeightOuter=windowHeight-150; 530 if (maxHeightOuter<300) 531 { 532 maxHeightOuter=300; 533 } 534 535 var lightboxFieldElem=$jqueryInstance("#cmApp_signupContainer.cmApp_lightbox"); 536 var slideoutElem=$jqueryInstance("#cmApp_signupContainer.cmApp_slideoutTab").find("#cmApp_signupForm"); 537 538 slideoutElem.css("max-height",(maxHeightOuter+"px")).css("overflow-y","auto"); 539 slideoutElem.find("input").css("margin-left",0).css("margin-right",0); 540 lightboxFieldElem.css("max-height",(maxHeightOuter+"px")).css("overflow-y","auto"); 541 lightboxFieldElem.find("input").css("margin-left",0).css("margin-right",0); 542 }; 543 544 $jqueryInstance(function () { 545 $jqueryInstance(document).on('click', '.post-ajax', function (e) { 546 e.preventDefault(); 547 548 $jqueryInstance('#cmApp_thankYouCheck').hide(); 549 550 551 if (!cmApp_validateForm()) { 552 return false; 553 } 554 555 556 var dataToSend = {}; 557 var recaptchaKey = $jqueryInstance('.g-recaptcha-response').val(); 558 dataToSend.action = 'ajax_handler_nopriv_cm_forms'; 559 dataToSend.recaptcha_key = recaptchaKey; 560 561 562 var formData = $jqueryInstance(this).closest('.cm-form-handler').serializeArray(); 563 $jqueryInstance(formData).each(function (index, obj) { 564 565 if (obj.name !== 'no_js'){ 566 dataToSend[obj.name] = obj.value; 567 } 568 }); 569 570 $jqueryInstance.ajax({
571 type: "POST", 572 url: ajax_request.ajax_url, 573 data: dataToSend, 574 dataType: "json" 575 }) 576 .done(function (data, textStatus, request) { 577 578 579 var successMessage = $jqueryInstance('<p/>'); 580 successMessage.text('Thank You!'); 581 582 if (typeof data.success_message != "undefined") { 583 successMessage.css('white-space', 'normal'); 584 successMessage.text(data.success_message); 585 } 586 $jqueryInstance('#cmApp_thankYouCheck').show(); 587 $jqueryInstance('.cmApp_processingMsg').show().text(''); 588 $jqueryInstance('.cmApp_processingMsg').show().append(successMessage); 589 $jqueryInstance('#cmApp_thankYouCheck').show(); 590 591 }) 592 .fail(function (request, textStatus, errorThrown) { 593 594 if (request.responseText) { 595 var errorMsg = request.responseText.replace("error:", ""); 596 } 597 else { 598 var errorMsg = "List Error. Email address not added."; 599 console.log(request); 600 } 601 var signupContainerElem = $jqueryInstance("#cmApp_signupContainer"); 602 var formElem = signupContainerElem.find("form"); 603 var errorElem = $jqueryInstance("#cmApp_emailError"); 604 cmApp_hideProcessing(); 605 formElem.show(); 606 errorElem.html(errorMsg).slideDown(200); 607 }); 608 }); 609 610 $jqueryInstance(window).on('resize', function () { 611 cmPreviewFormHeightUpdate(); 612 }); 613 614 cmApp_element = 'cmApp_signupContainer'; 615 cmApp_formType = $jqueryInstance('#cmApp_formType').val(); 616 cmApp_initForm(0); 617 618 }); 619 }); 620}); 621
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.