Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- var s = "loginCaptcha";
- var e = "detailCaptcha";
- var d = "loginPhoneCaptcha";
- var r = "";
- var c = $("#login-form");
- var l = c.find("button.signin");
- var o = $("#login-form-cn");
- if (o.length) {
- $("#phone-number").trigger("focus")
- } else {
- $("#email").trigger("focus")
- }
- if (navigator.userAgent.indexOf("CrOS") !== -1) {
- if (navigator.managed && navigator.managed.getManagedConfiguration) {
- var i = ["DisableGoogleLogin", "DisableFacebookLogin", "DisableAppleLogin", "DisableLoginWithSSO", "DisableLoginWithEmail", "ForceLoginWithSSO"];
- navigator.managed.getManagedConfiguration(i).then(function(w) {
- var z = $("#login-btn-group");
- var y = z.find(".ride-line");
- var v = z.find(".login-btn-sso");
- var t = z.find(".login-btn-apple");
- var x = z.find(".login-btn-google");
- var u = z.find(".login-btn-facebook");
- if (w) {
- if (w.DisableGoogleLogin && w.DisableFacebookLogin && w.DisableAppleLogin && w.DisableLoginWithEmail && w.DisableLoginWithSSO && !w.ForceLoginWithSSO) {
- $(".right-container").css({ display: "none" });
- $("#login_left_container").css({ display: "none" });
- $(".mini-layout-login-body").css({ display: "flex", "align-items": "center", "justify-content": "center", "background-color": "white", "min-height": "480px" });
- $("#disable_all_for_chrome_os").css({ display: "block" })
- } else {
- $(".right-container").css({ "min-height": "480px" });
- if (w.DisableGoogleLogin) {
- x.hide()
- }
- if (w.DisableFacebookLogin) {
- u.hide()
- }
- if (w.DisableAppleLogin) {
- t.hide()
- }
- if (w.DisableLoginWithEmail) {
- c.hide();
- y.hide();
- $(".right-container").css({ display: "flex", "align-items": "center" })
- }
- if (w.DisableLoginWithSSO && !w.ForceLoginWithSSO) {
- v.hide()
- }
- }
- }
- })
- }
- }
- $("#password").on("input", function() {
- $(this).val($(this).val().trim())
- });
- $("#email").on("input", function() {
- $(this).val($(this).val().trim())
- });
- //// THIS IS TRIGGERED ON CLICKING SIGNIN BUTTON
- l.on("click", function() {
- c.find("span.help-block").remove();
- c.find("div.has-error").removeClass("has-error");
- var t = c.valid();
- if (!t) {
- c.find("div.has-error input").length && c.find("div.has-error input").eq(0).trigger("focus");
- return
- }
- if (signinNeedCaptcha && newCaptcha.isReCaptcha) {
- l.disableBtn();
- window.setTimeout(function() { l.enableBtn() }, 3000);
- newCaptcha.executeReCaptcha(s, n)
- } else {
- c.trigger("submit") //// HERE I CAN DIRECTLY SUMBIT THE FORUM
- }
- });
- /////////////////////////////////////////////////
- var h = false;
- var q = $("#email").hasClass("validator-cn");
- $.validator.addMethod("email_or_phone_number", function(v, u) {
- var t = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(v.trim());
- if ($(u).hasClass("validator-cn")) {
- return this.optional(u) || /^\d{11}$/.test(v.trim()) || t
- } else {
- return this.optional(u) || t
- }
- },
- q ? $.i18n.get("user.common.email_phone_invalid") : $.i18n.get("user.common.email_invalid"));
- c.validate({
- rules: function() {
- var t = newCaptcha.getValidationRules();
- t.email = { required: true, email_or_phone_number: true };
- t.password = { required: true };
- return t
- }(),
- messages: {
- email: {
- required: q ? $.i18n.get("user.common.email_phone_invalid") : $.i18n.get("user.common.email_required")
- },
- password: {
- required: $.i18n.get("user.login.enter_password")
- }
- },
- submitHandler: function() {
- n();
- return false
- }
- });
- function n() {
- r = $("#email").val();
- var u = /^\d{11}$/.test(r.trim());
- var t = {
- email: $("#email").val(),
- password: $("#password").val(),
- keep_me_signin: $("#keep_me_signin").is(":checked"),
- recaptcha_challenge_field: $("#recaptcha_challenge_field").val(),
- recaptcha_response_field: $("#recaptcha_response_field").val(),
- type: u ? 11 : weSnsType,
- captcha: newCaptcha.getValue(s),
- captchaName: newCaptcha.getCaptchaName(s)
- };
- if (isFromChromePWA) {
- t.from = "pwa"
- }
- if (jQuery.cookie("_zm_fl") != "1") {
- SB.post3({
- url: "/signin",
- data: t,
- crossDomain: !SB.isIELower,
- xhrFields: {
- withCredentials: true
- },
- success: function(v) {
- if ($.cookie("enable_new_user_group_not_now")) {
- $.cookie("enable_new_user_group_not_now", null, { path: "/", secure: true })
- }
- if (!navigator.cookieEnabled) {
- SB.alert($.i18n.get("user.login.enable_browser_cookie"))
- } else {
- var w = v.result;
- if (isFromChromePWA && w.indexOf("from=pwa") < 0) {
- if (w.indexOf("?") > 0) {
- w += "&from=pwa"
- } else {
- w += "?from=pwa"
- }
- }
- location.href = w
- }
- },
- error: function(C, y, A) {
- var B = $("#error_msg");
- B.removeClass("alert-success");
- B.addClass("alert-danger");
- if (C) {
- if (A === 1106) {
- var z = new Date();
- z.setTime(z.getTime() + 30 * 60 * 1000);
- $.cookie("_zm_ct_smart", "true", { expires: z, path: "/" });
- location.href = "/signin";
- return
- } else {
- if (A == 1002) {
- var v = y.split("\r");
- if (u) {
- errorMsg = $.i18n.get("error.user.login_phone_failure_tip")
- } else {
- var x = $("#page_type");
- if (x && x.val()) {
- var w = x.val();
- if (w === "oauth.login") {
- errorMsg = $.i18n.get("error.user.login_failure")
- }
- } else {
- errorMsg = $.i18n.get("error.user.login_failure_tip")
- }
- }
- B.html(errorMsg).show()
- } else {
- if (A == 2029) {
- errorMsg = $.i18n.get("error.account.work_email_login_disabled");
- B.html(errorMsg).show()
- } else {
- if (A == 1035) {
- h = true;
- var v = y.split("\r");
- errorMsg = $.i18n.get("error.user.login_failure_not_activate");
- B.html(errorMsg).show()
- } else {
- if (A == 213) {
- errorMsg = $.i18n.get("error.user.is_clock_out_status");
- B.html(errorMsg).show()
- } else {
- B.text(y).show()
- }
- }
- }
- }
- }
- if (B.is(":visible")) {
- B.attr({
- "aria-label": B.text(),
- tabindex: -1
- });
- B.trigger("focus")
- }
- if (newCaptcha) {
- newCaptcha.refresh(s)
- }
- } else {
- B.empty().hide()
- }
- },
- btn: l,
- showBusy: true,
- busyNode: $(".busy")
- })
- }
- }
- c.find("[name=password],[name=captcha-text]").on("keyup", function(t) {
- if (t.keyCode == 13) {
- l.trigger("click")
- }
- });
- o && $("#form-group-captcha input[name=captcha-text]").removeClass("required");
- o && o.validate({
- rules: {
- phone_number: {
- required: true,
- rangelength: [11, 11],
- digits: true
- },
- code_number: {
- required: true
- }
- },
- messages: {
- phone_number: {
- required: $.i18n.get("phone_number_error"),
- rangelength: $.i18n.get("phone_number_digits_error"),
- digits: $.i18n.get("phone_number_digits")
- },
- code_number: {
- required: $.i18n.get("code_required")
- }
- },
- submitHandler: function() {
- var t = {
- pn: $("#phone-number").val(),
- smscode: $("#code-number").val()
- };
- SB.post3({
- url: "/signin/verify_sms",
- data: t,
- success: function(u) {
- SB.post3({
- url: "/signin/phone",
- data: {
- pn: $("#phone-number").val(),
- stype: 11,
- keep_me_signin: $("#keep_me_signin").is(":checked"),
- sms_token: u.result
- },
- success: function(v) {
- location.href = v.result
- },
- error: function(x, v, w) {
- if (x) {
- $("#error_msg").removeClass("alert-success").addClass("alert-danger").text(v).show();
- console.error(v, w)
- }
- }
- })
- },
- error: function(y, u, w) {
- var x = $("#error_msg");
- if (y) {
- var v = o.validate();
- if (w == 3084) {
- v.showErrors({
- code_number: u
- })
- } else {
- if (w == 3085) {
- v.showErrors({
- code_number: u
- })
- } else {
- if (w == 3086) {
- v.showErrors({
- phone_number: u
- })
- } else {
- x.removeClass("alert-success").addClass("alert-danger").text(u).show()
- }
- }
- }
- } else {
- x.empty().hide()
- }
- },
- btnContainer: o,
- showBusy: true,
- busyNode: $(".busy")
- });
- return false
- }
- });
- o && o.find("#code-number").on("keyup", function(t) {
- if (t.keyCode == 13) {
- o.trigger("submit")
- }
- });
- $("#btn-get-code").on("click", function() {
- $("#form-group-captcha input[name=captcha-text]").rules("add", {
- required: true,
- messages: {
- required: $.i18n.get("captcha.required")
- }
- });
- var u = o.validate();
- u.element("#login-form-cn input[name=captcha-text]");
- u.element("#phone-number");
- var t = false;
- if ($("#phone-number").parent(".form-group").hasClass("has-error") || $("#form-group-captcha").hasClass("has-error")) {
- t = true
- }
- if (t) {
- return
- }
- $("#form-group-captcha input[name=captcha-text]").rules("remove", "required");
- var v = this;
- $(this).html('<i class="zm-icon-loading"></i>');
- SB.post3({
- url: "/signin/sendsms",
- data: {
- pn: $("#phone-number").val().trim(),
- captcha: newCaptcha.getValue(d)
- },
- success: function(w) {
- if (typeof w === "string") {
- try {
- w = JSON.parse(w)
- } catch (x) {
- console.log(error)
- }
- }
- if (!w.status) {
- newCaptcha.refresh(d);
- $("input[name=captcha-text]", o).trigger("focus");
- $("#btn-get-code").attr("disabled", false).text($.i18n.get("send_code"))
- } else {
- $("#code-number").trigger("focus");
- var y = 59;
- $("#btn-get-code").attr("disabled", true);
- var z = setInterval(function() {
- var A = $.i18n.get("resend_after", y);
- y--;
- $("#btn-get-code").text(A);
- if (y === -1) {
- clearInterval(z);
- $("#btn-get-code").attr("disabled", false).text($.i18n.get("send_code"))
- }
- }, 1000)
- }
- },
- showBusy: false,
- error: function(x, y, w) {
- if (x) {
- newCaptcha.refresh(d);
- $(v).text($.i18n.get("send_code"));
- if (w === 3086) {
- u.showErrors({ phone_number: y });
- $("#phone-number").trigger("focus")
- } else {
- if (w === 300) {
- u.showErrors({ "captcha-text": y });
- $("input[name=captcha-text]", o).trigger("focus")
- } else {
- if (x) {
- $("#error_msg").text(y).show()
- }
- }
- }
- $("#btn-get-code").attr("disabled", false).text($.i18n.get("send_code"))
- }
- }
- })
- });
- var a = $("#existed_email_work").val() === "true";
- var p = $("#existed_email_gmail").val() === "true";
- var k = $("#existed_email_facebook").val() === "true";
- var f = $("#param_email").val();
- var j = "";
- if (a) {
- $("#email").val(f);
- j = $.i18n.get("user.login.with_work_mail", SB.htmlEncode(f))
- } else {
- if (p) {
- j = $.i18n.get("user.login.with_gmail", SB.htmlEncode(f))
- } else {
- if (k) {
- j = $.i18n.get("user.login.with_facebook", SB.htmlEncode(f))
- }
- }
- }
- if (j) {
- SB.showSuccessMsg(j, null, 120 * 1000, true)
- }
- var m = $("#confirmSendLoginDetailDialog");
- var g = $("#sendLoginDetailMailForm");
- $("#btnContinue").on("click", function() {
- var t = g.valid();
- if (!t) {
- return
- }
- if (newCaptcha.isReCaptcha) {
- newCaptcha.executeReCaptcha(e, b)
- } else {
- g.trigger("submit")
- }
- });
- g.validate({
- rules: newCaptcha.getValidationRules(),
- errorPlacement: function(t, u) {
- t.addClass("help-block");
- newCaptcha.addErrorClass(u, t)
- },
- submitHandler: function() {
- b();
- return false
- }
- });
- function b() {
- var t = {
- email: r,
- recaptcha: newCaptcha.getValue(e),
- captchaName: newCaptcha.getCaptchaName(e),
- fr: "login",
- type: weSnsType
- };
- var u = "/sendLoginFailDetail";
- if (h) {
- u = "/user_activate"
- }
- SB.post3({
- url: u,
- data: t,
- success: function(w) {
- $.modal.close();
- var x = $("#error_msg");
- var v = $.i18n.get("user.send_detail_success", r);
- x.removeClass("alert-danger");
- x.addClass("alert-success");
- x.text(v).show()
- },
- error: function(y, v, w) {
- var x = $("#error_sendmail_msg");
- if (y) {
- newCaptcha.refresh(e);
- x.text(v).show()
- } else {
- x.empty().hide()
- }
- },
- btnContainer: g,
- showBusy: true
- })
- }
- /////////// THIS IS TRIGGERED WHEN THE POST REQUEST FAILS WITH HTTP 401 UNAUTHORIZED
- $("#error_msg").on("click", "#sendDetailMailId", function() {
- $.modal(m, $.extend({}, SB.MODAL_DEFAULTS, {
- overlayId: "signin-email-dialog-overlay",
- containerId: "signin-email-dialog-container",
- persist: true,
- minHeight: m.outerHeight(),
- onShow: function() {
- if ($("#error_sendmail_msg").length) {
- $("#error_sendmail_msg").empty().hide()
- }
- newCaptcha.refresh(e)
- },
- onClose: function() {
- newCaptcha.refresh(s);
- $.modal.close()
- }
- }))
- /////////////////////////////////////////////////////////////////////////////////////
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment