測試Live Writer寫日誌

/** * @author ZhangYi */ var LOGIN_WIN_STATE = 0;//多次調用且不關閉,會出現bug function getLoginWin(para) { if(LOGIN_WIN_STATE || document.getElementById("globalLoginWin")) {//已經打開了登錄面板 return ; } LOGIN_WIN_STATE = 1; para = para || {}; //驗證.. function valid(id) { var elem = $("#"+id); if(elem.val() == "") { elem.trigger("focus"); return ; } else { return true; } } //登錄 function loginHandler() { if( formPanel.getForm().isValid() ) { var values = formPanel.getForm().getValues(); values['m'] = "login"; GameOIS.showLoading("正在驗證,請稍候..."); GameOIS.ajax("/login.do", values, function(json) { if(json.code == "0") {//登錄成功 LOGIN_WIN_STATE = 0; (para.callback || Ext.emptyFn)(json, win); } else { Ext.MessageBox.hide(); GameOIS.ajaxErr(json.msg); //刷新驗證碼 $("#verifyCodeImg").prev().val("").trigger("click"); } }); } else { valid("SLoginCode") && valid("SPasswd") && valid("randCode") } } var formPanel = new Ext.form.FormPanel({ baseCls : 'x-plain', style : "padding-top:100px;padding-bottom:30px; background:#fff url(/global/img/common/logo.jpg) no-repeat center 5px;", bodyStyle : 'color:#222;width:280px;margin:0 auto;', defaultType : 'textfield', labelSeparator : ":", labelWidth : 60, labelAlign : "right", frame: false, items : [{ id : "SLoginCode", name : "SLoginCode", width : 180, fieldLabel : "用戶名", allowBlank : false, blankText : "用戶名不能爲空" }, { id : "SPasswd", name : "SPasswd", inputType : "password", width : 180, fieldLabel : "密 碼", allowBlank : false, blankText : "密碼不能爲空" }, { id : "randCode", name : "randCode", width : 120, fieldLabel : "驗證碼", allowBlank : false, blankText : "請輸入驗證碼", maxLength : 4, regex : /^\w{4}$/, regexText : "驗證碼輸入不符合要求" }] }); var win = new Ext.Window({ width : 450, height : "auto", id : "globalLoginWin", title : para.title || "重新登錄", buttons : [{ text : "登 錄", width : 60, handler : loginHandler }], closable : para.closable || false, resizable : para.resizable || false, draggable : para.draggable || false, border : false, modal : para.modal || false, items : [formPanel] }); //加載登錄框並隱藏 win.show(); //增加驗證碼 Ext.get(Ext.getDom("randCode").parentNode).createChild({ tag : "img", id : "verifyCodeImg", src : "/login.do?m=verifyCode&kk="+(+new Date()), style : "padding-left:3px;width:60px;height:22px;border:none;cursor:pointer;", title : "點擊刷新驗證碼!", align : "absbottom" }); //刷新驗證碼 $("#verifyCodeImg").click(function() { this.src = this.src.replace(/\d+$/, +new Date()); $(this).prev().trigger("select"); return false; }); //響應回車 new Ext.KeyMap(win.getEl(), { key : Ext.EventObject.ENTER, fn : loginHandler, scope : win }); //居顯示 win.doLayout(); win.center(); setTimeout(function() { $("#SLoginCode").trigger("focus"); }, 300); return win; }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章