src/GlobalBundle/Resources/views/layouts/scripts-no-auth.html.twig line 1

Open in your IDE?
  1. <!-- scripts -->
  2. {# {% set CDN_URL = app_CDN_url() %} #}
  3. {% set CDN_URL = 'https://d2577j2dd5wuk.cloudfront.net' %}
  4. {% set currentSite = currentSite is defined ? currentSite : app_current_site() %}
  5. {% if skipDuplicateMainJs is defined and skipDuplicateMainJs %}
  6.     {# scripts.html.twig was already included and rendered on this page; drop what it
  7.        already printed so our own render below only adds the files unique to this file #}
  8.     {% do pimcore_head_script().getContainer().exchangeArray([]) %}
  9. {% endif %}
  10. {% if skipDuplicateMainJs is not defined or not skipDuplicateMainJs %}
  11.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/jquery.min.js')) %}
  12.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/popper.min.js')) %}
  13.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/bootstrap.min.js')) %}
  14.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/select2.min.js')) %}
  15.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/moment.min.js')) %}
  16.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/daterangepicker.min.js')) %}
  17.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/jquery.validate.min.js')) %}
  18.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/lighbox.js')) %}
  19.     {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/functions.js')) %}
  20.     {# {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/main.js')) %} #}
  21.     {% do pimcore_head_script().appendFile(asset('bundles/global/js/main.js')) %}
  22. {% endif %}
  23. {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/aos.js')) %}
  24. {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/examwizard.js')) %}
  25. {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/country/intlTelInput.js')) %}
  26. {# {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/TweenMax.min.js')) %}
  27. {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/wheel-indicator.js')) %}
  28. {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/ScrollToPlugin.min.js')) %}
  29. {% do pimcore_head_script().appendFile(asset(CDN_URL~'/assets/JS/script.js')) %} #}
  30. {# output scripts added before #}
  31. {% block headscripts deferred %}
  32.     {{ pimcore_head_script() }}
  33. {% endblock %}
  34. {% if 'salescampaign' in app.request.pathinfo %}
  35.     {% if isVerified == 0 %}
  36.     <script>
  37.         $(window).on('load', function() {
  38.             $('#leadForm').modal('show');
  39.         });
  40.         $('#leadForm').modal({
  41.             backdrop: 'static',
  42.             keyboard: false
  43.         });
  44.     </script>
  45.     {% endif %}
  46. {% endif %}
  47. {% if not is_granted('IS_AUTHENTICATED_REMEMBERED') and app.request.pathinfo == '/home' %}
  48.     <script type="text/javascript">
  49.         $(window).on('load', function() {
  50.             $('#login').modal('show');
  51.         });
  52.     </script>
  53. {% endif %}
  54. <script type="text/javascript">
  55.     $("#jquery-intl-phone").intlTelInput({});
  56.     $("#jquery-intl-phone-access").intlTelInput({});
  57.     $("#jquery-intl-phone-manufacture").intlTelInput({});
  58.     function pushGtmAuthEvent(eventName, payload) {
  59.         window.dataLayer = window.dataLayer || [];
  60.         var data = {
  61.             event: eventName,
  62.             method: 'onsite'
  63.         };
  64.         payload = payload || {};
  65.         for (var key in payload) {
  66.             if (Object.prototype.hasOwnProperty.call(payload, key) && payload[key] !== undefined && payload[key] !== null && payload[key] !== '') {
  67.                 data[key] = payload[key];
  68.             }
  69.         }
  70.         window.dataLayer.push(data);
  71.     }
  72.     function getValidationErrorReason(errorData) {
  73.         if (!errorData) {
  74.             return 'Validation Error';
  75.         }
  76.         if (typeof errorData === 'string') {
  77.             return errorData;
  78.         }
  79.         var reasons = [];
  80.         for (var key in errorData) {
  81.             if (Object.prototype.hasOwnProperty.call(errorData, key) && errorData[key]) {
  82.                 reasons.push(key + ': ' + errorData[key]);
  83.             }
  84.         }
  85.         return reasons.length ? reasons.join(', ') : 'Validation Error';
  86.     }
  87.     function getAuthUserId(data) {
  88.         return data && (data.userId || data.user_id || data['user-id']) ? (data.userId || data.user_id || data['user-id']) : '';
  89.     }
  90.     $(document).on('submit', 'form', function() {
  91.         if ($(this).find('#_username').length && $(this).find('#_password').length) {
  92.             pushGtmAuthEvent('user-login-submit');
  93.         }
  94.     });
  95.     {% set gtmLoginFailReason = app.session.get('gtm_login_fail_reason') %}
  96.     {% if app.request.get('errorFlag') == '1' or gtmLoginFailReason %}
  97.         pushGtmAuthEvent('user-login-fail', {
  98.             'validation-error': '{{ app.request.get('errorType')|default(gtmLoginFailReason|default('Login Failed'))|e('js') }}'
  99.         });
  100.         {% do app.session.remove('gtm_login_fail_reason') %}
  101.     {% endif %}
  102.     
  103.     $('.country-dropdown-select2').each(function () {
  104.         console.log("Initializing select2 for country dropdown");
  105.         $(this).select2({
  106.             placeholder: 'Select Country *',
  107.             dropdownParent: $(this).parent(),
  108.         });
  109.          $(this).on('change', function() {
  110.         var selectedCountry = $(this).val();
  111.         console.log("Country changed to: " + selectedCountry);
  112.      });
  113.     });
  114.     // examwizard
  115.     var examWizard = $.fn.examWizard({
  116.             nextOption: {        
  117.                 callBack: function(){
  118.                     $("#prev-screen").hide();
  119.                     $("#back-to-prev-question").show();
  120.                     
  121.                     if($("#current-question-number-label").text()=="5"){
  122.                         if ($("#signupAgreeMf").is(":checked")) {
  123.                             $("#finishExams").removeClass('disabled');
  124.                             $("#finishExams").show();
  125.                         }else{
  126.                             $("#finishExams").show();
  127.                             $("#finishExams").addClass('disabled');
  128.                         }
  129.                         $("#go-to-next-question").hide();
  130.                     } else {
  131.                         $("#finishExams").hide();
  132.                         $("#go-to-next-question").show();
  133.                     }
  134.                 }
  135.             },
  136.             prevOption: {     
  137.                 callBack: function(){
  138.                     $("#finishExams").hide(); 
  139.                     $("#go-to-next-question").show();  
  140.                     if($("#current-question-number-label").text()=="1"){
  141.                         $("#back-to-prev-question").hide();
  142.                         $("#prev-screen").show();
  143.                     } else {
  144.                         $("#back-to-prev-question").show();
  145.                         $("#prev-screen").hide();
  146.                     }
  147.                 }
  148.             }
  149.         });
  150.         
  151.     $('#signupAgree').change(function(){
  152.         if(this.checked) {
  153.         $("#signupDone").removeClass('disabled');
  154.         }else{
  155.         $("#signupDone").addClass('disabled');
  156.         }
  157.     });
  158.     $('#signupAgreeMf').change(function(){
  159.         if(this.checked) {
  160.         $("#finishExams").removeClass('disabled');
  161.         }else{
  162.         $("#finishExams").addClass('disabled');
  163.         }
  164.     });
  165.     $('input[name=SignupType]').click(function(){
  166.       //alert('on click type');
  167.       var value = $(this).val();
  168.       $('#customer-selection').hide();
  169.       
  170.       $('#signupCustTypes').prop('selectedIndex', 0).change();
  171.       $('#signupSupplierTypes').prop('selectedIndex', 0).change();
  172.       $('#signupSupplierTypesMf').prop('selectedIndex', 0).change();
  173.       
  174.       if(value == 'distributor'){
  175.           $('#typeSignup').val('S');
  176.           $('#frmSignup').show();
  177.           $('#signupSupplierTypes + span').show();
  178.           $('#signupCustTypes + span').hide();
  179.       }else{
  180.           $('#typeSignup').val('C');
  181.           $('#frmSignup').show();
  182.       $('#signupCustTypes + span').show();
  183.       $('#signupSupplierTypes + span').hide();
  184.       }
  185.     });
  186.     
  187.     $('#signupSupplierTypes').change(function(){
  188.       //alert('on click type');
  189.       var value = $(this).val();
  190.       //alert(value);
  191.     //   if(value == 'M'){
  192.     //       $('#manufacturer').show();
  193.     //       $('#frmSignup').hide();
  194.     //       $('#signupSupplierTypesMf').prop('selectedIndex', 2).change();
  195.     //   }else{
  196.           $('#frmSignup').show();
  197.           $('#manufacturer').hide();
  198.     //   }
  199.     });
  200.     
  201.     $('#signupSupplierTypesMf').change(function(){
  202.       //alert('on click type');
  203.       var value = $(this).val();
  204.       //alert(value);
  205.     //   if(value == 'M'){
  206.     //       $('#manufacturer').show();
  207.     //       $('#frmSignup').hide();
  208.     //   }else{
  209.           $('#frmSignup').show();
  210.           $('#manufacturer').hide();
  211.           if(value == 'D'){
  212.             $('#signupSupplierTypes').prop('selectedIndex', 1).change();
  213.           }else if(value == 'S'){
  214.                       //alert('select stylist');
  215.             $('#signupSupplierTypes').prop('selectedIndex', 3).change();
  216.           }else{
  217.             $('#signupSupplierTypes').prop('selectedIndex', 0).change();
  218.           }
  219.     //   }
  220.     });
  221.     
  222.     
  223.     
  224.     
  225.     $('#signupPrevious').click(function(){
  226.       //alert('on click type');
  227.       $('#customer-selection').show();
  228.       $('#frmSignup').hide();
  229.     });
  230.     
  231.     $('#prev-screen').click(function(){
  232.       //alert('on click type');
  233.       $('#customer-selection').show();
  234.       $('#manufacturer').hide();
  235.     });
  236.     
  237.     jQuery.validator.addMethod("validateURL", function (value, element) {
  238.         var regExp = new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/);
  239.         return this.optional(element) || regExp.test(value);
  240.     }, "Invalid URL");
  241.     window.history.replaceState(null, null, window.location.pathname);
  242.     var validationRules = {
  243.         // Specify validation rules
  244.         errorElement: 'span',
  245.         errorClass: 'error-msg',
  246.         rules: {
  247.             firstName: {
  248.                 required: true,
  249.                 // noSpace: true
  250.             },
  251.             lastName: {
  252.                 required: true,
  253.                 // noSpace: true
  254.             },
  255.             email: {
  256.                 required: true,
  257.                 ValidEmail: true,
  258.                 email: true,
  259.                 noSpace: true
  260.             },
  261.             jobRole: {
  262.                 required: true,
  263.                 //minlength : 3,
  264.             },
  265.             companyType: {
  266.                 required: true,
  267.                 //minlength : 3,
  268.             },
  269.             companySize: {
  270.                 required: true,
  271.                 //minlength : 3,
  272.             },
  273.             companyName: {
  274.                 required: true,
  275.                 noSpace: true
  276.             },
  277.             password:{
  278.                 required: true,
  279.                 noSpace: true,
  280.             },
  281.             ConfirmPassword:{
  282.                 required: true,
  283.                 noSpace: true,
  284.                 equalTo: "#password"
  285.             },
  286.                         
  287.         },
  288.         // Specify validation error messages
  289.         messages: {
  290.             firstName: {
  291.                 required: 'Required',
  292.                 maxlength: "Max 50",
  293.                 // noSpace: 'Required'
  294.             },
  295.             lastName: {
  296.                 required: 'Required',
  297.                 maxlength: "Max 50",
  298.                 // noSpace: 'Required'
  299.             },
  300.             email: {
  301.                 required: 'Required',
  302.                 email: 'Not valid',
  303.                 ValidEmail: 'Not valid`',
  304.                 noSpace: 'Required'
  305.             },
  306.             jobRole: {
  307.                 required: 'Required',
  308.             },
  309.             companyType: {
  310.                 required: 'Required',
  311.             },
  312.             companySize: {
  313.                 required: 'Required',
  314.             },
  315.             companyName: {
  316.                 required: 'Required',
  317.                 noSpace: 'Required'
  318.             },
  319.             password: {
  320.                 required: 'Required',
  321.                 noSpace: 'Required'
  322.             },
  323.             ConfirmPassword: {
  324.                 required: 'Required',
  325.                 noSpace: 'Required',
  326.                 equalTo: "Password not Matched"
  327.             }
  328.         },
  329.         errorPlacement: function (error, element) {
  330.             error.insertAfter(element);
  331.         }
  332.     };
  333.     $('#pimcore_editable_landing_bookdemo').click(function (e) {
  334.         $('select').prop('selectedIndex', 0).change();
  335.         $("#email-error, #companySize-error, #lastName-error,#firstName-error,#companyType-error,#jobRole-error,#companyName-error").html("");
  336.     });
  337.     $('#close-btn').click(function (e) {
  338.         $("#frmBookDemo").get(0).reset();
  339.         $('select').prop('selectedIndex', 0).change();
  340.         $('#companyType').prop('selectedIndex', 0).change();
  341.         $("#bookAdemo_success").hide();
  342.         $("#bookAdemo_normal").show();
  343.         $('#frmBookDemo').validate(validationRules).reset();
  344.         $("#email-error, #companySize-error, #lastName-error,#firstName-error,#companyType-error,#jobRole-error,#companyName-error").html("");        
  345.     });
  346.     
  347.     $("#signupPrevious").click(function (e) {
  348.         $('select').prop('selectedIndex', 0).change();
  349.         $("#signupDone").addClass('disabled');
  350.         $("#finishExams").addClass('disabled');
  351.         $('#signupCustTypes').prop('selectedIndex', 0).change();
  352.         $('#signupSupplierTypes').prop('selectedIndex', 0).change();
  353.         $('#signupSupplierTypesMf').prop('selectedIndex', 0).change();
  354.         document.getElementById("customer-selection").reset();
  355.         document.getElementById("frmSignup").reset();
  356.         document.getElementById("examwizard-question").reset();
  357.         $("#frmSignup").hide();
  358.         $("#manufacturer").hide();      
  359.         for (let el of document.querySelectorAll('span.error-msg')) el.style.display = 'none';
  360.         document.querySelector('.file-upload-label').textContent = "Please attach your portfolio";
  361.           $('.remove-file').removeClass('attached');
  362.           const fileInput = document.querySelector('#portfolio-upload');
  363.           fileInput.value="";
  364.         
  365.     });
  366.     $("#prev-screen").click(function (e) {
  367.         $('select').prop('selectedIndex', 0).change();
  368.         $("#signupDone").addClass('disabled');
  369.         $("#finishExams").addClass('disabled');
  370.         $('#signupCustTypes').prop('selectedIndex', 0).change();
  371.         $('#signupSupplierTypes').prop('selectedIndex', 0).change();
  372.         $('#signupSupplierTypesMf').prop('selectedIndex', 0).change();
  373.         document.getElementById("customer-selection").reset();
  374.         document.getElementById("frmSignup").reset();
  375.         document.getElementById("examwizard-question").reset();
  376.         $("#frmSignup").hide();
  377.         $("#manufacturer").hide();      
  378.         for (let el of document.querySelectorAll('span.error-msg')) el.style.display = 'none';
  379.         document.querySelector('.file-upload-label').textContent = "Please attach your portfolio";
  380.           $('.remove-file').removeClass('attached');
  381.           const fileInput = document.querySelector('#portfolio-upload');
  382.           fileInput.value="";
  383.         
  384.     });
  385.     $('#close-btn-signup').click(function (e) {
  386.         $("#signup_success").hide();
  387.         $("#currentQuestionNumber").val(1);
  388.         $('select').prop('selectedIndex', 0).change();
  389.         $('#signupCustTypes').prop('selectedIndex', 0).change();
  390.         $('#signupSupplierTypes').prop('selectedIndex', 0).change();
  391.         $('#signupSupplierTypesMf').prop('selectedIndex', 0).change();
  392.         $("#current-question-number-label").text('1');
  393.         var count=0;
  394.         for (let el of document.querySelectorAll('div.question')){
  395.             el.classList.remove("hidden");
  396.             if(count != 0){
  397.             el.classList.add("hidden");
  398.             }
  399.             count++;
  400.         }
  401.         $("#go-to-next-question").removeClass('disabled');
  402.         $("#go-to-next-question").show();
  403.         $("#finishExams").hide();
  404.         $("#frmSignup").hide();
  405.         $("#manufacturer").hide();        
  406.                 $("#customer-selection").show();
  407.         document.getElementById("customer-selection").reset();
  408.         document.getElementById("frmSignup").reset();
  409.         document.getElementById("examwizard-question").reset();
  410.         $("#signupDone").addClass('disabled');
  411.         $("#finishExams").addClass('disabled');
  412.         for (let el of document.querySelectorAll('span.error-msg')) el.style.visibility = 'hidden';
  413.         $("#signup_form").show();
  414.                 
  415.     });
  416.     $('#close-btn-signup-form').click(function (e) {
  417.         $("#signup_success").hide();
  418.         // $("#currentQuestionNumber").val(1);
  419.         // $('select').prop('selectedIndex', 0).change();
  420.         // $('#signupCustTypes').prop('selectedIndex', 0).change();
  421.         // $('#signupSupplierTypes').prop('selectedIndex', 0).change();
  422.         // $('#signupSupplierTypesMf').prop('selectedIndex', 0).change();
  423.         // $("#current-question-number-label").text('1');
  424.         // var count=0;
  425.         // for (let el of document.querySelectorAll('div.question')){
  426.         //     el.classList.remove("hidden");
  427.         //     if(count != 0){
  428.         //     el.classList.add("hidden");
  429.         //     }
  430.         //     count++;
  431.         // }
  432.         // $("#go-to-next-question").removeClass('disabled');
  433.         // $("#go-to-next-question").show();
  434.         // $("#finishExams").hide();
  435.         // $("#frmSignup").hide();
  436.         // $("#manufacturer").hide();        
  437.         //         $("#customer-selection").show();
  438.         // document.getElementById("customer-selection").reset();
  439.         document.getElementById("frmSignup").reset();
  440.         $("#frmSignup").show();
  441.         $(".modal-header").show();
  442.         // document.getElementById("examwizard-question").reset();
  443.         $("#signupDone").addClass('disabled');
  444.         // $("#finishExams").addClass('disabled');
  445.         // for (let el of document.querySelectorAll('span.error-msg')) el.style.visibility = 'hidden';
  446.         // $("#signup_form").show();
  447.                 
  448.     });
  449.     var validationRulesContact = {
  450.         // Specify validation rules
  451.         errorElement: 'span',
  452.         errorClass: 'error-msg',
  453.         rules: {
  454.             contactName: {
  455.                 required: true,
  456.                 noSpace: false
  457.             },
  458.             contactEmail: {
  459.                 required: true,
  460.                 ValidEmail: true,
  461.                 email: true,
  462.                 noSpace: true
  463.             }
  464.         },
  465.         // Specify validation error messages
  466.         messages: {
  467.             contactName: {
  468.                 required: 'Required',
  469.                 noSpace: 'Required',
  470.                 maxlength: "Max 50",
  471.             },
  472.             contactEmail: {
  473.                 required: 'Required',
  474.                 email: "Not valid",
  475.                 ValidEmail: 'Not valid'
  476.             }
  477.         },
  478.         errorPlacement: function (error, element) {
  479.             error.insertAfter(element);
  480.         }
  481.     };
  482.     
  483.     var validationRulesSignup = {
  484.         // Specify validation rules
  485.         errorElement: 'span',
  486.         errorClass: 'error-msg',
  487.         rules: {
  488.             firstName: {
  489.                 required: true,
  490.                 // noSpace: true
  491.             },
  492.             companyName: {
  493.                 required: true,
  494.                 //noSpace: true
  495.             },        
  496.             customerType: {
  497.                 required: true,
  498.             },        
  499.             email: {
  500.                 required: true,
  501.                 ValidEmail: true,
  502.                 email: true,
  503.                 noSpace: true
  504.             },
  505.             /*contactNumber:{
  506.                 required: true,
  507.                 noSpace: true
  508.             },*/
  509.             password:{
  510.                 required: true,
  511.                 noSpace: true,
  512.             },
  513.             ConfirmPassword:{
  514.                 required: true,
  515.                 noSpace: true,
  516.                 equalTo: "#password"
  517.             },
  518.             countryName:{
  519.                 required: true,
  520.             },
  521.             website:{
  522.                 validateURL: true,
  523.                 required: false,
  524.             }
  525.         },
  526.         // Specify validation error messages
  527.         messages: {
  528.             firstName: {
  529.                 required: 'Required',
  530.                 // noSpace: 'Required',
  531.                 maxlength: "Max 50",
  532.             },
  533.             companyName: {
  534.                 required: 'Required',
  535.                 //noSpace: 'Required',
  536.                 maxlength: "Max 50",
  537.             },
  538.             customerType: {
  539.                 required: 'Required'
  540.             },
  541.             email: {
  542.                 required: 'Required',
  543.                 email: "Not valid",
  544.                 ValidEmail: 'Not valid'
  545.             },
  546.             /*contactNumber: {
  547.                 required: 'Required',
  548.                 noSpace: 'Required'
  549.             },*/
  550.             password: {
  551.                 required: 'Required',
  552.                 noSpace: 'Required'
  553.             },
  554.             ConfirmPassword: {
  555.                 required: 'Required',
  556.                 noSpace: 'Required',
  557.                 equalTo: "Password not Matched"
  558.             },
  559.             countryName:{
  560.                 required: 'Required',
  561.             }
  562.         },
  563.         errorPlacement: function (error, element) {
  564.             error.insertAfter(element);
  565.         }
  566.     };
  567.     
  568.     var validationRulesSignupMf = {
  569.         // Specify validation rules
  570.         errorElement: 'span',
  571.         errorClass: 'error-msg',
  572.         rules: {
  573.             signupFirstNameMf: {
  574.                 required: true,
  575.                 // noSpace: true
  576.             },            
  577.             signupCompanyNameMf: {
  578.                 required: true,
  579.                 //noSpace: true
  580.             },            
  581.             signupEmailMf: {
  582.                 required: true,
  583.                 ValidEmail: true,
  584.                 email: true,
  585.                 noSpace: true
  586.             },            
  587.             contactNumbermanufacture: {
  588.                 required: true,
  589.                 noSpace: true
  590.             }
  591.         },
  592.         // Specify validation error messages
  593.         messages: {
  594.             signupFirstNameMf: {
  595.                 required: 'Required',
  596.                 // noSpace: 'Required'
  597.             },
  598.            signupCompanyNameMf: {
  599.                 required: 'Required',
  600.                 //noSpace: 'Required'
  601.             },
  602.             signupEmailMf: {
  603.                 required: 'Required',
  604.                 email: "Not valid",
  605.                 ValidEmail: 'Not valid'
  606.             },
  607.             contactNumbermanufacture: {
  608.                 required: 'Required',
  609.                 noSpace: 'Required'
  610.             }
  611.         },
  612.         errorPlacement: function (error, element) {
  613.             error.insertAfter(element);
  614.         }
  615.     };
  616.     var validationRulesSC = {
  617.         // Specify validation rules
  618.         errorElement: 'span',
  619.         errorClass: 'error-msg',
  620.         rules: {
  621.             SCFirstName: {
  622.                 required: true,
  623.                 // noSpace: true
  624.             },
  625.             SCLastName: {
  626.                 required: true,
  627.                 // noSpace: true
  628.             },
  629.             SCphone: {
  630.                 required: true,
  631.                 noSpace: true
  632.             },
  633.             SCemail: {
  634.                 required: true,
  635.                 ValidEmail: true,
  636.                 email: true,
  637.                 noSpace: true
  638.             },
  639.             SCaccessCode: {
  640.                 required: true,
  641.                 noSpace: true
  642.             }
  643.         },
  644.         // Specify validation error messages
  645.         messages: {
  646.             SCFirstName: {
  647.                 required: 'Required',
  648.                 // noSpace: 'Required'
  649.             },
  650.             SCLastName: {
  651.                 required: 'Required',
  652.                 // noSpace: 'Required'
  653.             },
  654.             SCphone: {
  655.                 required: 'Required',
  656.                 noSpace: 'Required'
  657.             },
  658.             SCemail: {
  659.                 required: 'Required',
  660.                 email: "Not valid",
  661.                 ValidEmail: 'Not valid'
  662.             },
  663.             SCaccessCode: {
  664.                 required: 'Required',
  665.                 noSpace: 'Required'
  666.             }
  667.         },
  668.         errorPlacement: function (error, element) {
  669.             error.insertAfter(element);
  670.         }
  671.     };
  672.     
  673.     $(function () {
  674.         //alert('test');
  675.         jQuery.validator.addMethod("ValidEmail", function (value, element) {
  676.             var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  677.             return regex.test(value);
  678.         });
  679.         jQuery.validator.addMethod("noSpace", function (value, element) {
  680.             return value.indexOf(" ") < 0 && value != "";
  681.         });
  682.         $('#frmBookDemo').validate(validationRules);
  683.         //alert('before submit');
  684.         $('#frmBookDemo').submit(function (event) {
  685.             //submit form with ajax - start
  686.             var firstName = $("#firstName").val();
  687.             var lastName = $("#lastName").val();
  688.             var email = $("#email").val();
  689.             var jobRole = $("#jobRole").val();
  690.             var companyType = $("#companyType").val();
  691.             var companySize = $("#companySize").val();
  692.             var companyName = $("#companyName").val();
  693.             // stop the form from submitting the normal way and refreshing the page
  694.             event.preventDefault();
  695.             if ($('#frmBookDemo').valid()) {
  696.                 $.ajax({
  697.                     type: "POST",
  698.                     url: "/booking",
  699.                     data: "firstName=" + firstName + "&lastName=" + lastName + "&email=" + email + "&jobRole=" + jobRole + "&companyType=" + companyType + "&companySize=" + companySize + "&companyName=" + companyName + "&submitAction=bookAdemo",
  700.                     success: function (data) {
  701.                     
  702.                         if (data == 'success') {
  703.                             $("#bookAdemo_success").show();
  704.                             $("#bookAdemo_normal").hide();
  705.                         } else {
  706.                             $("#bookAdemo_error").show();
  707.                         }
  708.                     }
  709.                 });
  710.                 //alert('ajax end');
  711.             }
  712.         });
  713.         
  714.         
  715.         $('#frmSignup').validate(validationRulesSignup);
  716.         $('#frmSignup').submit(function (event) {
  717.                 event.preventDefault();
  718.                 var firstName = $("#signupFirstName").val();
  719.                 var email = $("#signupEmail").val();
  720.                 var companyName = $("#signupCompanyName").val();
  721.                 var lastName = $("#signupLastName").val();
  722.                 var phoneCode = $("#jquery-intl-phone").val() ?? "";
  723.                 var phone = $("#signupContactNumber").val() ?? "";
  724.                 var password = $("#password").val();
  725.                 //var signupSupplierTypes = $('input[name="signupSupplierTypes"]:selectedIndex').val();
  726.                 var signupSupplierType = $('#signupSupplierTypes option:selected').val();
  727.                 var signupCustType = $('#signupCustTypes').find(":selected").text();
  728.                 //var type = $('input[name="type"]:checked').val();
  729.                 // var type = $("#customerType").val();
  730.                 var type = $('#customerType').val();
  731.                 //var country = $('#signupCountry').val();
  732.                 var website = $('#signupWebsite').val();
  733.                 var country = $('#signupCountry').select2('val');
  734.                 
  735.                 if(type == 'R'){
  736.                     var actionurl = '/customerSignup';
  737.                 }else{
  738.                     var actionurl = '/supplierSignup';
  739.                 }
  740.                 signupSupplierType  = type;
  741.                 signupCustType      = type;
  742.                // event.preventDefault();
  743.                 if ($('#frmSignup').valid()) {
  744.                     // reCAPTCHA is mandatory when it is configured on the page
  745.                     var recaptchaToken = "";
  746.                     if ($('#frmSignup').find('.g-recaptcha').length) {
  747.                         recaptchaToken = $('#frmSignup').find('[name="g-recaptcha-response"]').val() || "";
  748.                         if (recaptchaToken === "") {
  749.                             $('#signupRecaptcha-error').text('Please confirm you are not a robot').show();
  750.                             return false;
  751.                         }
  752.                         $('#signupRecaptcha-error').hide();
  753.                     }
  754.                     pushGtmAuthEvent('user-signup-submit');
  755.                     $('#signupMismatchData-error').remove();
  756.                     $.ajax({
  757.                         type: "POST",
  758.                         url: actionurl,
  759.                         data: "firstName=" + firstName + "&lastName="+lastName+"&email=" + email + "&companyName=" + companyName + "&supplierType=" + signupSupplierType + "&custType=" + signupCustType + "&password=" + password + "&country=" + country + "&website=" + website + "&phoneCode=" + phoneCode + "&phone=" + phone + "&g-recaptcha-response=" + encodeURIComponent(recaptchaToken),
  760.                         success: function (data) {
  761.                             data = JSON.parse(data);
  762.                             if (data.status == 'success') {
  763.                                 pushGtmAuthEvent('user-signup-success', {
  764.                                     'user-id': getAuthUserId(data)
  765.                                 });
  766.                                 $.ajax({
  767.                                     type: "POST",
  768.                                     url: '/signupEmails',
  769.                                     data: "firstName=" + firstName + "&lastName="+lastName+"&email=" + email + "&companyName=" + companyName + "&supplierType=" + signupSupplierType + "&custType=" + signupCustType + "&password=" + password + "&country=" + country + "&website=" + website + "&phoneCode=" + phoneCode + "&phone=" + phone,
  770.                                     success: function (data) {
  771.                                             data = JSON.parse(data);
  772.                                             if (data.status == 'success') {
  773.                                                 // console.log("hii");
  774.                                             }
  775.                                         }
  776.                                 });
  777.                                 if(type != 'R'){
  778.                                     signupCustType =    "Supplier";
  779.                                     actionurl      =    '/customerSignup';
  780.                                     $.ajax({
  781.                                     type: "POST",
  782.                                     url: actionurl,
  783.                                     data: "firstName=" + firstName + "&lastName="+lastName+"&email=" + email + "&companyName=" + companyName + "&supplierType=" + signupSupplierType + "&custType=" + signupCustType + "&password=" + password + "&country=" + country + "&website=" + website + "&phoneCode=" + phoneCode + "&phone=" + phone,
  784.                                     success: function (data) {
  785.                                             data = JSON.parse(data);
  786.                                             if (data.status == 'success') {
  787.                                                 // console.log("hii");
  788.                                             }
  789.                                         }
  790.                                     });
  791.                                 }
  792.                                 $("#signupCountry").val("").trigger("change");
  793.                                 $("#frmSignup").hide();
  794.                                 $(".modal-header").hide();
  795.                                 $("#signup_success").show();
  796.                                 $('#signupMismatchData-error').remove();
  797.                                 
  798.                             } else {
  799.                                 var error = data.errorData;
  800.                                 pushGtmAuthEvent('user-signup-fail', {
  801.                                     'validation-error': getValidationErrorReason(error)
  802.                                 });
  803.                                 //alert(error.companyName);
  804.                                 //alert(error.email);
  805.                                 if(error.email){
  806.                                     $('<span id="signupEmail-error" class="error-msg">'+error.email+'</span>').insertAfter("#signupEmail");
  807.                                 }
  808.                                 if(error.companyName){
  809.                                     $('<span id="signupCompanyName-error" class="error-msg">'+error.companyName+'</span>').insertAfter("#signupCompanyName");                                
  810.                                 }
  811.                                 if(error.signupContactNumber){
  812.                                     $('<span id="signupContactNumber-error" class="error-msg">'+error.signupContactNumber+'</span>').insertAfter("#signupContactNumber");                                
  813.                                 }
  814.                                 if(error.mismatchData){
  815.                                     $('<span id="signupMismatchData-error" class="error-msg" style="right: 145px;">'+error.mismatchData+'</span>').insertAfter(".modal-header");
  816.                                 }
  817.                                 if(error.recaptcha){
  818.                                     $('#signupRecaptcha-error').text(error.recaptcha).show();
  819.                                 }
  820.                                 // a token is single use at Google, so the widget
  821.                                 // must be reset before the customer tries again
  822.                                 if (window.grecaptcha && $('#frmSignup').find('.g-recaptcha').length) {
  823.                                     try { window.grecaptcha.reset(); } catch (e) {}
  824.                                 }
  825.                                 
  826.                                 $("#signup_form").show();
  827.                                 $("#signup_success").hide();
  828.                             }
  829.                         },
  830.                         error: function () {
  831.                             pushGtmAuthEvent('user-signup-fail', {
  832.                                 'validation-error': 'Network Error'
  833.                             });
  834.                         }
  835.                     });
  836.                 } else {
  837.                     pushGtmAuthEvent('user-signup-fail', {
  838.                         'validation-error': 'Validation Error'
  839.                     });
  840.                 }
  841.         });
  842.         
  843.         $('#examwizard-question').validate(validationRulesSignupMf);
  844.         $('#go-to-next-question').on('click', function(event) {
  845.            var screen = $("#currentQuestionNumber").val();
  846.            //alert(screen);            
  847.             if(screen == 1){
  848.                 //alert('validate first screen');
  849.                 event.preventDefault();
  850.                 if ($('#examwizard-question').valid()) {
  851.                     //return true;
  852.                     //alert('validated');            
  853.                     var actionurl = '/supplierSignupCheck';
  854.                     var firstName = $("#signupFirstNameMf").val();
  855.                     var email = $("#signupEmailMf").val();
  856.                     var companyName = $("#signupCompanyNameMf").val();
  857.                     var clients = $("#signupClientsMf").val();
  858.                     var lastName = $("#signupLastNameMf").val();
  859.                     var fd = new FormData();
  860.                     fd.append('firstName',firstName);
  861.                     fd.append('lastName',lastName);
  862.                     fd.append('email',email);
  863.                     fd.append('companyName',companyName);
  864.                     fd.append('clients',clients);
  865.                     $.ajax({
  866.                         type: "POST",
  867.                         url: actionurl,
  868.                         data: fd,
  869.                         contentType: false,
  870.                         processData: false,
  871.                         success: function (data) {
  872.                             data = JSON.parse(data);
  873.                             //alert(data.status);
  874.                             if (data.status == 'success') {
  875.                                 $("#current-question-number-label").text('2');
  876.                                 $("#currentQuestionNumber").val(2);
  877.                                 var count=0;
  878.                                 for (let el of document.querySelectorAll('div.question')){
  879.                                     el.classList.remove("hidden");
  880.                                     if(count != 1){
  881.                                     el.classList.add("hidden");
  882.                                     }
  883.                                     count++;
  884.                                 }
  885.                                 $("#back-to-prev-question").show();
  886.                                 $("#prev-screen").hide();
  887.                                 $("#back-to-prev-question").removeClass('disabled');
  888.                             } else {
  889.                                 var error = data.errorData;
  890.                                 pushGtmAuthEvent('user-signup-fail', {
  891.                                     'validation-error': getValidationErrorReason(error)
  892.                                 });
  893.                                 //alert(error.companyName);
  894.                                 //alert(error.email);
  895.                                 $("#current-question-number-label").text('1');
  896.                                 $("#currentQuestionNumber").val(1);
  897.                                 if(error.email){
  898.                                     $('<span id="signupEmailMf-error" class="error-msg">'+error.email+'</span>').insertAfter("#signupEmailMf");
  899.                                 }
  900.                                 if(error.companyName){
  901.                                     $('<span id="signupCompanyNameMf-error" class="error-msg">'+error.companyName+'</span>').insertAfter("#signupCompanyNameMf");                                
  902.                                 }
  903.                             }
  904.                         },
  905.                         error: function () {
  906.                             pushGtmAuthEvent('user-signup-fail', {
  907.                                 'validation-error': 'Network Error'
  908.                             });
  909.                         }
  910.                     });
  911.                     $("#current-question-number-label").text('1');
  912.                     $("#currentQuestionNumber").val(1);
  913.                     return false;
  914.                 }else{
  915.                     pushGtmAuthEvent('user-signup-fail', {
  916.                         'validation-error': 'Validation Error'
  917.                     });
  918.                     //alert('else validated');
  919.                     $("#current-question-number-label").text('1');
  920.                     $("#currentQuestionNumber").val(1);
  921.                     return false;
  922.                 }
  923.             }
  924.         });        
  925.         
  926.         $('#examwizard-question').submit(function (event) {
  927.             //alert("before submit");
  928.             // stop the form from submitting the normal way and refreshing the page
  929.             
  930.             var firstName = $("#signupFirstNameMf").val();
  931.             var email = $("#signupEmailMf").val();
  932.             var companyName = $("#signupCompanyNameMf").val();
  933.             var lastName = $("#signupLastNameMf").val();
  934.             var signupFactorySizeMf = $("#signupFactorySizeMf").val();
  935.             var signupEmployeesMf = $("#signupEmployeesMf").val();
  936.             var signupMachinesMf = $("#signupMachinesMf").val();
  937.             var signupPortMf = $('#signupPortMf').find(":selected").val();
  938.             var signupFOBMf = $("#signupFOBMf").val();
  939.             var clients = $("#signupClientsMf").val();
  940.             var phoneCode = $("#jquery-intl-phone-manufacture").val();
  941.             var phone = $("#signupContactNumber-manufacture").val();
  942.                    
  943.             ///alert(firstName);
  944.             var signupCountryMf = '';
  945.             $('input[name="signupCountryMf"]:checked').each(function() {
  946.                signupCountryMf = signupCountryMf + this.value+',';
  947.             });
  948.             
  949.             var signupCategoryMf = '';
  950.             $('input[name="signupCategoryMf"]:checked').each(function() {
  951.                signupCategoryMf = signupCategoryMf + this.value+',';
  952.             });
  953.             
  954.             var signupComplianceMf = '';
  955.             $('input[name="signupComplianceMf"]:checked').each(function() {
  956.                signupComplianceMf = signupComplianceMf + this.value+',';
  957.             });
  958.             
  959.             var signupSupplierType = $('#signupSupplierTypesMf option:selected').val();
  960.             
  961.             var fd = new FormData();
  962.             fd.append('firstName',firstName);
  963.             fd.append('lastName',lastName);
  964.             fd.append('email',email);
  965.             fd.append('companyName',companyName);
  966.             fd.append('signupFactorySizeMf',signupFactorySizeMf);
  967.             fd.append('signupEmployeesMf',signupEmployeesMf);
  968.             fd.append('signupMachinesMf',signupMachinesMf);
  969.             fd.append('signupPortMf',signupPortMf);
  970.             fd.append('signupFOBMf',signupFOBMf);
  971.             fd.append('signupCountryMf',signupCountryMf);
  972.             fd.append('signupCategoryMf',signupCategoryMf);
  973.             fd.append('signupComplianceMf',signupComplianceMf);
  974.             fd.append('supplierType',signupSupplierType);
  975.             fd.append('phoneCode',phoneCode);
  976.             fd.append('phone',phone);
  977.             fd.append('clients',clients);
  978.             
  979.             var files = $('#portfolio-upload')[0].files;  
  980.             // Check file selected or not
  981.             //alert(files.length);
  982.             if(files.length > 0 ){
  983.                fd.append('file',files[0]);
  984.             }
  985.             var actionurl = '/supplierSignup';
  986.             event.preventDefault();
  987.             //if ($('#frmSignup').valid()) {
  988.                 //return true;
  989.                 pushGtmAuthEvent('user-signup-submit');
  990.                 $.ajax({
  991.                     type: "POST",
  992.                     url: actionurl,
  993.                     data: fd,
  994.                     contentType: false,
  995.                     processData: false,
  996.                     success: function (data) {
  997.                         data = JSON.parse(data);
  998.                         if (data.status == 'success') {
  999.                             pushGtmAuthEvent('user-signup-success', {
  1000.                                 'user-id': getAuthUserId(data)
  1001.                             });
  1002.                             $("#signup_success").show();
  1003.                             $("#signup_form").hide();
  1004.                         } else {
  1005.                             pushGtmAuthEvent('user-signup-fail', {
  1006.                                 'validation-error': getValidationErrorReason(data.errorData)
  1007.                             });
  1008.                             $("#signup_form").show();
  1009.                             $("#signup_success").hide();
  1010.                         }
  1011.                     },
  1012.                     error: function () {
  1013.                         pushGtmAuthEvent('user-signup-fail', {
  1014.                             'validation-error': 'Network Error'
  1015.                         });
  1016.                     }
  1017.                 });
  1018.             //}
  1019.     });
  1020.     
  1021.         $('#frmContactUs').validate(validationRulesContact);
  1022.         //alert('before submit');
  1023.         $('#frmContactUs').submit(function (event) {
  1024.             //submit form with ajax - start
  1025.             var contactName = $("#contactName").val();
  1026.             var contactMessage = $("#contactMessage").val();
  1027.             var contactEmail = $("#contactEmail").val();
  1028.             var contactInquiryType = $("#contactInquiryType").val();
  1029.             // stop the form from submitting the normal way and refreshing the page
  1030.             event.preventDefault();
  1031.             console.log('1111');
  1032.             if ($('#frmContactUs').valid()) {
  1033.                 //alert('validated');
  1034.                 console.log('2222');
  1035.                 //return true;
  1036.                 //alert('ajax start');
  1037.                 //alert("name=" + contactName +"&message=" +contactMessage+"&email=" +contactEmail+"&inquiryType=" +contactInquiryType+"&submitAction=contactUs");
  1038.                 $.ajax({
  1039.                     type: "POST",
  1040.                     url: "/contact",
  1041.                     data: "name=" + contactName + "&message=" + contactMessage + "&email=" + contactEmail + "&inquiryType=" + contactInquiryType + "&submitAction=contactUs",
  1042.                     success: function (data) {
  1043.                         if (data == 'success') {
  1044.                             $("#frmContactUs").get(0).reset();
  1045.                             $('#contactInquiryType').prop('selectedIndex', 0).change();
  1046.                             // $("#contactusmodal").modal('hide');
  1047.                             // $("#success-message").html("Thanks! Our team will contact you shortly.");
  1048.                             // $("#contact_success").modal('show');
  1049.                         } else {
  1050.                             $("#contact_error").show();
  1051.                         }
  1052.                     }
  1053.                 });
  1054.                 $("#contactusmodal").modal('hide');
  1055.                 $("#success-message").html("Thanks! Our team will contact you shortly.");
  1056.                 $("#contact_success").modal('show');
  1057.                 //alert('ajax end');
  1058.             }
  1059.         });
  1060.     
  1061.         $('#frmScAccessCode').validate(validationRulesSC);
  1062.         //alert('before submit');
  1063.     
  1064.         $('#frmScAccessCode').submit(function (event) {
  1065.             //submit form with ajax - start
  1066.             var firstName = $("#SCFirstName").val();
  1067.             var lastName = $("#SCLastName").val();
  1068.             var email = $("#SCemail").val();
  1069.             var phone = $("#SCphone").val();
  1070.             var accessCode = $("#SCaccessCode").val();
  1071.             // stop the form from submitting the normal way and refreshing the page
  1072.             event.preventDefault();
  1073.             if ($('#frmScAccessCode').valid()) {
  1074.                 $.ajax({
  1075.                     type: "POST",
  1076.                     data: $('#frmScAccessCode').serialize(),
  1077.                     success: function (data) {      
  1078.                         data = JSON.parse(data);              
  1079.                         if (data.status == 'success') {
  1080.                             $('#leadForm').modal('hide');
  1081.                         }else{
  1082.                             var error = data.errorData;
  1083.                             if(error.accessCode){
  1084.                                 $('<span id="SCaccessCode-error" class="error-msg">Invalid!!</span>').insertAfter("#SCaccessCode");
  1085.                             }
  1086.                         }
  1087.                     }
  1088.                 });
  1089.                 //alert('ajax end');
  1090.             }
  1091.         });
  1092.         
  1093.     });
  1094.     function sitemenuValueStore(id) {  
  1095.             $.post("/sitemenuValue", {"siteMenuId": id});
  1096.     }
  1097.     function validatePassword() {
  1098.         $.validator.addMethod( "pattern", function( value, element, param ) {
  1099.             if ( this.optional( element ) ) {
  1100.                 return true;
  1101.             }
  1102.             if ( typeof param === "string" ) {
  1103.                 param = new RegExp( "^(?:" + param + ")$" );
  1104.             }
  1105.             return param.test( value );
  1106.         }, "Invalid format." );
  1107.         var validator = $("#resetPassword").validate({
  1108.             rules: {
  1109.                 newPassword: {
  1110.                     required: true,
  1111.                     minlength: 6,
  1112.                     maxlength: 20,
  1113.                     pattern: "((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{6,20})"
  1114.                 },
  1115.                 confirmPassword: {
  1116.                     equalTo: "#newPassword"
  1117.                 }
  1118.             },
  1119.             messages: {
  1120.                 newPassword: {
  1121.                     required: "Please enter your new password",
  1122.                     minlength: "Please enter at least 6 characters",
  1123.                     maxlength: "Please enter no more than 20 characters",
  1124.                     pattern: "Please enter a valid password. 1 number,1 Capital Alphabet "
  1125.                 },
  1126.                 confirmPassword: " Enter Confirm Password Same as Password"
  1127.             }
  1128.         });
  1129.         if (validator.form()) {
  1130.             $("#resetPassword").submit();
  1131.         }
  1132.     }
  1133. // $(".moveToDiv").on("click", function( e ) {
  1134. //     e.preventDefault();
  1135. //     document.getElementById("signupToExplore").focus()
  1136. // });
  1137. function salesCampaignPdfPreview(salesCampaignId){
  1138.          $(".bs-loader-pdf").show();
  1139.         var url = "/salesCampaignPreview/"+salesCampaignId;
  1140.          $('#myModal-wish-catalog').hide();
  1141.           $(".salesCampaign-catalog").html("");
  1142.         $.get( url, function( data ) {
  1143.           $(".salesCampaign-catalog").append(data);
  1144.           $("#myModal-wish-catalog").modal('show');
  1145.             $(".bs-loader-pdf").hide();
  1146.         });
  1147.     }
  1148.     function genrateSalesCampaignXLS(salesCampaignId){
  1149.         $.ajax({
  1150.             type: "POST",
  1151.             url:'/salesxls',
  1152.             // dataType:'json',
  1153.             data: ({salesCampaignId: salesCampaignId}),
  1154.             beforeSend: function(){
  1155.                 $(".bs-loader").show();
  1156.             },
  1157.             success: function(response)
  1158.             {
  1159.                 $(".bs-loader").hide();
  1160.                 data = JSON.parse(response);  
  1161.                 // console.log(data.ExportLink);
  1162.                 window.open(data.ExportLink, '_blank')
  1163.             }
  1164.         });
  1165.     }
  1166.     function genrateSalesCampaignPDF(salesCampaignId){
  1167.         $.ajax({
  1168.             type: "POST",
  1169.             url:'/salesCampaignPdf',
  1170.             dataType:'json',
  1171.             data: ({salesCampaignId: salesCampaignId}),
  1172.             beforeSend: function(){
  1173.                 $(".bs-loader").show();
  1174.             },
  1175.             success: function(response)
  1176.             {
  1177.                 //console.log(respose);
  1178.                 $(".bs-loader").hide();
  1179.                 window.open(response);
  1180.             }
  1181.         });
  1182.     }
  1183. $(document).ready(function(){
  1184.     var error = $("#_error").val();
  1185.     if(error){
  1186.         $("#login").modal('show');
  1187.     }
  1188.     $("#buyerbtn").addClass('active');
  1189.     $("#buyer").show();
  1190.     $("#supplier").hide();
  1191.     $("#designer").hide();
  1192.     //ON SIGNUP MODAL SHOW FORCE TO SHOW FORM
  1193.     $("#signup").on("shown.bs.modal",function(){
  1194.         $("#frmSignup").show();
  1195.         $("body").addClass("singup-modal-body");
  1196.     });
  1197.     $("#signup").on("hidden.bs.modal",function(){
  1198.         $("body").removeClass("singup-modal-body");
  1199.     });
  1200.     
  1201. });
  1202. $(".benefit-btn").on("click", function( e ) {
  1203.     var value   = this.id;
  1204.     $(this).addClass('active');
  1205.     if(value == 'buyerbtn'){
  1206.         $("#supplier").removeClass('active');
  1207.         $("#designerbtn").removeClass('active');
  1208.         $("#buyer").show();
  1209.         $("#supplier").hide();
  1210.         $("#designer").hide();
  1211.     }else if(value == 'supplierbtn'){
  1212.         $("#buyerbtn").removeClass('active');
  1213.         $("#designerbtn").removeClass('active');
  1214.         $("#buyer").hide();
  1215.         $("#supplier").show();
  1216.         $("#designer").hide();
  1217.     }else if(value == "designerbtn"){
  1218.         $("#supplierbtn").removeClass('active');
  1219.         $("#buyerbtn").removeClass('active');
  1220.         $("#buyer").hide();
  1221.         $("#supplier").hide();
  1222.         $("#designer").show();
  1223.     }
  1224.     $("video").each(function(){
  1225.         $(this).get(0).pause();
  1226.     });
  1227.     $(".benefit").css("background-color", $(this).attr("data-color"));
  1228. });
  1229. </script>
  1230. {% if '/blog' in app.request.pathinfo %}
  1231. <script>
  1232.     $(document).ready(function(){
  1233.         var blogId = $("#blogId").val();
  1234.         // alert("hii");
  1235.         $.ajax({
  1236.             type: "POST",
  1237.             url: "/saveBlogPageView",
  1238.             data: "blogId=" + blogId,
  1239.             success: function (data) {
  1240.             }
  1241.         });
  1242.     });
  1243. </script>
  1244. {% endif %}
  1245. {% if 'marketingreport' in app.request.pathinfo %}
  1246. <script type="text/javascript"> 
  1247.     $(document).ready(function(){
  1248.        var firstName = $('#signupFirstName');
  1249.         var lastName = $('#signupLastName');
  1250.         var email = $('#signupEmail');
  1251.         var downloadButton = $('#downloadButton');
  1252.         function checkInputs() {
  1253.             var emailRegex = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  1254.             if(firstName.val() && lastName.val() && emailRegex.test(email.val())) {
  1255.                 downloadButton.prop('disabled', false); // Enable the button
  1256.             } else {
  1257.                 downloadButton.prop('disabled', true); // Disable the button
  1258.             }
  1259.         }
  1260.         firstName.on('input', checkInputs);
  1261.         lastName.on('input', checkInputs);
  1262.         email.on('input', checkInputs);
  1263.         $("#download-report-form").on('submit', function(e){
  1264.             e.preventDefault(); 
  1265.             var formData = $(this).serialize(); 
  1266.             $.ajax({
  1267.                 url: "/marketingreport/response", 
  1268.                 type: "post",
  1269.                 data: formData,
  1270.                 success: function(response) {
  1271.                 data = JSON.parse(response);
  1272.                     if (data.status == 'success') {
  1273.                            $('#thankyou-popup').modal('show');
  1274.                     }
  1275.                 },
  1276.                 error: function(jqXHR, textStatus, errorThrown) {
  1277.                     // Handle the error here
  1278.                 }
  1279.             });
  1280.         });
  1281.     });
  1282. </script>
  1283. {% endif %}
  1284. {% if 'salescampaign' in app.request.pathinfo %}
  1285. <script>
  1286. $(document).ready(function(){
  1287.   $(".product-download-icon").click(function(e){
  1288.     e.preventDefault();
  1289.     var parameters = $(this).data('parameters');
  1290.     $.ajax({
  1291.       url: $(this).attr('href'),
  1292.       type: 'get',
  1293.       data: parameters,
  1294.       success: function (response) {
  1295.             data = JSON.parse(response);
  1296.             // downloadImageThumbnailAction returns {"success": false, "message": ...}
  1297.             // when the thumbnail cannot be generated. Without this guard the modal
  1298.             // opens with an undefined imageUrl and a dead download link.
  1299.             if (!data.success) {
  1300.                 alert(data.message || 'Unable to load the high resolution image. Please try again later.');
  1301.                 return;
  1302.             }
  1303.             var downloadFile = data.downloadFile;
  1304.             var downloadFileName = data.downloadFileName;
  1305.              // Clear the previous URL
  1306.             $('.produt-big-image img').attr('src', '');
  1307.             $('.download-popup-img').attr('href', '');
  1308.             // Set the new URL
  1309.             $('.produt-big-image img').attr('src', data.imageUrl);
  1310.             $('#downLoadProductImg').modal('show');
  1311.            $('.download-popup-img').on('click', function(e) {
  1312.             
  1313.                 e.preventDefault(); // prevent the default action
  1314.                  window.location = '/download-image-popup?downloadFile=' + encodeURIComponent(downloadFile) + '&downloadFileName=' + encodeURIComponent(downloadFileName);
  1315.             });
  1316.         }
  1317.     });
  1318.   });
  1319. });
  1320. </script>
  1321. {# common image download model popup #}
  1322. <div class="modal signup-modal download-product-image" id="downLoadProductImg">
  1323.     <div class="modal-dialog">
  1324.         <div class="modal-content">
  1325.             <div class="modal-header p-0">
  1326.                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  1327.                     <span aria-hidden="true">×</span>
  1328.                 </button>
  1329.                 <a href="#" class="download-popup-img">
  1330.                     <img src="https://d2fzew76uxzkhe.cloudfront.net/assets/images/download-arrow.svg">
  1331.                 </a>
  1332.             </div>
  1333.             <!-- Modal body -->
  1334.             <div class="modal-body p-0">
  1335.                 <div class="row">
  1336.                     <div class="col-lg-12 text-center col-md-12 col-12">
  1337.                         <div class="produt-big-image">
  1338.                             <img src="" alt="product big image">
  1339.                         </div>
  1340.                     </div>
  1341.                 </div>
  1342.             </div>
  1343.         </div>
  1344.     </div>
  1345. </div>
  1346. {# common image download popup end #}
  1347. {% endif %}
  1348. {% if currentSite == 'NuFind' %}
  1349. <!-- Global site tag (gtag.js) - Google Analytics -->
  1350. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-236265253-1"></script>
  1351. <script>
  1352.   window.dataLayer = window.dataLayer || [];
  1353.   function gtag(){dataLayer.push(arguments);}
  1354.   gtag('js', new Date());
  1355.   gtag('config', 'UA-236265253-1');
  1356.   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  1357.     (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  1358.     m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  1359.     })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  1360.     ga('create', 'UA-236265253-1', 'auto');
  1361.     ga('send', 'pageview');
  1362. </script>
  1363. {% endif %}
  1364. <script>
  1365.     document.addEventListener('DOMContentLoaded', function() {
  1366.         // ---------------------------------------------
  1367.         // 1️⃣ Enable "READY, SET, GO!" only if email is filled and valid
  1368.         // ---------------------------------------------
  1369.         const emailInput = document.getElementById('_username');
  1370.         const readyBtn = document.querySelector('.level-start .btn-sa-pink');
  1371.         if (!emailInput || !readyBtn) {
  1372.             return;
  1373.         }
  1374.         emailInput.addEventListener('input', function() {
  1375.             if (/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(emailInput.value.trim())) {
  1376.                 readyBtn.classList.remove('btn-disabled');
  1377.                 readyBtn.removeAttribute('disabled');
  1378.             } else {
  1379.                 readyBtn.classList.add('btn-disabled');
  1380.                 readyBtn.setAttribute('disabled', 'disabled');
  1381.             }
  1382.         });
  1383.         // ---------------------------------------------
  1384.         // 2️⃣ Initial setup - show only start screen
  1385.         // ---------------------------------------------
  1386.         document.querySelectorAll('.level-screens-main').forEach(el => el.style.display = 'none');
  1387.         document.querySelector('.level-start').style.display = 'block';
  1388.         let totalLevels = 4;
  1389.         let answers = {};
  1390.         let userEmail = '';
  1391.         let isSubmitting = false;
  1392.         // ---------------------------------------------
  1393.         // 3️⃣ Start Quiz
  1394.         // ---------------------------------------------
  1395.         readyBtn.addEventListener('click', function(e) {
  1396.             e.preventDefault();
  1397.             if (readyBtn.classList.contains('btn-disabled')) return;
  1398.             userEmail = emailInput.value.trim();
  1399.             document.querySelector('.level-start').style.display = 'none';
  1400.             document.querySelector('.level-1').style.display = 'block';
  1401.         });
  1402.         // ---------------------------------------------
  1403.         // 4️⃣ Levels 1 - 3 logic
  1404.         // ---------------------------------------------
  1405.         for (let i = 1; i <= totalLevels; i++) {
  1406.             let levelDiv = document.querySelector(`.level-${i}`);
  1407.             if (levelDiv) {
  1408.                 let radios = levelDiv.querySelectorAll('.radio-group');
  1409.                 let nextBtn = levelDiv.querySelector('.level-btn .btn-sa-pink');
  1410.                 nextBtn.classList.add('btn-disabled');
  1411.                 //nextBtn.setAttribute('disabled', 'disabled');
  1412.                 radios.forEach(function(group) {
  1413.                     group.addEventListener('change', function() {
  1414.                         let allAnswered = Array.from(radios).every(g => g.querySelector('input[type=radio]:checked'));
  1415.                         console.log(`Level ${i} allAnswered:`, allAnswered);
  1416.                         if (allAnswered) {
  1417.                             nextBtn.classList.remove('btn-disabled');
  1418.                             nextBtn.removeAttribute('disabled');
  1419.                         } else {
  1420.                             nextBtn.classList.add('btn-disabled');
  1421.                             //nextBtn.setAttribute('disabled', 'disabled');
  1422.                         }
  1423.                     });
  1424.                 });
  1425.                 nextBtn.addEventListener('click', function(e) {
  1426.                     e.preventDefault();
  1427.                     if (nextBtn.classList.contains('btn-disabled')) return;
  1428.                     radios.forEach(function(group, idx) {
  1429.                         let checked = group.querySelector('input[type=radio]:checked');
  1430.                         if (checked) {
  1431.                             answers[`level${i}_q${idx + 1}`] = parseInt(checked.labels[0].innerText);
  1432.                         }
  1433.                     });
  1434.                     levelDiv.style.display = 'none';
  1435.                     if (i < totalLevels) {
  1436.                         document.querySelector(`.level-${i + 1}`).style.display = 'block';
  1437.                     }
  1438.                     if (i === totalLevels) {
  1439.                         let total = Object.values(answers).reduce((a, b) => a + b, 0);
  1440.                         console.log('Sending data to backend:', { email: userEmail, score: total, answers: answers });
  1441.                         // Show circular loader
  1442.                         const loader = document.querySelector('.new-circle-loader-with-percentage');
  1443.                         const percentText = loader.querySelector('.percentage-text');
  1444.                         loader.style.display = 'flex';
  1445.                         percentText.textContent = '0%';
  1446.                         // Animate percentage (slower and smoother progress)
  1447.                         let percent = 0;
  1448.                         let interval = setInterval(() => {
  1449.                             percent += 2; // Smaller, consistent step for smoother effect
  1450.                             if (percent > 100) percent = 100;
  1451.                             percentText.textContent = percent + '%';
  1452.                             if (percent >= 100) clearInterval(interval);
  1453.                         }, 150); // Slower interval (150ms)
  1454.                         $.ajax({
  1455.                             url: '/sourcing-assessment',
  1456.                             type: 'POST',
  1457.                             dataType: 'json',
  1458.                             contentType: 'application/json',
  1459.                             data: JSON.stringify({ email: userEmail, score: total, answers: answers }),
  1460.                             success: function(resp) {
  1461.                                 console.log('Backend response:', resp);
  1462.                                 clearInterval(interval);
  1463.                                 percentText.textContent = '100%';
  1464.                                 setTimeout(function() {
  1465.                                     loader.style.display = 'none';
  1466.                                     document.querySelectorAll('.level-screens-main').forEach(el => el.style.display = 'none');
  1467.                                     document.querySelector('.get-your-score').style.display = 'block';
  1468.                                     // Show all score sections
  1469.                                     document.querySelectorAll('.final-level-score .score-section').forEach(sec => sec.style.display = 'block');
  1470.                                     // Hide all score badges
  1471.                                     document.querySelectorAll('.final-level-score .score-badge').forEach(badge => badge.style.display = 'none');
  1472.                                     let sec;
  1473.                                     if (total >= 44) {
  1474.                                         sec = document.querySelector('.final-level-score .score-section');
  1475.                                     } else if (total >= 30) {
  1476.                                         sec = document.querySelector('.final-level-score .score-section.yellow');
  1477.                                     } else {
  1478.                                         sec = document.querySelector('.final-level-score .score-section.red');
  1479.                                     }
  1480.                                     // Show only the correct score badge and set the score
  1481.                                     if (sec) {
  1482.                                         let badge = sec.querySelector('.score-badge');
  1483.                                         if (badge) {
  1484.                                             badge.style.display = 'flex';
  1485.                                             badge.querySelector('span').innerText = total;
  1486.                                         }
  1487.                                     }
  1488.                                     isSubmitting = false;
  1489.                                 }, 1200); // delay for effect
  1490.                             },
  1491.                             error: function() {
  1492.                                 clearInterval(interval);
  1493.                                 loader.style.display = 'none';
  1494.                                 getScoreBtn.classList.remove('btn-disabled');
  1495.                                 getScoreBtn.removeAttribute('disabled');
  1496.                                 isSubmitting = false;
  1497.                                 alert('An error occurred while submitting your score. Please try again.');
  1498.                             }
  1499.                         });
  1500.                     }
  1501.                 });
  1502.             }
  1503.         }
  1504.         // Handle modal show to ensure listeners are active
  1505.         $('#SourcingAssessment').on('shown.bs.modal', function() {
  1506.             console.log('Modal fully shown, re-checking final radios');
  1507.             const getScoreBtn = document.querySelector('.level-final .get-score-btn');
  1508.             if (getScoreBtn) {
  1509.                 const finalRadios = document.querySelectorAll('.level-final .radio-group');
  1510.                 let allAnswered = Array.from(finalRadios).every(g => g.querySelector('input[type=radio]:checked'));
  1511.                 if (allAnswered) {
  1512.                     getScoreBtn.classList.remove('btn-disabled');
  1513.                     getScoreBtn.removeAttribute('disabled');
  1514.                 }
  1515.             }
  1516.         });
  1517.         $('#SourcingAssessment .close').on('click', function() {
  1518.             // Hide the modal
  1519.             $('#SourcingAssessment').modal('hide');
  1520.             // Reset email input and button
  1521.             $('#_username').val('');
  1522.             $('.level-start .btn-sa-pink').addClass('btn-disabled').attr('disabled', 'disabled');
  1523.             // Reset answers and state
  1524.             answers = {};
  1525.             userEmail = '';
  1526.             isSubmitting = false;
  1527.             // Uncheck all radios
  1528.             $('#SourcingAssessment input[type=radio]').prop('checked', false);
  1529.             // Hide all levels and loader
  1530.             $('#SourcingAssessment .level-screens-main').hide();
  1531.             $('#SourcingAssessment .new-circle-loader-with-percentage').hide();
  1532.             // Show start screen
  1533.             $('#SourcingAssessment .level-start').show();
  1534.             // Reset all next/score buttons
  1535.             $('#SourcingAssessment .btn-sa-pink').addClass('btn-disabled').attr('disabled', 'disabled');
  1536.         });
  1537.     });
  1538.     // Sample Kit Registration Form Submissio
  1539.     document.addEventListener('DOMContentLoaded', function() {
  1540.         const form = document.getElementById('smapleKit3sForm');
  1541.         const submitBtn = document.getElementById('smplekitDone');
  1542.         const successPopup = $('#samplekit-success-popup');
  1543.         if (!form) {
  1544.             return;
  1545.         }
  1546.         function showError(input, message) {
  1547.             let errorSpan = input.parentNode.querySelector('.error-msg');
  1548.             if (!errorSpan) {
  1549.                 errorSpan = document.createElement('span');
  1550.                 errorSpan.className = 'error-msg';
  1551.                 errorSpan.style.display = 'none';
  1552.                 input.parentNode.appendChild(errorSpan);
  1553.             }
  1554.             errorSpan.innerText = message;
  1555.             errorSpan.style.display = 'block';
  1556.             errorSpan.style.opacity = 0;
  1557.             errorSpan.style.transition = 'opacity 0.3s';
  1558.             setTimeout(() => { errorSpan.style.opacity = 1; }, 10);
  1559.             input.classList.add('input-error');
  1560.         }
  1561.         function clearError(input) {
  1562.             let errorSpan = input.parentNode.querySelector('.error-msg');
  1563.             if (errorSpan) {
  1564.                 errorSpan.style.opacity = 0;
  1565.                 setTimeout(() => { errorSpan.style.display = 'none'; }, 300);
  1566.             }
  1567.             input.classList.remove('input-error');
  1568.         }
  1569.         function validateForm() {
  1570.             let valid = true;
  1571.             const firstName = document.getElementById('smplekitFirstName');
  1572.             const lastName = document.getElementById('smplekitLastName');
  1573.             const companyName = document.getElementById('smplekitCompanyName');
  1574.             const country = document.getElementById('sampleSignupCountry');
  1575.             const email = document.getElementById('smplekitEmail');
  1576.             const contactNumber = document.getElementById('smplekitContactNumber');
  1577.             const phoneCode = document.getElementById('jquery-intl-phone');
  1578.             const emailValid = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/.test(email.value.trim());
  1579.             const nameValid = /^[A-Za-z\s]+$/;
  1580.             [firstName, lastName, companyName, country, email, contactNumber, phoneCode].forEach(clearError);
  1581.             if (!firstName.value.trim()) {
  1582.                 showError(firstName, '*');
  1583.                 valid = false;
  1584.             } else if (!nameValid.test(firstName.value.trim())) {
  1585.                 showError(firstName, 'Only letters allowed');
  1586.                 valid = false;
  1587.             }
  1588.             if (!lastName.value.trim()) {
  1589.                 showError(lastName, '*');
  1590.                 valid = false;
  1591.             } else if (!nameValid.test(lastName.value.trim())) {
  1592.                 showError(lastName, 'Only letters allowed');
  1593.                 valid = false;
  1594.             }
  1595.             if (!companyName.value.trim()) {
  1596.                 showError(companyName, '*');
  1597.                 valid = false;
  1598.             }
  1599.             if (!country.value.trim()) {
  1600.                 showError(country, '*');
  1601.                 valid = false;
  1602.             }
  1603.             if (!email.value.trim()) {
  1604.                 showError(email, '*');
  1605.                 valid = false;
  1606.             } else if (!emailValid) {
  1607.                 showError(email, 'Invalid email');
  1608.                 valid = false;
  1609.             }
  1610.             if (!phoneCode.value.trim()) {
  1611.                 showError(phoneCode, '*');
  1612.                 valid = false;
  1613.             }
  1614.             if (!contactNumber.value.trim()) {
  1615.                 showError(contactNumber, '*');
  1616.                 valid = false;
  1617.             }
  1618.             return valid;
  1619.         }
  1620.         ['smplekitFirstName','smplekitLastName','smplekitCompanyName','sampleSignupCountry','smplekitEmail','smplekitContactNumber','jquery-intl-phone'].forEach(id => {
  1621.             const el = document.getElementById(id);
  1622.             if (el) {
  1623.                 el.addEventListener('input', () => clearError(el));
  1624.                 el.addEventListener('change', () => clearError(el));
  1625.             }
  1626.         });
  1627.         form.addEventListener('submit', function(e) {
  1628.             e.preventDefault();
  1629.             if (!validateForm()) {
  1630.                 return;
  1631.             }
  1632.             submitBtn.disabled = true;
  1633.             submitBtn.innerText = 'Submitting...';
  1634.             const data = {
  1635.                 firstName: document.getElementById('smplekitFirstName').value.trim(),
  1636.                 lastName: document.getElementById('smplekitLastName').value.trim(),
  1637.                 companyName: document.getElementById('smplekitCompanyName').value.trim(),
  1638.                 country: document.getElementById('sampleSignupCountry').value.trim(),
  1639.                 countryCode: document.getElementById('jquery-intl-phone').value.trim(),
  1640.                 contactNumber: document.getElementById('smplekitContactNumber').value.trim(),
  1641.                 notes: document.getElementById('commentProductsamplekit').value.trim(),
  1642.                 email: document.getElementById('smplekitEmail').value.trim()
  1643.             };
  1644.             fetch('/sample-kit-registration-form-submit', {
  1645.                 method: 'POST',
  1646.                 headers: {'Content-Type': 'application/json'},
  1647.                 body: JSON.stringify(data)
  1648.             })
  1649.             .then(resp => resp.json())
  1650.             .then(resp => {
  1651.                 if (resp.status === 'success') {
  1652.                     form.reset();
  1653.                     $('.input-error').removeClass('input-error');
  1654.                     $('.error-msg').remove();
  1655.                     successPopup.modal('show');
  1656.                     setTimeout(() => { successPopup.modal('hide'); }, 3000);
  1657.                 } else {
  1658.                     let formError = document.getElementById('samplekit-form-error');
  1659.                     if (!formError) {
  1660.                         formError = document.createElement('div');
  1661.                         formError.id = 'samplekit-form-error';
  1662.                         formError.className = 'form-global-error';
  1663.                         form.insertBefore(formError, form.firstChild);
  1664.                     }
  1665.                     formError.innerText = resp.message || 'Submission failed.';
  1666.                     formError.style.display = 'block';
  1667.                     formError.style.opacity = 0;
  1668.                     formError.style.transition = 'opacity 0.3s';
  1669.                     setTimeout(() => { formError.style.opacity = 1; }, 10);
  1670.                 }
  1671.             })
  1672.             .catch(() => {
  1673.                 let formError = document.getElementById('samplekit-form-error');
  1674.                 if (!formError) {
  1675.                     formError = document.createElement('div');
  1676.                     formError.id = 'samplekit-form-error';
  1677.                     formError.className = 'form-global-error';
  1678.                     form.insertBefore(formError, form.firstChild);
  1679.                 }
  1680.                 formError.innerText = 'Server error. Please try again.';
  1681.                 formError.style.display = 'block';
  1682.                 formError.style.opacity = 0;
  1683.                 formError.style.transition = 'opacity 0.3s';
  1684.                 setTimeout(() => { formError.style.opacity = 1; }, 10);
  1685.             })
  1686.             .finally(() => {
  1687.                 submitBtn.disabled = false;
  1688.                 submitBtn.innerText = 'Sign Up';
  1689.             });
  1690.         });
  1691.     });
  1692. </script>