1// Configure a few settings and attach camera 2if(jQuery('#capture-image').length>0) { 3 Webcam.set({ 4 width: 252, 5 height: 190, 6 dest_width: 252, 7 dest_height: 190, 8 crop_width: 190, 9 crop_height: 190, 10 image_format: 'jpeg', 11 jpeg_quality: 90, 12 constraints: { 13 facingMode: 'user', 14 frameRate: 30 15 } 16 }); 17} 18 19function imageData() { 20 // Check if getUserMedia is available 21 if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { 22 // Access webcam 23 navigator.mediaDevices.getUserMedia({ 24 video: true 25 }).then(function(stream) { 26 // Display webcam stream in <video> element 27 jQuery(window).scrollTop(0); 28 jQuery(".confirm-location-box").hide(); 29 jQuery(".capture-image-box").show(); 30 Webcam.attach('#image-wrapper'); 31 }).catch(function(error) { 32 // Handle errors 33 console.error('Error accessing webcam:', error); 34 if(error.name === 'NotAllowedError') { 35 // User denied permission to access the webcam 36 alert('You denied access to the webcam. Please enable camera access to Actcorp website.'); 37 } else if(error.name === 'NotFoundError') { 38 // Webcam not found or unavailable 39 alert('Webcam not found or unavailable.'); 40 } else { 41 // Other errors 42 alert('Error accessing webcam.'); 43 } 44 }); 45 } else { 46 console.error('getUserMedia is not supported in this browser'); 47 } 48} 49 50function uniqid() { 51 var now = new Date(); 52 var timestamp = now.getFullYear().toString().substr(-2) + ('0' + (now.getMonth() + 1)).slice(-2) + ('0' + now.getDate()).slice(-2); 53 var uniqueId = timestamp + Math.random().toString(36).substr(2, 9); // Concatenate timestamp with a random string 54 return uniqueId; 55} 56 57function take_snapshot() { 58 Webcam.snap(function(data_uri) { 59 jQuery(".image-tag").val(data_uri); 60 jQuery('#webcam-image-box').removeClass('webcam-image-style'); 61 document.getElementById('webcam-image-box').innerHTML = '<img src="' + data_uri + '"/>'; 62 jQuery('.completed').removeClass('d-none'); 63 // Convert data URI to Blob 64 const byteString = atob(data_uri.split(',')[1]); 65 const mimeString = data_uri.split(',')[0].split(':')[1].split(';')[0]; 66 const ab = new ArrayBuffer(byteString.length); 67 const ia = new Uint8Array(ab); 68 for(let i = 0; i < byteString.length; i++) { 69 ia[i] = byteString.charCodeAt(i); 70 } 71 const blob = new Blob([ab], { 72 type: mimeString 73 }); 74 // Create FormData and append the image 75 const formData = new FormData(); 76 // Usage 77 var uniqueId = uniqid(); 78 //var imageType = ".jpeg"; 79 var imageName = "profile_" + uniqueId + "_img.jpeg"; 80 var imgFullPath = base_url + "sites/default/files/webcam_images/" + imageName; 81 jQuery('.completed').removeClass('d-none'); 82 formData.append('file', blob, imageName); 83 // Send image to Drupal endpoint 84 fetch('/upload-webcam-image', { 85 method: 'POST', 86 body: formData 87 }).then(response => { 88 console.log('Image uploaded successfully:', response); 89 jQuery('input[name="profile_image"]').val(imgFullPath); 90 //jQuery('#photoClicked .circle').attr('data-percent', '100'); 91 // Handle response accordingly 92 }).catch(error => { 93 console.error('Error uploading image:', error); 94 }); 95 }); 96} 97jQuery('.needHelpDevice').addClass('d-none'); 98jQuery(document).ready(function($) { 99 function animateElements2() { 100 $('.progressbar').each(function() { 101 var elementPos = $(this).offset().top; 102 var topOfWindow = $(window).scrollTop(); 103 var percent = $(this).find('.circle').attr('data-percent'); 104 105 // Use .attr() to set and get data-animate 106 var animate = $(this).attr('data-animate'); // Default to false if not set 107 var snapshotTaken = $(this).attr('data-snapshot-taken') === 'true'; // Check if snapshot is already taken 108 109 if (elementPos < topOfWindow + $(window).height() - 3 && (!animate === false || typeof animate === 'undefined')) { 110 $(this).attr('data-animate', true); // Set animate to true once triggered 111 112 $(this).find('.circle').circleProgress({ 113 startAngle: -Math.PI / 2, 114 value: percent / 100, 115 size: 220, 116 thickness: 3, 117 emptyFill: "#E3FFCD", 118 fill: { 119 color: '#27AE60' 120 } 121 }).on('circle-animation-progress', function(event, progress, stepValue) { 122 $(this).find('.percent-val').text((stepValue * 100).toFixed(0) + "%"); 123 124 // Only take a snapshot if not already taken and the value is 100% 125 if (!snapshotTaken && (stepValue * 100).toFixed(0) == '100') { 126 snapshotTaken = true; // Update the flag to prevent further calls 127 $(this).attr('data-snapshot-taken', 'true'); // Store it as an attribute 128 take_snapshot(); 129 } 130 }); 131 132 if (percent == '100') { 133 $('#photoClicked').addClass('verified'); 134 $('.capture-picture').addClass('d-none'); 135 $('.varifying-picture').addClass('d-none'); 136 } else { 137 $('#photoClicked').removeClass('verified'); 138 } 139 } 140 }); 141 } 142 $('.image_continue').on('click', function() { 143 $(".capture_profile_image").addClass('completed'); 144 $(".successfully-text").show(); 145 $(".confirm-location-box").show(); 146 $(".capture-image-box").hide(); 147 Webcam.reset(); 148 }); 149 $('[rel-data]').on('click', function() {
150 var getId = $(this).attr('rel-data'); 151 // Check if getUserMedia is available 152 if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { 153 // Access webcam 154 navigator.mediaDevices.getUserMedia({ 155 video: true 156 }).then(function(stream) { 157 $("#capture-image").trigger("click"); 158 $('.completed').addClass('d-none'); 159 $('.capture-block').addClass('d-none') 160 $(getId).removeClass('d-none'); 161 // Display webcam stream in <video> element 162 if($('.circle').attr('data-percent') == '100') { 163 $('.capture-picture').addClass('d-none'); 164 animateElements2(); 165 } else { 166 $('.capture-picture').removeClass('d-none'); 167 } 168 }).catch(function(error) { 169 // Handle errors 170 console.error('Error accessing webcam:', error); 171 if(error.name === 'NotAllowedError') { 172 // User denied permission to access the webcam 173 alert('You denied access to the webcam. Please enable camera access to Actcorp website.'); 174 location.reload(); 175 } else if(error.name === 'NotFoundError') { 176 // Webcam not found or unavailable 177 alert('Webcam not found or unavailable.'); 178 location.reload(); 179 } else { 180 // Other errors 181 alert('Error accessing webcam.'); 182 location.reload(); 183 } 184 }); 185 } else { 186 console.error('getUserMedia is not supported in this browser'); 187 location.reload(); 188 } 189 }); 190 $('.form-checkbox').change(function() { 191 // Check the number of checkboxes checked 192 var checkedCheckboxes = $('.form-checkbox:checked'); 193 // Disable or enable checkboxes based on the count 194 if(checkedCheckboxes.length >= 3) { 195 $('.form-checkbox:not(:checked)').prop('disabled', true); 196 } else { 197 $('.form-checkbox').prop('disabled', false); 198 } 199 }); 200 $('.DevicesPlan').click(function() { 201 $('.DevicesPlans').addClass('d-none'); 202 $('.UsageInformations').removeClass('d-none'); 203 }); 204 $('.UsageInformationback').click(function() { 205 $('.UsageInformations').addClass('d-none'); 206 $('.DevicesPlans').removeClass('d-none'); 207 }); 208 $('.UsageInformation').click(function() { 209 $('.UsageInformations').addClass('d-none'); 210 $('.homeDetail').removeClass('d-none'); 211 }); 212 $('.homeDetailBack').click(function() { 213 $('.homeDetail').addClass('d-none'); 214 $('.UsageInformations').removeClass('d-none'); 215 }); 216 $('.filter-list .btn-filter').on("click", function() { 217 var getVal = $(this).data('filter'); 218 $('.filterPlan').text(getVal); 219 }); 220}); 221 222 223(function($, Drupal, once) { 224 Drupal.behaviors.myCustomBehavior = { 225 attach: function(context, settings) { 226 227 if ($(".jsDriveSlider .drive-progress-row").length < 4) { 228 // Destroy Slick slider if number of slides is less than or equal to 4 229 $('.jsDriveSlider').slick('unslick'); 230 } 231 232 233 $('.jsDriveSlider').not('.slick-initialized').slick({ 234 infinite: true, 235 slidesToShow: 4, 236 slidesToScroll: 2, 237 arrows: false, 238 dots: true, 239 responsive: [ 240 { 241 breakpoint: 992, 242 settings: { 243 slidesToShow: 3, 244 slidesToScroll: 1 245 } 246 }, 247 { 248 breakpoint: 768, 249 settings: { 250 slidesToShow: 2, 251 slidesToScroll: 1, 252 } 253 }, 254 { 255 breakpoint: 565, 256 settings: { 257 slidesToShow: 1, 258 slidesToScroll: 1, 259 } 260 } 261 ] 262 }); 263 264 265 $(document).ajaxStart(function () { 266 // Code to execute when AJAX starts (e.g., show a loading indicator) 267 $('#ajax_loader').removeClass('d-none'); // Assuming #ajax-loader is your loading element 268 269 }); 270 271 $(document).ajaxStop(function () { 272 // Code to execute when AJAX stops (e.g., hide the loading indicator) 273 $('#ajax_loader').addClass('d-none'); // Hides the loading element when AJAX completes 274 275 }); 276 277 278 $(document).ajaxComplete(function (event, xhr, settings) { 279 $('[data-bs-toggle="tooltip"]').tooltip(); 280 jQuery(document).ready(function($) { 281 // Attach a change event handler to the select box 282 //$('select[name="field_plan_location_target_id"]').change(function() { 283 $(document).on('change', 'select[name="field_plan_location_target_id"]', function() { 284 var selectedValue = $(this).val(); 285 var selectedText = $('#edit-field-plan-location-target-id option:selected').text(); 286 $('select[name="field_plan_location_target_id"]').val(selectedValue); 287 $('#CitySelect .js-form-submit').trigger('click'); 288 $('#sellingPlanSelect .js-form-submit').trigger('click'); 289 $('.Banner-location-change .js-form-submit').trigger('click'); 290 if(selectedValue !=3){ 291 setTimeout(function() { 292 $('.HomepagebannerNCForm').addClass('HomepagebannerNCForm'+selectedText); 293 }, 3000); 294 } 295 296 }); 297 298 //$('select[name="field_plan_location_target_id"]').change(function() { 299 $(document).on('change', 'select[name="field_plan_location_target_id"]', function() { 300 var selectedValue = $(this).val(); 301 $('select[name="field_product_locations_target_id"]').val(selectedValue); 302 $('.netflix-plans-togal .js-form-submit').trigger('click'); 303 }); 304 }); 305 306 307 if (settings.extraData) { 308 if (settings.extraData.view_name == 'home_page_banner_view' && settings.extraData.view_display_id == 'block_1') { 309 $('#banner-carousel').not('.slick-initialized').not('.slick-initialized').slick({ 310 infinite: true, 311 slidesToShow: 1, 312 slidesToScroll: 1,
313 arrows: false, 314 dots: true, 315 autoplay: false, 316 autoplaySpeed: 4000, 317 centerMode: true, 318 centerPadding: '2px' 319 }); 320 } 321 322 if (settings.extraData.view_name == 'current_openings' && settings.extraData.view_display_id == 'block_1') { 323 /*csr page blog and openings filters style*/ 324 $('.js-city-search2').select2({ 325 dropdownParent: $('#initiativesSelect'), 326 }).on('select2:open', function (e) { 327 $('.select2-search__field').attr('placeholder', 'Search...'); 328 }); 329 $('.js-city-search3').select2({ 330 dropdownParent: $('#newCitySelect'), 331 }).on('select2:open', function (e) { 332 $('.select2-search__field').attr('placeholder', 'Search...'); 333 }); 334 $('.js-city-search').select2({ 335 dropdownParent: $('#CitySelect'), 336 }).on('select2:open', function (e) { 337 $('.select2-search__field').attr('placeholder', 'Search...'); 338 }); 339 /*csr page blog filters style end*/ 340 } 341 342 if (settings.extraData.view_name == 'locate_us' && settings.extraData.view_display_id == 'block_1') { 343 $('.js-city-search3').select2({ 344 dropdownParent: $('#newCitySelect'), 345 }).on('select2:open', function (e) { 346 $('.select2-search__field').attr('placeholder', 'Search...'); 347 }); 348 } 349 350 if (settings.extraData.view_name == 'learn_more_with_act_view' && settings.extraData.view_display_id == 'block_10') { 351 $('.js-city-search2').select2({ 352 dropdownParent: $('#initiativesSelect'), 353 }).on('select2:open', function (e) { 354 $('.select2-search__field').attr('placeholder', 'Search...'); 355 }); 356 357 $('.js-city-search3').select2({ 358 dropdownParent: $('#newCitySelect'), 359 }).on('select2:open', function (e) { 360 $('.select2-search__field').attr('placeholder', 'Search...'); 361 }); 362 } 363 } 364 }); 365 366 367$('.learingResorceClass input[name=field_learning_resource_sub_cat_target_id]').addClass('jsTabInput') 368 369 370 371 372 373 $('.blog_listing_clear').click(function(event) { 374 event.preventDefault(); 375 location.reload(true); 376 377 }); 378 379 380 381 $('.blog_catgeory .blogcatgeory').not(':eq(0), :eq(1) , :eq(2) , :eq(3)').addClass('d-none'); 382 383 $('.show_more_blog').click(function(event) { 384 event.preventDefault(); 385 $('.blog_catgeory .blogcatgeory').removeClass('d-none'); 386 $(this).addClass('d-none'); 387 $('.show_less_blog').removeClass('d-none'); 388 389 }); 390 391 $('.show_less_blog').click(function(event) { 392 event.preventDefault(); 393 $('.blog_catgeory .blogcatgeory').not(':eq(0), :eq(1) , :eq(2) , :eq(3)').addClass('d-none'); 394 $(this).addClass('d-none'); 395 $('.show_more_blog').removeClass('d-none'); 396 397 }); 398 399 $(".nav-tabs .nav-item .nav-link").on('click', (function () { 400 $('.jsDriveSlider').slick('unslick'); 401 $('.jsDriveSlider').slick('destroy'); 402 // $('.my-slide').remove(); 403 $('.jsDriveSlider').not('.slick-initialized').slick({ 404 infinite: true, 405 slidesToShow: 4, 406 slidesToScroll: 2, 407 arrows: false, 408 dots: true, 409 responsive: [ 410 { 411 breakpoint: 992, 412 settings: { 413 slidesToShow: 3, 414 slidesToScroll: 1 415 } 416 }, 417 { 418 breakpoint: 768, 419 settings: { 420 slidesToShow: 2, 421 slidesToScroll: 1, 422 } 423 }, 424 { 425 breakpoint: 565, 426 settings: { 427 slidesToShow: 1, 428 slidesToScroll: 1, 429 } 430 } 431 ] 432 }) 433 })); 434 435 // $('.jsDriveSlider').not('.slick-initialized').not('.slick-initialized').slick({ 436 // infinite: true, 437 // slidesToShow: 4, 438 // slidesToScroll: 2, 439 // arrows: false, 440 // dots: true, 441 // responsive: [ 442 // { 443 // breakpoint: 992, 444 // settings: { 445 // slidesToShow: 3, 446 // slidesToScroll: 1 447 // } 448 // }, 449 // { 450 // breakpoint: 768, 451 // settings: { 452 // slidesToShow: 2, 453 // slidesToScroll: 1, 454 // } 455 // }, 456 // { 457 // breakpoint: 565, 458 // settings: { 459 // slidesToShow: 1, 460 // slidesToScroll: 1, 461 // } 462 // } 463 // ] 464 // }) 465 466 467 // $(".jsGallerySliders").on("init reInit afterChange", function (event, slick, currentSlide, nextSlide) { 468 // if ($(".jsGallerySliders .gallery-rows").length <= 1) { 469 // $(".jsGallerySliders").removeClass("slick-dot-wrapper"); 470 // } else { 471 // $(".jsGallerySliders").addClass("slick-dot-wrapper"); 472 // } 473 // } 474 // ); 475 476 $('.jsGallerySliders').not('.slick-initialized').not('.slick-initialized').not('.slick-initialized').slick({ 477 infinite: true, 478 slidesToShow: 1, 479 slidesToScroll: 1, 480 arrows: true, 481 dots: true, 482 responsive: [ 483 { 484 breakpoint: 768, 485 settings: {
486 arrows: false 487 } 488 }, 489 ] 490 }) 491 492 493 // $(".address-proof-select-search").select2({ 494 // placeholder: "Select", 495 // minimumResultsForSearch: -1, 496 // dropdownParent: $("#address-proof").parent(), 497 // }); 498 499 var CitySelectEle = $("#CitySelect").find("select"); 500 var sellingPlanSelectEle = $("#sellingPlanSelect").find("select"); 501 502 503 //slider 504 if($(window).width() <= 767){ 505 506 $('#selling-plan').on('afterChange', function (event, slick, currentSlide, nextSlide) { 507 $('.tool-tip').tooltip('hide'); 508 }); 509 510 $('#selling-plan').not('.slick-initialized').slick({ 511 infinite: false, 512 slidesToShow: 1.5, 513 slidesToScroll: 1, 514 arrows: false, 515 dots: true, 516 // centerMode: true, 517 responsive: [ 518 { 519 breakpoint: 768, 520 settings: { 521 slidesToShow: 1.1, 522 slidesToScroll: 1, 523 } 524 }, 525 ] 526 }); 527 528 } 529 530 //end 531 532 CitySelectEle.select2({ 533 dropdownParent: $('#CitySelect'), 534 }).on('select2:open', function(e) { 535 $('.select2-search__field').attr('placeholder', 'Search dfasf...'); 536 }); 537 sellingPlanSelectEle.select2().on('select2:open', function(e) { 538 $('.select2-search__field').attr('placeholder', 'Search...'); 539 $('body').find('span.select2-dropdown--below').addClass('select2-dropdown__city'); 540 }); 541 $('#views-exposed-form-products-view-block-2').removeClass("views-exposed-form bef-exposed-form"); 542 $('#views-exposed-form-products-view-block-1').removeClass("views-exposed-form bef-exposed-form"); 543 // Attach a change event handler to both input elements 544 545 546 $("#sellingPlanSelect > select").on("change", function() { 547 var newValue = $(this).val(); // Get the new value from the changed input 548 // Set the value of both input elements to the new value 549 var currentUrl = window.location.href; 550 if (currentUrl.indexOf("/activate-learning") === -1 ) { 551 $("#CitySelect > select, #sellingPlanSelect > select").val(newValue); 552 } 553 554 }); 555 $("#CitySelect > select").on("change", function() { 556 var newValue = $(this).val(); // Get the new value from the changed input 557 if(newValue !=3){ 558 $('.HomepagebannerNCForm').addClass('HomepagebannerNCForm'+newValue); 559 } 560 561 // Set the value of both input elements to the new value 562 //$(".Banner-location-change > select").val(newValue); 563 $("#CitySelect > select, #sellingPlanSelect > select").val(newValue); 564 $('.action-holder input.submit-form-by-click').trigger("click"); 565 }); 566 $("#CitySelect > select").on("change", function() { 567 var newValue = $(this).val(); // Get the new value from the changed input 568 // Set the value of both input elements to the new value 569 //$("# > select").val(newValue); 570 $("#CitySelect > select, #BannerSelect > select").val(newValue); 571 $('.action-holder input.submit-form-by-click').trigger("click"); 572 }); 573 $('.jsSwitch [type="radio"]').on("click", function() { 574 var getVal = $(this).val(); 575 if(getVal == 'for_home') { 576 $('.jsSellingPlan').addClass('d-none') 577 $('#for_homeService').removeClass('d-none') 578 } 579 if(getVal == 'for_business') { 580 $('.jsSellingPlan').addClass('d-none') 581 $('#for_businessService').removeClass('d-none') 582 } 583 }); 584 585 // Destroy the previous Slick instance if it's already initialized. 586 if ($('.jsFocusAreaSlider').hasClass('slick-initialized')) { 587 $('.jsFocusAreaSlider').slick('unslick'); 588 } 589 590 // Reinitialize Slick after the new content is loaded. 591 $('.jsFocusAreaSlider').not('.slick-initialized').slick({ 592 infinite: false, 593 slidesToShow: 3, 594 slidesToScroll: 3, 595 arrows: false, 596 dots: true, 597 responsive: [ 598 { 599 breakpoint: 992, 600 settings: { 601 slidesToShow: 2.2, 602 slidesToScroll: 1 603 } 604 }, 605 { 606 breakpoint: 565, 607 settings: { 608 slidesToShow: 1.2, 609 slidesToScroll: 1 610 } 611 } 612 ] 613 }); 614 615 616 $(".action-holder input.submit-form-by-click, .action-holder input").click(function() { 617 $('#sortFilter').modal('hide'); 618 }); 619 $("#plan-cards input").change(function() { 620 var id = $(this).attr('id'); 621 $('#form-plan-cards input#' + id).prop('checked', 'checked').trigger("change"); 622 }); 623 $('.filter-list .btn-filter').on("click", function() { 624 var getVal = $(this).data('filter'); 625 $('.filterPlan').text(getVal); 626 }); 627 if($(".js-range-slider").length) { 628 $(".js-range-slider").ionRangeSlider({ 629 onStart: function(data) { 630 // Called right after range slider instance initialised 631 }, 632 onChange: function(data) { 633 // Called every time handle position is changed 634 $("input.ct_field_plan_speed_from").val(data.from) 635 $("input.ct_field_plan_speed_to").val(data.to) 636 product_filter_with_data(data.from, data.to); 637 }, 638 onFinish: function(data) { 639 // Called then action is done and mouse is released 640 $("input.ct_field_plan_speed_from").val(data.from) 641 $("input.ct_field_plan_speed_to").val(data.to) 642 product_filter_with_data(data.from, data.to); 643 }, 644 onUpdate: function(data) { 645 // Called then slider is changed using Update public method 646 } 647 }); 648 } 649 650 651 652 653 654 const buttons = once('custom-clear', '.views-exposed-form .resetFormData', context); 655 buttons.forEach(function(element) { 656 const $button = $(element); 657 $button.click(function() { 658 const $form = $(this).closest('.views-exposed-form'); 659 $form.find('input[type=checkbox]').prop("checked", false); 660 $form.find('input[name=sort_bef_combine]').prop("checked", false); 661 $form.find('input.ct_field_plan_speed_from').val(10); 662 $form.find('input.ct_field_plan_speed_to').val(1000); 663 product_filter_with_data('10', '1000'); 664 }) 665 }) 666 667 //Popup data populate 668 $('.plan-bottom button').on("click", function() { 669 //alert('1'); 670 //var getTenure = $('#choosePlan #language-list li:first-child input[name="selectTenure"]').val(); 671 var getId = $(this).closest('.selling-plan-card').find('.plan-top .heading-plan').data('plan-id'); 672 var getTitle = $(this).closest('.selling-plan-card').find('.plan-top .heading-plan span').text(); 673 var dataLimit = $(this).closest('.selling-plan-card').find('.plan-top .heading-plan .data-limit').text(); 674 var getSpeed = $(this).closest('.selling-plan-card').find('.plan-top .heading-plan h2').text(); 675 // var getNum = $(this).closest('.selling-plan-card').find('.addon-plan ul li').length(); 676 var getRate = parseInt($(this).data('rate')); 677 var productmrp = $(this).data('productmrp'); 678 let getInstallation = parseInt($(this).data('installation')); 679 680 var getSecurity = parseInt($(this).data('securityamt')); 681 var getTotalAmt = getRate + getInstallation + getSecurity; 682 console.log("getTotalAmt="+getTotalAmt); 683 684 $('.included-addon-list').removeClass('d-none'); 685 // Check if any radio buttons exist 686 // var checkedFirst = $(this).closest('.selling-plan-card').find('.offer-plans .add-plan-to-model li.checkedFirst').first(); 687 // if(checkedFirst.length > 0) { 688 // checkedFirst.find('input[name="addon_include"]').attr('checked', true); 689 // $('.plans-offers .no-offer').hide(); 690 // } else { 691 // $('.plans-offers .no-offer').show(); 692 // } 693 694 var originalHTML = $(this).closest('.selling-plan-card').find('.offer-plans .add-plan-to-model').html(); 695 $('.modal-plan-head .plan-name').text(getTitle); 696 $('.modal-plan-head .plan-consumption').text(dataLimit); 697 $('.modal-plan-head .plan-speed h3').text(getSpeed); 698 $('.plan-charges .permonth_rate').text(getRate); 699 $('.plan-charges .strike-price').text('productmrp'); 700 $('.plan-charges .total_amount').text(getTotalAmt); 701 $('.plan-charges .installation_amount').text(getInstallation); 702 $('.plan-charges .security_amount').text(getSecurity); 703 $('input[name="selected_rate"]').val(getRate); 704 $('input[name="installation_amt"]').val(getInstallation); 705 $('input[name="security_amt"]').val(getSecurity); 706 $('input[name="planId"]').val(getId); 707 $('input[name="getCustomId"]').val(window.location.search.split('=')[1]); 708 $('.plans-offers .offers-list').html(''); 709 $('.plans-offers .offers-list').prepend(originalHTML); 710 $('.plans-offers .no-offer').css("display", "block"); 711 712 var checkedFirst = $('#choosePlan .offers-list li:first-child input[name="addon_include"]'); 713 // Trigger a click event on the first radio button 714 if(checkedFirst.length > 0) { 715 checkedFirst.trigger('click'); 716 $('.plans-offers .no-offer').css("display", "none");
717 $(this).parent('.plandetailsparent').find('input[name="plancode"]').each(function() { 718 var installation = parseInt($(this).data('installation')); 719 var security = parseInt($(this).data('security')); 720 // Update the total amount in the UI 721 $('.plan-charges .installation_amount').text(installation); 722 $('.plan-charges .security_amount').text(security); 723 // Break out of the loop 724 return false; // This acts like break inside jQuery's .each() 725 }); 726 // $('.plans-offers .no-offer').hide(); 727 } else { 728 $('.plans-offers .no-offer').css("display", "block"); 729 var TotalAmount =0; 730 $(this).parent('.plandetailsparent').find('input[name="plancode"]').each(function() { 731 var installation = parseInt($(this).data('installation')); 732 var security = parseInt($(this).data('security')); 733 var plan_month_val = parseInt($(this).data('monthvalue').trim()); 734 var TotalAmount = (getRate * plan_month_val) + installation + security; 735 console.log(TotalAmount); 736 // Update the total amount in the UI 737 $('.plan-charges .total_amount').text(TotalAmount); 738 $('.plan-charges .installation_amount').text(installation); 739 $('.plan-charges .security_amount').text(security); 740 // Break out of the loop 741 return false; // This acts like break inside jQuery's .each() 742 }); 743 744 } 745 746 var getDefaultTenure = $(this).closest('.selling-plan-card').find('.plan_details:first-child input[name="plancode"]').data('monthvalue').trim(); 747 // alert(getDefaultTenure); 748 var elements1 = $('.plans-offers .offers-list .included-addon-list'); 749 var checked =true; 750 elements1.each(function(index, element) { 751 var strData = $(element).attr('data-id').trim(); // Fetch the data-id attribute 752 var valueToFind = getDefaultTenure; // The tenure value you're looking for 753 // console.log('strData'+strData); 754 // console.log('valuetofind'+valueToFind); 755 // Check if strData contains multiple values separated by commas 756 if (strData.indexOf(',') !== -1) { 757 // Split the string into an array 758 var arr = strData.split(','); 759 760 // Check if the valueToFind exists in the array 761 if ($.inArray(valueToFind, arr) !== -1) { 762 $(this).removeClass('d-none'); // Show the element 763 if (checked) { 764 $(this).find('input[name="addon_include"]').prop('checked', true); // Check the first matching input 765 checked = false; 766 } 767 } else { 768 $(this).addClass('d-none'); // Hide the element if no match 769 } 770 } else { 771 // If strData does not contain a comma, treat it as a single value 772 if (strData == valueToFind) { 773 // $(this).addClass('charu'); 774 $(this).removeClass('d-none'); // Show the element 775 if (checked) { 776 $(this).find('input[name="addon_include"]').prop('checked', true); // Check the input 777 checked = false; 778 } 779 } else { 780 $(this).addClass('d-none'); // Hide the element if no match 781 } 782 } 783 }); 784 785 786 }); 787 788 $('.recommended-plan-bottom button').on("click", function() { 789 //alert('1'); 790 //var getTenure = $('#choosePlan #language-list li:first-child input[name="selectTenure"]').val(); 791 var getId = $(this).closest('.plan-cart').find('.plan-img').data('plan-id'); 792 var getTitle = $(this).closest('.plan-cart').find('.plan-img p').text(); 793 var dataLimit = $(this).closest('.plan-cart').find('.plan-body .data-limit').text(); 794 var getSpeed = $(this).closest('.plan-cart').find('.plan-body .plan-speed').text(); 795 //var getSpeed = $(this).closest('.plan-cart').find('.plan-top .heading-plan h2').text(); 796 // var getNum = $(this).closest('.selling-plan-card').find('.addon-plan ul li').length(); 797 var getRate = parseInt($(this).data('rate')); 798 var productmrp = $(this).data('productmrp'); 799 let getInstallation = parseInt($(this).data('installation')); 800 801 var getSecurity = parseInt($(this).data('securityamt')); 802 var getTotalAmt = getRate + getInstallation + getSecurity; 803 console.log("getTotalAmt="+getTotalAmt); 804 805 $('.included-addon-list').removeClass('d-none'); 806 // Check if any radio buttons exist 807 // var checkedFirst = $(this).closest('.selling-plan-card').find('.offer-plans .add-plan-to-model li.checkedFirst').first(); 808 // if(checkedFirst.length > 0) { 809 // checkedFirst.find('input[name="addon_include"]').attr('checked', true); 810 // $('.plans-offers .no-offer').hide(); 811 // } else { 812 // $('.plans-offers .no-offer').show(); 813 // } 814 815 var originalHTML = $(this).closest('.plan-cart').find('.offer-plans .add-plan-to-model').html(); 816 $('.modal-plan-head .plan-name').text(getTitle); 817 $('.modal-plan-head .plan-consumption').text(dataLimit); 818 $('.modal-plan-head .plan-speed h3').text(getSpeed); 819 $('.plan-charges .permonth_rate').text(getRate); 820 $('.plan-charges .strike-price').text('productmrp'); 821 $('.plan-charges .total_amount').text(getTotalAmt); 822 $('.plan-charges .installation_amount').text(getInstallation); 823 $('.plan-charges .security_amount').text(getSecurity); 824 $('input[name="selected_rate"]').val(getRate); 825 $('input[name="installation_amt"]').val(getInstallation); 826 $('input[name="security_amt"]').val(getSecurity); 827 $('input[name="planId"]').val(getId); 828 $('input[name="getCustomId"]').val(window.location.search.split('=')[1]); 829 $('.plans-offers .offers-list').html(''); 830 $('.plans-offers .offers-list').prepend(originalHTML); 831 $('.plans-offers .no-offer').css("display", "block"); 832 833 var checkedFirst = $('#choosePlan .offers-list li:first-child input[name="addon_include"]'); 834 // Trigger a click event on the first radio button 835 if(checkedFirst.length > 0) { 836 checkedFirst.trigger('click'); 837 $('.plans-offers .no-offer').css("display", "none");
838 $(this).parent('.plandetailsparent').find('input[name="plancode"]').each(function() { 839 var installation = parseInt($(this).data('installation')); 840 var security = parseInt($(this).data('security')); 841 // Update the total amount in the UI 842 $('.plan-charges .installation_amount').text(installation); 843 $('.plan-charges .security_amount').text(security); 844 // Break out of the loop 845 return false; // This acts like break inside jQuery's .each() 846 }); 847 // $('.plans-offers .no-offer').hide(); 848 } else { 849 $('.plans-offers .no-offer').css("display", "block"); 850 var TotalAmount =0; 851 $(this).parent('.plandetailsparent').find('input[name="plancode"]').each(function() { 852 var installation = parseInt($(this).data('installation')); 853 var security = parseInt($(this).data('security')); 854 var plan_month_val = parseInt($(this).data('monthvalue').trim()); 855 var TotalAmount = (getRate * plan_month_val) + installation + security; 856 console.log(TotalAmount); 857 // Update the total amount in the UI 858 $('.plan-charges .total_amount').text(TotalAmount); 859 $('.plan-charges .installation_amount').text(installation); 860 $('.plan-charges .security_amount').text(security); 861 // Break out of the loop 862 return false; // This acts like break inside jQuery's .each() 863 }); 864 865 } 866 867 var getDefaultTenure = $(this).closest('.plan-cart').find('.plan_details:first-child input[name="plancode"]').data('monthvalue').trim(); 868 // alert(getDefaultTenure); 869 var elements1 = $('.plans-offers .offers-list .included-addon-list'); 870 var checked =true; 871 elements1.each(function(index, element) { 872 var strData = $(element).attr('data-id').trim(); // Fetch the data-id attribute 873 var valueToFind = getDefaultTenure; // The tenure value you're looking for 874 // console.log('strData'+strData); 875 // console.log('valuetofind'+valueToFind); 876 // Check if strData contains multiple values separated by commas 877 if (strData.indexOf(',') !== -1) { 878 // Split the string into an array 879 var arr = strData.split(','); 880 881 // Check if the valueToFind exists in the array 882 if ($.inArray(valueToFind, arr) !== -1) { 883 $(this).removeClass('d-none'); // Show the element 884 if (checked) { 885 $(this).find('input[name="addon_include"]').prop('checked', true); // Check the first matching input 886 checked = false; 887 } 888 } else { 889 $(this).addClass('d-none'); // Hide the element if no match 890 } 891 } else { 892 // If strData does not contain a comma, treat it as a single value 893 if (strData == valueToFind) { 894 // $(this).addClass('charu'); 895 $(this).removeClass('d-none'); // Show the element 896 if (checked) { 897 $(this).find('input[name="addon_include"]').prop('checked', true); // Check the input 898 checked = false; 899 } 900 } else { 901 $(this).addClass('d-none'); // Hide the element if no match 902 } 903 } 904 }); 905 906 907 }); 908 909 $('.customtitleclass input').addClass('search-input'); 910 911 // Select tenure 912 $(document).on("change",'.tenure input[name="selectTenure"]',function() { 913 // alert('hre'); 914 //$('.tenure input[name="selectTenure"]').on("change", function() { 915 var tenure = $(this).val().replace(/\s+/g, ''); 916 // console.log('tenure'+tenure); 917 var getRate = $('input[name="selected_rate"]').val(); 918 // console.log('getRate'+getRate); 919 var getadvanceRate = $('input[name="addon_include"]').data('advancerental'); 920 // alert(getadvanceRate); 921 //var getInstallation = $('input[name="installation_amt"]').val(); 922 var getInstallation = $(this).data('installation'); 923 var getSecurity = $(this).data('security'); 924 $('#buy_plan_by_selection_modal .plan-charges .installation_amount').text(getInstallation); 925 $('#buy_plan_by_selection_modal .plan-charges .security_amount').text(getSecurity); 926 //var getSecurity = $('input[name="security_amt"]').val(); 927 $('input[name="security_amt"]').val(getSecurity); 928 $('input[name="installation_amt"]').val(getInstallation); 929 930 // var total_amount1 = parseInt(getadvanceRate ? getadvanceRate : tenure) * parseInt(getRate); 931 var total_amount1 = parseInt(tenure) * parseInt(getRate); 932 var total_amount = parseInt(total_amount1) + parseInt(getInstallation) + parseInt(getSecurity); 933 // console.log('totalamount'+total_amount); 934 $('.plan-charges .total_amount').text(total_amount); 935 $('.plans-offers .no-offer').hide(); 936 $('input[name="addon_include"]').prop('checked', false); 937 var checked = true; 938 var elements = $('.plans-offers .offers-list .included-addon-list'); 939 940 elements.each(function(index, element) { 941 var strData = $(element).attr('data-id'); // Fetch the data-id attribute 942 var valueToFind = tenure; // The tenure value you're looking for 943 944 // Check if strData contains multiple values separated by commas 945 if (strData.indexOf(',') !== -1) { 946 // Split the string into an array 947 var arr = strData.split(','); 948 949 // Check if the valueToFind exists in the array 950 if ($.inArray(valueToFind, arr) !== -1) { 951 $(this).removeClass('d-none'); // Show the element 952 if (checked) { 953 $(this).find('input[name="addon_include"]').prop('checked', true); // Check the first matching input 954 checked = false;
955 } 956 } else { 957 $(this).addClass('d-none'); // Hide the element if no match 958 } 959 } else { 960 // If strData does not contain a comma, treat it as a single value 961 if (strData == valueToFind) { 962 // $(this).addClass('charu'); 963 $(this).removeClass('d-none'); // Show the element 964 if (checked) { 965 $(this).find('input[name="addon_include"]').prop('checked', true); // Check the input 966 checked = false; 967 } 968 } else { 969 $(this).addClass('d-none'); // Hide the element if no match 970 } 971 } 972 }); 973 974 if(checked) { 975 $('.plans-offers .no-offer').show(); 976 } 977 // if (tenure == 1) { 978 // $('.plans-offers .offers-list .plan-6month').hide(); 979 // $('.plans-offers .offers-list .plan-12month').hide(); 980 // $('.plans-offers .offers-list .plan-routerfree').hide(); 981 // } else if (tenure == 6) { 982 // $('.plans-offers .offers-list .plan-6month').show(); 983 // $('.plans-offers .offers-list .plan-routerfree').show(); 984 // $('.plans-offers .offers-list .plan-12month').hide(); 985 // } else if (tenure == 12) { 986 // $('.plans-offers .offers-list .plan-12month').show(); 987 // $('.plans-offers .offers-list .plan-routerfree').show(); 988 // $('.plans-offers .offers-list .plan-6month').hide(); 989 // } 990 }); 991 $('#choosePlan').on('hidden.bs.modal', function() { 992 $('.plans-offers .offers-list .plan-6month').hide(); 993 $('.plans-offers .offers-list .plan-12month').hide(); 994 $('.plans-offers .offers-list .plan-routerfree').hide(); 995 $('.tenure input[name="selectTenure"]').prop("checked", false); 996 $('.tenure #selectTenure1').prop("checked", true); 997 $('.plans-offers .offers-list .included-addon-list').remove(); 998 }); 999 1000 //// Select tenure 1001 $(document).on("change",'input[name="addon_include"]',function() { 1002 //alert('3'); 1003 var getRate = parseInt($('input[name="selected_rate"]').val()); 1004 var getadvanceRate = parseInt($(this).data('advancerental')); 1005 var getplantag = $(this).data('plantag'); 1006 1007 var tenure = parseInt($('input[name="selectTenure"]').val()); 1008 var getInstallation = $('input[name="installation_amt"]').val(); 1009 var getSecurity = parseFloat($('input[name="security_amt"]').val()); 1010 1011 // var getInstallation = $('.installation_amount').text(); 1012 // var getSecurity = $('.security_amount').text(); 1013 1014 $('#buy_plan_by_selection_modal .plan-charges .installation_amount').text(getInstallation); 1015 $('#buy_plan_by_selection_modal .plan-charges .security_amount').text(getSecurity); 1016 1017 $('input[name="security_amt"]').val(getSecurity); 1018 $('input[name="installation_amt"]').val(getInstallation); 1019 1020 1021 var total_amount1 = parseInt(((getadvanceRate) ? getadvanceRate : tenure)) * parseInt(getRate); 1022 var getstrikePrice = total_amount1/parseInt(getadvanceRate ? getadvanceRate : tenure)+getplantag; 1023 var total_amount = parseInt(total_amount1) + parseInt(getInstallation) + parseInt(getSecurity); 1024 $('.plan-charges .total_amount').text(total_amount); 1025 $('.plan-charges .strike-price').text('â¹'+getstrikePrice); 1026 }); 1027 1028 //Kyc form scripting 1029 $('#front_input_id_proof .kyc-verification-form-element input[type="file"], #back_input_id_proof .kyc-verification-form-element input[type="file"], #sellectIdproof select').on('change', function() { 1030 // Check if both file inputs are filled and select field has a value selected 1031 var file1Filled = $('#front_input_id_proof').find('.kyc-verification-form-element span.file-link').length > 0; 1032 var file2Filled = $('#back_input_id_proof').find('.kyc-verification-form-element span.file-link').length > 0; 1033 var selectFilled = $('#sellectIdproof select').val() !== ''; 1034 if(file1Filled && file2Filled && selectFilled) { 1035 $('.add-file-upload h5').addClass('file-uploaded'); // Add the class 'file-uploaded' to the form 1036 } else { 1037 $('.add-file-upload h5').removeClass('file-uploaded'); // Remove the class 'file-uploaded' from the form 1038 } 1039 }); 1040 $('#front_input_id_proof, #back_input_id_proof').on('DOMSubtreeModified', function() { 1041 var file1Filled = $('#front_input_id_proof').find('.kyc-verification-form-element span.file-link').length > 0; 1042 var file2Filled = $('#back_input_id_proof').find('.kyc-verification-form-element span.file-link').length > 0; 1043 var selectFilled = $('#sellectIdproof select').val() !== ''; 1044 if(file1Filled && file2Filled && selectFilled) { 1045 $('.add-file-upload h5').addClass('file-uploaded'); // Add the class 'file-uploaded' to the form 1046 } else { 1047 $('.add-file-upload h5').removeClass('file-uploaded'); // Remove the class 'file-uploaded' from the form 1048 } 1049 }); 1050 //File upload validation error 1051 $('#front_input_id_proof, #back_input_id_proof').on('DOMSubtreeModified', function() { 1052 // Check if both file inputs are filled and select field has a value selected 1053 var file1Filled = $('#front_input_id_proof').find('.kyc-verification-form-element div.messages.messages--error.file-upload-js-error').length > 0; 1054 var file2Filled = $('#back_input_id_proof').find('.kyc-verification-form-element div.messages.messages--error.file-upload-js-error').length > 0; 1055 if(file1Filled) { 1056 $('#front_input_id_proof').addClass('text-error-textbox'); // Add the class 'text-error-textbox' to the form 1057 $('#front_input_id_proof').find('.errors').removeClass('d-none'); 1058 $('#front_input_id_proof').find('.custom-required-error').addClass('d-none'); 1059 } else if(file2Filled) { 1060 $('#back_input_id_proof').addClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1061 $('#back_input_id_proof').find('.errors').removeClass('d-none'); 1062 $('#back_input_id_proof').find('.custom-required-error').addClass('d-none'); 1063 } else { 1064 $('#front_input_id_proof').removeClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1065 $('#back_input_id_proof').removeClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1066 $('#front_input_id_proof').find('.errors').addClass('d-none'); 1067 $('#back_input_id_proof').find('.errors').addClass('d-none'); 1068 $('#front_input_id_proof').find('.custom-required-error').removeClass('d-none'); 1069 $('#back_input_id_proof').find('.custom-required-error').removeClass('d-none'); 1070 } 1071 }); 1072 $('#address_front_input_id_proof, #address_back_input_id_proof').on('DOMSubtreeModified', function() { 1073 // Check if both file inputs are filled and select field has a value selected 1074 var file1Filled = $('#address_front_input_id_proof').find('.kyc-verification-form-element div.messages.messages--error.file-upload-js-error').length > 0; 1075 var file2Filled = $('#address_back_input_id_proof').find('.kyc-verification-form-element div.messages.messages--error.file-upload-js-error').length > 0; 1076 if(file1Filled) { 1077 $('#address_front_input_id_proof').addClass('text-error-textbox'); // Add the class 'text-error-textbox' to the form 1078 $('#address_front_input_id_proof').find('.errors').removeClass('d-none'); 1079 $('#address_front_input_id_proof').find('.custom-required-error').addClass('d-none'); 1080 } else if(file2Filled) { 1081 $('#address_back_input_id_proof').addClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1082 $('#address_back_input_id_proof').find('.errors').removeClass('d-none'); 1083 $('#address_back_input_id_proof').find('.custom-required-error').addClass('d-none'); 1084 } else { 1085 $('#address_front_input_id_proof').removeClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1086 $('#address_back_input_id_proof').removeClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1087 $('#address_front_input_id_proof').find('.errors').addClass('d-none'); 1088 $('#address_back_input_id_proof').find('.errors').addClass('d-none'); 1089 $('#address_front_input_id_proof').find('.custom-required-error').removeClass('d-none'); 1090 $('#address_back_input_id_proof').find('.custom-required-error').removeClass('d-none'); 1091 } 1092 }); 1093 $('#upload_signature_file').on('DOMSubtreeModified', function() { 1094 // Check if both file inputs are filled and select field has a value selected 1095 var file1Filled = $('#upload_signature_file').find('.kyc-verification-form-element div.messages.messages--error.file-upload-js-error').length > 0; 1096 if(file1Filled) { 1097 $('#upload_signature_file').addClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1098 $('#upload_signature_file').find('.errors').removeClass('d-none'); 1099 $('#upload_signature_file').find('.custom-required-error').addClass('d-none'); 1100 } else { 1101 $('#upload_signature_file').removeClass('text-error-textbox'); // Remove the class 'text-error-textbox' from the form 1102 $('#upload_signature_file').children('.errors').addClass('d-none'); 1103 $('#upload_signature_file').find('.custom-required-error').removeClass('d-none'); 1104 } 1105 }); 1106 $('.proceedtonext').on("click", function() { 1107 var cname = $('.proceed-cntr input[name="your_name"]').val(); 1108 $('.refer-step-2').removeClass('d-none'); 1109 $('.refer-step-1').addClass('d-none'); 1110 $('.proceed-cntr .step-progress li').addClass('completed'); 1111 $('.proceed-cntr .step-progress li').removeClass('current'); 1112 }); 1113 1114 $('.customjstitle input').addClass('search-input'); 1115 1116 1117 1118 1119 //call thank you page 1120 $.fn.myCustomAjaxFormSubmit = function(firstName) { 1121 var firstNameFromWebform = firstName; 1122 // Logs the value of the first_name field from our webform. 1123 //Show modal confirmation. 1124 $('#thankYou').modal('show'); 1125 // Redirect after 2 seconds. 1126 setTimeout(function() { 1127 window.location.href = '/refer-a-friend'; 1128 }, 7000); 1129 }; 1130 $('#submitForOrder').on("click", function() { 1131 var service_available = $('input[name="service_available"]').val(); 1132 console.log(service_available); 1133 if(service_available == "failed") { 1134 $('#choosePlan').modal('hide'); 1135 //Show modal confirmation. 1136 $('#thankYou2').modal('show'); 1137 } else { 1138 $('#buy_plan_by_selection_modal').submit(); 1139 } 1140 }); 1141 1142 //New connection form changes 1143 jQuery('.webform-submission-order-summary-form #edit-actions-01-wizard-next').on("click", function(e) { 1144 e.preventDefault(); 1145 1146 var f_name = $('.webform-submission-order-summary-form #edit-name').val(); 1147 var mobile = $('.webform-submission-order-summary-form #edit-phone-number').val(); 1148 var location = $('.webform-submission-order-summary-form #edit-locations').val(); 1149 var captcha = $('.webform-submission-order-summary-form #edit-captcha-response').val(); 1150 var address = $('.webform-submission-order-summary-form #place-address-autocomplete').val(); 1151 var society = $('.webform-submission-order-summary-form #edit-society').val(); 1152 var nameRegex = /^[a-zA-Z]+(?:\s[a-zA-Z]+)*$/; 1153 var phoneRegex = /^(?:\d{10})$/; 1154 var addressregexspecial = /^[a-zA-Z0-9, \s\-_+.]+$/; 1155 var regexspecial = /^[a-zA-Z, ]+$/; 1156 var checkbox = document.getElementById('edit-multi-story-option'); 1157
1158 var validation = true; 1159 $(".webform-submission-order-summary-form .friend-error").remove(); 1160 if (f_name == '' || !nameRegex.test(f_name)) { 1161 $(".webform-submission-order-summary-form #edit-name").parent().after('<span class="friend-error">Please enter valid name!</span>'); 1162 validation = false; 1163 } 1164 if (mobile == '' || !phoneRegex.test(mobile)) { 1165 $(".webform-submission-order-summary-form #edit-phone-number").parent().after('<span class="friend-error">Please enter valid mobile no!</span>'); 1166 validation = false; 1167 } 1168 if (address == '') { 1169 $(".webform-submission-order-summary-form #place-address-autocomplete").parent().after('<span class="friend-error">Please enter letters only!</span>'); 1170 validation = false; 1171 } 1172 if (checkbox.checked) { 1173 if (society == '' || !regexspecial.test(society)) { 1174 $(".webform-submission-order-summary-form #edit-society").parent().after('<span class="friend-error">Please enter letters only!</span>'); 1175 validation = false; 1176 } 1177 } 1178 1179 if (!validation) { 1180 return false; 1181 } 1182 1183 // Disable the submit button 1184 var $submitButton = jQuery('.webform-submission-order-summary-form #edit-actions-01-wizard-next'); 1185 $submitButton.prop('disabled', true); 1186 1187 $('#loader').removeClass('d-none'); 1188 // Access form data and serialize it 1189 var formData = $('#webform-submission-order-summary-add-form').serialize(); 1190 // Define the URL for the AJAX request 1191 var url = '/check-order'; 1192 // Send AJAX POST request 1193 $.ajax({ 1194 url: url, 1195 method: 'POST', 1196 data: formData, 1197 success: function(response) { 1198 $('.reload-captcha').trigger('click'); 1199 $('#loader').addClass('d-none'); 1200 if (response.status === "error") { 1201 if (response.message == 'Prospect Id Issue') { 1202 $('#thankYou2').modal('show'); 1203 setTimeout(function() { 1204 window.location.href = '/explore-all-plans'; 1205 }, 7000); 1206 } else {
1207 $('#failed2 .modal-body .thankyou-content').html('<p class="fontSize-14 semibold">' + response.message + '</p>'); 1208 $('#failed2').modal('show'); 1209 } 1210 } else { 1211 $('.propectId').val(''); 1212 $('.propectId').val(response.prospectId); 1213 $('.webform-submission-order-summary-form').submit(); 1214 } 1215 }, 1216 error: function(jqXHR, textStatus, errorThrown) { 1217 $('#failed2 .modal-body .thankyou-content').html('<p class="fontSize-14 semibold">An error occurred while processing your request. Please try again later.</p>'); 1218 $('#failed2').modal('show'); 1219 }, 1220 complete: function() { 1221 // Re-enable the submit button after the AJAX call is complete 1222 $submitButton.prop('disabled', false); 1223 } 1224 }); 1225 }); 1226 1227 1228 1229 $('.webform-submission-order-summary-form #edit-actions-02-wizard-next').on("click", function(e) { 1230 // Prevent the default behavior of the Next button (stopping the wizard). 1231 e.preventDefault(); 1232 // Show loader 1233 $('#loader').show(); 1234 // Access form data and serialize it 1235 var formData = $('#webform-submission-order-summary-add-form').serialize(); 1236 // Define the URL for the AJAX request 1237 var url = '/check-order-summary'; 1238 const getUrl = window.location.href; 1239 // Extract only the hostname from the URL 1240 const domain = new URL(getUrl).hostname; 1241 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 1242 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 1243 1244 const updatedUrl = isLiveSite 1245 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 1246 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 1247 // Send AJAX POST request 1248 $.ajax({ 1249 url: url, 1250 method: 'POST', 1251 data: formData, 1252 success: function(response) { 1253 //return false; 1254 $('#loader').hide(); 1255 if(response.status === "error") { 1256 // If the response status is 'error', display the error message in the modal
1257 $('#failed2 .modal-body .thankyou-content').html('<p class="fontSize-14 semibold">' + response.message + '</p>'); 1258 $('#failed2').modal('show'); 1259 } else { 1260 if(response.key){ 1261 console.log('updatedurl+response.key'+ updatedUrl+response.key); 1262 window.location.href = updatedUrl+response.key; 1263 } 1264 else{ 1265 $('#thankYou2').modal('show'); 1266 // Redirect after 5 seconds. 1267 setTimeout(function() { 1268 $('#thankYou2').modal('hide'); 1269 window.location.href = '/explore-all-plans'; 1270 }, 5000); 1271 } 1272 1273 } 1274 }, 1275 error: function(jqXHR, textStatus, errorThrown) { 1276 // If an error occurs during the AJAX request, display a generic error message 1277 $('#failed2 .modal-body .thankyou-content').html('<p class="fontSize-14 semibold">An error occurred while processing your request. Please try again later.</p>'); 1278 $('#failed2').modal('show'); 1279 } 1280 }); 1281 }); 1282 1283 $('.webform-submission-order-summary-new-connection-form #edit-actions-02-wizard-next').on("click", function(e) { 1284 1285 // Prevent the default behavior of the Next button (stopping the wizard). 1286 e.preventDefault(); 1287 // Show loader 1288 $('#loader').show(); 1289 // Access form data and serialize it 1290 var formData = $('.webform-submission-order-summary-new-connection-form').serialize(); 1291 // Define the URL for the AJAX request 1292 var url = '/check-order-summary'; 1293 const getUrl = window.location.href; 1294 // Extract only the hostname from the URL 1295 const domain = new URL(getUrl).hostname; 1296 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 1297 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 1298 1299 const updatedUrl = isLiveSite 1300 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 1301 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 1302 // Send AJAX POST request 1303 $.ajax({ 1304 url: url, 1305 method: 'POST', 1306 data: formData, 1307 success: function(response) { 1308 $('#loader').hide(); 1309 if(response.status === "error") { 1310 // If the response status is 'error', display the error message in the modal
1311 $('#failed2 .modal-body .thankyou-content').html('<p class="fontSize-14 semibold">' + response.message + '</p>'); 1312 $('#failed2').modal('show'); 1313 } else { 1314 if(response.key){ 1315 window.location.href = updatedUrl+response.key; 1316 } 1317 else{ 1318 $('#thankYou2').modal('show'); 1319 // Redirect after 5 seconds. 1320 setTimeout(function() { 1321 $('#thankYou2').modal('hide'); 1322 window.location.href = '/explore-all-plans'; 1323 }, 5000); 1324 1325 } 1326 1327 } 1328 }, 1329 error: function(jqXHR, textStatus, errorThrown) { 1330 // If an error occurs during the AJAX request, display a generic error message 1331 $('#failed2 .modal-body .thankyou-content').html('<p class="fontSize-14 semibold">An error occurred while processing your request. Please try again later.</p>'); 1332 $('#failed2').modal('show'); 1333 } 1334 }); 1335 }); 1336 1337 $('.customsortby').click(function(event){ 1338 // Prevent the default form submission 1339 event.preventDefault(); 1340 }); 1341 1342 1343 // Kyc verification fields condition// 1344 1345 1346 $('input[name="files[upload_your_signature]"]').change(function(event) { 1347 var fileInput = event.target; 1348 var selectedFile = fileInput.files[0]; 1349 //console.log('File selected:', selectedFile); 1350 if(selectedFile) { 1351 //console.log('File selected:', selectedFile.name); 1352 $("canvas").css("display", "none"); 1353 // Perform actions with the selected file 1354 } else { 1355 $("canvas").css("display", "block"); 1356 } 1357 }); 1358 $('#upload_signature_file').on('DOMSubtreeModified', function() { 1359 var file1Filled = $('#upload_signature_file').find('.kyc-verification-form-element span.file-link').length > 0; 1360 if(file1Filled) { 1361 $("canvas").css("display", "none"); 1362 } else { 1363 $("canvas").css("display", "block"); 1364 } 1365 }); 1366 $("canvas").on("click", function() { 1367 // alert(); 1368 if($('input[name="sign_here"]').val() != '') { 1369 $('input[name="files[upload_your_signature]"]').attr('disabled', true); 1370 $('.add-sign-box h5').addClass('file-uploaded'); 1371 } else { 1372 $('input[name="files[upload_your_signature]"]').attr('disabled', false); 1373 } 1374 }); 1375 $(".sign-reset-alignment .webform-signature-pad input.button").on("click", function() { 1376 $('input[name="files[upload_your_signature]"]').attr('disabled', false); 1377 $('.add-sign-box h5').removeClass('file-uploaded'); 1378 }); 1379 1380 $('select[name="id_proof"]').change(function() { 1381 var idProofValue = $(this).val(); 1382 if(idProofValue != '') { 1383 $('.idProofSpanJs').removeClass('disabled'); 1384 $('input[name="files[front_id_proof]').attr('disabled', false); 1385 $('input[name="files[back_id_proof]"]').attr('disabled', false); 1386 } else { 1387 $('.idProofSpanJs').addClass('disabled'); 1388 $('input[name="files[front_id_proof]"]').attr('disabled', true); 1389 $('input[name="files[back_id_proof]"]').attr('disabled', true); 1390 } 1391 if(idProofValue == 'aadhaar') { 1392 $('.hideShowaddressMsg').css('display', 'none'); 1393 } else { 1394 $('.hideShowaddressMsg').css('display', 'block'); 1395 } 1396 }); 1397 $('select[name="address_proof"]').change(function() { 1398 var idaddProofValue = $(this).val(); 1399 if(idaddProofValue != '') { 1400 $('.idaddProofSpanJs').removeClass('disabled'); 1401 $('input[name="files[address_front_id_proof]').attr('disabled', false); 1402 $('input[name="files[address_back_of_id_proof]"]').attr('disabled', false); 1403 } else { 1404 $('.idaddProofSpanJs').addClass('disabled'); 1405 $('input[name="files[address_front_id_proof]"]').attr('disabled', true); 1406 $('input[name="files[address_back_of_id_proof]"]').attr('disabled', true); 1407 } 1408 }); 1409 $(".jsMultiStoryCheck").change(function() { 1410 if($(this).is(":checked")) { 1411 $('.jsSociaty').removeClass('d-none'); 1412 } else { 1413 $('.jsSociaty').addClass('d-none'); 1414 } 1415 }) 1416 $(".jsHaveCoupanCheck").change(function() { 1417 if($(this).is(":checked")) { 1418 $('.jsCouponCode').removeClass('d-none'); 1419 } else { 1420 $('.jsCouponCode').addClass('d-none'); 1421 } 1422 }) 1423 $("#submitExplorePlans").on('click', function() { 1424 var hiddenInputValue = ""; 1425 $('input[name="explore-plan-id"]:checked').each(function() { 1426 var plan_id = this.value; 1427 var product_qty = $("input[name='addon_product_number[" + plan_id + "]']").val(); 1428 hiddenInputValue += plan_id + "=" + product_qty + "&"; 1429 }); 1430 $('input[name="explorePlanId"]').val(hiddenInputValue); 1431 var explorePlans = hiddenInputValue; 1432 var totalAmt = $('input[name="totalAmt"]').val(); 1433 var gstPercent = $('input[name="gstPercent"]').val(); 1434 var entPackAmt = $('input[name="entertainmentPackAmt"]').val(); 1435 var selectTenure = $('input[name="selectTenure"]').val(); 1436 var getrequestId = window.location.search.split('=')[1]; 1437 update_explore_data(explorePlans, totalAmt, gstPercent, entPackAmt, selectTenure); 1438 $('#exploreAddOns').modal('hide'); 1439 }); 1440 1441 function update_explore_data(exploreIds, totalAmt, gstPercent, entPackAmt, selectTenure) { 1442 // console.log(data); 1443 //formData.append('ids', data); 1444 var url = '/update-explore-data'; 1445 // Send AJAX POST request. 1446 $.ajax({ 1447 url: url, 1448 method: 'POST', 1449 data: { 1450 exploreIds: exploreIds, 1451 totalAmt: totalAmt, 1452 gstPercent: gstPercent, 1453 entPackAmt: entPackAmt, 1454 selectTenure: selectTenure 1455 }, 1456 success: function(response) { 1457 $('#entpackamt').text('â¹ ' + response.updEnterPackAmt); 1458 $('#totalamt').text('â¹ ' + response.finalUpdtAmt); 1459 $('#gstamt').text('â¹ ' + response.gstAmt); 1460 $('#totalpayamt').text('â¹ ' + response.totalPayAmt); 1461 $('#exploreaddondata').html(response.exploreAddonData); 1462 $('input[name="totalAmt"]').val(response.finalUpdtAmt.replace(/,/g, '')); 1463 $('input[name="entertainmentPackAmt"]').val(response.updEnterPackAmt.replace(/,/g, '')); 1464 $('input[name="totalPayAmt"]').val(response.totalPayAmt.replace(/,/g, '')).trigger('change'); 1465 } 1466 }); 1467 } 1468 $(document).on('click', '#clickOnApplyCoupon', function() { 1469 // $("#clickOnApplyCoupon").on('click', function() { 1470 var coupon_code_id = $('input[name="coupon_code_id1"]').val(); 1471 var coupon_code_value = $('input[name="coupon_code_value"]').val(); 1472 var discountAmt = $('input[name="discountAmount"]').val(); 1473 var totalAmt = $('input[name="totalAmt"]').val(); 1474 var gstPercent = $('input[name="gstPercent"]').val(); 1475 var amountPlanFee = $('input[name="amountPlanFee"]').val(); 1476 $('button.couponApplied').removeClass('d-none'); 1477 $('button.couponRemoved').addClass('d-none'); 1478 // Select the button with data-coupon-id='73' using jQuery 1479 var button = $("button[data-coupon-id='" + coupon_code_id + "'].couponApplied"); 1480 var button1 = $("button[data-coupon-id='" + coupon_code_id + "'].couponRemoved"); 1481 // Check if the button is found 1482 if(button.length > 0) { 1483 button.addClass('d-none'); 1484 } 1485 // Check if the button is found 1486 if(button1.length > 0) { 1487 button1.removeClass('d-none'); 1488 } 1489 update_coupon_data(coupon_code_id, coupon_code_value, discountAmt, totalAmt, gstPercent, amountPlanFee); 1490 }); 1491 1492 function update_coupon_data(coupon_code_id, coupon_code_value, discountAmt, totalAmt, gstPercent, amountPlanFee) { 1493 // console.log(data); 1494 //formData.append('ids', data); 1495 var url = '/update-coupon-data'; 1496 // var formData = $(this).serialize(); // Serialize form data. 1497 // Send AJAX POST request. 1498 $.ajax({ 1499 url: url, 1500 method: 'POST', 1501 data: { 1502 coupon_code_id: coupon_code_id, 1503 coupon_code_value: coupon_code_value, 1504 totalAmt: totalAmt, 1505 gstPercent: gstPercent, 1506 discountAmt: discountAmt, 1507 amountPlanFee: amountPlanFee
1508 }, 1509 success: function(response) { 1510 //console.log(response.updateData); 1511 if(response.updateStatus == "failed") { 1512 $('.new-apply-sec').addClass('text-error'); 1513 } else { 1514 $('.new-apply-sec').removeClass('text-error'); 1515 $('#disamt').text('-' + response.updDiscountAmt); 1516 $('#coupontype').text(coupon_code_value); 1517 $('#totalamt').text('â¹ ' + response.finalUpdtAmt); 1518 $('input[name="totalAmt"]').val(response.finalUpdtAmt.replace(/,/g, '')); 1519 $('input[name="discountAmount"]').val(response.updDiscountAmt.replace(/,/g, '')); 1520 $('input[name="coupon_code_id"]').val(response.couponId); 1521 $('input[name="coupon_code_id1"]').val(response.couponId); 1522 $('#gstamt').text('â¹ ' + response.gstAmt); 1523 $('#totalpayamt').text('â¹ ' + response.totalPayAmt); 1524 $('.appliedCouponMsg').text('You have saved â¹' + response.updDiscountAmt + ' on your bill'); 1525 $('#offerBenefits').modal('hide'); 1526 $('#congratulations').modal('show'); 1527 } 1528 } 1529 }); 1530 } 1531 $(".couponRemoved").on('click', function() { 1532 var discountAmt = $('input[name="discountAmount"]').val(); 1533 var totalAmt = $('input[name="totalAmt"]').val(); 1534 var gstPercent = $('input[name="gstPercent"]').val(); 1535 var amountPlanFee = $('input[name="amountPlanFee"]').val(); 1536 if(discountAmt > 0) { 1537 remove_coupon_data(discountAmt, totalAmt, gstPercent, amountPlanFee); 1538 } 1539 }); 1540 1541 function remove_coupon_data(discountAmt, totalAmt, gstPercent, amountPlanFee) { 1542 // console.log(data); 1543 var url = '/remove-coupon-data'; 1544 $.ajax({ 1545 url: url, 1546 method: 'POST', 1547 data: { 1548 totalAmt: totalAmt, 1549 gstPercent: gstPercent, 1550 discountAmt: discountAmt, 1551 amountPlanFee: amountPlanFee 1552 }, 1553 success: function(response) { 1554 //console.log(response.updateData); 1555 if(response.updateStatus == "success") { 1556 $('.new-apply-sec').removeClass('text-error'); 1557 $('#disamt').text('-' + response.updDiscountAmt); 1558 $('#coupontype').text('--'); 1559 $('#totalamt').text('â¹ ' + response.finalUpdtAmt); 1560 $('input[name="totalAmt"]').val(response.finalUpdtAmt.replace(/,/g, '')); 1561 $('input[name="discountAmount"]').val(response.updDiscountAmt.replace(/,/g, '')); 1562 $('#gstamt').text('â¹ ' + response.gstAmt); 1563 $('#totalpayamt').text('â¹ ' + response.totalPayAmt); 1564 } 1565 } 1566 }); 1567 } 1568 $(".ct_field_plan_speed_from").on('keyup', function() { 1569 var maxRange = $('.ct_field_plan_speed_to').val(); 1570 product_filter_with_data($(this).val(), maxRange); 1571 }) 1572 $(".ct_field_plan_speed_to").on('keyup', function() { 1573 var minRange = $('.ct_field_plan_speed_from').val(); 1574 product_filter_with_data(minRange, $(this).val()); 1575 }) 1576 $('input[name^="field_additional_filters_target_id"]').on('change', function() { 1577 var minRange = $('.ct_field_plan_speed_from').val(); 1578 var maxRange = $('.ct_field_plan_speed_to').val(); 1579 product_filter_with_data(minRange, maxRange); 1580 }); 1581 1582 function product_filter_with_data(field_plan_speed_from, field_plan_speed_to) { 1583 var field_product_for_target_id = $('input[name="field_product_for_target_id"]:checked').val(); 1584 var field_product_locations_target_id = $('select[name="field_product_locations_target_id"]').val(); 1585 var field_product_sub_category_target_id = $('input[name="field_product_sub_category_target_id"]:checked').val(); 1586 var additionalFilters = new Array(); 1587 $('input[name^="field_additional_filters_target_id"]:checked').each(function() { 1588 additionalFilters.push(this.value); 1589 }); 1590 var field_additional_filters_target_id = additionalFilters; 1591 // console.log(field_product_locations_target_id); 1592 // console.log(field_product_sub_category_target_id); 1593 var url = '/product-filter-count'; 1594 $.ajax({ 1595 url: url, 1596 method: 'POST', 1597 data: { 1598 field_product_for_target_id: field_product_for_target_id, 1599 field_product_locations_target_id: field_product_locations_target_id, 1600 field_product_sub_category_target_id: field_product_sub_category_target_id, 1601 field_additional_filters_target_id: field_additional_filters_target_id, 1602 field_plan_speed_from: field_plan_speed_from, 1603 field_plan_speed_to: field_plan_speed_to 1604 }, 1605 success: function(response) {
1606 $('.filterPlan').text(response.productCount); 1607 } 1608 }); 1609 } 1610 $(".id-proof-select-search").select2({ 1611 placeholder: "Select Id Proof", 1612 minimumResultsForSearch: -1, 1613 dropdownParent: $("#sellectIdproof").parent(), 1614 }); 1615 //copy referal code in refer a friend page 1616 $(".copy-code").on('click', function() { 1617 var $temp = $("<input>"); 1618 $("body").append($temp); 1619 $temp.val($('#copyText').text()).select(); 1620 document.execCommand("copy"); 1621 $temp.remove(); 1622 $('#copyText').css('border', '2px dashed #52642a'); 1623 }); 1624 1625 $('.webform-button--previous').on('click', function(e) { 1626 e.stopPropagation(); 1627 //some code 1628 }); 1629 $('.back-arrow').on('click', function(e) { 1630 //var thisclass = this; 1631 $(this + ' .webform-button--previous').trigger("click"); 1632 }); 1633 //count down timer for resend otp 1634 let timerOn = true; 1635 1636 1637 1638 1639//kyc verification form submit 1640 1641// $('.kycverfictionsubmit').on('click', function(e) { 1642// // Prevent the default behavior of the Next button (stopping the wizard). 1643// e.preventDefault(); 1644// var orderId = $('[data-drupal-selector="edit-order-id"]').val(); 1645// $.ajax({ 1646// url: '/congratulations', 1647// method: 'POST', 1648// data: { 1649// order_id: orderId, 1650// }, 1651// success: function(response) { 1652// if(response.status == "success") { 1653// $('#webform-submission-kyc-verification-add-form').submit(); 1654// setTimeout(function() { 1655// window.location.href = '/explore-all-plans'; 1656// }, 7000); 1657// } 1658// } 1659// }); 1660 1661 1662// }); 1663 //KYC form submit js 1664 $('.webform-submission-kyc-form .jsconfirmKycButton ').on('click', function(e) { 1665 // Prevent the default behavior of the Next button (stopping the wizard). 1666 e.preventDefault(); 1667 // Access form data and display in the modal. 1668 var orderId = $('#paymentOrderId').val(); 1669 var kycType = $('input[name="kyc_type"]:checked').val(); 1670 $('input[name="order_id"]').val(orderId); 1671 //console.log(orderId); 1672 //console.log(kycType); 1673 if(kycType == "Online KYC") { 1674 $('.webform-submission-kyc-form').submit(); 1675 setTimeout(function() { 1676 $('#kyc').modal('hide'); 1677 $('.webform-submission-kyc-form')[0].reset(); 1678 }, 1000); 1679 } else if(kycType == "Assisted E-KYC") { 1680 // Send AJAX POST request. 1681 $.ajax({ 1682 url: '/submit-kyc-data', 1683 method: 'POST', 1684 data: { 1685 order_id: orderId, 1686 kyc_type: kycType 1687 }, 1688 success: function(response) { 1689 if(response.status == "success") { 1690 $('#kyc').modal('hide'); 1691 $('.webform-submission-kyc-form')[0].reset(); 1692 $('#kycThankYou').modal('show'); 1693 // Redirect after 5 seconds. 1694 setTimeout(function() { 1695 $('#kycThankYou').modal('hide'); 1696 window.location.href = '/explore-all-plans'; 1697 }, 5000); 1698 } 1699 } 1700 }); 1701 } 1702 }); 1703 } 1704 }; 1705 1706 // $(document).ready(function() { 1707 // $('.KYCdocument').on('click', function(e) { 1708 // // Prevent the default behavior of the button 1709 // e.preventDefault(); 1710 1711 // // Access form data 1712 // var orderId = $('input[data-drupal-selector="edit-order-id"]').val(); 1713 1714 // // Send AJAX POST request 1715 // $.ajax({ 1716 // url: '/kyc-verifications', 1717 // method: 'POST', 1718 // data: { 1719 // order_id: orderId, 1720 // }, 1721 // success: function(response) { 1722 // if (response.token) { 1723 // // Redirect to the congratulations page with the token 1724 // window.location.href = '/congratulations?token=' + response.token; 1725 // } else { 1726 // // Handle the case where the token is not returned 1727 // alert('Failed to retrieve token'); 1728 // } 1729 // }, 1730 // error: function(xhr, status, error) { 1731 // // Handle any errors that occurred during the AJAX request 1732 // console.error('AJAX request failed:', status, error); 1733 // alert('An error occurred. Please try again.'); 1734 // } 1735 // }); 1736 // }); 1737 // }); 1738 1739 1740 1741 1742 1743 $(document).ready(function() { 1744 //first radion button checked 1745 // var firstRadio = $('input[name="addon_include"]').first(); 1746 1747 // // Check if the first radio button is already checked 1748 // if (!firstRadio.is(':checked')) { 1749 // firstRadio.prop('checked', true); 1750 // } 1751// var radios = $('input[name="addon_include"]'); 1752 1753// if (radios.length > 0) { 1754// // Select the first radio button 1755// var firstRadio = radios.first(); 1756 1757// // Check if the first radio button is already checked 1758// if (!firstRadio.is(':checked')) { 1759// firstRadio.attr('checked', true); 1760// // Trigger a click event 1761// firstRadio.trigger('click'); 1762 1763// // Optionally, log to verify 1764// console.log('First radio button triggered'); 1765// } else { 1766// console.log('First radio button is already checked'); 1767// } 1768// } 1769
1770 //Change icon angle up and down on explore plan page 1771 $("#plan-cards-header .filter-list .btn-filter").click(function() { 1772 var element = $(this).find('i.icon-angle-down'); 1773 element.addClass('icon-angle-up'); 1774 element.removeClass('icon-angle-down'); 1775 }); 1776 $('#sortFilter').on('hide.bs.modal', function() { 1777 var element = $("#plan-cards-header .filter-list .btn-filter").find('i.icon-angle-up'); 1778 element.addClass('icon-angle-down'); 1779 element.removeClass('icon-angle-up'); 1780 }); 1781 // Only alphabet for fields 1782 $('.alphaonly').keydown(function(e) { 1783 if(e.shiftKey || e.ctrlKey || e.altKey) { 1784 e.preventDefault(); 1785 } else { 1786 var key = e.keyCode; 1787 if(!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) { 1788 e.preventDefault(); 1789 } 1790 } 1791 }); 1792 $('.couponApplied').on("click", function() { 1793 var getCouponCode = $(this).data('coupon'); 1794 var getCouponID = $(this).data('coupon-id'); 1795 $('#applyjsbutton').html('<a href="javascript:void(0);" class="link" id="clickOnApplyCoupon">Apply</a>'); 1796 $('#selectedCouponCode').text(getCouponCode); 1797 $('input[name="coupon_code_id1"]').val(getCouponID); 1798 $('input[name="coupon_code_value"]').val(getCouponCode); 1799 $('.couponRemoved').addClass('d-none'); 1800 $('.couponApplied').removeClass('d-none'); 1801 $('.new-apply-sec').removeClass('text-error'); 1802 $(this).parents('.btn-holder').find('.couponRemoved').removeClass('d-none'); 1803 $(this).addClass('d-none'); 1804 }); 1805 $('input[name="coupon_code_value"]').on("keyup", function() { 1806 if($(this).val() != "") { 1807 $('#applyjsbutton').html('<a href="javascript:void(0);" class="link" id="clickOnApplyCoupon">Apply</a>'); 1808 } else { 1809 $('#applyjsbutton').html('<a href="javascript:void(0);" class="link" style="opacity: .3;">Apply</a>'); 1810 } 1811 $('.new-apply-sec').removeClass('text-error'); 1812 $('input[name="coupon_code_id1"]').val(''); 1813 }); 1814 $('.couponRemoved').on("click", function() { 1815 $('#applyjsbutton').html('<a href="javascript:void(0);" class="link" style="opacity: .3;">Apply</a>'); 1816 $('#selectedCouponCode').text(''); 1817 $('input[name="coupon_code_id1"]').val(''); 1818 $('input[name="coupon_code_id"]').val(''); 1819 $('input[name="coupon_code_value"]').val(''); 1820 $('.new-apply-sec').removeClass('text-error'); 1821 $('.couponRemoved').addClass('d-none'); 1822 $('.couponApplied').removeClass('d-none'); 1823 $(this).parents('.btn-holder').find('.couponApplied').removeClass('d-none'); 1824 $(this).addClass('d-none'); 1825 }); 1826 $('.jsAdd').on('click', function() { 1827 $(this).addClass('d-none') 1828 $(this).parents('.acc-btn-holder').find('.jsAdded').removeClass('d-none').addClass('selected'); 1829 $(this).parents('.acc-btn-holder').find('input[name="explore-plan-id"]').prop("checked", true); 1830 }) 1831 $('.jsAdded').on('click', function() { 1832 $(this).addClass('d-none') 1833 $(this).parents('.acc-btn-holder').find('.jsAdd').removeClass('d-none'); 1834 $(this).removeClass('selected'); 1835 $(this).parents('.acc-btn-holder').find('input[name="explore-plan-id"]').prop("checked", false); 1836 }) 1837 $(document).on("click",".video_block", function(){ 1838 var dataId = $(this).data("id"); 1839 var iframeSrc = "https://www.youtube.com/embed/" + dataId + "?si=siLBBKQRv4v5V807&autoplay=1"; 1840 $("#video_iframe").attr("src", iframeSrc); 1841 }); 1842 $(document).on("click","#close_iframe", function(){ 1843 $("#video_iframe").attr("src", ""); 1844 }); 1845 }); 1846 //Share text on all social media 1847 $('#shareButton').click(function() { 1848 if(navigator.share) { 1849 // Web Share API is supported 1850 var textToShare = $('#copyText').text(); 1851 // Call navigator.share to share the text 1852 navigator.share({ 1853 title: 'Share Text', // Optional title 1854 text: textToShare, // Text to share 1855 // url: textToShare 1856 }).then(() => { 1857 console.log('Text shared successfully'); 1858 }).catch((error) => { 1859 console.error('Error sharing text:', error); 1860 }); 1861 } else { 1862 // Fallback behavior 1863 // You can open a custom share modal or implement other fallback mechanisms 1864 alert('Sharing not supported in this browser.'); 1865 } 1866 }); 1867 1868 $('#orderPDFDownload').click(function() { 1869 // var orderId = $('#paymentOrderId').val(); 1870 var orderId = $('#paymentOrderEnc').val(); 1871 1872 $.ajax({ 1873 url: '/generate-pdf/'+orderId, 1874 method: 'POST', 1875 data: { 1876 order_id: orderId 1877 }, 1878 xhrFields: { 1879 responseType: 'blob' // Ensure we handle the PDF response correctly 1880 }, 1881 success: function(response) { 1882 var blob = new Blob([response], { type: 'application/pdf' }); 1883 var link = document.createElement('a'); 1884 link.href = window.URL.createObjectURL(blob); 1885 link.download = 'Invoice-' + orderId + '.pdf'; 1886 link.click(); 1887 }, 1888 error: function(xhr, status, error) { 1889 console.error(error); 1890 } 1891 }); 1892}); 1893 1894 $('#orderPDFShare').click(function() { 1895 // var orderId = $('#paymentOrderId').val(); 1896 var orderId = $('#paymentOrderEnc').val(); 1897 $.ajax({ 1898 url: '/generate-pdf-share', 1899 method: 'POST', 1900 data: { 1901 order_id: orderId 1902 }, 1903 success: function(response) { 1904 //var jsonString = JSON.stringify(response); 1905 console.log(response); 1906 //Check if the navigator.share API is supported 1907 // Create a Blob object from the PDF content 1908 // Decode the base64-encoded PDF content 1909 var decodedPdfContent = atob(response); 1910 // Convert decoded content to Uint8Array 1911 var uint8Array = new Uint8Array(decodedPdfContent.length); 1912 for(var i = 0; i < decodedPdfContent.length; i++) { 1913 uint8Array[i] = decodedPdfContent.charCodeAt(i); 1914 } 1915 var pdfBlob = new Blob([uint8Array], { 1916 type: 'application/pdf' 1917 }); 1918 // Create a data URL for the Blob 1919 // var pdfDataUrl = URL.createObjectURL(pdfBlob); 1920 var fileName = 'Invoice-' + orderId + '.pdf'; 1921 // Check if the Web Share API is supported by the browser 1922 if(navigator.share) { 1923 // Use the Web Share API to share the PDF content 1924 navigator.share({ 1925 title: 'Share PDF', 1926 files: [new File([pdfBlob], fileName, { 1927 type: 'application/pdf' 1928 })], 1929 text: 'Check out this PDF file!' 1930 }).then(() => console.log('Shared successfully')).catch((error) => console.error('Error sharing:', error)); 1931 } else { 1932 // Web Share API is not supported, handle accordingly 1933 alert('Web Share API is not supported in this browser.'); 1934 } 1935 }, 1936 error: function(xhr, status, error) { 1937 // Handle error 1938 console.error(error); 1939 } 1940 }); 1941 }); 1942 1943 1944 /*Verify OTP common handler*/ 1945 $(document).on('click', '.send-otp-form .jsProceedBtn', function(e) { 1946 e.preventDefault(); 1947 $('#loader').removeClass('d-none'); 1948 var formData = $('.send-otp-form').serialize(); 1949 $.ajax({ 1950 url: '/session/token', // Drupal's built-in route to get the CSRF token 1951 type: 'GET', 1952 success: function (token) { 1953 // Now use the token in your API request 1954 makeApiRequest(token,formData); 1955 }, 1956 error: function (xhr, status, error) { 1957 console.log("Error fetching CSRF token: " + error); 1958 } 1959 1960 }) 1961 1962 }); 1963 1964 1965 1966 1967 $(document).on('click', '.Getaccountnumber', function(e) { 1968 e.preventDefault(); // Prevent the default action 1969 1970 // Hide account screen and show offer page 1971 $('.account-screen').addClass('d-none'); 1972 $('.offer-page').removeClass('d-none'); 1973 }); 1974 1975 $(document).on('click', '.offersubmmit', function(e) { 1976 e.preventDefault(); // Prevent the default action 1977 $('.offer-page').addClass('d-none'); 1978 $('.shipment_address').removeClass('d-none'); 1979 }); 1980 1981 $(document).on('click', '.shippinginformation', function (e) { 1982 e.preventDefault(); 1983 let shippingData = {}; 1984 let isValid = true; 1985 let firstInvalidField = null; 1986 // Remove existing errors 1987 $('.shipment_address input').removeClass('is-invalid'); 1988 $('.error-message').remove(); 1989 $('.shipment_address input[required]').each(function () { 1990 const $input = $(this); 1991 const value = $input.val().trim(); 1992 const fieldName = $input.attr('name'); // Use name attribute for correct mapping 1993 shippingData[fieldName] = value; 1994 // If the field is empty, show error 1995 if (value === '') { 1996 isValid = false;
1997 showError($input, 'This field is required.'); 1998 firstInvalidField = firstInvalidField || $input; 1999 } 2000 }); 2001 if (!isValid) { 2002 firstInvalidField[0].scrollIntoView({ behavior: 'smooth', block: 'center' }); 2003 firstInvalidField.focus(); 2004 return; 2005 } 2006 // Send data to the server for validation 2007 $.ajax({ 2008 url: '/shipping/validate', 2009 type: 'POST', 2010 contentType: 'application/json', 2011 data: JSON.stringify(shippingData), 2012 success: function (response) { 2013 $('.shipment_address input').removeClass('is-invalid'); 2014 $('.error-message').remove(); 2015 // Move to next step 2016 $('.shipment_address').addClass('d-none'); 2017 $('.order_summary').removeClass('d-none'); 2018 }, 2019 error: function (xhr) { 2020 let errors = xhr.responseJSON.errors; 2021 // Remove previous errors 2022 $('.shipment_address input').removeClass('is-invalid'); 2023 $('.error-message').remove(); 2024 let firstErrorField = null; 2025 // Loop through all errors 2026 for (let field in errors) { 2027 let $input = $('[name="' + field + '"]'); // Match by name attribute 2028 if ($input.length > 0) { 2029 showError($input, errors[field]); 2030 if (!firstErrorField) firstErrorField = $input; 2031 } 2032 } 2033 if (firstErrorField) { 2034 firstErrorField[0].scrollIntoView({ behavior: 'smooth', block: 'center' }); 2035 firstErrorField.focus(); 2036 } 2037 } 2038 }); 2039 }); 2040 // Function to append error messages 2041 function showError($input, message) { 2042 $input.addClass('is-invalid'); 2043 // Find the closest .form-group and append error message 2044 if ($input.closest('.form-group').find('.error-message').length === 0) { 2045 $input.closest('.form-group').append(`<small class="error-message text-danger">${message}</small>`); 2046 } 2047 } 2048 2049 $(document).on('click', '.submitallinfo', function(e) { 2050 e.preventDefault(); // Prevent the default action 2051 var formData = $('.send-otp-form').serialize(); 2052 var url = '/stream-tv-submission'; 2053 const getUrl = window.location.href; 2054 // Extract only the hostname from the URL 2055 const domain = new URL(getUrl).hostname; 2056 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 2057 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 2058 2059 const updatedUrl = isLiveSite 2060 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 2061 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 2062 // Send AJAX POST request. 2063 $.ajax({ 2064 url: url, 2065 method: 'POST', 2066 data: formData, 2067 success: function(response) { 2068 $('#loader').addClass('d-none'); 2069 if(response.status == "failed") { 2070 2071 $('#actvas_failed').modal('show'); 2072 $('#actvas_failed p').text("Please try again later") 2073 $('#loader').addClass('d-none'); 2074 if(response.message_plan){ 2075 $('#actvas_failed p').text(response.message_plan); 2076 $('#loader').addClass('d-none'); 2077 } 2078 if(response.message){ 2079 $('#actvas_failed .backend-error').text(response.message); 2080 $('#loader').addClass('d-none'); 2081 } 2082 }else if(response.status == 'AlreadyPurchase'){ 2083 $('#alreadypurchased_popup').modal('show'); 2084 // Redirect after 2 seconds. 2085 setTimeout(function() { 2086 window.location.href = '/cultfit'; 2087 }, 7000); 2088 } 2089 else if(response.key){ 2090 $('#loader').addClass('d-none'); 2091 window.location.href = updatedUrl+response.key; 2092 } 2093 else{ 2094 $('#thankYou2').modal('show'); 2095 // Redirect after 5 seconds. 2096 setTimeout(function() { 2097 $('#thankYou2').modal('hide'); 2098 window.location.href = '/cultfit'; 2099 }, 5000); 2100 } 2101 } 2102 }); 2103 }); 2104 2105 2106 2107 // Function to get the value of a specific cookie by name 2108 function getCookie(name) { 2109 let cookieArr = document.cookie.split(";"); 2110 2111 for (let i = 0; i < cookieArr.length; i++) { 2112 let cookiePair = cookieArr[i].split("="); 2113 2114 // Removing whitespace at the beginning of the cookie name and compare it with the name we want 2115 if (name === cookiePair[0].trim()) { 2116 // Decode the cookie value and return 2117 return decodeURIComponent(cookiePair[1]); 2118 } 2119 } 2120 2121 // Return null if the cookie is not found 2122 return null; 2123 } 2124 let spotifyRedirectDone = false; 2125 function makeApiRequest(token, formData) { 2126 2127 const getUrl = window.location.href; 2128 // Extract only the hostname from the URL 2129 const domain = new URL(getUrl).hostname; 2130 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 2131 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 2132 2133 const updatedUrl = isLiveSite 2134 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 2135 : 'https://sitselfcare.actcorp.in/payments/website?authKey='; 2136 2137 const url = '/otp-check'; 2138 2139 $.ajax({ 2140 url: url, 2141 method: 'POST', 2142 data: formData, 2143 headers: { 2144 'X-CSRF-Token': token 2145 }, 2146 success: function (response) { 2147 const cookieToken = getCookie('otp_token'); 2148 const status = response.status?.trim().toLowerCase(); 2149 2150 if (response.type === 'spotify') { 2151 $('#loader').addClass('d-none'); 2152 if (response.action === 'redirect' && response.redirect_token) { 2153 if (spotifyRedirectDone) return; 2154 spotifyRedirectDone = true;
2155 window.location.href = '/spotify/redirect/' + response.redirect_token; 2156 return; 2157 } 2158 if (response.action === 'already_active') { 2159 $('.thankyou-content .product_msg').html( 2160 '<span style="color:green;">' + response.message + '</span>' 2161 ); 2162 $('#success_popup').modal('show'); 2163 setTimeout(function () { 2164 window.location.href = "/"; 2165 }, 3000); 2166 return; 2167 } 2168 if (response.action === 'error') { 2169 2170 $('#actvas_failed .backend-error') 2171 .text(response.message) 2172 .show(); 2173 2174 $('#actvas_failed').modal('show'); 2175 2176 setTimeout(function () { 2177 window.location.href = "/"; 2178 }, 3000); 2179 2180 return; 2181 } 2182 } 2183 2184 if (status === "failed") { 2185 $('#loader').addClass('d-none'); 2186 $('#failed2').modal('show'); 2187 } 2188 else if (status === "success") { 2189 $('#loader').addClass('d-none'); 2190 // Optional: Overwrite cookie token with latest from response 2191 var authToken = response.otp_token; 2192 2193 // TURITO ACTIVE HANDLER (FIRST) 2194 if (response.turito_active === 1) { 2195 window.location.href = "https://www.turito.com/in"; 2196 return; 2197 } 2198 2199 // TURITO PAYMENT REDIRECT 2200 if (response.key && response.type === 'turito') { 2201 2202 $('.thankyou-content .product_msg').html('<span style="color:green;">' + response.message + '</span>'); 2203 $('#success_popup').modal('show'); 2204 2205 setTimeout(function() { 2206 window.location.href = updatedUrl + response.key; // Change this to your redirect URL 2207 }, 3000); 2208 2209 return; 2210 } 2211 2212 // STREAMTV PAYMENT REDIRECT ADD HERE 2213 if (response.key && response.type === 'streamtv') { 2214 $('.thankyou-content .product_msg').html( 2215 '<span style="color:green;">' + response.message + '</span>' 2216 ); 2217 $('#success_popup').modal('show'); 2218 setTimeout(function () { 2219 window.location.href = updatedUrl + response.key; 2220 }, 3000); 2221 return; 2222 } 2223 2224 // CASE 1: ap_res response 2225 if (response.ap_res && response.ap_res !== "") { 2226 if (response.ap_res.email) { 2227 $('#thankYou2').modal('show'); 2228 $('#thankYou2 .justify-content-center').html(` 2229 <img src='/themes/custom/actcorp/assets/images/spinning-loader.webp' height='20' width='20' alt='' class='mg-r-10'> 2230 ${response.ap_res.message}<br>${response.ap_res.email} 2231 `); 2232 } 2233 else if (response.ap_res.link) { 2234 if (typeof response.ap_res === 'string' && response.ap_res.startsWith('Error:')) { 2235 window.location.href = "/amazon-prime"; 2236 } else if (response.ap_res.link) { 2237 window.location.href = response.ap_res.link; 2238 } 2239 } 2240 else if (response.ap_res.msg) { 2241 $('#thankYou2').modal('show'); 2242 $('#thankYou2 .justify-content-center').html(` 2243 <img src='/themes/custom/actcorp/assets/images/spinning-loader.webp' height='20' width='20' alt='' class='mg-r-10'> 2244 ${response.ap_res.msg} 2245 `); 2246 } 2247 else if (response.ap_res.ActivateUserResponse) { 2248 $('#thankYou2').modal('show'); 2249 $('#thankYou2 .justify-content-center').html(` 2250 <img src='/themes/custom/actcorp/assets/images/spinning-loader.webp' height='20' width='20' alt='' class='mg-r-10'> 2251 ${response.ap_res.ActivateUserResponse.responseMessage}`); 2252 2253 if (response.ap_res.ActivateUserResponse.status === 0 || response.ap_res.status === "failed") { 2254 $('h2.heading36.semibold').remove(); 2255 } 2256 // Check if the URL exists and is not empty 2257 if ( 2258 response.ap_res.ActivateUserResponse.status === 0 || response.ap_res.status === "failed") { 2259 const url = response.ap_res.ActivateUserResponse.url || ''; 2260 const containsValidPath = url.includes('www.amazon.in'); 2261 setTimeout(function () { 2262 if (containsValidPath) { 2263 window.location.href = url; 2264 } else { 2265 const accountNo = response.ap_res.accountno; 2266 const upgradeUrl = `https://myfibernet.actcorp.in/Pc/login?id=${accountNo}&bundle=Amazon`; 2267 window.location.href = upgradeUrl; 2268 } 2269 }, 5000); 2270 } else if ( response.ap_res.ActivateUserResponse.status === 1 ) { 2271 setTimeout(function () { 2272 window.location.href = "/amazon/redirect"; 2273 }, 5000); 2274 } 2275 2276 2277 } 2278 else if (response.ap_res.msg) { 2279 $('#thankYou2').modal('show'); 2280 $('#thankYou2 .justify-content-center').html(` 2281 <img src='/themes/custom/actcorp/assets/images/spinning-loader.webp' height='20' width='20' alt='' class='mg-r-10'> 2282 ${response.ap_res.msg} 2283 `); 2284 } 2285 else { 2286 $('#thankYou2').modal('show'); 2287 $('#thankYou2 .justify-content-center').html(` 2288 <img src='/themes/custom/actcorp/assets/images/spinning-loader.webp' height='20' width='20' alt='' class='mg-r-10'> 2289 ${response.ap_res.message} 2290 `); 2291 } 2292 2293 // Redirection on modal close 2294 $(document).on('click', '.btn-close-modal', function () { 2295 if (response.ap_res.redirection_url) { 2296 window.location.href = response.ap_res.redirection_url; 2297 } 2298 2299 var amazonpath = window.location.pathname.replace(/\/+$/, ""); // normalize 2300 if (amazonpath === "/amazon-prime/switch-plan" || amazonpath === "/amazon-prime/claim-now") { 2301 window.location.href = "/amazon-prime"; 2302 } 2303 }); 2304 } 2305 2306 // CASE 2: Accounts list present 2307 else if (response.status === 'success' && response.accounts && response.otp_token === cookieToken) { 2308 // console.log(" Showing account selection"); 2309 2310 $('.otp-screen').addClass('d-none'); 2311 $('.account-screen').removeClass('d-none'); 2312 2313 $('.accountnumberlist').empty(); 2314
2315 response.accounts.forEach(function (account, index) { 2316 const listItem = ` 2317 <li> 2318 <div class="text"> 2319 <p class="purchase-text fontSize-16">${account}</p> 2320 </div> 2321 <label class="custom-radiobox-label" for="id${index + 1}"> 2322 <span class="custom-radio"> 2323 <input type="radio" name="account_number" id="id${index + 1}" value="${account}" data-once="webform-disable-autosubmit"> 2324 <span class="radiobox-check"></span> 2325 </span> 2326 </label> 2327 </li>`; 2328 $('.accountnumberlist').append(listItem); 2329 }); 2330 } 2331 2332 // CASE 3: Offer present 2333 else if (response.offer && response.otp_token === cookieToken) { 2334 // console.log(" Showing offer screen"); 2335 2336 $('.otp-screen').addClass('d-none'); 2337 $('.offer-page').removeClass('d-none'); 2338 } 2339 // console.log('call'); 2340 // Trigger next action 2341 $('.send-otp-form .otp_check_submit').trigger('click'); 2342 } 2343 }, 2344 error: function (xhr, status, error) { 2345 const errorMessage = xhr.responseText || "An unknown error occurred"; 2346 // console.log("â API Error:", errorMessage); 2347 } 2348 }); 2349 } 2350 /*Actvas activate api event handler*/ 2351 $('.send-otp-form .submit-actvas-btn').click(function(e) { 2352 e.preventDefault(); 2353 // Function to validate the form 2354 function validateForm() { 2355 let isValid = true; 2356 let errorMessage = ''; 2357 2358 // Check if a pack is selected 2359 if (!$('input[name="plans"]:checked').val()) { 2360 errorMessage += 'You must select a pack.<br>'; 2361 isValid = false; 2362 } 2363 2364 // Check if terms and conditions are accepted 2365 // if (!$('input[name="i_accept_the_terms_and_conditions"]').is(':checked')) { 2366 // errorMessage += 'You must accept the terms and conditions.<br>'; 2367 // isValid = false; 2368 // } 2369 2370 // Display error messages if any 2371 if (!isValid) { 2372 $('.input-errors-withoutpay').html('<p class="fontSize-14 semibold mg-t-2">' + errorMessage + '</p>'); 2373 } else { 2374 $('.input-errors-withoutpay').html(''); // Clear previous error messages if any 2375 } 2376 2377 return isValid; 2378 } 2379 2380 // Proceed only if the form is valid 2381 if (validateForm()) { 2382 $('#loader').removeClass('d-none'); 2383 var formData = $('.send-otp-form').serialize(); 2384 var url = '/actvas-activate'; 2385 // Send AJAX POST request. 2386 $.ajax({ 2387 url: url, 2388 method: 'POST', 2389 data: formData, 2390 success: function(response) { 2391 if(response.status == "failed") { 2392 $('#loader').addClass('d-none'); 2393 $('#actvas_failed').modal('show'); 2394 $('#actvas_failed p').text("Please try again later") 2395 if(response.message_plan){ 2396 $('#loader').addClass('d-none'); 2397 $('#actvas_failed p').text(response.message_plan) 2398 } 2399 if(response.message){ 2400 $('#loader').addClass('d-none'); 2401 $('#actvas_failed .backend-error').text(response.message) 2402 } 2403 } else { 2404 $('#loader').addClass('d-none'); 2405 var product = $("#productName").val(); 2406 $('#success_popup .thankyou-content .product_msg').text('Dear customer you are successfully subscribed to '+product); 2407 $('#success_popup').modal('show'); 2408 setTimeout(function() { 2409 window.location.href = '/'; 2410 }, 4000); 2411 } 2412 } 2413 }); 2414 } 2415 }); 2416 2417 /*only for cultfit product*/ 2418 $('.send-otp-form .submit-cultfit-btn').click(function(e) { 2419 e.preventDefault(); 2420 $('#loader').removeClass('d-none'); 2421 var selectedRadio = $('input[name="plans"]:checked'); 2422 var selectedValue = selectedRadio.val(); 2423 var selectedLi = selectedRadio.closest('li'); 2424 var formData = $('.send-otp-form').serialize(); 2425 const getUrl = window.location.href; 2426 // Extract only the hostname from the URL 2427 const domain = new URL(getUrl).hostname; 2428 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 2429 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 2430 2431 const updatedUrl = isLiveSite 2432 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 2433 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 2434 2435 // Get the data-prize attribute from the parent li element 2436 var prize = selectedLi.data('prize'); 2437 if(prize <= 707 ){ 2438 2439 var url = '/actvas-activate-cultfit'; 2440 // Send AJAX POST request. 2441 $.ajax({ 2442 url: url, 2443 method: 'POST', 2444 data: formData, 2445 success: function(response) { 2446 if(response.status == "failed") { 2447 $('#loader').addClass('d-none'); 2448 $('#actvas_failed').modal('show'); 2449 $('#actvas_failed p').text("Please try again later") 2450 if(response.message_plan){ 2451 $('#loader').addClass('d-none'); 2452 $('#actvas_failed p').text(response.message_plan) 2453 } 2454 if(response.message){ 2455 $('#loader').addClass('d-none'); 2456 $('#actvas_failed .backend-error').text(response.message) 2457 } 2458 }else if(response.status == 'AlreadyPurchase'){ 2459 $('#alreadypurchased_popup').modal('show'); 2460 // Redirect after 2 seconds. 2461 setTimeout(function() { 2462 window.location.href = '/cultfit'; 2463 }, 7000);} 2464 else { 2465 $('#loader').addClass('d-none'); 2466 var product = $("#productName").val(); 2467 $('#success_popup .thankyou-content .product_msg').text('Dear customer you are successfully subscribed to '+product); 2468 $('#success_popup').modal('show'); 2469 setTimeout(function() { 2470 window.location.href = '/'; 2471 }, 4000); 2472 } 2473 } 2474 }); 2475 }else{ 2476 var url = '/get-payment-gateway-cultfit'; 2477 // Send AJAX POST request. 2478 $.ajax({ 2479 url: url, 2480 method: 'POST', 2481 data: formData, 2482 success: function(response) { 2483 $('#loader').addClass('d-none'); 2484 if(response.status == "failed") { 2485 2486 $('#actvas_failed').modal('show'); 2487 $('#actvas_failed p').text("Please try again later") 2488 $('#loader').addClass('d-none'); 2489 if(response.message_plan){ 2490 $('#actvas_failed p').text(response.message_plan); 2491 $('#loader').addClass('d-none'); 2492 } 2493 if(response.message){ 2494 $('#actvas_failed .backend-error').text(response.message); 2495 $('#loader').addClass('d-none'); 2496 } 2497 }else if(response.status == 'AlreadyPurchase'){ 2498 $('#alreadypurchased_popup').modal('show'); 2499 // Redirect after 2 seconds. 2500 setTimeout(function() { 2501 window.location.href = '/cultfit'; 2502 }, 7000); 2503 } 2504 else if(response.key){ 2505 $('#loader').addClass('d-none'); 2506 window.location.href = updatedUrl+response.key; 2507 } 2508 else{ 2509 $('#thankYou2').modal('show'); 2510 // Redirect after 5 seconds. 2511 setTimeout(function() { 2512 $('#thankYou2').modal('hide'); 2513 window.location.href = '/cultfit'; 2514 }, 5000); 2515 } 2516 2517 }, 2518 error: function(xhr, status, error) { 2519 // Handle error 2520 alert('Error: ' + error); 2521 } 2522 }); 2523 2524 } 2525 2526 console.log('out:', prize); 2527 return false;
2528 2529 }); 2530 2531 /*Payment gateway*/ 2532 $('.send-otp-form .submit-payment-btn').click(function(e) { 2533 e.preventDefault(); 2534 const getUrl = window.location.href; 2535 // Extract only the hostname from the URL 2536 const domain = new URL(getUrl).hostname; 2537 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 2538 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 2539 2540 const updatedUrl = isLiveSite 2541 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 2542 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 2543 2544 2545 // Function to validate the form 2546 function validateForm() { 2547 let isValid = true; 2548 let errorMessage = ''; 2549 2550 // Check if a pack is selected 2551 if (!$('input[name="plans"]:checked').val()) { 2552 errorMessage += 'You must select a pack.<br>'; 2553 isValid = false; 2554 } 2555 2556 // Check if terms and conditions are accepted 2557 // if (!$('input[name="i_accept_the_terms_and_conditions"]').is(':checked')) { 2558 // errorMessage += 'You must accept the terms and conditions.<br>'; 2559 // isValid = false; 2560 // } 2561 2562 // Display error messages if any 2563 if (!isValid) { 2564 $('.input-errors-pay').html('<p class="fontSize-14 semibold">' + errorMessage + '</p>'); 2565 } else { 2566 $('.input-errors-pay').html(''); // Clear previous error messages if any 2567 } 2568 2569 return isValid; 2570 } 2571 2572 // Proceed only if the form is valid 2573 if (validateForm()) { 2574 $('#loader').removeClass('d-none'); 2575 var formData = $('.send-otp-form').serialize(); 2576 var url = '/get-payment-gateway'; 2577 // Send AJAX POST request. 2578 $.ajax({ 2579 url: url, 2580 method: 'POST', 2581 data: formData, 2582 success: function(response) { 2583 if(response.status == "failed") { 2584 $('#actvas_failed').modal('show'); 2585 $('#actvas_failed p').text("Please try again later") 2586 $('#loader').addClass('d-none'); 2587 if(response.message_plan){ 2588 $('#actvas_failed p').text(response.message_plan); 2589 $('#loader').addClass('d-none'); 2590 } 2591 if(response.message){ 2592 $('#actvas_failed .backend-error').text(response.message); 2593 $('#loader').addClass('d-none'); 2594 } 2595 } 2596 else if(response.key){ 2597 $('#loader').addClass('d-none'); 2598 window.location.href = updatedUrl+response.key; 2599 } 2600 else{ 2601 $('#thankYou2').modal('show'); 2602 // Redirect after 5 seconds. 2603 setTimeout(function() { 2604 $('#thankYou2').modal('hide'); 2605 window.location.href = '/cultfit'; 2606 }, 5000); 2607 } 2608 2609 }, 2610 error: function(xhr, status, error) { 2611 // Handle error 2612 alert('Error: ' + error); 2613 } 2614 }); 2615 } 2616 }); 2617 2618 /* ACT Shield form handler*/ 2619 $('.send-otp-form .submit-actshield-btn').click(function(e) { 2620 e.preventDefault(); 2621 $('#loader').removeClass('d-none'); 2622 var getSelectedPlan = $('input[name="plan_type_radio"]:checked').val(); 2623 var service = $('#actShieldService').val(); 2624 // Assuming getSelectedPlan contains a value like "2,49" 2625 var getDevice = getSelectedPlan.split(',')[0]; // Split the string by ',' and take the first part 2626 $('#productName').val('ACTSHIELD'+getDevice); 2627 var formData = $('.send-otp-form').serialize(); 2628 if(service=='Change Subscription'){ 2629 var url = '/actvas-actshield-change'; 2630 // Send AJAX POST request. 2631 $.ajax({ 2632 url: url, 2633 method: 'POST', 2634 data: formData, 2635 success: function(response) { 2636 console.log(response); 2637 if(response.status == "failed") { 2638 $('#loader').addClass('d-none'); 2639 $('#actvas_failed').modal('show'); 2640 $('#actvas_failed p').text("Please try again later"); 2641 if(response.message_plan){ 2642 $('#loader').addClass('d-none'); 2643 $('#actvas_failed p').text(response.message_plan); 2644 } 2645 if(response.message){ 2646 $('#loader').addClass('d-none'); 2647 $('#actvas_failed .backend-error').text(response.message); 2648 setTimeout(function() { 2649 window.location.href = '/act-shield'; 2650 }, 4000); 2651 } 2652 } else { 2653 $('#loader').addClass('d-none'); 2654 var product = $("#productName").val(); 2655 $('#success_popup .thankyou-content .product_msg').text('Dear customer you are successfully subscribed to '+product); 2656 $('#success_popup').modal('show'); 2657 setTimeout(function() { 2658 window.location.href = '/act-shield'; 2659 }, 4000); 2660 } 2661 } 2662 }); 2663 2664 }else{ 2665 var url = '/actvas-activate-actshield'; 2666 // Send AJAX POST request. 2667 $.ajax({ 2668 url: url, 2669 method: 'POST', 2670 data: formData, 2671 success: function(response) { 2672 if(response.status == "failed") { 2673 $('#loader').addClass('d-none'); 2674 $('#actvas_failed').modal('show'); 2675 $('#actvas_failed p').text("Please try again later"); 2676 if(response.message_plan){ 2677 $('#loader').addClass('d-none'); 2678 $('#actvas_failed p').text(response.message_plan); 2679 } 2680 if(response.message){ 2681 $('#loader').addClass('d-none'); 2682 $('#actvas_failed .backend-error').text(response.message); 2683 setTimeout(function() { 2684 window.location.href = '/'; 2685 }, 4000); 2686 } 2687 } else { 2688 $('#loader').addClass('d-none'); 2689 var product = $("#productName").val(); 2690 $('#success_popup .thankyou-content .product_msg').text('Dear customer you are successfully subscribed to '+product); 2691 $('#success_popup').modal('show'); 2692 setTimeout(function() { 2693 window.location.href = '/'; 2694 }, 4000); 2695 } 2696 } 2697 }); 2698 } 2699 2700 }); 2701 2702 /*home camera submit event handler*/ 2703 $('.send-otp-form .home-camera-submit').click(function(e) { 2704 e.preventDefault(); 2705 const getUrl = window.location.href; 2706 // Extract only the hostname from the URL 2707 const domain = new URL(getUrl).hostname; 2708 // Check if the domain is 'actcorp.in' or 'www.actcorp.in' 2709 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 2710 2711 const updatedUrl = isLiveSite 2712 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 2713 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 2714 $('#loader').removeClass('d-none'); 2715 var home_camera_plan = $('input[name="homecameraplan"]:checked').attr('id'); 2716 if(home_camera_plan == 'rentalonly'){ 2717 var formData = $('.send-otp-form').serialize(); 2718 $.ajax({ 2719 // url: '/homecamera-onetime', 2720 url: '/check-homecamera-rental', 2721 type: 'POST', 2722 data: formData, 2723 success: function(response) { 2724 $('#loader').addClass('d-none'); 2725 if(response.key){ 2726 2727 window.location.href = updatedUrl+response.key; 2728 } 2729 else{ 2730 $('#thankYou2').modal('show'); 2731 // Redirect after 5 seconds. 2732 setTimeout(function() { 2733 $('#thankYou2').modal('hide'); 2734 window.location.href = '/home-camera'; 2735 }, 7000); 2736 } 2737 }, 2738 error: function(xhr, status, error) { 2739 // Handle error 2740 alert('Error: ' + error); 2741 } 2742 }); 2743 } 2744 else{ 2745 var formData = $('.send-otp-form').serialize(); 2746 $('#loader').removeClass('d-none'); 2747 // Make the API request 2748 $.ajax({ 2749 // url: '/homecamera-onetime', 2750 url: '/check-homecamera', 2751 type: 'POST', 2752 data: formData, 2753 success: function(response) { 2754 $('#loader').addClass('d-none'); 2755 if(response.key){ 2756 2757 window.location.href = updatedUrl+response.key; 2758 } 2759 else{ 2760 $('#thankYou2').modal('show'); 2761 // Redirect after 5 seconds. 2762 setTimeout(function() { 2763 $('#thankYou2').modal('hide'); 2764 window.location.href = '/home-camera'; 2765 }, 5000); 2766 } 2767 2768 }, 2769 error: function(xhr, status, error) { 2770 // Handle error 2771 alert('Error: ' + error); 2772 } 2773 }); 2774 } 2775 return false;
2776 }); 2777 2778 //deactivate act shield 2779 $('.webform-submission-act-shield-form-form #edit-actions-03-wizard-next').on('click', function(e){ 2780 e.preventDefault(); 2781 var checkPlan = $('input[name="subscription_type_radio"]:checked').val(); 2782 $('#actShieldService').val(checkPlan); 2783 if(checkPlan == 'Deactivate Subscription'){ 2784 var formData = $('.send-otp-form').serialize(); 2785 // Make the API request 2786 $.ajax({ 2787 url: '/deactivate-plan-check', 2788 type: 'POST', 2789 data: formData, 2790 success: function(response) { 2791 if(response.status == "failed") { 2792 $('#deactivateNoSubscription').modal('show'); 2793 setTimeout(function() { 2794 window.location.href = '/act-shield'; 2795 }, 4000); 2796 2797 // $('#actvas_failed').modal('show'); 2798 // $('#actvas_failed p').text("Please try again later") 2799 // if(response.message_plan){ 2800 // $('#actvas_failed p').text(response.message_plan) 2801 // } 2802 // if(response.message){ 2803 // $('#actvas_failed .backend-error').text(response.message) 2804 // } 2805 } else { 2806 $('#deactivateSubscription').modal('show'); 2807 } 2808 }, 2809 error: function(xhr, status, error) { 2810 // Handle error 2811 alert('Error: ' + error); 2812 } 2813 }); 2814 } 2815 else if(checkPlan == 'Activate Subscription'){ 2816 var formData = $('.send-otp-form').serialize(); 2817 // Make the API request 2818 $.ajax({ 2819 url: '/activate-plan-check', 2820 type: 'POST', 2821 data: formData, 2822 success: function(response) { 2823 // console.log(response); 2824 // return false; 2825 if(response.status == "failed") { 2826 $('#actvas_failed').modal('show'); 2827 $('#actvas_failed p').text("Please try again later") 2828 if(response.message_plan){ 2829 $('#actvas_failed p').text(response.message_plan) 2830 } 2831 if(response.message){ 2832 $('#actvas_failed .backend-error').text(response.message) 2833 } 2834 } else { 2835 2836 $('.webform-submission-act-shield-form-form').submit(); 2837 2838 2839 } 2840 }, 2841 error: function(xhr, status, error) { 2842 // Handle error 2843 alert('Error: ' + error); 2844 } 2845 }); 2846 } 2847 else{ 2848 $('.webform-submission-act-shield-form-form').submit(); 2849 } 2850 2851 }); 2852 2853 2854 $('#confirmDeactivate').on('click', function(){ 2855 // Close the current modal 2856 $('#deactivateSubscription').modal('hide'); 2857 var formData = $('.send-otp-form').serialize(); 2858 // Make the API request 2859 $.ajax({ 2860 url: '/actvas-deactivate', 2861 type: 'POST', 2862 data: formData, 2863 success: function(response) { 2864 if(response.status == "failed") { 2865 $('#actvas_failed').modal('show'); 2866 $('#actvas_failed p').text("Please try again later") 2867 if(response.message_plan){ 2868 $('#actvas_failed p').text(response.message_plan) 2869 } 2870 if(response.message){ 2871 $('#actvas_failed .backend-error').text(response.message) 2872 } 2873 } else { 2874 $('#deactivateSuccessful').modal('show'); 2875 setTimeout(function() { 2876 window.location.href = '/'; 2877 }, 4000); 2878 } 2879 }, 2880 error: function(xhr, status, error) { 2881 // Handle error 2882 alert('Error: ' + error); 2883 } 2884 }); 2885 }); 2886 2887 2888 if(window.location.pathname === '/help-and-support/faq') { 2889 $('select[name="field_plan_location_target_id"]').change(function() { 2890 // Code to execute when the select box value changes 2891 var selectedValue = $(this).val(); 2892 // Perform actions based on the selected value 2893 $(this).closest('form').submit(); 2894 }); 2895 } 2896 $(".jsBlazingSlider").on("init reInit afterChange", function(event, slick, currentSlide, nextSlide) { 2897 if($(".jsBlazingSlider .blazing-row").length <= 3) { 2898 if($(window).width() > 1199) { 2899 $(".jsBlazingSlider").removeClass("slick-dot-wrapper"); 2900 } 2901 } else { 2902 $(".jsBlazingSlider").addClass("slick-dot-wrapper"); 2903 } 2904 }); 2905 $(".jsBlazingSlider").not('.slick-initialized').slick({ 2906 infinite: true, 2907 speed: 1000, 2908 slidesToShow: 3, 2909 slidesToScroll: 3, 2910 dots: true, 2911 arrows: false, 2912 autoplay: true, 2913 autoplaySpeed: 5000, 2914 responsive: [{ 2915 breakpoint: 1200, 2916 settings: { 2917 slidesToShow: 3, 2918 slidesToScroll: 3, 2919 }, 2920 }, { 2921 breakpoint: 992, 2922 settings: { 2923 slidesToShow: 2, 2924 slidesToScroll: 2, 2925 }, 2926 }, { 2927 breakpoint: 768, 2928 settings: { 2929 infinite: true, 2930 slidesToShow: 1, 2931 slidesToScroll: 1, 2932 dots: true,
2933 arrows: false, 2934 centerMode: true, 2935 centerPadding: "50px" 2936 }, 2937 }], 2938 }); 2939 2940 2941 2942 2943 2944 // $(document).ready(function() { 2945 // $(".like-button").click(function() { 2946 // // Increase the like count by 1 2947 2948 // var currentLikes = parseInt($("#like-button").text().split(" ")[1]); 2949 // console.log(currentLikes); 2950 // var newLikes = currentLikes + 1; 2951 2952 // // Update the button text 2953 // $(".number_of_count").text( newLikes + "people found this useful "); 2954 // }); 2955 // }); 2956 2957 //$('.terms-links').append('<span class="icon-external"></span>'); 2958 2959 $('.js-single-select-widthout-search').select2().on('select2:open', function (e) { 2960 $('.select2-search__field').attr('placeholder', 'Search...'); 2961 $('body').find('span.select2-dropdown--below').addClass('select2-dropdown__city'); 2962 }); 2963 2964 if ($(".jsDriveSlider .drive-progress-row").length < 4) { 2965 // Destroy Slick slider if number of slides is less than or equal to 4 2966 $('.jsDriveSlider').slick('unslick'); 2967 } 2968 2969 2970 $('.jsDriveSlider').not('.slick-initialized').slick({ 2971 infinite: true, 2972 slidesToShow: 4, 2973 slidesToScroll: 2, 2974 arrows: false, 2975 dots: true, 2976 responsive: [ 2977 { 2978 breakpoint: 992, 2979 settings: { 2980 slidesToShow: 3, 2981 slidesToScroll: 1 2982 } 2983 }, 2984 { 2985 breakpoint: 768, 2986 settings: { 2987 slidesToShow: 2, 2988 slidesToScroll: 1, 2989 } 2990 }, 2991 { 2992 breakpoint: 565, 2993 settings: { 2994 slidesToShow: 1, 2995 slidesToScroll: 1, 2996 } 2997 } 2998 ] 2999 }); 3000 3001 3002 // jQuery document ready function 3003$(document).ready(function() { 3004 // Attach click event to elements with class 'show_more_faq' 3005 if ($(window).width() <= 767) { 3006 $('.faq-categeory .faqcatgeory').not(':eq(0), :eq(1) , :eq(2)').addClass('d-none'); 3007 3008 $('.show_more_faq').click(function(event) { 3009 event.preventDefault(); 3010 $('.faq-categeory .faqcatgeory').removeClass('d-none'); 3011 $(this).addClass('d-none'); 3012 $('.show_less_faq').removeClass('d-none'); 3013 3014 }); 3015 3016 $('.show_less_faq').click(function(event) { 3017 event.preventDefault(); 3018 $('.faq-categeory .faqcatgeory').not(':eq(0), :eq(1) , :eq(2)').addClass('d-none'); 3019 $(this).addClass('d-none'); 3020 $('.show_more_faq').removeClass('d-none'); 3021 3022 }); 3023 } 3024 3025 3026 $('.blog_catgeory .blogcatgeory').not(':eq(0), :eq(1) , :eq(2) , :eq(3)').addClass('d-none'); 3027 3028 $('.show_more_blog').click(function(event) { 3029 event.preventDefault(); 3030 $('.blog_catgeory .blogcatgeory').removeClass('d-none'); 3031 $(this).addClass('d-none'); 3032 $('.show_less_blog').removeClass('d-none'); 3033 3034 }); 3035 3036 $('.show_less_blog').click(function(event) { 3037 event.preventDefault(); 3038 $('.blog_catgeory .blogcatgeory').not(':eq(0), :eq(1) , :eq(2) , :eq(3)').addClass('d-none'); 3039 $(this).addClass('d-none'); 3040 $('.show_more_blog').removeClass('d-none'); 3041 3042 }); 3043 3044 3045 3046 3047 3048 3049 3050 // Define the maximum number of list items to display initially 3051 var maxItems = 3; 3052 3053 // Hide all list items beyond the maximum initially 3054 $('.rectangle-list').each(function() { 3055 $(this).find('li:gt(' + (maxItems - 1) + ')').hide(); 3056 }); 3057 3058 // Show more items when "Read more" button is clicked 3059 $('.read-more').click(function(e) { 3060 e.preventDefault(); 3061 var $list = $(this).closest('.internet-leased-row').find('.rectangle-list'); 3062 $list.find('li:gt(' + (maxItems - 1) + ')').toggle(); 3063 $(this).text(function(i, text) { 3064 return text === "READ MORE" ? "READ LESS" : "READ MORE"; 3065 }); 3066 }); 3067 3068 // $('.blog_listing_clear').click(function(e) { 3069 // //$("#views-exposed-form-learn-more-with-act-view-block-8")[0].reset(); 3070 // window.location.href = "/blog"; 3071 3072 3073 // }); 3074 3075 }); 3076 3077 3078 3079$(document).ready(function() { 3080 $('.faq_like').click(function() { 3081 var dataId = $(this).data('id'); 3082 var dynamicClasses = $('#faqlikeclick').attr('class'); 3083 console.log(dynamicClasses); 3084 // You can now use the formData string to access form data 3085 // For example, you can send it to the server via AJAX 3086 $.ajax({ 3087 type: 'POST', 3088 url: '/your-endpoint', 3089 data: formData, 3090 success: function(response) { 3091 // Handle success response 3092 }, 3093 error: function(xhr, status, error) { 3094 // Handle error 3095 } 3096 }); 3097 }); 3098}); 3099 3100$(document).ready(function() { 3101 3102 var dataIds = []; 3103 $('#accordionFAQ .accordion-item').each(function() { 3104 var dataId = $(this).data('id'); 3105 if (dataId) { 3106 dataIds.push(dataId); 3107 } 3108 }); 3109 // $.ajax({ 3110 // type: 'POST', 3111 // url: '/faq-likes-total-count', 3112 // data: { dataIds: dataIds }, // Send number as key-value pair 3113 // success: function(response) { 3114 // if (response.status === 'success') { 3115 3116 3117 // } else { 3118 // //alert(response.message); 3119 // } 3120 // }, 3121 // error: function() { 3122 // //alert('An error occurred. Please try again.'); 3123 // } 3124 // }); 3125 3126 // Log the dataIds array to check if it's correct 3127 //console.log(dataIds); 3128 $('.faqparentclass').on('click', '[class^="faq_like"]', function() { 3129 var dynamicClass = $(this).attr('class'); 3130 var match = dynamicClass.match(/\bfaq_like(\d+)\b/); 3131 if (match[1]) { 3132 var number = parseInt(match[1]); 3133 $.ajax({ 3134 type: 'POST', 3135 url: '/faq-likes', 3136 data: { number: number }, // Send number as key-value pair 3137 success: function(response) { 3138 if (response.status === 'Success') { 3139 $('.faq_like_count'+number).text(response.count+ " people found this useful"); 3140 $('.icons'+number).addClass('icon-thumb-up-fill'); 3141 $('.icons'+number).removeClass('icon-thumb-up'); 3142 3143 }else if (response.message == 'liked'){ 3144 //alert('Already liked'); 3145 } else { 3146 //alert(response.message); 3147 } 3148 }, 3149 error: function() { 3150 alert('An error occurred. Please try again.'); 3151 } 3152 }); 3153 } 3154 }); 3155 3156 // $("#city-proof .address-proof-select-search").select2({ 3157 // placeholder: "city*", 3158 // minimumResultsForSearch: -1, 3159 // dropdownParent: $("#city-proof").parent(), 3160 // }).on('select2:open', function (e) { 3161 // $('.select2-search__field').attr('placeholder', 'Search...'); 3162 // }); 3163 $('.address-proof-select-search').select2({ 3164 dropdownParent: $('#city-proof'), 3165 placeholder: "City*", 3166 matcher: function (params, data) { 3167 // If there is no search term, return all results 3168 if ($.trim(params.term) === '') { 3169 return data; 3170 } 3171 3172 var term = params.term.toLowerCase(); 3173 3174 // Define mappings for search terms 3175 var searchMapping = { 3176 'vizag': 'visakhapatnam', 3177 'bang': 'bengaluru', 3178 'banga': 'bengaluru', 3179 'bangal': 'bengaluru', 3180 'bangalo': 'bengaluru', 3181 'bangalor': 'bengaluru', 3182 'bangalore': 'bengaluru' 3183 }; 3184 3185 // Check if the entered search term matches the mapping and update it accordingly 3186 if (searchMapping[term]) { 3187 term = searchMapping[term]; 3188 } 3189 3190 var text = data.text.toLowerCase(); 3191 3192 // Match the updated term with available options 3193 if (text.indexOf(term) > -1) { 3194 return data; 3195 } 3196 3197 // No match, return null 3198 return null; 3199 } 3200 }).on('select2:open', function () { 3201 // Change the placeholder text when dropdown is opened 3202 $('.select2-search__field').attr('placeholder', 'Search..'); 3203 }); 3204 3205}); 3206 3207 3208 3209 3210$(".jsActSlider").not('.slick-initialized').slick({ 3211 infinite: true, 3212 speed: 1000, 3213 slidesToShow: 3, 3214 slidesToScroll: 3, 3215 dots: true,
3216 arrows: false, 3217 autoplay: true, 3218 autoplaySpeed: 5000, 3219 responsive: [ 3220 { 3221 breakpoint: 1200, 3222 settings: { 3223 slidesToShow: 3, 3224 slidesToScroll: 3, 3225 }, 3226 }, 3227 { 3228 breakpoint: 992, 3229 settings: { 3230 slidesToShow: 2, 3231 slidesToScroll: 2, 3232 }, 3233 }, 3234 { 3235 breakpoint: 768, 3236 settings: { 3237 infinite: true, 3238 slidesToShow: 1, 3239 slidesToScroll: 1, 3240 dots: true, 3241 arrows: false, 3242 // centerMode: true, 3243 // centerPadding: "50px" 3244 }, 3245 } 3246 ], 3247 }); 3248 3249// new connection 3250$(document).on('click', '#edit-do-you-live-in-a-multi-storey-house-yes', function() { 3251 3252 $('#custom-society').removeClass('d-none'); 3253}); 3254$(document).on('click', '#edit-do-you-live-in-a-multi-storey-house-no', function() { 3255 $('#custom-society').removeClass('d-none'); 3256 $('#custom-society').addClass('d-none'); 3257}); 3258 3259//explore new plan page 3260$(document).on('click', '#edit-do-you-live-in-a-multi-storey-house-new-yes', function() { 3261 3262 $('#custom-society-new').removeClass('d-none'); 3263}); 3264$(document).on('click', '#edit-do-you-live-in-a-multi-storey-house-new-no', function() { 3265 $('#custom-society-new').removeClass('d-none'); 3266 $('#custom-society-new').addClass('d-none'); 3267}); 3268 3269$(document).on('click', '#edit-is-your-office-premises-within-a-tech-park-yes', function() { 3270 3271 $('#custom-tech_park').removeClass('d-none'); 3272}); 3273$(document).on('click', '#edit-is-your-office-premises-within-a-tech-park-no', function() { 3274 $('#custom-tech_park').removeClass('d-none'); 3275 $('#custom-tech_park').addClass('d-none'); 3276}) 3277 3278//$('#edit-for-home-49').on('click',function(){ 3279$(document).on('click', '#edit-for-home-49', function() { 3280 3281 $('.company-email').removeClass('d-none'); 3282 $('#flat_no').removeClass('d-none'); 3283 $('#multistorey').addClass('d-none'); 3284 $('#edit-actions-submit').val('Request Call'); 3285 $("input[name='op']").val('Request Call'); 3286}) 3287//$('#edit-for-home-48').on('click',function(){ 3288$(document).on('click', '#edit-for-home-48', function() { 3289 $('.company-email').removeClass('d-none'); 3290 $('#flat_no').removeClass('d-none'); 3291 $('.company-email').addClass('d-none'); 3292 $('#flat_no').addClass('d-none'); 3293 $('#multistorey').removeClass('d-none'); 3294 $('#edit-actions-submit').val('Get Offer'); 3295 $("input[name='op']").val('Get Offer'); 3296}) 3297 3298$('#edit-front-id-proof-upload').addClass('d-none'); 3299$('#edit-back-id-proof-upload').addClass('d-none'); 3300$('#edit-address-back-of-id-proof-upload').addClass('d-none'); 3301$('#edit-address-front-id-proof-upload').addClass('d-none'); 3302$('#edit-upload-your-signature-upload').addClass('d-none'); 3303 3304$(document).ready(function() { 3305 const $deviceSelect = $('#deviceSelect'); 3306 const $purchaseButton = $('.purchaseprize'); 3307 const $rentButton = $('.rentprize'); 3308 3309 // Prices based on the number of devices 3310 const prices = { 3311 1: { buy: 2249.00, rent: 200.00 }, 3312 2: { buy: 4000.00, rent: 350.00 }, 3313 3: { buy: 5500.00, rent: 500.00 }, 3314 }; 3315 3316 function updatePrices() { 3317 const selectedValue = parseInt($deviceSelect.val()); 3318 $('.selecteddevice').val(selectedValue); 3319 3320 // Update prices based on the selected value 3321 if (prices[selectedValue]) { 3322 $purchaseButton.val(`BUY @â¹${prices[selectedValue].buy.toFixed(2)}`); 3323 $purchaseButton.text(`BUY @â¹${prices[selectedValue].buy.toFixed(2)}`); 3324 $rentButton.val(`RENT @â¹${prices[selectedValue].rent.toFixed(2)} PER MONTH`); 3325 $rentButton.text(`RENT @â¹${prices[selectedValue].rent.toFixed(2)} PER MONTH`); 3326 3327 } 3328 } 3329 3330 // Attach change event listener to the select element 3331 $deviceSelect.change(updatePrices); 3332 3333 // Trigger the change event on page load to set initial values 3334 updatePrices(); 3335 3336 3337 3338 }); 3339 3340 3341$(document).ready(function() { 3342 // Event handler for button click to get the selected radio button value 3343 $('.product_select_act').on('change', function() { 3344 var selectedValue = $(this).val(); 3345 $('#purchaseprize').text("BUY @â¹"+selectedValue +".00 PER MONTH"); 3346 $('.selecteddeviceshield').val(selectedValue); 3347 3348 }); 3349 }); 3350 3351 3352 var timerOn = true; 3353 3354 function timerCountDown(remaining) { 3355 if (document.getElementById('timer')) { 3356 var m = Math.floor(remaining / 60); 3357 var s = remaining % 60; 3358 m = m < 10 ? '0' + m : m; 3359 s = s < 10 ? '0' + s : s; 3360 document.getElementById('timer').innerHTML = m + ':' + s; 3361 document.getElementById('timer').innerHTML = m + ':' + s; 3362 remaining -= 1; 3363 if (remaining >= 0 && timerOn) { 3364 setTimeout(function() { 3365 timerCountDown(remaining); 3366 }, 1000); 3367 return; 3368 }
3369 if (!timerOn) { 3370 // Do validate stuff here 3371 return; 3372 } 3373 $('.jsResendBtn').css('display', 'inline'); 3374 $('.ResendBtn').css('display', 'inline'); 3375 $('.OtpResend').css('display', 'inline'); 3376 } 3377 } 3378 3379 timerCountDown(30); //in sec 3380 3381 3382 $('.jsResendBtn').click(function(e) { 3383 // Prevent the default behavior of the Next button (stopping the wizard). 3384 e.preventDefault(); 3385 //$('#your-modal-id .modal-body').html(formData); 3386 var registered_mobile_number = $('#registeredMobileNumber').val(); 3387 var resetotp = $('#resetotp').val(); 3388 3389 // console.log(registered_mobile_number); 3390 var url = '/otp-send'; 3391 // Send AJAX POST request. 3392 $.ajax({ 3393 url: url, 3394 method: 'POST', 3395 data: { 3396 registered_mobile_number: registered_mobile_number, 3397 resetotp: resetotp 3398 }, 3399 success: function(response) { 3400 if(response.status == "success") { 3401 $('#registeredMobileNumber').val(response.registered_mobile_number); 3402 timerCountDown(30); //in sec 3403 $('.jsResendBtn').css('display', 'none'); 3404 } 3405 } 3406 }); 3407}); 3408 3409$('.turitojsResendBtn').click(function(e) { 3410 // Prevent the default behavior of the Next button (stopping the wizard). 3411 e.preventDefault(); 3412 //$('#your-modal-id .modal-body').html(formData); 3413 var registered_mobile_number = $('#registeredMobileNumber').val(); 3414 var resetotp = $('#resetotp').val(); 3415 3416 // console.log(registered_mobile_number); 3417 var url = '/turito-otp-sent'; 3418 // Send AJAX POST request. 3419 $.ajax({ 3420 url: url, 3421 method: 'POST', 3422 data: { 3423 user_mobile_number: registered_mobile_number, 3424 resetotp: resetotp 3425 }, 3426 success: function(response) { 3427 if(response.status == "success") { 3428 $('#registeredMobileNumber').val(response.registered_mobile_number); 3429 timerCountDown(30); //in sec 3430 $('.turitojsResendBtn').css('display', 'none'); 3431 } 3432 } 3433 }); 3434}); 3435 3436 3437 3438 /*Send OTP common handler*/ 3439 $(document).on('click', '.custom-sent-otp', function(e) { 3440 // Prevent the default behavior of the Next button (stopping the wizard). 3441 e.preventDefault(); 3442 // Function to validate the phone number / account number field 3443 function validateInput() { 3444 let isValid = true; 3445 let errorMessage = ''; 3446 // Get the input value 3447 const input = $('input[name="user_mobile_number"]').val().trim(); 3448 const phonePattern = /^[6-9]\d{9}$/; // Indian phone number pattern 3449 const accountPattern = /^\d{12}$/; // 12-digit account number pattern 3450 3451 if (!input) { 3452 errorMessage += 'Phone number / Account number is required.<br>'; 3453 isValid = false; 3454 } else if (!phonePattern.test(input) && !accountPattern.test(input)) { 3455 errorMessage += 'Phone number must be a valid 10-digit or a 12-digit account number.<br>'; 3456 isValid = false; 3457 } 3458 // Display error messages if any 3459 if (!isValid) { 3460 $('.input-errors').html('<p class="fontSize-14 semibold mg-t-5">' + errorMessage + '</p>'); 3461 } else { 3462 $('.input-errors').html(''); // Clear previous error messages if any 3463 } 3464 3465 return isValid; 3466 } 3467 // Proceed only if the input is valid 3468 if (validateInput()) { 3469 $('#loader').removeClass('d-none'); 3470 var registered_mobile_number = $('#edit-user-mobile-number').val(); 3471 var checkVASServiceName = $('#productName').val(); 3472 var table_name = $('#table').val(); 3473 var captcha_response = $('input[name="captcha_response"]').val(); // Adjust according to your CAPTCHA input name 3474 var urlParams = new URLSearchParams(window.location.search); 3475 var utm_params = { 3476 utm_source: urlParams.get('utm_source'), 3477 utm_campaign: urlParams.get('utm_campaign'), 3478 utm_medium: urlParams.get('utm_medium'), 3479 utm_term: urlParams.get('utm_term'), 3480 utm_content: urlParams.get('utm_content'), 3481 utm_adgroup: urlParams.get('utm_adgroup'), 3482 creative: urlParams.get('creative'), 3483 device: urlParams.get('device'), 3484 devicemodel: urlParams.get('devicemodel'), 3485 matchtype: urlParams.get('matchtype'), 3486 feeditemid: urlParams.get('feeditemid'), 3487 targetid: urlParams.get('targetid'), 3488 placement: urlParams.get('placement'), 3489 adposition: urlParams.get('adposition'),
3490 GA_loc_interest_ms: urlParams.get('GA_loc_interest_ms'), 3491 GA_loc_physical_ms: urlParams.get('GA_loc_physical_ms'), 3492 gclid: urlParams.get('gclid'), 3493 network: urlParams.get('network'), 3494 gclid: urlParams.get('gclid') 3495 }; 3496 var url = '/otp-send'; 3497 // Send AJAX POST request. 3498 $.ajax({ 3499 url: url, 3500 method: 'POST', 3501 cache: false, // Prevent caching of the request 3502 data: { 3503 registered_mobile_number: registered_mobile_number, 3504 utm_params: utm_params, 3505 productName : checkVASServiceName, 3506 table : table_name, 3507 captcha: captcha_response, 3508 captcha_sid: $("input[name=captcha_sid]").val(), // Ensure this is set correctly 3509 captcha_response: $('#edit-captcha-response').val(), // User's CAPTCHA input 3510 }, 3511 success: function(response) { 3512 $('#loader').addClass('d-none'); 3513 if(response.status == "failed") { 3514 //$('.reload-captcha').trigger('click'); 3515 if(response.error_msg){ 3516 $('#failed .thankyou-content p').text(response.error_msg); 3517 $('#loader').addClass('d-none'); 3518 }else{ 3519 $('#failed .thankyou-content p').text('Please enter your registered phone number to proceed'); 3520 $('#loader').addClass('d-none'); 3521 } 3522 $('#failed').modal('show'); 3523 } 3524 else if(response.status == 'AlreadyPurchase'){ 3525 $('#alreadypurchased_popup').modal('show'); 3526 // Redirect after 2 seconds. 3527 setTimeout(function() { 3528 window.location.href = '/'; 3529 }, 7000); 3530 // } 3531 // else if (response.status == 'success' && response.token == authToken){ 3532 // $('#loader').addClass('d-none'); 3533 // $('#registeredMobileNumber').val(response.registered_mobile_number); 3534 // //console.log(response); 3535 // $('.send-otp-form').submit(); 3536 // timerCountDown(30); //in sec 3537 // //$('.jsResendBtn').css('display', 'none'); 3538 } 3539 else { 3540 $('#loader').addClass('d-none'); 3541 $('#registeredMobileNumber').val(response.registered_mobile_number); 3542 //console.log(response); 3543 $('.send-otp-form').submit(); 3544 timerCountDown(30); //in sec 3545 //$('.jsResendBtn').css('display', 'none'); 3546 } 3547 } 3548 }); 3549 } 3550 }); 3551 3552 $(document).ready(function() { 3553 // Get the current URL path 3554 var path = window.location.pathname; 3555 3556 // Extract the location part from the URL 3557 var parts = path.split('/').filter(Boolean); // Split by '/' and filter out empty segments 3558 var location = parts[1] ? parts[1].trim().toLowerCase() : ''; // Check if parts[1] exists 3559 3560 // Proceed only if location is not empty 3561 if (location) { 3562 // Map the location to the select box 3563 var locationFound = false; 3564 $('.changelocation select[name="field_product_locations_target_id"] option').each(function() { 3565 var optionText = $(this).text().trim().toLowerCase(); // Normalize to lowercase 3566 if (optionText === location) { 3567 $(this).prop('selected', true); 3568 locationFound = true; 3569 return false; // Exit the loop early once matched 3570 } 3571 }); 3572 3573 if (!locationFound) { 3574 // Handle case when location is not found (optional) 3575 // console.log("Location not found in the select options."); 3576 } 3577 3578 // Trigger change event to update the select box 3579 $('.changelocation select[name="field_product_locations_target_id"]').trigger('change'); 3580 } 3581 3582 // Event listener for change 3583 $(document).on('change', '.changelocation select[name="field_product_locations_target_id"]', function() { 3584 var selectedText = $(this).find('option:selected').text().trim().toLowerCase(); 3585 // Redirect based on the selected option 3586 window.location.href = '/broadband/' + selectedText + '/broadband-plans/'; 3587 }); 3588 }); 3589 3590 3591 $(document).ready(function() { 3592 // Get the current URL path 3593 var path = window.location.pathname; 3594 3595 // Extract the location part from the URL 3596 var parts = path.split('/'); 3597 var location = parts[parts.length - 1].trim().toLowerCase(); // Normalize to lowercase 3598 3599 // console.log("URL Path: ", path); 3600 //console.log("Extracted Location: ", location); 3601 3602 // Map the location to the select box 3603 var locationFound = false;
3604 $('.changelocationwifi select[name="field_product_locations_target_id"] option').each(function() { 3605 var optionText = $(this).text().trim().toLowerCase(); // Normalize to lowercase 3606 // console.log("Checking option: ", optionText); 3607 3608 if (optionText === location) { 3609 $(this).prop('selected', true); 3610 locationFound = true; 3611 // console.log("Matched location: ", optionText); 3612 return false; // Exit the loop early once matched 3613 } 3614 }); 3615 3616 if (!locationFound) { 3617 // console.log("Location not found in the select options."); 3618 } 3619 3620 // Trigger change event to update the select box 3621 $('.changelocationwifi select[name="field_product_locations_target_id"]').trigger('change'); 3622 3623 // Event listener for change 3624 $(document).on('change', '.changelocationwifi select[name="field_product_locations_target_id"]', function() { 3625 var selectedText = $(this).find('option:selected').text().trim(); 3626 //console.log("Selected Text: ", selectedText); 3627 window.location.href = '/wifi-plans/wifi-plans-in-' + selectedText; 3628 }); 3629 //click event for select businees option in popup 3630 $(document).on('click', '.business-modal', function() { 3631 $('#checkAbailabilityModal .check-availity-list').find('input[name=for_home][value=49]').trigger("click"); 3632 }); 3633 3634 //restrict modal to not close on body click 3635 $('#checkAbailabilityModal').modal({backdrop: 'static', keyboard: false}); 3636 $('#choosePlan').modal({backdrop: 'static', keyboard: false}); 3637 $('#videoModal').modal({backdrop: 'static', keyboard: false}); 3638 $('#searchModal').modal({backdrop: 'static', keyboard: false}); 3639 $('#kyc').modal({backdrop: 'static', keyboard: false}); 3640 $('#searchModal').modal({backdrop: 'static', keyboard: false}); 3641 $('#searchModal').modal({backdrop: 'static', keyboard: false}); 3642 $('#chatbotModal').modal({backdrop: 'static', keyboard: false}); 3643 $('#getStarted').modal({backdrop: 'static', keyboard: false}); 3644 3645 3646 3647 }); 3648 3649 $(document).ready(function() { 3650 $('.read-more-btn').click(function() { 3651 var moreText = $(this).closest('div').prev().find('.more-text'); 3652 if (moreText.is(':visible')) { 3653 moreText.hide(); 3654 $(this).text('Read more'); 3655 } else { 3656 moreText.show(); 3657 $(this).text('Read less'); 3658 } 3659 }); 3660 }); 3661 3662 $('.chatbox').show(); 3663 $(document).ready(function() { 3664 // Attach click event listener to each .plandetails element 3665 //$('.plandetails').on('click', function() { 3666 $(document).on("click", '.plandetails', function() { 3667 //alert('2'); 3668 $('#buy_plan_by_selection_modal .language-list').html(''); 3669 var plans_li = ''; 3670 var row = 1; 3671 const tenureArray = []; 3672 3673 $(this).parent('.plandetailsparent').find('input[name="plancode"]').each(function() { 3674 var plan_month_text = $(this).data('monthname'); 3675 var plan_month_val = $(this).data('monthvalue').trim(); 3676 var installation = $(this).data('installation'); 3677 var security = $(this).data('security'); 3678 var tag = $(this).data('tag'); 3679 3680 // Check if plan_month_val is not already in tenureArray 3681 if(plan_month_val !== '' && !tenureArray.includes(plan_month_val)) { 3682 var tags = ''; 3683 if (typeof tag !== 'undefined' && tag !== null && tag !== '' && tag !== 0) { 3684 tags = `<span>` + tag + ` month free</span>`; 3685 } 3686 3687 plans_li += `<li> 3688 <div class="form-check-group form-check-group--radio w-100">`; 3689 if(row === 1) { 3690 plans_li += `<input type="radio" name="selectTenure" id="selectTenure` + row + `" data-installation="` + installation + `" data-security="` + security + `" value="` + plan_month_val + `" checked="checked">`; 3691 } else { 3692 plans_li += `<input type="radio" name="selectTenure" id="selectTenure` + row + `" data-installation="` + installation + `" data-security="` + security + `" value="` + plan_month_val + `">`; 3693 } 3694 plans_li += `<label class="form-check-label" for="selectTenure` + row + `">` + plan_month_text + `</label> 3695 </div> 3696 </li>`; 3697 3698 // Add plan_month_val to tenureArray after processing 3699 tenureArray.push(plan_month_val); 3700 3701 row++; 3702 } 3703 }); 3704 3705 // console.log('tenureArray:', tenureArray); 3706 3707 // Display the plans list 3708 if(plans_li !== '') { 3709 $('#buy_plan_by_selection_modal .language-list').html(plans_li); 3710 } 3711 }); 3712 3713 3714 //disable dropdown arrow if single device on home camera 3715 if($(".single-device")[0]){ 3716 //$(".single-device").next().find('.select2-container').css("pointer-events", "none"); 3717 $(".single-device").next().find('.select2-selection__arrow').css("display", "none"); 3718 } 3719 3720 }); 3721 3722 $(document).keydown(function(event) { 3723 if (event.keyCode == 27) { 3724 $('#chatbotModal').modal('hide'); 3725 } 3726 }); 3727 3728 $('.webform-submission-digital-tv-enquire-now-form select[name="city"]').on('change', function() { 3729 getpincodecity(); 3730 }); 3731 3732 $('.webform-submission-digital-tv-enquire-now-form input[name="pincode"]').on('keyup', function(event) { 3733 //$('#edit-select-area').append(newOption); 3734 getpincodecity(); 3735 }); 3736 3737function getpincodecity(){ 3738 3739 var selectedValue = $('.webform-submission-digital-tv-enquire-now-form select[name="city"]').val(); // Get the selected value 3740 var pincode = $('.webform-submission-digital-tv-enquire-now-form input[name="pincode"]').val(); // Get the selected value 3741 3742 if(pincode.length == 6 && selectedValue != ''){ 3743 3744 var url = '/check-pincode-city'; 3745 //$('#edit-select-area').append(newOption); 3746 //$('#edit-select-area').empty(); 3747 //$('#edit-select-area').val(null).trigger('change'); 3748 $('.webform-submission-digital-tv-enquire-now-form select[name="select_area"]').empty().trigger('change'); 3749 // Send AJAX POST request. 3750 $.ajax({ 3751 url: url, 3752 method: 'POST', 3753 data: { 3754 city: selectedValue, 3755 pincode: pincode, 3756 }, 3757 success: function(response) { 3758 var jsonData = response.data; 3759 if(jsonData == 'Value Matched'){ 3760 var newOption = new Option('Other', 'other', true, true); 3761 $('.webform-submission-digital-tv-enquire-now-form select[name="select_area"]').empty().trigger('change'); 3762 $('.webform-submission-digital-tv-enquire-now-form select[name="select_area"]').append(newOption).trigger('change'); 3763 3764 } else if (response.data == ''){ 3765 var newOption = new Option('Other', 'other', true, true); 3766 $('.webform-submission-digital-tv-enquire-now-form select[name="select_area"]').empty().trigger('change'); 3767 $('.webform-submission-digital-tv-enquire-now-form select[name="select_area"]').append(newOption).trigger('change'); 3768 3769 } else{ 3770 data = JSON.parse(jsonData); 3771 $.each(data, function(index, option) { 3772 var newOption = new Option(option.location, option.index, false, false); 3773 $('.webform-submission-digital-tv-enquire-now-form select[name="select_area"]').append(newOption); 3774 }); 3775 } 3776 3777 } 3778 }); 3779} 3780 3781} 3782 3783$('.webform-submission-digital-tv-enquire-now-form #edit-actions-submit').click(function(event) { 3784 event.preventDefault(); 3785 // Clear all previous error messages 3786 $('.error-msg').remove(); 3787 3788 var name = $('#edit-digital-name').val(); 3789 var mobile = $('#edit-mobile-number').val(); 3790 var pincode = $('#edit-pincode').val(); 3791 var email = $('#edit-email').val();
3792 var address = $('#edit-address-1').val(); 3793 var street = $('#edit-street').val(); 3794 3795 var pincodeRegex = /^(?:\d{6})$/; 3796 var nameRegex = /^[a-zA-Z]+(?:\s[a-zA-Z]+)*$/; 3797 var phoneRegex = /^(?:\d{10}|\d{12})$/; 3798 var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 3799 var addressRegex = /.+/; // Simple non-empty check 3800 var streetRegex = /.+/; // Simple non-empty check 3801 var validation = true; 3802 3803 // Name validation 3804 if(name == '' || !nameRegex.test(name)){ 3805 if($("#edit-digital-name").parent().find('.error-msg').length === 0) { 3806 $("#edit-digital-name").parent().append('<span class="error-msg">Please enter a valid Name</span>'); 3807 } 3808 validation = false; 3809 } else { 3810 $("#edit-digital-name").parent().find('.error-msg').remove(); 3811 } 3812 3813 // Mobile validation 3814 if(mobile == '' || !phoneRegex.test(mobile)){ 3815 if($("#edit-mobile-number").parent().find('.error-msg').length === 0) { 3816 $("#edit-mobile-number").parent().append('<span class="error-msg">Please enter a valid Mobile Number</span>'); 3817 } 3818 validation = false; 3819 } else { 3820 $("#edit-mobile-number").parent().find('.error-msg').remove(); 3821 } 3822 3823 // Pincode validation 3824 if(pincode == '' || !pincodeRegex.test(pincode)){ 3825 if($("#edit-pincode").parent().find('.error-msg').length === 0) { 3826 $("#edit-pincode").parent().append('<span class="error-msg">Please enter a valid Pincode</span>'); 3827 } 3828 validation = false; 3829 } else { 3830 $("#edit-pincode").parent().find('.error-msg').remove(); 3831 } 3832 3833 // Email validation 3834 if(email == '' || !emailRegex.test(email)){ 3835 if($("#edit-email").parent().find('.error-msg').length === 0) { 3836 $("#edit-email").parent().append('<span class="error-msg">Please enter a valid Email Address</span>'); 3837 } 3838 validation = false; 3839 } else { 3840 $("#edit-email").parent().find('.error-msg').remove(); 3841 } 3842 3843 // Address validation 3844 if(address == '' || !addressRegex.test(address)){ 3845 if($("#edit-address-1").parent().find('.error-msg').length === 0) { 3846 $("#edit-address-1").parent().append('<span class="error-msg">Please enter a valid Address</span>'); 3847 } 3848 validation = false; 3849 } else { 3850 $("#edit-address-1").parent().find('.error-msg').remove(); 3851 } 3852 3853 // Street validation 3854 if(street == '' || !streetRegex.test(street)){ 3855 if($("#edit-street").parent().find('.error-msg').length === 0) { 3856 $("#edit-street").parent().append('<span class="error-msg">Please enter a valid Street</span>'); 3857 } 3858 validation = false; 3859 } else { 3860 $("#edit-street").parent().find('.error-msg').remove(); 3861 } 3862 3863 // Add other validation conditions as needed 3864 3865 if (validation) { 3866 // Submit form if validation is successful 3867 $('.webform-submission-digital-tv-enquire-now-form').submit(); 3868 } 3869}); 3870 3871$('.webform-submission-see-plans-offers-in-your-area-form input[name="society"]').on('keyup', function(event) { 3872 var society = $('.webform-submission-see-plans-offers-in-your-area-form input[name="society"]').val(); 3873 if (society > 3) { 3874 var url = '/check-society'; 3875 $.ajax({ 3876 url: url, 3877 method: 'POST', 3878 data: { 3879 society: society, 3880 }, 3881 success: function(response) { 3882 // Handle the response here 3883 console.log(response); // Example of handling response 3884 }, 3885 error: function(xhr, status, error) { 3886 // Handle any errors here 3887 console.error('AJAX Error:', status, error); 3888 } 3889 }); 3890 } 3891}); 3892 3893// for explore new journey sagar 3894$('.webform-submission-new-journey-for-plans-offer-form input[name="society"]').on('keyup', function(event) { 3895 var society = $('.webform-submission-new-journey-for-plans-offer-form input[name="society"]').val(); 3896 if (society > 3) { 3897 var url = '/check-society'; 3898 $.ajax({ 3899 url: url, 3900 method: 'POST', 3901 data: { 3902 society: society, 3903 }, 3904 success: function(response) { 3905 // Handle the response here 3906 console.log(response); // Example of handling response 3907 }, 3908 error: function(xhr, status, error) { 3909 // Handle any errors here 3910 console.error('AJAX Error:', status, error); 3911 } 3912 }); 3913 } 3914}); 3915 3916 //Refer a friend page js // The class of your Next button. 3917 $('.webform-submission-refer-a-friend-form .proceed_to_otp').click(function(e) { 3918 // Prevent the default behavior of the Next button (stopping the wizard). 3919 e.preventDefault(); 3920 //check fields validation 3921 var name = $('.webform-submission-refer-a-friend-form #edit-your-name').val().trim(); 3922 var formtype = $('.webform-submission-refer-a-friend-form #formtype').val(); 3923 var mobile = $('.webform-submission-refer-a-friend-form #edit-user-mobile-number').val(); 3924 var nameRegex = /^[a-zA-Z\s]+$/; 3925 var phoneRegex = /^(?:\d{10}|\d{12})$/;
3926 var validation = true; 3927 $(".webform-submission-refer-a-friend-form .friend-error").remove(); 3928 if(!name){ 3929 $(".webform-submission-refer-a-friend-form #edit-your-name").parent().after('<span class="friend-error">Name is Required!</span>'); 3930 validation = false; 3931 } 3932 if(!nameRegex.test(name)){ 3933 $(".webform-submission-refer-a-friend-form #edit-your-name").parent().after('<span class="friend-error">Please enter valid name!</span>'); 3934 validation = false; 3935 } 3936 if(mobile=='' || !phoneRegex.test(mobile)){ 3937 $(".webform-submission-refer-a-friend-form #edit-user-mobile-number").parent().after('<span class="friend-error">Please enter valid mobile/account no!</span>'); 3938 validation = false; 3939 } 3940 if(!validation){ 3941 return false; 3942 } 3943 3944 // Access form data and display in the modal. 3945 var formData = $('.webform-submission-refer-a-friend-form').serialize(); 3946 // Show the modal. 3947 // Replace 'your-modal-id' with the ID of your modal. 3948 //$('#your-modal-id .modal-body').html(formData); 3949 var url = '/otp-send'; 3950 // Send AJAX POST request. 3951 $.ajax({ 3952 url: url, 3953 method: 'POST', 3954 data: { 3955 registered_mobile_number: mobile, 3956 form_type: formtype 3957 }, 3958 success: function(response) { 3959 if(response.status == "success") { 3960 $('#registeredMobileNumber').val(response.registered_mobile_number); 3961 $('.webform-submission-refer-a-friend-form').submit(); 3962 timerCountDown(30); 3963 } 3964 else if(response.status == "failed") { 3965 $('.reload-captcha').trigger('click'); 3966 if(response.error_msg){ 3967 $('#failed .thankyou-content p').text(response.error_msg); 3968 $('#loader').addClass('d-none'); 3969 }else{ 3970 $('#failed .thankyou-content p').text('Please enter your registered phone number to proceed'); 3971 $('#loader').addClass('d-none'); 3972 } 3973 $('#failed').modal('show'); 3974 } else { 3975 $('#failed').modal('show'); 3976 } 3977 // $('input[name="totalAmt"]').val(response.finalUpdtAmt); 3978 } 3979 }); 3980 }); 3981 // The class of your Next button. 3982 $('.webform-submission-refer-a-friend-form .jsProceedBtn ').click(function(e) { 3983 // Prevent the default behavior of the Next button (stopping the wizard). 3984 // e.preventDefault(); 3985 // Access form data and display in the modal. 3986 var authToken = getCookie('otp_token'); 3987 var formData = $('.webform-submission-refer-a-friend-form').serialize(); 3988 // Show the modal 3989 // Replace 'your-modal-id' with the ID of your modal. 3990 //$('#your-modal-id .modal-body').html(formData); 3991 var url = '/otp-check'; 3992 // Send AJAX POST request. 3993 $.ajax({ 3994 url: url, 3995 method: 'POST', 3996 data: formData, 3997 success: function(response) { 3998 var authToken = getCookie('otp_token'); 3999 //console.log(response.exploreAddonData); 4000 // if(response.status == "success" && response.otp_token == authToken) { 4001 if(response.status == "success" && response.otp_token) { 4002 $('.webform-submission-refer-a-friend-form .otp_check_submit').trigger('click'); 4003 } else { 4004 $('#failed2').modal('show'); 4005 } 4006 } 4007 }); 4008 }); 4009 4010 $('.webform-submission-refer-a-friend-form .friendsSubmit ').click(function(e) { 4011 // Prevent the default behavior of the Next button (stopping the wizard). 4012 e.preventDefault(); 4013 var f_name = $('.webform-submission-refer-a-friend-form #edit-friend-name').val().trim(); 4014 var mobile = $('.webform-submission-refer-a-friend-form #edit-friend-mobile-number').val(); 4015 var location = $('.webform-submission-refer-a-friend-form #edit-locations').val(); 4016 var nameRegex = /^[a-zA-Z]+(?:\s[a-zA-Z]+)*$/; 4017 var phoneRegex = /^(?:\d{10})$/; 4018 var validation = true; 4019 $(".webform-submission-refer-a-friend-form .friend-error").remove(); 4020 if(f_name=='' || !nameRegex.test(f_name)){ 4021 $(".webform-submission-refer-a-friend-form #edit-friend-name").parent().after('<span class="friend-error">Please enter valid name!</span>'); 4022 validation = false; 4023 } 4024 if(mobile=='' || !phoneRegex.test(mobile)){ 4025 $(".webform-submission-refer-a-friend-form #edit-friend-mobile-number").parent().after('<span class="friend-error">Please enter valid mobile/account no!</span>'); 4026 validation = false;
4027 } 4028 if(location==''){ 4029 //$(".webform-submission-refer-a-friend-form #edit-locations").parent().after('<span class="friend-error">Please Select location</span>'); 4030 //$(".webform-submission-refer-a-friend-form #edit-locations").find('<div class="form-group">').after('<span class="friend-error">Please Select location</span>'); 4031 $(".webform-submission-refer-a-friend-form #edit-locations").closest('.form-group').after('<span class="friend-error">Please Select location</span>'); 4032 4033 4034 validation = false; 4035 } 4036 if(!validation){ 4037 return false; 4038 }else{ 4039 4040 function getSeCodeFromUrl() { 4041 var params = new URLSearchParams(window.location.search); 4042 var seCode = params.get('se_code'); 4043 return seCode && seCode.trim() ? seCode.trim() : null; 4044 } 4045 4046 var formData = $('.webform-submission-refer-a-friend-form').serialize(); 4047 4048 4049 var seCode = getSeCodeFromUrl(); 4050 // If present, add it to the serialized form payload 4051 if (seCode) { 4052 formData += '&se_code=' + encodeURIComponent(seCode); 4053 } 4054 4055 $.ajax({ 4056 url: '/refer-a-friend-data', 4057 method: 'POST', 4058 data: formData, 4059 success: function(response) { 4060 if(response.status == 'failed'){ 4061 $('.thankyou-content').html(''); 4062 $('.thankyou-content').html('<h2 class="heading36 semibold">Thank you!</h2><p class="fontSize-14 semibold">Referral limit reached! Donât worry, referrals will open up again next month.</p><p class="fontSize-14 semibold d-flex justify-content-center mg-t-10"><img src="/themes/custom/actcorp/assets/images/spinning-loader.webp" height="20" width="20" alt="" class="mg-r-10" loading="lazy">Please wait while we redirect you</p>'); 4063 $('#thankYou').modal('show'); 4064 } 4065 $('#thankYou').modal('show'); 4066 // Redirect after 2 seconds. 4067 setTimeout(function() { 4068 window.location.href = '/refer-a-friend'; 4069 }, 7000); 4070 } 4071 }); 4072 4073 4074 } 4075 4076 }); 4077 4078// Select all elements with class 'jsChatBotBtn' 4079document.querySelectorAll('.jsChatBotBtn').forEach(function(button) { 4080 button.addEventListener('click', function() { 4081 var iframe = document.getElementById('chatbotFrame'); 4082 iframe.src = 'https://soa.actcorp.in/bot/v4/?newconnection=1'; 4083 }); 4084 }); 4085 4086 4087 // Optional: Clear iframe src when modal is closed 4088 document.getElementById('chatbotModal').addEventListener('hidden.bs.modal', function () { 4089 document.getElementById('chatbotFrame').src = ''; 4090 }); 4091 4092 4093// var selectLength = $("#NewCitySelectPopup .js-webform-select2").length; 4094// console.log(selectLength); 4095 4096// if (selectLength > 0) { 4097// $("#NewCitySelectPopup .js-webform-select2").select2({ 4098// allowClear: false, 4099// minimumResultsForSearch: 0, 4100// dropdownParent: $('#checkAbailabilityModal') 4101// }); 4102// } 4103 4104$(document).ready(function() { 4105 $('#views-exposed-form-products-view-block-2').on('submit', function(event) { 4106 event.preventDefault(); // Prevent the default form submission 4107 event.stopPropagation(); // Stop the event from bubbling up 4108 // Your custom logic here, e.g., AJAX submission or other actions 4109 }); 4110 4111 }); 4112 4113 $(document).ready(function () { 4114 // Attach a change event listener to the autocomplete input 4115 $('#suggestion-block-form #edit-keys').on('autocompleteselect', function (event, ui) { 4116 // Set the selected value to the input field 4117 $(this).val(ui.item.value); 4118 // Submit the form 4119 $(this).closest('form').submit(); 4120 }); 4121 4122 }); 4123 4124 4125 4126 if (window.performance && window.performance.navigation.type === window.performance.navigation.TYPE_BACK_FORWARD) { 4127 var currentUrl = window.location.href; 4128 var baseUrl = window.location.origin + "/"; // Assuming the homepage is at the root of the domain 4129 if (currentUrl === baseUrl || currentUrl === window.location.origin) { 4130 // Reload the page 4131 location.reload(); 4132 } 4133 if (currentUrl.indexOf("/need-help-device") !== -1 || currentUrl.indexOf("/explore-all-plans") !== -1 || currentUrl.indexOf("/broadband/broadband-plans/") !== -1 || currentUrl.indexOf("/wifi-plans/wifi-plans-in-") !== -1) { 4134 location.reload(); 4135 } 4136 if (currentUrl.indexOf("/kyc-verification") !== -1){ 4137 window.location = '/'; 4138 } 4139 4140 } 4141 4142jQuery(document).ready(function ($) { 4143 4144 const selectBox = $('select[name="field_plan_location_target_id"]'); 4145 const link = $('.floating-chat-offer a.btn-tag'); 4146 4147 // Clear session on homepage 4148 if (window.location.pathname === '/' || window.location.pathname === '/home') { 4149 sessionStorage.removeItem('selectedCity'); 4150 } 4151 4152 function updateLink() { 4153 if (selectBox.val() == '3' || selectBox.val() == '4' || selectBox.val() == '6' || selectBox.val() == '7') { 4154 link.attr('href', 'https://docs.google.com/forms/d/e/1FAIpQLSeC
4154Dkx0WwrEHOtoc-SQGQsJsDF4qt_oAUnDfeI9244L2Z-3RA/viewform?usp=dialog'); 4155 } else { 4156 link.attr('href', '/new-connection'); 4157 } 4158 } 4159 4160 // Delay restore until Select2 is fully mounted 4161 setTimeout(function () { 4162 const savedValue = sessionStorage.getItem('selectedCity'); 4163 if (savedValue) { 4164 selectBox.val(savedValue).trigger('change.select2'); // sync display only 4165 $('.need-help-location #edit-location').val(savedValue); 4166 updateLink(); // update link after restore 4167 } 4168 }, 300); 4169 4170 updateLink(); // run on load with current value 4171 4172 // On city change: save to session + update link 4173 selectBox.on('change', function () { 4174 sessionStorage.setItem('selectedCity', $(this).val()); 4175 updateLink(); 4176 }); 4177 4178 }); 4179 4180 4181 $(document).ready(function () { 4182 $('.webform-submission-add-form.webform-submission-turito-form-form .turitootpsend').click(function(e) { 4183 // Prevent default form submission 4184 e.preventDefault(); 4185 4186 // Validation function 4187 let isValid = true; 4188 4189 // Validate grade select box 4190 const gradeSelect = $('#edit-grade'); 4191 console.log("Grade value: " + gradeSelect.val()); // Debugging log 4192 if (gradeSelect.val() === "" || gradeSelect.val() === null) { 4193 isValid = false; 4194 showError(gradeSelect, "Please select a grade"); 4195 } else { 4196 clearError(gradeSelect); // Clear the error if valid 4197 } 4198 4199 // Validate mobile number (input field) 4200 const mobileInput = $('#edit-user-mobile-number'); 4201 const mobileValue = mobileInput.val().trim(); 4202 console.log("Mobile value: " + mobileValue); // Debugging log 4203 if (mobileValue.length < 10 || mobileValue.length > 12 || !/^\d+$/.test(mobileValue)) { 4204 isValid = false; 4205 showError(mobileInput, "Please enter a valid mobile number (10 to 12 digits)"); 4206 } else { 4207 clearError(mobileInput); // Clear the error if valid 4208 } 4209 4210 4211 4212 4213 // If the form is valid, allow submission (remove preventDefault for actual submission) 4214 if (isValid) { 4215 // Submit the form programmatically 4216 //this.submit(); 4217 //$('.grade-screen').addClass('d-none'); 4218 //$('.otp-screen').removeClass('d-none'); 4219 var formData = $('.webform-submission-add-form.webform-submission-turito-form-form').serialize(); 4220 var url = '/turito-otp-sent'; 4221 // Send AJAX POST request. 4222 $.ajax({ 4223 url: url, 4224 method: 'POST', 4225 data: formData, 4226 success: function(response) { 4227 $('#loader').addClass('d-none'); 4228 4229 if (response.status == "failed") { 4230 // Trigger captcha reload 4231 $('.reload-captcha').trigger('click'); 4232 4233 if (response.error_msg) { 4234 // Remove any existing error message 4235 $(".webform-submission-add-form.webform-submission-turito-form-form .friend-error").remove(); 4236 4237 // Append error message **outside** the .form-floating div, for example below the entire form 4238 $(".webform-submission-add-form.webform-submission-turito-form-form #edit-user-mobile-number") 4239 .closest('.form-floating') 4240 .after('<span class="friend-error" style="color:red;">' + response.error_msg + '</span>'); 4241 } 4242 } else { 4243 // Handle success 4244 $('#registeredMobileNumber').val(response.registered_mobile_number); 4245 $('#loader').addClass('d-none'); 4246 $('.grade-screen').addClass('d-none'); 4247 $('.otp-screen').removeClass('d-none'); 4248 4249 // Start countdown timer 4250 timerCountDown(30); // in seconds 4251 } 4252 } 4253 4254 }); 4255 4256 } 4257 }); 4258 4259// Function to show the error message 4260function showError(inputElement) { 4261 const errorMessage = inputElement.attr('data-webform-required-error'); 4262 4263 // Check if error message already exists to prevent duplication 4264 if (!inputElement.closest('.form-floating.form-group-label').next('.error-message').length) { 4265 const errorDiv = $('<div class="error-message" style="color: red; font-size: 12px;"></div>').text(errorMessage); 4266 inputElement.closest('.form-floating.form-group-label').after(errorDiv); 4267 console.log("Error shown for " + inputElement.attr('name')); // Debugging log 4268 } 4269} 4270 4271// Function to clear the error message 4272function clearError(inputElement) { 4273 const errorDiv = inputElement.closest('.form-floating.form-group-label').next('.error-message'); 4274 if (errorDiv.length) { 4275 errorDiv.remove(); 4276 console.log("Error cleared for " + inputElement.attr('name')); // Debugging log 4277 } 4278} 4279 4280 4281 }); 4282 4283 4284 $('.webform-submission-add-form.webform-submission-turito-form-form .CheckTurito').click(function(e) { 4285 // Prevent the default behavior of the button 4286 e.preventDefault(); 4287 4288 // Serialize form data 4289 var formData = $('.webform-submission-add-form.webform-submission-turito-form-form').serialize(); 4290 var url = '/turito-otp-check'; 4291 4292 // AJAX POST request 4293 $.ajax({ 4294 url: url, 4295 method: 'POST', 4296 data: formData, 4297 success: function(response) { 4298 if (response.status === 'failed') { 4299 $('#failed2 .thankyou-content p').html('<span style="color:red;">
4299' + response.message + '</span>'); 4300 // Show failure message in the #failed2 modal 4301 $('#failed2').modal('show'); 4302 4303 // Optional: Redirect after a delay 4304 setTimeout(function() { 4305 window.location.href = '/turito-e-learning'; // Change this to your redirect URL 4306 }, 3000); 4307 } else if (response.status === 'success') { 4308 // Show success message in the #success_popup modal 4309 $('.thankyou-content .product_msg').html('<span style="color:green;">' + response.message + '</span>'); 4310 $('#success_popup').modal('show'); 4311 4312 // Optional: Redirect after a delay 4313 setTimeout(function() { 4314 window.location.href = '/turito-e-learning'; // Change this to your redirect URL 4315 }, 3000); 4316 } 4317 }, 4318 4319 4320 }); 4321}); 4322 4323 (function ($) { 4324 $(document).ready(function () { 4325 //console.log("Script loaded"); 4326 4327 var path = window.location.pathname; 4328 //console.log("Current path: ", path); 4329 4330 var match = path.match(/\/wifi-plans\/wifi-plans-in-([a-zA-Z-]+)/); 4331 if (match && match[1]) { 4332 var location = match[1].replace(/-/g, ' ').toLowerCase(); 4333 //console.log("Extracted location: ", location); 4334 4335 function selectLocationInDropdown(selectId) { 4336 var selectElement = $(`#${selectId}`); 4337 if (selectElement.length) { 4338 //console.log(`Processing select box with ID: ${selectId}`); 4339 selectElement.find('option').each(function () { 4340 if ($(this).text().trim().toLowerCase() === location) { 4341 //console.log(`Found match: ${$(this).text().trim()}`); 4342 $(this).prop('selected', true); 4343 selectElement.trigger('change'); 4344 return false; 4345 } 4346 }); 4347 } else { 4348 //console.log(`Select box with ID ${selectId} not found.`); 4349 } 4350 } 4351 4352 // Handle the first dropdown 4353 selectLocationInDropdown('edit-field-plan-location-target-id'); 4354 4355 // Wait for the second dropdown to load 4356 var interval = setInterval(function () { 4357 if ($(`#edit-field-product-locations-target-id`).length) { 4358 //console.log("Second dropdown detected."); 4359 selectLocationInDropdown('edit-field-product-locations-target-id'); 4360 clearInterval(interval); // Stop checking once the dropdown is found 4361 } 4362 }, 500); 4363 } else { 4364 //console.log("URL does not match the expected pattern."); 4365 } 4366 }); 4367 })(jQuery); 4368 4369 4370 $(document).ready(function () { 4371 $('.download-brochure .submit-form').click(function (e) { 4372 // Prevent default form submission 4373 e.preventDefault(); 4374 4375 // Clear previous error messages 4376 $(".download-brochure .error-message").remove(); 4377 4378 // Get form field values 4379 var name = $('.download-brochure #name').val(); 4380 var email = $('.download-brochure #email').val(); 4381 var mobile = $('.download-brochure #mobile').val(); 4382 var pincode = $('.download-brochure #pincode').val(); 4383 4384 // Validation Regex 4385 var nameRegex = /^[a-zA-Z\s]+$/; 4386 var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 4387 var phoneRegex = /^[6-9]\d{9}$/; 4388 var pincodeRegex = /^\d{6}$/; 4389 4390 var validation = true; 4391 4392 // Validate Name 4393 if (name === '' || !nameRegex.test(name)) { 4394 $('.download-brochure #name').closest('.col-md-3').append('<span class="error-message text-danger">Please enter a valid email.</span>'); 4395 validation = false; 4396 } 4397 4398 // Validate Email 4399 if (email === '' || !emailRegex.test(email)) { 4400 $('.download-brochure #email').closest('.col-md-3').append('<span class="error-message text-danger">Please enter a valid email.</span>'); 4401 validation = false; 4402 4403 } 4404 4405 // Validate Mobile 4406 if (mobile === '' || !phoneRegex.test(mobile)) { 4407 $('.download-brochure #mobile').closest('.col-md-3').append('<span class="error-message text-danger">Please enter a valid mobile number.</span>'); 4408 validation = false; 4409 4410 } 4411 4412 // Validate Pincode 4413 if (pincode === '' || !pincodeRegex.test(pincode)) { 4414 $('.download-brochure #pincode').closest('.col-md-3').append('<span class="error-message text-danger">
4414Please enter a valid pincode.</span>'); 4415 validation = false; 4416 } 4417 4418 // If validation fails, stop submission 4419 if (!validation) { 4420 return false; 4421 } 4422 4423 // Serialize form data// Extract URL parameters 4424 var urlParams = new URLSearchParams(window.location.search); 4425 var utm_source = urlParams.get('utm_source') || 'Direct'; 4426 var utm_medium = urlParams.get('utm_medium') || ''; 4427 var utm_campaign = urlParams.get('utm_campaign') || 'paid'; 4428 var gclid = urlParams.get('gclid') || ''; 4429 4430 // Prepare data for AJAX request 4431 var formData = { 4432 name: name, 4433 email: email, 4434 mobile: mobile, 4435 pincode: pincode, 4436 utm_source: utm_source, 4437 utm_medium: utm_medium, 4438 utm_campaign: utm_campaign, 4439 gclid: gclid, 4440 };var formData = $('.download-brochure').serialize(); 4441 4442 // AJAX Request 4443 $.ajax({ 4444 url: '/download-brochure-data', 4445 method: 'POST', 4446 data: formData, 4447 success: function (response) { 4448 if (response.status === 'success') { 4449 $('.download-brochure').addClass('d-none'); 4450 $('.download-brochure-thankyou').removeClass('d-none'); 4451 } else { 4452 alert('Something went wrong. Please try again.'); 4453 } 4454 }, 4455 error: function () { 4456 alert('An error occurred. Please try again later.'); 4457 }, 4458 }); 4459 }); 4460 }); 4461 4462 $(document).on('click', '.ResendBtn', function (e) { 4463 e.preventDefault(); // Prevent the default action 4464 4465 var formData = $('.send-otp-form').serialize(); 4466 4467 $.ajax({ 4468 url: '/resend-otp-streamtv', 4469 method: 'POST', 4470 data: formData, 4471 headers: { 4472 'X-CSRF-Token': Drupal.csrfToken, // Use the CSRF token for security. 4473 }, 4474 success: function (response) { 4475 if (response.status === 'success') { 4476 // If successful, show a success message 4477 alert('OTP resent successfully!'); 4478 $('.ResendBtn').css('display', 'none'); 4479 timerCountDown(30); //in sec 4480 4481 } else { 4482 // If there's an error message in the response, display it in the modal 4483 $('#failed').modal('show'); 4484 $('#failed .thankyou-content p').text(response.error_msg || 'An unexpected error occurred.'); 4485 } 4486 }, 4487 error: function (jqXHR) { 4488 // Handle AJAX errors and display them in the modal 4489 var errorMsg = 'An error occurred. Please try again later.'; 4490 if (jqXHR.responseJSON && jqXHR.responseJSON.error_msg) { 4491 errorMsg = jqXHR.responseJSON.error_msg; // Use the error message from the response, if available 4492 } 4493 $('#failed').modal('show'); 4494 $('#failed .thankyou-content p').text(errorMsg); 4495 }, 4496 }); 4497 }); 4498 4499 $(document).on('click', '.TrackReffral', function (e) { 4500 e.preventDefault(); // Prevent the default action 4501 4502 var formData = $('.webform-submission-refer-a-friend-form').serialize(); 4503 4504 $.ajax({ 4505 url: '/get-track-refferal', 4506 method: 'POST', 4507 data: formData, 4508 headers: { 4509 'X-CSRF-Token': Drupal.csrfToken, // Use the CSRF token for security. 4510 }, 4511 success: function (response) { 4512 4513 }, 4514 }); 4515 }); 4516 4517 $(document).on('click', '.OtpResend', function (e) { 4518 e.preventDefault(); // Prevent the default action 4519 4520 var formData = $('.send-otp-form').serialize(); 4521 4522 $.ajax({ 4523 url: '/otp-resend', 4524 method: 'POST', 4525 data: formData, 4526 headers: { 4527 'X-CSRF-Token': Drupal.csrfToken, // Use the CSRF token for security. 4528 }, 4529 success: function (response) { 4530 console.log("1error " + JSON.stringify(response)); 4531 4532 if (response.status === 'success') { 4533 // If successful, show a success message 4534 alert('OTP resent successfully!'); 4535 $('.OtpResend').css('display', 'none'); 4536 timerCountDown(30); // in seconds 4537 } else { 4538 // If there's an error message in the response, display it in the modal 4539 $('#failed').modal('show'); 4540 $('#failed .thankyou-content p').text(response.message || 'An unexpected error occurred.'); 4541 } 4542 }, 4543 error: function (jqXHR) { 4544 console.log('error ' +jqXHR.responseJSON); 4545 // Handle AJAX errors and display them in the modal 4546 var errorMsg = 'An error occurred. Please try again later.'; 4547 if (jqXHR.responseJSON && jqXHR.responseJSON.error_msg) { 4548 errorMsg = jqXHR.responseJSON.error_msg; // Use the error message from the response, if available 4549 } 4550 $('#failed').modal('show'); 4551 $('#failed .thankyou-content p').text(errorMsg); 4552 }, 4553 }); 4554 }); 4555 4556 $(document).ready(function() { 4557 // Get the current URL path 4558 var path = window.location.pathname; 4559 4560 // Extract the location part from the URL
4561 var parts = path.split('/').filter(Boolean); // Split by '/' and filter out empty segments 4562 var location = parts[1] ? parts[1].trim().toLowerCase() : ''; // Check if parts[1] exists 4563 4564 // Proceed only if location is not empty 4565 if (location) { 4566 // Map the location to the select box 4567 var locationFound = false; 4568 $('.changelocationunlimited select[name="field_product_locations_target_id"] option').each(function() { 4569 var optionText = $(this).text().trim().toLowerCase(); // Normalize to lowercase 4570 if (optionText === location) { 4571 $(this).prop('selected', true); 4572 locationFound = true; 4573 return false; // Exit the loop early once matched 4574 } 4575 }); 4576 4577 if (!locationFound) { 4578 // Handle case when location is not found (optional) 4579 // console.log("Location not found in the select options."); 4580 } 4581 4582 // Trigger change event to update the select box 4583 $('.changelocationunlimited select[name="field_product_locations_target_id"]').trigger('change'); 4584 } 4585 4586 // Event listener for change 4587 $(document).on('change', '.changelocationunlimited select[name="field_product_locations_target_id"]', function() { 4588 var selectedText = $(this).find('option:selected').text().trim().toLowerCase(); 4589 // Redirect based on the selected option 4590 window.location.href = '/broadband/' + selectedText + '/unlimited-broadband-plans/'; 4591 }); 4592 }); 4593 4594 $('.multi-range-slider').each(function () { 4595 const slider = $(this); 4596 const track = slider.find('.slider-track'); 4597 const minHandle = slider.find('.min-handle'); 4598 const maxHandle = slider.find('.max-handle'); 4599 const range = slider.find('.slider-range'); 4600 const minValue = parseInt(slider.data('min')); 4601 const maxValue = parseInt(slider.data('max')); 4602 4603 let isDragging = false; 4604 let currentHandle = null; 4605 let minPosition = 0; 4606 let maxPosition = 100; 4607 4608 // Initialize positions 4609 updateHandlePositions(minPosition, maxPosition); 4610 updateValues(); 4611 4612 function updateHandlePositions(min, max) { 4613 minHandle.css('left', min + '%'); 4614 maxHandle.css('left', max + '%'); 4615 range.css({ 4616 'left': min + '%', 4617 'width': (max - min) + '%' 4618 }); 4619 } 4620 4621 function updateValues() { 4622 const minVal = Math.round(minValue + (maxValue - minValue) * (minPosition / 100)); 4623 const maxVal = Math.round(minValue + (maxValue - minValue) * (maxPosition / 100)); 4624 4625 slider.find('.min-value-display').text(minVal.toLocaleString()); 4626 slider.find('.max-value-display').text(maxVal.toLocaleString()); 4627 slider.find('.min-value').val(minVal); 4628 slider.find('.max-value').val(maxVal); 4629 } 4630 4631 function getPosition(e) { 4632 const rect = track[0].getBoundingClientRect(); 4633 const x = e.clientX - rect.left; 4634 let percentage = (x / track.width()) * 100; 4635 return Math.min(Math.max(percentage, 0), 100); 4636 } 4637 4638 // Handle events 4639 slider.find('.slider-handle').on('mousedown', function (e) { 4640 isDragging = true; 4641 currentHandle = $(this); 4642 $(document).on('mousemove', onMouseMove); 4643 $(document).on('mouseup', onMouseUp); 4644 }); 4645 4646 function onMouseMove(e) { 4647 if (!isDragging) return; 4648 4649 const newPosition = getPosition(e); 4650 4651 if (currentHandle.hasClass('min-handle')) { 4652 if (newPosition >= maxPosition) return; 4653 minPosition = newPosition; 4654 } else { 4655 if (newPosition <= minPosition) return; 4656 maxPosition = newPosition; 4657 } 4658 4659 updateHandlePositions(minPosition, maxPosition); 4660 updateValues(); 4661 } 4662 4663 function onMouseUp() { 4664 isDragging = false; 4665 currentHandle = null; 4666 $(document).off('mousemove', onMouseMove); 4667 $(document).off('mouseup', onMouseUp); 4668 } 4669 4670 // Handle resize 4671 $(window).on('resize', function () { 4672 updateHandlePositions(minPosition, maxPosition); 4673 }); 4674 }); 4675 4676 $(document).on('click', '.pricerangefilter', function (e) { 4677 e.preventDefault(); // Prevent the default action 4678 var minvalue = $('input[name="min_price"]').val(); 4679 var maxvalue = $('input[name="max_price"]').val(); 4680 $('input[name="field_product_price_range[min]"]').val(minvalue); 4681 $('input[name="field_product_price_range[max]"]').val(maxvalue); 4682 $('input[name="field_product_price_range[max]"]').trigger("keyup"); 4683 }); 4684 4685 $(document).on('click', '.speedrangefilter', function (e) { 4686 e.preventDefault(); // Prevent the default action 4687 var minvalue = $('input[name="min_quantity"]').val(); 4688 var maxvalue = $('input[name="max_quantity"]').val(); 4689 $('input[name="field_plan_speed_to_range[min]"]').val(minvalue); 4690 $('input[name="field_plan_speed_to_range[max]"]').val(maxvalue); 4691 $('input[name="field_plan_speed_to_range[max]"]').trigger("keyup"); 4692 }); 4693 4694
4695// for new explore plan journey date 22-09-25 sagar DOkhe 4696 4697 $('#exploreorderSummaryForm #explore-order-summary-submit').on("click", function(e) { 4698 // Prevent normal form submit 4699 e.preventDefault(); 4700 4701 console.log('explore in submit method'); 4702 4703 // Show loader 4704 $('#loader').show(); 4705 4706 // Serialize form data 4707 var formData = $('#exploreorderSummaryForm').serialize(); 4708 4709 // AJAX check URL for explore summary 4710 var url = '/check-order-explore-summary'; 4711 4712 // Get current hostname 4713 const getUrl = window.location.href; 4714 const domain = new URL(getUrl).hostname; 4715 4716 // Live vs UAT 4717 const isLiveSite = domain === 'actcorp.in' || domain === 'www.actcorp.in'; 4718 const updatedUrl = isLiveSite 4719 ? 'https://selfcare.actcorp.in/payments/website?authKey=' 4720 : 'https://uatselfcare.actcorp.in/payments/website?authKey='; 4721 4722 // Send AJAX 4723 $.ajax({ 4724 url: url, 4725 method: 'POST', 4726 data: formData, 4727 success: function(response) { 4728 $('#loader').hide(); 4729 if (response.status === "error") { 4730 // Show error modal 4731 $('#failed2 .modal
4731-body .thankyou-content').html( 4732 '<p class="fontSize-14 semibold">' + response.message + '</p>' 4733 ); 4734 $('#failed2').modal('show'); 4735 } else { 4736 if (response.key) { 4737 // Redirect to payment URL 4738 window.location.href = updatedUrl + response.key; 4739 } else { 4740 // Show thank you modal 4741 $('#thankYou2').modal('show'); 4742 setTimeout(function() { 4743 $('#thankYou2').modal('hide'); 4744 window.location.href = '/explore-all-plans'; 4745 }, 5000); 4746 } 4747 } 4748 }, 4749 error: function() { 4750 $('#loader').hide(); 4751 $('#failed2 .modal-body .thankyou-content').html( 4752 '<p class="fontSize-14 semibold">An error occurred while processing your request. Please try again later.</p>' 4753 ); 4754 $('#failed2').modal('show'); 4755 } 4756 }); 4757 }); 4758 // end the code for journy 4759 4760 4761}(jQuery, Drupal, once));
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.