$(document).ready(function () { LanguageSwitching(); var timer = null; timer = setInterval(function () { $(".zhedang").hide(); }, 400) document.addEventListener('gesturestart', function (e) { e.preventDefault(); }); document.addEventListener('dblclick', function (e) { e.preventDefault(); }); document.addEventListener('touchstart', function (event) { if (event.touches.length > 1) { event.preventDefault(); } }); $(".SLdetaileHeaderImg").on("click", function () { window.history.back(); }) var lastTouchEnd = 0; document.addEventListener('touchend', function (event) { var now = (new Date()).getTime(); if (now - lastTouchEnd <= 300) { event.preventDefault(); } lastTouchEnd = now; }, false); var timer = null; function publicBox(publicText) { $(".AlertBox").show(); $(".AlertBoxChilds").html(publicText); timer = setInterval(function () { $(".AlertBox").hide(); }, 2000) } function publicBoxBack(publicText) { $(".AlertBox").show(); $(".AlertBoxChilds").html(publicText); timer = setInterval(function () { $(".AlertBox").hide(); // window.history.back(); $(location).attr("href", 'blogin.html'); }, 2000) } $(".registerShuomingBackBtn").on("click", function () { $(location).attr("href", 'blogin.html'); }) $(".LoginBtn").on("click", function () { clearInterval(timer) var languageParameter = localStorage.getItem('language') || 'CN'; if(languageParameter === 'CN') { if ($("#account").val() == "") { publicBox("請填寫帳戶"); } else if ($("#password").val() == "") { publicBox("請填寫密碼"); } else if ($("#repeatpassword").val() == "") { publicBox("請重複密碼"); } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) { publicBox("賬號格式錯誤"); } else if ($("#password").val() != $("#repeatpassword").val()) { publicBox("兩次密碼不一致"); } else if (!/^\d{6}$/.test($("#repeatpassword").val())) { publicBox("密碼格式錯誤"); } else if (!/^\d{6}$/.test($("#password").val())) { publicBox("密碼格式錯誤"); } else { $.ajax({ type: "post", url: "https://www.bibidd.com/bibidd/usertest/slUserRegister", dataType: "json", data: { account: $("#account").val(), password: $("#password").val() }, success: function (res) { if (res.code == "200") { publicBoxBack("已成功註冊") } else if (res.code == "201") { publicBox("註冊失敗。 請重試"); } else if (res.code == "202") { publicBox("參數不正確"); } else if (res.code == "203") { publicBox("該帳戶已註冊"); } } }) } }else{ if ($("#account").val() == "") { publicBox("Please fill in the account number"); } else if ($("#password").val() == "") { publicBox("Please fill in the password"); } else if ($("#repeatpassword").val() == "") { publicBox("Please repeat the password"); } else if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,12}$/.test($("#account").val())) { publicBox("Account format error"); } else if ($("#password").val() != $("#repeatpassword").val()) { publicBox("The two passwords do not match"); } else if (!/^\d{6}$/.test($("#repeatpassword").val())) { publicBox("Wrong password format"); } else if (!/^\d{6}$/.test($("#password").val())) { publicBox("Wrong password format"); } else { $.ajax({ type: "post", url: "https://www.bibidd.com/bibidd/usertest/slUserRegister", dataType: "json", data: { account: $("#account").val(), password: $("#password").val() }, success: function (res) { if (res.code == "200") { publicBoxBack("Registered successfully") } else { publicBox("Account format error or password format error"); } return if (res.code == "200") { publicBoxBack("Registered successfully") } else if (res.code == "201") { publicBox("Registration failed. Please try again"); } else if (res.code == "202") { publicBox("Incorrect parameters"); } else if (res.code == "203") { publicBox("The account has already been registered"); } } }) } } }) function LanguageSwitching() { var languageParameter = localStorage.getItem('language') || 'CN'; if ( languageParameter == 'CN') { // 切换中文语言 $('.LoginTitle').text(' 註冊 '); $('#account').attr('placeholder','長度 8-12位數字+字母'); $('#password').attr('placeholder','密碼(6位密碼)'); $('#repeatpassword').attr('placeholder','重複密碼(6位密碼)'); $('.registerShuoming').text('請牢記賬號密碼,丟失將無法找回'); $('.LoginBtn').text('創建帳戶'); $('.registerShuomingBackText').text('已有帳戶?'); $('.registerShuomingBackBtn').text('登錄'); }else if (!languageParameter || languageParameter == 'EN'){ // 切换英文语言 $('.LoginTitle').text(' Sign Up '); $('#account').attr('Length 8-12 digits + letters'); $('#password').attr('Password (6 digit password)'); $('#repeatpassword').attr('Repeat password (6 digit password)'); $('.registerShuoming').text('Please keep in mind the account password, you can not find it if you lose'); $('.LoginBtn').text('Creat Account'); $('.registerShuomingBackText').text('Already have an account? '); $('.registerShuomingBackBtn').text('Sign In'); } } })