1jQuery.noConflict(); 2 3jQuery(document).ready(function($) { 4 5 function _changeHtmlTxt(obj, searchVal, newVal) { 6 7 //console.log(obj); 8 var ReplaceValue = searchVal; 9 10 if (searchVal.indexOf("[") > -1) 11 searchVal = "[" + searchVal + "]"; 12 13 var tagName = $(obj).prop("tagName"); 14 15 if (tagName != "SCRIPT" && tagName != "NOSCRIPT" && tagName != "IFRAME") { 16 17 var objChildNodesLength = $(obj).children().length; 18 /***************** 19 Replace text 20 ********************/ 21 if (typeof(obj.innerHTML) !== "undefined" && obj.innerHTML.search(searchVal) > -1 && objChildNodesLength == 0) { 22 var objHtml = obj.innerHTML; 23 var objHtmlReplaceHtml = objHtml.replace(ReplaceValue, newVal); 24 obj.innerHTML = objHtmlReplaceHtml; 25 } 26 27 for (var i = 0; i < obj.attributes.length; i++) { 28 29 var attr = obj.attributes[i]; 30 31 if (attr.value.search(searchVal) > -1) { 32 $(obj).attr(attr.name, attr.value.replace(ReplaceValue, newVal)); 33 var objHtml = obj.innerHTML; 34 var objHtmlReplaceHtml = objHtml.replace(ReplaceValue, newVal); 35 obj.innerHTML = objHtmlReplaceHtml; 36 //console.log(attr.name + " = " + attr.value); 37 } 38 39 } 40 41 for (var i = 0; i < objChildNodesLength; i++) { 42 43 var objChildObj = $(obj).children().get(i); 44 var objChildNodesChildLength = $(objChildObj).children().length; 45 46 /***************** 47 Replace text 48 ********************/ 49 if (typeof(objChildObj.innerHTML) !== "undefined" && objChildObj.innerHTML.search(searchVal) > -1 && objChildNodesChildLength == 0) { 50 var objHtml = objChildObj.innerHTML; 51 var objHtmlReplaceHtml = objHtml.replace(ReplaceValue, newVal); 52 objChildObj.innerHTML = objHtmlReplaceHtml; 53 } 54 55 for (var p = 0; p < objChildObj.attributes.length; p++) { 56 57 var attr = objChildObj.attributes[p]; 58 59 if (attr.value.search(searchVal) > -1) { 60 $(objChildObj).attr(attr.name, attr.value.replace(ReplaceValue, newVal)); 61 var objHtml = objChildObj.innerHTML; 62 var objHtmlReplaceHtml = objHtml.replace(ReplaceValue, newVal); 63 objChildObj.innerHTML = objHtmlReplaceHtml; 64 //console.log(attr.name + " = " + attr.value); 65 } 66 67 } 68 69 for (var p = 0; p < objChildNodesChildLength; p++) { 70 71 var objChildObjChild = $(objChildObj).children().get(p); 72 _changeHtmlTxt(objChildObjChild, ReplaceValue, newVal); 73 74 } 75 76 } 77 78 } 79 80 } 81 82 _pageGetCookie = function getCookie(cname) { 83 var name = cname + "="; 84 var decodedCookie = decodeURIComponent(document.cookie); 85 var ca = decodedCookie.split(';'); 86 for (var i = 0; i < ca.length; i++) { 87 var c = ca[i]; 88 while (c.charAt(0) == ' ') { 89 c = c.substring(1); 90 } 91 if (c.indexOf(name) == 0) { 92 return c.substring(name.length, c.length); 93 } 94 } 95 return ""; 96 } 97 98 _pageSetCookie = function setCookie(cname, val) { 99 var d = new Date(); 100 d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000)); 101 var expires = "expires=" + d.toUTCString(); 102 var urldomain = window.location.hostname; 103 document.cookie = cname + '=' + val + ';' + expires + ";domain=" + urldomain + ";path=/"; 104 } 105 106 _getParams = function(url) { 107 var params = {}; 108 var parser = document.createElement('a'); 109 parser.href = url; 110 var query = parser.search.substring(1); 111 var vars = query.split('&'); 112 for (var i = 0; i < vars.length; i++) { 113 var pair = vars[i].split('='); 114 params[pair[0]] = decodeURIComponent(pair[1]); 115 } 116 return params; 117 }; 118 119 function _htmlCleanUp(urlSearch, cookieName, htmlElement, cleanUp, defaultValue, setCookie) { 120 121 var pageUrl = window.location.href; 122 var siteCookieValue = _pageGetCookie(cookieName); 123 124 var url = _getParams(pageUrl); 125 var pageUrlValue = typeof(url[urlSearch]) == "undefined" ? "" : url[urlSearch]; 126 127 if ((pageUrlValue == null || pageUrlValue == "") && siteCookieValue == '') { 128 _changeHtmlTxt(htmlElement, "[" + cleanUp + "]", defaultValue); 129 _changeHtmlTxt(htmlElement, "%91" + cleanUp + "%93", defaultValue); 130 _pageSetCookie(cookieName, defaultValue); 131 } else if ((pageUrlValue == null || pageUrlValue == "") && siteCookieValue != '') { 132 _changeHtmlTxt(htmlElement, "[" + cleanUp + "]", siteCookieValue); 133 _changeHtmlTxt(htmlElement, "%91" + cleanUp + "%93", siteCookieValue); 134 } else { 135 _changeHtmlTxt(htmlElement, "[" + cleanUp + "]", pageUrlValue); 136 _changeHtmlTxt(htmlElement, "%91" + cleanUp + "%93", pageUrlValue); 137 _pageSetCookie(cookieName, pageUrlValue); 138 } 139 140 } 141 142 //show find my plan popup 143 $('.findmyplanbtn').click(function() { 144 $('#findmyplan').css('display', 'flex'); 145 $('body').addClass('blur'); 146 }); 147 $('.closepopup').click(function() { 148 $('.popups').hide(500); 149 $('body').removeClass('blur'); 150 }); 151 152 $(document).keydown(function(event) { 153 if (event.keyCode === 27 && $('.popups').is(':visible')) { 154 $('.popups').hide(500); 155 $('body').removeClass('blur'); 156 } 157 }); 158 159 160 //slider 161 $(".customer-logos").closest("et_pb_row").addClass("container-carousel"); 162 163 $('.customer-logos').slick({ 164 slidesToShow: 4, 165 autoplay: true, 166 autoplaySpeed: 0, 167 speed: 5000, 168 infinite: true, 169 cssEase: 'linear', 170 focusOnSelect: false,
171 arrows: false, 172 dots: false, 173 pauseOnHover: false, 174 responsive: [{ 175 breakpoint: 768, 176 settings: { 177 slidesToShow: 2 178 179 } 180 }, { 181 breakpoint: 520, 182 settings: { 183 slidesToShow: 2, 184 // centerMode: true, 185 // centerPadding: '40px', 186 } 187 }] 188 }); 189 190 // Business Hours // 191 var bizHours = 'https://global.isg.us/wp-content/themes/infsalesgroup-child/api/hours/?' + Date.now(); 192 $.ajax({ 193 url: bizHours, 194 type: 'GET', 195 dataType: 'json', 196 success: function(data) { 197 // console.log(data); 198 if (data.is_open === true) { 199 console.log('open'); 200 } else { 201 console.log('close'); 202 $("body").addClass('ct-yes'); 203 $("body").removeClass('ct-no'); 204 $("footer .et_pb_section").removeClass('ct-no'); 205 } 206 }, 207 error: function() { 208 // API FAILS 209 console.log('something went wrong with the API BIZ HOURS'); 210 } 211 }); 212 213 214 /* // Business Hours Start COUNTDOWN // 215 var bizHours = 'https://www.infsalesgroup.com/wp-content/themes/infsalesgroup-child/api/hours/?' + Date.now(); 216 217 $.ajax({ 218 url: bizHours, 219 type: 'GET', 220 dataType: 'json', 221 success: function(data) { 222 console.log(data); 223 224 var now = moment(data.currentDateTime); 225 // var now = moment("2021-06-26 03:58:15"); 226 var weekday = now.weekday(); // 0 is Sunday - Sat is 6 227 228 var $countdownText = $('.countdownText'); 229 var openingToday = moment({ 230 hour: 8 231 }); 232 var closingTime = moment({ 233 hour: 22, 234 minutes: 59 235 236 }); 237 238 var openingTime = moment({ 239 year: now.year(), 240 month: now.month(), 241 date: now.date() + 1, 242 hour: 8 243 244 }); 245 246 console.log(moment(openingTime).format('MM/DD/YYYY HH:mm:ss')) 247 248 //M_F 249 if (weekday > 0 && weekday < 6) { 250 251 closingTime = closingTime.add(1, 'hours'); 252 console.log('M_F Closing @: ' + moment(closingTime).format('MM/DD/YYYY HH:mm:ss')); 253 } 254 255 256 //SatSun 257 if (weekday == 6 || weekday == 0) { 258 259 closingTime = closingTime; 260 console.log('SAT_SUN Closing @: ' + moment(closingTime).format('MM/DD/YYYY HH:mm:ss')); 261 } 262 263 264 //Opening Sunday 265 266 if (weekday == 0) { 267 268 openingToday = openingToday.add(1, 'hours'); 269 console.log('SUN Open @: ' + moment(openingToday).format('MM/DD/YYYY HH:mm:ss')); 270 } 271 272 console.log(moment(now.diff(openingToday)).format('MM/DD/YYYY HH:mm:ss')); 273 274 275 if (now.diff(openingToday) < 0) { 276 277 console.log("if1"); 278 279 openingToday = moment(openingToday).format('MM/DD/YYYY HH:mm:ss'); 280 281 $('.clock').countdown(openingToday).on('update.countdown', function(event) { 282 var $this = $(this).html(event.strftime('' + 283 '<span>%H hrs </span>: ' + 284 '<span>%M min </span>: ' + 285 '<span>%S sec </span>')); 286 }); 287 288 $countdownText.addClass('closed'); 289 290 291 } else if (now.diff(closingTime) < 0) { 292 console.log("if2"); 293 294 closingTime = moment(closingTime).format('MM/DD/YYYY HH:mm:ss'); 295 296 $('.clock').countdown(closingTime).on('update.countdown', function(event) { 297 var $this = $(this).html(event.strftime('' + 298 '<span>%H hrs </span>: ' + 299 '<span>%M min </span>: ' + 300 '<span>%S sec </span>')); 301 }); 302 303 $countdownText.addClass('opened'); 304 305 } else { 306 307 console.log("Close :( but you can call us later!"); 308 openingTime = moment(openingTime).format('MM/DD/YYYY HH:mm:ss'); 309 310 $('.clock').countdown(openingTime).on('update.countdown', function(event) { 311 var $this = $(this).html(event.strftime('' + 312 '<span>%H hrs </span>: ' + 313 '<span>%M min </span>: ' + 314 '<span>%S sec</span>')); 315 }); 316 317 $countdownText.addClass('closed'); 318 } 319 320 // but if fails! 321 322 }, 323 error: function() { 324 $('.failBiz').show(); 325 console.log('something went wrong with the API call') 326 } 327 328 }); 329 */ 330 // ENDS Business Hours Start COUNTDOWN 331 332 var pageUrl = window.location.href; 333 var paramUrl = _getParams(pageUrl); 334 var cart_tel = ''; 335 var cart_igp = ''; 336 var cart_sid = ''; 337 var cart_address = ''; 338 var cart_address2 = ''; 339 var cart_city = ''; 340 var cart_zip = ''; 341 var cart_state = ''; 342 var cart_gc; 343 var cart_subid = ''; 344 var cart_invsrc = ''; 345 var cart_url = ''; 346 347 // get values 348 let intervalCount = 0; 349 const maxIntervalTime = 3000; // 3 seconds 350 const intervalStep = 100; // check every 100ms 351 352 const interval = setInterval(() => { 353 if (paramUrl['tel'] !== undefined) { 354 cart_tel = paramUrl['tel']; 355 } else { 356 cart_tel = _pageGetCookie('Windstream_Tel') || _pageGetCookie('WindstreamKinetic_Tel'); 357 } 358 359 if (paramUrl['igp'] !== undefined) { 360 cart_igp = paramUrl['igp']; 361 } else { 362 cart_igp = _pageGetCookie('Windstream_Igp') || _pageGetCookie('WindstreamKinetic_Igp'); 363 } 364 365 intervalCount += intervalStep; 366 if (intervalCount >= maxIntervalTime) { 367 clearInterval(interval); 368 } 369 cart_url = 'https://cart.kineticfiberinternet.com/?tel=' + cart_tel + '&igp=' + cart_igp + '&dnis=' + cart_tel; 370 console.log(cart_url); 371 runInvocaLogic(); 372 373 }, intervalStep); 374 375 if (paramUrl['sid'] !== undefined) { 376 cart_sid = paramUrl['sid']; 377 } else if (_pageGetCookie('sid') !== undefined) { 378 cart_sid = _pageGetCookie('sid'); 379 } else { 380 cart_sid = ''; 381 } 382 383 if (paramUrl['gc'] !== undefined) { 384 cart_gc = paramUrl['gc']; 385 } else if (_pageGetCookie('gc') !== undefined) { 386 cart_gc = _pageGetCookie('gc'); 387 } else { 388 cart_gc = ''; 389 } 390 391 if (paramUrl['subid'] !== undefined) { 392 cart_subid = paramUrl['subid']; 393 } else if (_pageGetCookie('subid') !== undefined) { 394 cart_subid = _pageGetCookie('subid'); 395 } else { 396 cart_subid = ''; 397 } 398 399 if (_pageGetCookie('cart_address') !== undefined) { 400 cart_address = _pageGetCookie('cart_address'); 401 cart_address2 = _pageGetCookie('cart_address2'); 402 cart_city = _pageGetCookie('cart_city'); 403 cart_zip = _pageGetCookie('cart_zip'); 404 cart_state = _pageGetCookie('cart_state'); 405 } 406 407 // _pageGetCookie('sid'); 408 409 410 411 // cart_tel = encodeURI(cart_tel); 412 cart_sid = encodeURI(cart_sid); 413 cart_igp = encodeURI(cart_igp); 414 cart_address = encodeURI(cart_address); 415 cart_address2 = encodeURI(cart_address2); 416 cart_city = encodeURI(cart_city); 417 cart_zip = encodeURI(cart_zip); 418 cart_state = encodeURI(cart_state); 419 420 421 console.log(cart_tel); 422 console.log(cart_sid); 423 console.log(cart_igp); 424 console.log(cart_address); 425 console.log(cart_address2); 426 console.log(cart_city); 427 console.log(cart_zip); 428 console.log(cart_state); 429 console.log(cart_invsrc); 430 console.log(cart_gc); 431 432 cart_gc = '1'; 433 434 435 //invoca tel number in cart url 436 function runInvocaLogic() { 437 var new_cart_tel = cart_tel.substring(2).replace(/\D/g, ''); 438 var invoca_tel = new_cart_tel; 439 console.log('base cart url: ', cart_url); 440 441 if (paramUrl['invsrc'] !== undefined || localStorage.getItem('invoca_tel') !== null) { 442 var maxAttempts = 50; 443 var attempts = 0; 444 445 var checkInterval = setInterval(function () { 446 var raw_tel = $('.ctabar .telnum').text().trim(); 447 448 // Keep formatting: do not strip dashes or leading 1s 449 if (raw_tel && raw_tel !== '') { 450 invoca_tel = raw_tel; 451 localStorage.setItem('invoca_tel', invoca_tel); 452 453 if (cart_url.includes('tel=')) { 454 cart_url = cart_url.replace(/([?&]tel=)[^&]*/, '$1' + encodeURIComponent(invoca_tel)); 455 cart_url = cart_url.replace(/([?&]dnis=)[^&]*/, '$1' + encodeURIComponent(cart_tel)); 456 } else { 457 const separator = cart_url.includes('?') ? '&' : '?'; 458 cart_url += separator + 'tel=' + encodeURIComponent(invoca_tel); 459 } 460 461 clearInterval(checkInterval); 462 console.log('added invoca tel to cart: ', cart_url); 463 } 464 465 if (++attempts >= maxAttempts) { 466 clearInterval(checkInterval); 467 } 468 }, 200); 469 } 470 } 471 472 473 let checkCount = 0; 474 let maxChecks = 10; 475 let intervalTime = 500; 476 var ab = 0; 477 let checkInterval = setInterval(function () { 478 checkCount++; 479 480 if ($('body').hasClass('abtest')) { 481 console.log("Found 'abtest' in body!"); 482 clearInterval(checkInterval); 483 ab = 1; 484 _pageSetCookie('ab','1'); 485 //$('body').removeClass('ct-no') 486 } 487 488 if (checkCount >= maxChecks) { 489 console.log("Stopped checking after 5 seconds."); 490 clearInterval(checkInterval); 491 } 492 }, intervalTime); 493 494 495 $(".orderbtn").attr("href", cart_url); 496 console.log(cart_url); 497 498 var currentLang = window.location.href.includes("/es/"); 499 console.log(currentLang) 500 501 $(".address_data .street_number").val(""); 502 $(".address_data .route").val(""); 503 $(".address_data .country").val(""); 504 $(".address_data .administrative_area_level_1").val(""); 505 $(".address_data .locality").val(""); 506 $(".address_data .postal_code").val(""); 507 $(".address_data .geoLat").val(""); 508 $(".address_data .geoLong").val(""); 509 $(".autocomplete").val(""); 510 511 512 // $(".autocomplete").blur(function() { 513 // $('.select_address').css('opacity', '0'); 514 // $(".address_data .street_number").val(""); 515 // $(".address_data .route").val(""); 516 // $('.address2').val(""); 517 // $(".address_data .country").val(""); 518 // $(".address_data .administrative_area_level_1").val(""); 519 // $(".address_data .locality").val(""); 520 // $(".address_data .postal_code").val(""); 521 // $(this).val(""); 522 523 // }); 524 525 // $(".autocomplete").focus(function() { 526 // $(this).attr("autocomplete", 'new-password'); 527 // $(this).val("");
528 // $('.invalidAddresss').remove(); 529 // $(".address_data .street_number").val(""); 530 // $(".address_data .route").val(""); 531 // $('.address2').val(""); 532 // $(".address_data .country").val(""); 533 // $(".address_data .administrative_area_level_1").val(""); 534 // $(".address_data .locality").val(""); 535 // $(".address_data .postal_code").val(""); 536 // }); 537 538 if (window.location.pathname !== '/packages/' && window.location.pathname !== '/es/packages/') { 539 localStorage.removeItem('formData'); 540 } 541 542 var redirect_cart = true; 543 544 var container = $('div.addressNotValid'); 545 $('.searchsectionbar').val(''); 546 547 $('.addressForm').each(function() { 548 $(this).validate({ 549 rules: { 550 postal_code: { 551 required: true, 552 minlength: 5 553 }, 554 country: { 555 required: true 556 } 557 }, 558 submitHandler: function(form) { 559 console.log('Submit handler triggered'); 560 const $form = $(form); 561 562 if ($form.hasClass('submitted')) { 563 console.log('Form already submitted'); 564 return; 565 } 566 567 $form.addClass('submitted'); 568 $('input[type="submit"]').attr("disabled", 'disabled').val(currentLang ? "Búsqueda" : "Searching"); 569 $('.popups').hide(500); 570 $('#loading_search').css('display', 'flex'); 571 $('body').addClass('blur'); 572 573 setTimeout(function() { 574 $('#loading_search_hurry').show(); 575 }, 5000); 576 577 const apiURL = "/wp-content/themes/isg-ws24/api/api.php?" + (new Date()).getTime(); 578 579 var street_number = $form.find('input[name="street_number"]').val(); 580 var address2 = $form.find('.address2').val(); 581 var route = $form.find('input[name="route"]').val(); 582 var city = $form.find('input[name="locality"]').val(); 583 var state = $form.find('input[name="administrative_area_level_1"]').val(); 584 var postal_code = $form.find('input[name="postal_code"]').val(); 585 var geoLat = $form.find('input[name="geoLat"]').val(); 586 var geoLong = $form.find('input[name="geoLong"]').val(); 587 588 _pageSetCookie('cart_address', street_number + " " + route); 589 _pageSetCookie('cart_address2', address2); 590 _pageSetCookie('cart_city', city); 591 _pageSetCookie('cart_zip', postal_code); 592 _pageSetCookie('cart_state', state); 593 594 $.ajax({ 595 type: 'POST', 596 url: apiURL, 597 data: { 598 street_number: street_number, 599 address2: address2, 600 route: route, 601 postal_code: postal_code, 602 administrative_area_level_1: state, 603 locality: city, 604 geoLat: geoLat, 605 geoLong: geoLong 606 }, 607 success: function(response) { 608 console.log('AJAX response received'); 609 $('input[type="submit"]').attr("disabled", 'disabled').val(currentLang ? "Comprobar Disponibilidad" : "Check Availability"); 610 $('.searchsectionbar').val(''); 611 console.log(response); 612 _pageSetCookie('post_epq', '1'); 613 614 if (response != null){ 615 if ((response && response.Internet_Solo && response.Internet_Solo[0] && response.Internet_Solo[0].Speed > 50) && !response.Internet_Solo[0].Name.toLowerCase().includes('basic')) { 616 console.log('Redirecting...'); 617 _pageSetCookie('cart_valid', '1'); 618 619 console.log(street_number); 620 console.log(route); 621 console.log(postal_code); 622 console.log(state); 623 console.log(city); 624 console.log(geoLat); 625 console.log(geoLong); 626 627 var street_number_route = street_number + ' ' + route; 628 629 localStorage.setItem('formData', JSON.stringify(response)); 630 631 if (redirect_cart === true) { 632 var cart_redirect_url = cart_url + '&address=' + street_number + ' ' + route + '&address2=' + address2 + '&city=' + city + '&state=' + state
632+ '&zip=' + postal_code; 633 634 window.dataLayer = window.dataLayer || []; 635 window.dataLayer.push({ 636 'cartServiceable': true, 637 'event': 'cartServiceableRedirect', 638 'product': 'Fiber' 639 }); 640 641 _pageSetCookie('cart_redirect_url', cart_redirect_url); 642 643 setTimeout(function() { 644 window.location.href = cart_redirect_url; 645 }, 100); 646 647 } else { 648 window.location.href = currentLang ? '/es/packages/' : '/packages/'; 649 } 650 } else { 651 652 653 if(response.Internet_Solo[0].Name.toLowerCase().includes('basic')){ 654 console.log('DSL product'); 655 window.dataLayer = window.dataLayer || []; 656 window.dataLayer.push({ 657 'cartServiceable': false, 658 'event': 'cartServiceableRedirect', 659 'product': 'DSL' 660 }); 661 662 } else { 663 console.log('No products'); 664 window.dataLayer = window.dataLayer || []; 665 window.dataLayer.push({ 666 'cartServiceable': false, 667 'event': 'cartServiceableRedirect', 668 'product': 'None' 669 }); 670 } 671 672 $('#notseraddress').text(`${city}, ${state}`); 673 $('#currentadd').text(`${street_number} ${route}, ${city}, ${state} ${postal_code}`); 674 $('.popups').hide(); 675 $('#loading_search_not').css('display', 'flex'); 676 $('body').addClass('blur'); 677 } 678 } else { 679 window.dataLayer = window.dataLayer || []; 680 window.dataLayer.push({ 681 'cartServiceable': false, 682 'event': 'cartServiceableRedirect', 683 'product': 'None' 684 }); 685 console.log('No products'); 686 $('#notseraddress').text(`${city}, ${state}`); 687 $('#currentadd').text(`${street_number} ${route}, ${city}, ${state} ${postal_code}`); 688 $('.popups').hide(); 689 $('#loading_search_not').css('display', 'flex'); 690 $('body').addClass('blur'); 691 } 692 }, 693 error: function(xhr, status, error) { 694 console.error('AJAX request failed', status, error); 695 }, 696 complete: function() { 697 $form.removeClass('submitted'); 698 } 699 }); 700 } 701 }); 702 703 $(".autocomplete").on("input", function() { 704 $(this).closest('.addressForm_input').find('.select_address').css('opacity', '1'); 705 }); 706 707 }); 708 709/* 710 $('.autocomplete').on('focus', function() { 711 loadGoogleMapsScript(); 712 }); */ 713 714 if (_pageGetCookie('cart_redirect_url')) { 715 $('.orderbtn').attr('href', _pageGetCookie('cart_redirect_url')); 716 } else { 717 $('.orderbtn').attr('href', cart_url); 718 } 719 720 //if ct=1 show order online btn 721 // if (paramUrl['ct'] === '1' || _pageGetCookie('ct', '1')) { 722 // $('body').removeClass('ct-no').addClass('ct-yes'); 723 // _pageSetCookie('ct', '1'); 724 725 // $('.orderbtn').on('click', function(event) { 726 // event.preventDefault(); 727 728 // if (_pageGetCookie('cart_redirect_url')) { 729 // window.dataLayer = window.dataLayer || []; 730 // window.dataLayer.push({ 731 // 'cartServiceable': true, 732 // 'event': 'cartServiceableRedirect' 733 // }); 734 735 // setTimeout(function() { 736 // window.location.href = _pageGetCookie('cart_redirect_url'); 737 // }, 200); 738 // } else { 739 // $('.popups').hide(); 740 // $('#findmyplan').css('display', 'flex'); 741 // $('body').addClass('blur'); 742 // } 743 // }); 744 // } 745 746 747 let url_lang = ''; 748 if (window.location.href.indexOf('/es/') !== -1) { 749 url_lang = '/es'; 750 } 751 752 let Skip_Secound_Question = false; 753 754 //populate questionnaire 755 if ($('div').hasClass('windquestions')) { 756 $.getJSON(url_lang + "/wp-json/custom/v1/acf-options/", function(data) { 757 var q_and_r = data.q_and_r; 758 var qr = data.qr; 759 var plans = data.plans; 760 var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); 761 var step = 1; 762 var page = 0; 763 var step_length = 0; 764 let nextbtn = 'Next'; 765 let prevbtn = 'Previous'; 766 let submitbtn = 'Submit'; 767 let submitting = 'Submitting'; 768 let alert_select = 'Please make a selection'; 769 let select_all = '(Select all that apply)'; 770 771 //abtest 772 //if (_pageGetCookie('ab') == '1' || $('body').hasClass('abtest')){ 773 Skip_Secound_Question = false;
774 //} 775 776 if (window.location.href.indexOf('/es/') !== -1) { 777 nextbtn = 'Próxima'; 778 prevbtn = 'Anterior'; 779 submitbtn = 'Enviar'; 780 submitting = 'Enviando'; 781 alert_select = 'Seleccione una opción'; 782 select_all = '(Selecciona todos los que apliquen)'; 783 } 784 785 var html = '<div class="selections">'; 786 var img_html = '<div class="q_img_selections">'; 787 var questionCount = 0; 788 789 q_and_r.forEach(function(item, index) { 790 questionCount++; 791 792 // Skip the second question if Skip_Secound_Question is true 793 if (Skip_Secound_Question && questionCount === 2) { 794 return; 795 } 796 797 page++; 798 step_length++; 799 800 var questionHtml = '<div class="questionpage questionq page-' + page + '">'; 801 questionHtml += '<h3 style="padding-bottom:0">' + item.question.split('?')[0] + '?</h3>'; 802 if (item.question.toLowerCase().includes('select all that apply') || item.question.toLowerCase().includes('selecciona todos los que apliquen')) { 803 questionHtml += '<p>' + select_all + '</p>'; 804 } 805 questionHtml += '</div>'; 806 807 var selectHtml = '<div class="questionpage selectq page-' + page; 808 if (!item.question.toLowerCase().includes('select all that apply' || !item.question.toLowerCase().includes('selecciona todos los que apliquen'))) { 809 selectHtml += ' selectone'; 810 } 811 selectHtml += '">'; 812 813 item.responses.forEach(function(response) { 814 selectHtml += '<div class="single-select ctaTk">' + response.response + '</div>'; 815 }); 816 selectHtml += '</div>'; 817 818 if (item.question_disclaimer) { 819 selectHtml += '<div class="questionpage selectdisc page-' + page + '">'; 820 selectHtml += item.question_disclaimer; 821 selectHtml += '</div>'; 822 } 823 824 if (item.question_image) { 825 img_html += '<div class="questionpage selectimg page-' + page + '">'; 826 img_html += '<img src="' + item.question_image + '">'; 827 img_html += '</div>'; 828 } 829 830 html += questionHtml + selectHtml; 831 }); 832 833 html += '<div class="questionbtnsec">'; 834 html += '<div class="questionbtn prebtn ctaTk">' + prevbtn + '</div>'; 835 html += '<div class="questionbtn nextbtn"><span class="nextword ctaTk">' + nextbtn + ' <span id="nextid">' + step + '</span>/' + step_length + '</span><span class="subword ctaTk 1" >' + submitbtn + '</span></div>'; 836 html += '</div></div>'; 837 838 img_html += '</div>'; 839 840 $('#q_and_r').html(html); 841 $('#q_img').html(img_html); 842 843 let questionnaireRes = []; 844 var userSelections = {}; 845 let internet = false; 846 var popcount = 0; 847 let close_ok_word = 'OK'; 848 var current_page = 1; 849 850 //build userSelections 851 for (let i = 1; i <= step_length; i++) { 852 userSelections['q' + i] = []; 853 } 854 855 $('.page-' + step).show(); 856 $('.nextbtn').click(function() { 857 if (!$('.page-' + current_page + ' .single-select').hasClass('selected')) { 858 alert(alert_select); 859 } else { 860 if (internet != false && popcount != 0) { 861 current_page++; 862 $('.prebtn').show(); 863 if ($(this).hasClass('submitbtn')) { 864 $(this).addClass('disblebtn'); 865 $('.prebtn').addClass('disblebtn'); 866 var $loadingSpan = $(this).find('.loading'); 867 //$(this).text(submitting).append('<span class="loading"></span>'); 868 $(this).append('<span class="loading"></span>'); 869 870 871 //clear userSelections 872 for (let i = 1; i <= step_length; i++) { 873 userSelections['q' + i] = []; 874 } 875 876 //build userSelections array 877 for (let j = 1; j <= step_length; j++) { 878 var selectedOptions = $(`.page-${j} .single-select.selected`); 879 if (selectedOptions.length > 0) { 880 selectedOptions.each(function() { 881 var optionIndex = $(this).index() + 1; 882 userSelections['q' + j].push(optionIndex); 883 }); 884 } else { 885 userSelections['q' + j] = ['None']; 886 } 887 } 888 console.log('User Selection array:', userSelections); 889 890 //logic for QR 891 let matchedResponse = ['1']; // set to 1 for default package if no matches 892 qr.forEach(function(qrEntry) { 893 let isMatch = true; 894 for (let i = 1; i <= step_length; i++) { 895 if (qrEntry['q' + i].includes("Any")) { 896 continue; 897 } 898 if (qrEntry['q' + i].includes("None")) { 899 if (userSelections['q' + i].includes("None")) { 900 continue; 901 } else { 902 isMatch = false;
903 break; 904 } 905 } 906 907 let qrValue = Array.isArray(qrEntry['q' + i]) ? qrEntry['q' + i] : [qrEntry['q' + i]]; 908 if (JSON.stringify(userSelections['q' + i].sort()) !== JSON.stringify(qrValue.map(Number).sort())) { 909 isMatch = false; 910 break; 911 } 912 } 913 if (isMatch) { 914 matchedResponse = qrEntry.response; 915 return false; 916 } 917 }); 918 console.log("Matched Response: ", matchedResponse); 919 920 //logic to show the contents of selected matchedResponse 921 if (matchedResponse) { 922 var planIndex = matchedResponse[0] - 1; 923 var selectedPlan = plans[planIndex]; 924 $('#p_title').html(selectedPlan.title); 925 $('#p_disc').html(selectedPlan.product_disclaimer); 926 $('#p_speed').html(selectedPlan.speed); 927 928 //formating the price output 929 var priceParts = selectedPlan.price.split('.'); 930 var dollars = priceParts[0].replace('$', ''); 931 var cents = priceParts[1] ? priceParts[1].replace('.', '') : ''; 932 var formattedPrice = '<sup>$</sup>' + dollars + '<sup>' + cents + '</sup>'; 933 934 //replacing based on matchedResponse 935 $('#p_price').html(formattedPrice); 936 $('#price_cross').html(selectedPlan.price_cross); 937 $('#pck_gift').html(selectedPlan.gift_card); 938 $('#p_mos').html(selectedPlan['price-disclaimor']); 939 $('#p_over').html(selectedPlan.package_overview); 940 $('#p_why').html(selectedPlan.why_we_picked_this_package); 941 $('#p_feats').html(selectedPlan.package_features); 942 $('#whats_in').html(selectedPlan.whats_included); 943 $('#lead_in_title').html(selectedPlan.lead_in_title); 944 945 let usersText = ''; 946 if (userSelections.q1 && userSelections.q1[0]) { 947 let usersIndex = userSelections.q1[0] - 1; 948 // strip any HTML tags 949 usersText = $('<div>').html(q_and_r[0].responses[usersIndex].response).text().trim(); 950 } 951 952 let activitiesText = ''; 953 if (userSelections.q2 && userSelections.q2.length > 0) { 954 let activities = []; 955 userSelections.q2.forEach(i => { 956 let responseText = $('<div>').html(q_and_r[1].responses[i - 1].response).text().trim(); 957 activities.push(responseText); 958 }); 959 960 // Format activities with Oxford comma 961 if (activities.length > 2) { 962 activitiesText = activities.slice(0, -1).join(', ') + ', and ' + activities[activities.length - 1]; 963 } else if (activities.length === 2) { 964 activitiesText = activities.join(' and '); 965 } else { 966 activitiesText = activities[0]; 967 } 968 } 969 970 // Populate the spans as plain text 971 $('.wind_users').text(usersText); 972 $('.wind_support').text(activitiesText); 973 } 974 975 setTimeout(function() { 976 $loadingSpan.remove(); 977 $('.hideonfinal').hide(); 978 $('.finalpage').show(); 979 var targetElement = $('#showpackage'); 980 if (targetElement.length) { 981 var offset = targetElement.offset().top - 100; 982 $('html, body').animate({ 983 scrollTop: offset 984 }, 300); 985 } 986 }, 1500); 987 988 //for invoca to send responses 989 for (let i = 1; i <= step; i++) { 990 let selections = []; 991 $(`.page-${i} .single-select.selected`).each(function() { 992 selections.push($(this).text()); 993 }); 994 let questionText = $(`.page-${i} h3`).text(); 995 questionnaireRes.push({ 996 question: questionText, 997 responses: selections.join(', ') 998 }); 999 } 1000 1001 window.Questionnaire = questionnaireRes; 1002 var telCookie = essentials.prop + '_Tel'; 1003 $(this).append('<span class="hide">' + _pageGetCookie(telCookie) + '<span>'); 1004 Invoca.PNAPI.run(); 1005 } 1006 1007 if (step < step_length) { 1008 $('.page-' + step).hide(300); 1009 step++; 1010 $('.page-' + step).show(300); 1011 $('#nextid').text(step); 1012 if (step == step_length) { 1013 $('.nextbtn').addClass('submitbtn'); 1014 } 1015 } 1016 } else { 1017 if (isSafari) { 1018 close_ok_word = 'CLOSE'; 1019 } 1020 //alert('The selected service(s) must be bundled with Spectrum Internet®. Please click "' + close_ok_word + '" to proceed and explore the best offers and bundle options tailored for you.'); 1021 popcount = 1; 1022 internet = true;
1023 $('.nextbtn').click(); 1024 } 1025 } 1026 }); 1027 1028 $('.prebtn').click(function(){ 1029 if(step >= 2){ 1030 $('.nextbtn').removeClass('submitbtn'); 1031 $('.page-' + step).hide(300); 1032 step--; 1033 $('.page-' + step).show(300); 1034 $('#nextid').text(step); 1035 if(step == 1){ 1036 $('.prebtn').hide(); 1037 } 1038 } 1039 }); 1040 1041 $('.single-select').click(function() { 1042 var $parent = $(this).closest('.questionpage'); 1043 var index = $(this).index() + 1; 1044 if ($parent.hasClass('selectone')) { 1045 $parent.find('.single-select').removeClass('selected'); 1046 $(this).addClass('selected'); 1047 } else { 1048 $(this).toggleClass('selected'); 1049 } 1050 if ($(this).hasClass('selected')) { 1051 console.log(index); 1052 } 1053 $('.page-' + step + ' .noneabove').removeClass('selected'); 1054 1055 //if internet is selected 1056 if ($('.page-1 .single-select:nth-child(1)').hasClass('selected')) { 1057 internet = true; 1058 popcount = 1; 1059 } 1060 }); 1061 1062 $('.noneabove').click(function(){ 1063 $('.page-' + step + '.questionpage .single-select').removeClass('selected'); 1064 $(this).toggleClass('selected'); 1065 }); 1066 1067 $('.resetbtn').click(function(){ 1068 step = 1; 1069 popcount = 0; 1070 current_page = 1; 1071 internet = false; 1072 $('.selectq .single-select').removeClass('selected'); 1073 $('.questionpage').hide(); 1074 $('.finalpage').hide(); 1075 $('.prebtn').hide(); 1076 $('.questionbtn').removeClass('submitbtn').removeClass('disblebtn'); 1077 $('.nextbtn').html('<span class="nextword ctaTk">' + nextbtn + ' <span id="nextid">' + step + '</span>/' + step_length + '</span><span class="subword ctaTk 2">' + submitbtn + '</span>'); 1078 $('.hideonfinal').show(); 1079 var targetElement = $('#questionnaire'); 1080 if (targetElement.length) { 1081 var offset = targetElement.offset().top - 100; 1082 $('html, body').animate({ 1083 scrollTop: offset 1084 }, 300); 1085 } 1086 $('.page-' + step).show(300); 1087 }); 1088 }); 1089 1090 } else { 1091 console.log('no questionnaire'); 1092 } 1093 1094 1095 $('.slide_out').on('click', function() { 1096 const $panel = $(this); 1097 const isOpening = !$panel.hasClass('active'); 1098 1099 $panel.toggleClass('active'); 1100 1101 if (isOpening) { 1102 const rect = this.getBoundingClientRect(); 1103 1104 const originX = (rect.left + rect.width / 2) / window.innerWidth; 1105 const originY = (rect.top + rect.height / 2) / window.innerHeight; 1106 1107 confetti({ 1108 particleCount: 150, 1109 spread: 80, 1110 startVelocity: 50, 1111 origin: { x: originX, y: originY } 1112 }); 1113 } 1114 }); 1115 1116 1117 //hide order online on small bizz 1118 if ($('body').hasClass('page-id-13503') || $('body').hasClass('page-id-13534')) { 1119 $('body').addClass('ct-no'); 1120 } 1121 1122 //hide cart on spanish 1123 if (window.location.pathname.indexOf('/es/') !== -1) { 1124 $('body').addClass('ct-no'); 1125 } 1126 1127 1128/*setTimeout(function () { 1129 window.LOQ = window.LOQ || [] 1130 window.LOQ.push(['ready', async LO => { 1131 // Track an event 1132 // await LO.$internal.ready('events') 1133 // LO.events.track('My Event') 1134 // Or, identify a visitor 1135 await LO.$internal.ready('visitor') 1136 1137 if (_pageGetCookie('Windstream_Tel')) { 1138 LO.visitor.identify({ tel: _pageGetCookie('Windstream_Tel') }) 1139 } 1140 LO.visitor.identify({ siteId: window.location.hostname }) 1141 }]); 1142}, 500); */ 1143 1144}); 1145
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.