function jump(url){ if(url == 'cart.html?way=99') { if(!window.confirm('Confirm empty shopping cart data ?')){ return; } } var tmpForm = $("
"); $(tmpForm).attr("action",url); tmpForm.appendTo(document.body).submit(); } $(document).ready(function() { $("#loginCheck").click(function() { if(!CookieEnable()) { alert("Sorry, your browser Cookie feature is disable. Please enable it!"); return ; } var userType = $("#userType").val(); var autelId = $("#autelId").val(); var password = $("#password").val(); var imagenum = $("#imagenum").val(); var $form = $("#loginCustomerInfo"); var regEmail = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; var userTypeErrorInfoTip = $("#userTypeErrorInfoTip"); var autelIdErrorInfoTip = $("#autelIdErrorInfoTip"); var passwordErrorInfoTip = $("#passwordErrorInfoTip"); var imagenumErrorInfoTip = $("#imagenumErrorInfoTip"); clearAllErrorInfo(); if(userType == -1) { $("#userTypeErrorInfo").show(); $("#userTypeImg").show(); userTypeErrorInfoTip.html("Select a user type"); return; } if(autelId == null || autelId == "" || autelId == "Enter your Autel ID (E-mail)") { $("#autelIdErrorInfo").show(); $("#autelIdImg").show(); $("#autelId").attr("value",""); $("#autelId").css("color",""); autelIdErrorInfoTip.html("Please enter an Autel ID."); return; } if(password == null || password == "") { $("#passwordErrorInfo").show(); $("#passwordImg").show(); passwordErrorInfoTip.html("Please specify a password."); return; } if(imagenum == null || imagenum == "") { $("#imagenumErrorInfo").show(); $("#imagenumImg").show(); imagenumErrorInfoTip.html("Please enter the characters you see to continue."); return; } var resultCode = true; $.ajax({ url:'front/user/checkUserLogin.do', type:"post", async:false, data:JSON.stringify({"userType":userType,"autelId":autelId,"userPwd":password,"imageCode":imagenum}), contentType:"application/json;charset=UTF-8", dataType:'JSON', success :function(data) { var jsonData = eval(data); var autelId1 = jsonData[0].autelId; var userPwd = jsonData[0].userPwd; var actCode = jsonData[0].actCode; var imageCode = jsonData[0].imageCode; var systemError = jsonData[0].systemError; if(imageCode == "false") { $("#imagenumErrorInfo").show(); $("#imagenumImg").show(); imagenumErrorInfoTip.html("The entered verification code is incorrect."); resultCode = false; buildRandom(); return; } if(systemError == "false") { $("#imagenumErrorInfo").show(); $("#imagenumImg").show(); imagenumErrorInfoTip.html("System error, please mail to support@auteltech.com. "); resultCode = false; buildRandom(); return; } if(autelId1 == "false") { $("#autelIdErrorInfo").show(); $("#autelIdImg").show(); autelIdErrorInfoTip.html("Please enter a valid Autel ID."); resultCode = false; return; } if(userPwd == "false") { $("#passwordErrorInfo").show(); $("#passwordImg").show(); passwordErrorInfoTip.html("The entered password is incorrect."); resultCode = false; return; } if(actCode == "false") { $("#autelIdErrorInfo").show(); $("#autelIdImg").show(); autelIdErrorInfoTip.html("The Autel ID you input is not activated. Please login your email "+autelId+" to activate"); resultCode = false; return; } }, error :function(){ $("#imagenumErrorInfo").show(); imagenumErrorInfoTip.html("Network error, please try again later!"); resultCode=false; } }); if(resultCode == false) { return; } $("#returnUrl").val(location.href); $form.action="loginCustomerInfoResult.html?operationType=4"; $form.submit(); }); $("#imageField").click(function() { jump("regCustomerInfo.html?operationType=1"); }); window.fbAsyncInit = function() { FB.init({ appId : '321017782371326', cookie : true, xfbml : true, version : 'v7.0' }); FB.AppEvents.logPageView(); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "https://connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); }); function enterkey(e) { if (e==13) { $("#loginCheck").click(); } } function clearAllErrorInfo(){ var userTypeErrorInfoTip = $("#userTypeErrorInfoTip"); var autelIdErrorInfoTip = $("#autelIdErrorInfoTip"); var passwordErrorInfoTip = $("#passwordErrorInfoTip"); var imagenumErrorInfoTip = $("#imagenumErrorInfoTip"); userTypeErrorInfoTip.html(""); autelIdErrorInfoTip.html(""); passwordErrorInfoTip.html(""); imagenumErrorInfoTip.html(""); $("#userTypeErrorInfo").hide(); $("#userTypeImg").hide(); $("#autelIdErrorInfo").hide(); $("#autelIdImg").hide(); $("#passwordErrorInfo").hide(); $("#passwordImg").hide(); $("#imagenumErrorInfo").hide(); $("#imagenumImg").hide(); } function clearUserTypeErrorInfo(){ $("#userTypeErrorInfo").hide(); $("#userTypeImg").hide(); } function clearAutelIdErrorInfo(){ $("#autelIdErrorInfo").hide(); $("#autelIdImg").hide(); if($("#autelId").val()=="Enter your Autel ID (E-mail)") { $("#autelId").attr("value",""); $("#autelId").css("color",""); } } function clearPasswordErrorInfo(){ $("#passwordErrorInfo").hide(); $("#passwordImg").hide(); } function clearImagenumErrorInfo(){ $("#imagenumErrorInfo").hide(); $("#imagenumImg").hide(); } function CookieEnable() { var result=false; if(navigator.cookiesEnabled){ return true; } document.cookie = "testcookie=yes;"; var cookieSet = document.cookie; if (cookieSet.indexOf("testcookie=yes") > -1){ result=true; } document.cookie = ""; return result; } function fawordUrl(){ var autelId=$("#autelId").val(); jump("goForgotPassword.html?operationType=10&autelId="+autelId); } function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } function statusChangeCallback(response) { if (response.status === 'connected') { testAPI(); } else { } } function testAPI() { var autelId = ""; FB.api('/me/ids_for_business', function (response) { if (response && !response.error) { $.each(response.data, function(i, item){ var id_appid = item.id + "_" + item.app.id; autelId = autelId + id_appid + ","; }); autelId = autelId.substring(0, autelId.length-1); FB.api('/me?locale=en_US', 'get', {fields: 'name, gender, last_name, first_name, email'}, function(user) { if(user != null) { var thridSource = 'facebook'; var email = user.email; var name = user.name; var firstName = user.first_name; var lastName = user.last_name; thirdLogin(thridSource, autelId, email, name, firstName, lastName); $("#facebookSingout").click(); } }); } }); } function fbsignOut() { FB.getLoginStatus(function(response) { if(response && response.status ==='connected') { FB.logout(function(response) { }); } }); } function thirdLogin(thridSource, autelId, email, name, firstName, lastName) { var $form = $("#loginCustomerInfo"); var resultCode = true; $.ajax({ url:'front/user/checkThirdUserLogin.do', type:"post", async:false, data:{"userInfoVo.thridSource":thridSource, "userInfoVo.autelId":autelId, "userInfoVo.email":email, "userInfoVo.name":name, "userInfoVo.firstName":firstName, "userInfoVo.lastName":lastName}, dataType:'JSON', success :function(data) { var jsonData = eval(data); autelId = jsonData[0].autelId; var actCode = jsonData[0].actCode; var systemError = jsonData[0].systemError; if (typeof(autelId) == "undefined" || null == autelId || autelId == "") { $("#imagenumErrorInfo").show(); $("#imagenumImg").show(); imagenumErrorInfoTip.html("System error, please mail to support@auteltech.com. "); resultCode = false; buildRandom(); return; } if(actCode == "false") { var thridErrorInfoTip = $("#thridErrorInfoTip"); $("#thridErrorInfo").show(); $("#thridImg").show(); thridErrorInfoTip.html("Network error, please try again later!"); resultCode = false; buildRandom(); return; } if(systemError == "false") { $("#imagenumErrorInfo").show(); $("#imagenumImg").show(); imagenumErrorInfoTip.html("System error, please mail to support@auteltech.com. "); resultCode = false; buildRandom(); return; } }, error :function(){ $("#imagenumErrorInfo").show(); imagenumErrorInfoTip.html("Network error, please try again later!"); resultCode=false; } }); if(resultCode == false) { return; } $("#returnUrl").val(location.href); $("#thirdID").val(autelId); $("#operationType").val('30'); $form.action="loginCustomerInfoResult.html?operationType=30"; $form.submit(); } function onSignIn(googleUser) { var profile = googleUser.getBasicProfile(); var thridSource = 'google'; var autelId = profile.getId(); var email = profile.getEmail(); var name = profile.getName(); var firstName = profile.getFamilyName(); var lastName = profile.getGivenName(); thirdLogin(thridSource, autelId, email, name, firstName, lastName); $("#googleSingout").click(); } function signOut() { var auth2 = gapi.auth2.getAuthInstance(); auth2.signOut().then(function () { }); }