window.console = window.console || (function () { var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function () { }; return c; })(); $(document).ajaxError(function (event, XMLHttpRequest, ajaxOptions, thrownError) { if (XMLHttpRequest.status == 400) showTip(XMLHttpRequest.responseText); else if (XMLHttpRequest.status == 403) ShowLogin(); }); $(document).ajaxStart(function () { try { $("span.loading", $("#DoHead")[0].contentWindow.document).show(); } catch (e) { } }).ajaxComplete(function (event, request, settings) { try { $("span.loading", $("#DoHead")[0].contentWindow.document).hide(); } catch (e) { } }); var timer = null; $("#ChangeSubject,#SubjectPanel").hover(function () { clearTimeout(timer); timer = setTimeout(function () { $("#SubjectPanel").show(); }, 100); }, function () { clearTimeout(timer); timer = setTimeout(function () { $("#SubjectPanel").hide(); }, 100); }); function ChangeSubject(url) { var d = dialog({ title: "请选择学科", content: "" }); d.showModal(); } /*低版本ie模拟placeholder*/ var funPlaceholder = function (element) { var placeholder = ''; if (element && !("placeholder" in document.createElement("input")) && (placeholder = element.getAttribute("placeholder"))) { element.onfocus = function () { if (this.value === placeholder) { this.value = ""; } this.style.color = ''; }; element.onblur = function () { if (this.value === "") { this.value = placeholder; this.style.color = 'graytext'; } }; //样式初始化 if (element.value === "") { element.value = placeholder; element.style.color = 'graytext'; } } }; $(":text").each(function () { funPlaceholder(this); }); function showTip(message) { var win = dialog({ content: message, cancel: true, cancelValue: '确定' }).showModal(); if (message.length < 10) { win.width(200); } } function showMessage(errorStr, fun) { var win = dialog({ content: errorStr, okValue: '确定', ok: fun, cancel: false }).showModal(); if (errorStr.length < 10) { win.width(200); } } function showConfirm(message, fun) { var win = dialog({ title: '操作提示', content: message, ok: fun, okValue: '确定', cancelValue: '取消', cancel: true }).showModal(); if (message.length < 10) { win.width(200); } } function checkLogin() { $("a.needLogin").unbind("click").removeAttr('onclick').click(function () { ShowLogin(); return false; }); } function ShowLogin() { var Buffer = []; Buffer.push('
'); window.LoginWin = dialog({ zIndex: 30000, id: 'Login', statusbar: '', title: '登录窗口', content: Buffer.join(""), okValue: '立即登录', ok: function () { PostLogin(); return false; } }).showModal(); $("#UserLogin input").keydown(function (e) { if (e.keyCode == 13) { $('button[data-id="ok"]').trigger("click"); } }); } function PostLogin() { var UserName = $("#UserName").val(); var PassWord = $("#PassWord").val(); var IsSave = $("#IsSave")[0].checked; if (UserName == "" || UserName == "网校号或邮箱或手机号") { alert("请输入网校号或者邮箱或手机号"); $("#UserName").focus(); } else if (PassWord == "") { alert("请输入网校号密码"); $("#PassWord").focus(); } else { $.post("/Login.DoLogin.data", { UserName: UserName, PassWord: PassWord, IsSave: IsSave }, function (data) { if (data.R != "ok") { top.alert(data.R); } else { location.reload(true); } }, "json"); } } if (typeof (IsLogin) != "undefined" && !IsLogin) { checkLogin(); setTimeout(function () { if (!IsLogin) { checkLogin(); } }, 1000); } String.Format = function () { if (arguments.length == 0) return null; var str = arguments[0]; for (var i = 1; i < arguments.length; i++) { var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm'); str = str.replace(re, arguments[i]); } return str; }; String.prototype.len = function () { var value = this.replace(/(^\s*)|(\s*$)/g, ""); if (value == "") { return 0; } else { return value.replace(/[^\x00-\xff]/g, "xx").length; } };