File: //home/cafsindia/lifemaze_in/js/sign.js
(function($){$(function(){M.AutoInit();$('.sidenav').sidenav();$('.carousel').carousel({indicators:true});$('input#mobile_no').characterCounter();$(".number").bind('keyup',function(e){this.value=this.value.replace(/[^0-9_.]/g,'');});$("a").on('click',function(event){if(this.hash!==""){event.preventDefault();var hash=this.hash;$('html, body').animate({scrollTop:$(hash).offset().top},800,function(){window.location.hash=hash;});}});var header=$('.bg_cover');var backgrounds=new Array('url(./images/banner/slide_2.jpg)','url(./images/banner/slide_2.1.jpg)','url(./images/banner/slide_1.jpg)','url(./images/banner/slide_3.jpg)','url(./images/banner/slide_4.jpg)','url(./images/banner/slide_5.jpg)','url(./images/banner/slide_6.jpg)','url(./images/banner/slide_7.jpg)','url(./images/banner/slide_8.jpg)',);var current=0;function nextBackground(){current++;current=current%backgrounds.length;header.css('background-image',backgrounds[current]);}setInterval(nextBackground,3000);header.css('background-image',backgrounds[0]);jQuery.validator.addMethod("alphanumeric",function(value,element){return this.optional(element)||/^[\w.]+$/i.test(value);},"Letters and numbers only please");$("#change_mob").click(function(event){$("#otp_div,#pwd_div,#signin_up_note").hide();$("#mobile_no").val("");$("#mob_div").show();$("label[for='mob']").addClass("active");$("#mob").focus();});$("#resnd_otp").click(function(event){mobile_no=$("#mobile_no").val();if(mobile_no){var frm="resend_otp";$.ajax({type:"POST",url:"./bend/sign_callback",data:{frm:frm,mobile_no:mobile_no},success:function(data){var rslt=JSON.parse(data);if(rslt.sts){msg="Resend otp sent";M.toast({html:msg});$("#resnd_otp").hide();}}});}});$("#mobile_no").bind('keyup',function(e){var mobile_no=$("#mobile_no").val();var mob_len=mobile_no.length;if(mob_len===10){var frm="cust_exist";$.ajax({type:"POST",url:"./bend/sign_callback",data:{frm:frm,mobile_no:mobile_no},success:function(data){var rslt=JSON.parse(data);$("#mode").val(rslt.mode);if(rslt.mode==='sign_in'){var otp_mob=mobile_no.substr(5);otp_note="Enter your login password of *****"+otp_mob;$("#otp_note").html(otp_note);$("#mob_div,#otp_div,#timer,#resnd_otp").hide();$("#pwd_div,#signin_up_note").show();$("label[for='pwd']").html("Enter password");$("label[for='pwd']").addClass("active");$("#pwd").focus();}else
if(rslt.mode==='sign_up'){var otp_mob=mobile_no.substr(5);otp_note="We have sent One time password to *****"+otp_mob;$("#otp_note").html(otp_note);timer(30);$("#mob_div").hide();$("#otp_div,#pwd_div,#signin_up_note,#timer").show();$("label[for='otp']").addClass("active");$("#otp").focus();$("label[for='pwd']").html("Enter new password");}}});}});$('#sign_form').validate($.extend({submitHandler:function(form){var frm="sign";var fdata=JSON.stringify($("#sign_form").serializeArray());$.ajax({type:"POST",url:"./bend/sign_callback",data:{frm:frm,fdata:fdata},success:function(data){var rslt=JSON.parse(data);if(rslt.sts){M.toast({html:rslt.info});window.location.replace("./planner");}else{msg="<span style='color:red'>"+rslt.info+"</span>";M.toast({html:msg});}}});},rules:{mobile_no:{required:true,minlength:10,maxlength:10,number:true},otp:{required:true,number:true},pwd:{required:true,alphanumeric:true}},errorClass:"invalid_form",errorElement:'div',errorPlacement:function(error,element){error.appendTo(element.parent());}}));$("#for_mobile_no").bind('keyup',function(e){var mobile_no=$("#for_mobile_no").val();var mob_len=mobile_no.length;if(mob_len===10){var frm="forgot_pwd";$.ajax({type:"POST",url:"./bend/sign_callback",data:{frm:frm,mobile_no:mobile_no},success:function(data){var rslt=JSON.parse(data);if(rslt.mode==='reset_pwd'){$("#for_mobile_no_div").hide();$("#for_otp_div,#for_pwd_div,#for_btn_div").show();}else{$("#for_mobile_no_div").show();$("#for_otp_div,#for_pwd_div,#for_btn_div").hide();alert("Enter mobile number doesn't exist please enter valid mobile no.");$("#for_mobile_no").val("");}}});}});$('#forgot_pwd_form').validate($.extend({submitHandler:function(form){var frm="forgot_pwd_val";var fdata=JSON.stringify($("#forgot_pwd_form").serializeArray());$.ajax({type:"POST",url:"./bend/sign_callback",data:{frm:frm,fdata:fdata},success:function(data){var rslt=JSON.parse(data);if(rslt.sts){$("#forgot_pwd_form")[0].reset();$('#forgot_pwd_modal').modal('close');M.toast({html:rslt.info});$("#for_mobile_no_div").show();$("#for_otp_div,#for_pwd_div,#for_btn_div").hide();}else{msg="<span style='color:red'>"+rslt.info+"</span>";M.toast({html:msg});}}});},rules:{for_mobile_no:{required:true,minlength:10,maxlength:10,number:true},for_otp:{required:true,number:true},for_pwd:{required:true,alphanumeric:true}},errorClass:"invalid_form",errorElement:'div',errorPlacement:function(error,element){error.appendTo(element.parent());}}));$('#feedback_form').validate($.extend({submitHandler:function(form){$('#feedback_btn').attr('disabled','disabled');var frm="feedback_save";var fdata=JSON.stringify($("#feedback_form").serializeArray());$.ajax({type:"POST",url:"./bend/sign_callback",data:{frm:frm,fdata:fdata},success:function(data){var rslt=JSON.parse(data);if(rslt.sts){M.toast({html:rslt.info});}else{msg="<span style='color:red'>"+rslt.info+"</span>";M.toast({html:msg});}$("#feedback_form")[0].reset();}});},rules:{name:{required:true},mobile:{required:true,minlength:10,maxlength:10,number:true},feedback:{required:true}},errorClass:"invalid_form",errorElement:'div',errorPlacement:function(error,element){error.appendTo(element.parent());}}));});})(jQuery);function autoplay(){$('.carousel').carousel('next');setTimeout(autoplay,1500);}let timerOn=true;function timer(remaining){var m=Math.floor(remaining/60);var s=remaining%60;m=m<10?'0'+m:m;s=s<10?'0'+s:s;document.getElementById('timer').innerHTML=m+':'+s;remaining-=1;if(remaining>=0&&timerOn){setTimeout(function(){timer(remaining);},1000);return;}if(!timerOn){return;}$("#timer").hide();$("#resnd_otp").show();}