// JavaScript Document (function(){ Ext.Loader.setConfig({ enabled: true, disableCaching: false }); function updateProgressVal() { smb.user.loadVal += 0.1; if(smb.user.loadVal >= 1) { smb.user.loadVal -= 1; } Ext.getCmp('loadProBar').updateProgress(smb.user.loadVal); } Ext.onReady(function(){ //Ext.getBody().show(); //Ext.fly('bodyCnt').hide(); Ext.fly('header').hide(); Ext.fly('content').hide(); Ext.fly('footer').hide(); //Ext.fly('waiting').hide(); /* if(Ext.isIE) { //Ext.fly("browserRecommend").show(); } */ //定义命名空间,smb是应用的命名空间,smb.userInfos是当前登录用户的相关信息。 Ext.ns('smb'); //应用的命名空间 Ext.ns('smb.user'); //用户信息命名空间 Ext.ns('smb.version'); //设备版本信息 Ext.ns('smb.mode'); //设备运行模式 Ext.ns('smb.modules'); //模块注册管理对象 Ext.ns('smb.pages'); Ext.ns('smb.verify'); //验证函数入口 Ext.ns('smb.format'); //函数格式化 Ext.ns('smb.main'); //函数格式化 //smb.user.bodyMask3 = new Ext.LoadMask(window, {id:'initLoadMask', autoRender:true, resizable:true, msg:" the system is loading, please wait"}); //smb.user.bodyMask3.show(); /* smb.user.getStatus = function(){ //从服务器获取当前用户状态!返回是否超时,其他用户登录等信息。 }; */ smb.user.loginFlag = false; smb.user.is2G = false; //标记当前机型号,在其他页面的initComponent函数中用来判断哪些控件予以显示和隐藏 smb.user.loop = new Object; smb.user.loop.info = false; smb.user.loop.progress = false; smb.user.loop.monitor = false; smb.user.loop.ddns = false; smb.user.loop.speedTest = false; smb.mode.refreshFlag = true; //当模式改变时吗,是否需要重新加载新模式的页面,主要用于判断确认是否ok smb.user.loadFlag = true; smb.user.wirelessFirstLoadFlag = false; smb.user.isRemoteLogin = false; smb.user.isWirelessAccess = false; smb.user.firstLogin = false; smb.user.monitor = 0; smb.user.infoLoad = false;//判断info信息是否加载 smb.user.regionChangeAvalid = false; smb.user.newRegion = -1; //smb.user.loadVal = 0.1; smb.user.regionPage = -1; smb.user.isLockCountryID = false; smb.user.pid = 0; smb.user.progressWidth = parseInt(Ext.fly('progress_cnt').getStyle('width'),10); smb.user.regionConfirm = Ext.create('Ext.window.Window', { //title: 'Hello', height: 220, width: 500, header:false, modal :true, id : 'regionConfirmMsg', //padding:'0 0 0 5', /*html:'
TERMS OF USE

This TP-Link wireless device must be installed by a certified professional.Properly installed shielded Ethernet cable and earth grounding must be used in compliance with this product\'s warranty. Installers must abide by local rules and regulations in terms of legal frequency channels, output power,and Dynamic Frequency Selection (DFS) requirements. The End User accepts responsibility for maintaining the product in accordance with these rules and regulations. For further information, please visit www.tp-link.com.

I agree to these terms of use.
',*/ items:[ { xtype: 'fieldcontainer', width: 480, height: 35, margin: '0 10 10 10', html: smb.charset.tip.regionConfirmUser }, { xtype: 'fieldcontainer', width: 480, height: 80, margin: '0 10 10 10', //title: 'TERMS OF USE', html: smb.charset.tip.regionConfirmContent }, { xtype: 'fieldcontainer', width: 480, height: 20, //id: 'loginCfmCnt', margin: '0 10 10 10', items: { xtype: 'checkbox', id: 'regionAgreeTerm', checked: false, listeners:{ change: function( checkbox, newValue, oldValue, eOpts) { if(newValue) { Ext.getCmp('regionAccept').enable(); } else { Ext.getCmp('regionAccept').disable(); } } }, boxLabel: smb.charset.tip.regionConfirmAgree } }, { xtype: 'fieldcontainer', width: 480, // id: 'loginCfmCnt', margin: '10 0 0 10', layout:{ type:'hbox', pack:'center' }, items: [ { xtype: 'button', id: 'regionAccept', disabled: true, text: smb.charset.button.accept, margin: '0 10 0 0', listeners:{ click: function( button, e, eOpts) { //console.log("aaa"); smb.user.regionConfirm.hide(); smb.user.regionChangeAvalid = true; //console.log(smb.user.newRegion); if( smb.user.regionPage==0 ) { if(Ext.getCmp('apRegion')) { Ext.getCmp('apRegion').setValue(smb.user.newRegion); } } else if( smb.user.regionPage==1 ) { if(Ext.getCmp('apRegionQS')) { Ext.getCmp('apRegionQS').setValue(smb.user.newRegion); } } else if( smb.user.regionPage==2 ) { if(Ext.getCmp('clientRegionQS')) { Ext.getCmp('clientRegionQS').setValue(smb.user.newRegion); } } Ext.getCmp('regionAgreeTerm').setValue(false); } }, width: 80 }, { xtype: 'button', id: 'regionCancle', text: smb.charset.button.cancel, listeners:{ click: function( button, e, eOpts) { //console.log("bbb"); smb.user.regionConfirm.hide(); Ext.getCmp('regionAgreeTerm').setValue(false); } }, width: 80 } ] } ] }); if(!smb.user.loginFlag)//如果已经登录成功,显示加载进度条 { /*smb.user.loadWin = Ext.MessageBox.wait("system is loading, please wait......", "wait", { interval: 100, //bar will move fast! duration: 500000, increment: 15, text: 'Loading...', animate: true, //scope: this, fn: function(){ //alert('Done!'); } }); */ /*var temp = Ext.create('Ext.Window',{ width: 600, height: 200, hidden: false, closable: false, title:'waiting......', layout: { type:'hbox', align: 'center' }, items:[ { xtype: 'displayfield', hideLabel: true, value: "system is loading, please wait" }, { xtype:'progressbar', id:'loadProBar', width:480 } ] }); temp.show(); Ext.getCmp('loadProBar').reset(); Ext.getCmp('loadProBar').updateProgress(0.1); Ext.getCmp('loadProBar').wait({ interval: 1000, //bar will move fast! duration: 500000, increment: 10, text: 'Loading...' //scope: this, });*/ //setInterval(updateProgressVal,500); } //Ext.fly("bodyCnt").show(); var topHeight = 150; //检查用户信息,由于login.htm这个页面也需要调用这部分函数,所以这个对象不应该放在这个文件里面! //smb.user.status = 'null'; smb.user.errorType = { standby: -1, success: 0, passError: 1, timeout: 2, convFull: 3, otherLogin: 4, changePwd: 5 }; smb.user.timeout = function(response, operation, para) //para: 0-form 1-无需转码 { if(para==0) { var res = Ext.decode(operation.response.responseText); } else if(para == 1) { var res = operation; } else { var res = Ext.decode(operation.responseText); } if (res.timeout && res.timeout == true) { // 这里的参数应该同步为response的所有内容而不仅是timeout。 Ext.Ajax.request({ url: './data/version.json', timeout: 10000, method: 'GET', params: { option: 'timeout' }, success: function(response) { var data = Ext.JSON.decode(response.responseText); smb.user.showLogin.call(this, data); document.title = data.devInfo; clearInterval(smb.user.loop.station); clearInterval(smb.user.loop.interfaces); clearInterval(smb.user.loop.arpTable); clearInterval(smb.user.loop.routes); clearInterval(smb.user.loop.dhcpClients); clearInterval(smb.user.loop.dynamicWan); }, failure: function(response){ } }); return true; } else { return false; } }; //noinspection FunctionWithInconsistentReturnsJS smb.user.doLogin = function(){ //向服务器发送请求,当前用户登录! // var form = btn.findParentByType('form').getForm(); var submitStr = getCookie(); if(submitStr == null) { Ext.Msg.alert(smb.charset.tip.error, smb.charset.tip.cookieDisabled); return false; } if( Ext.getCmp('loginUsername').isValid() && Ext.getCmp('loginPassword').isValid() && Ext.getCmp('loginRegion').isValid() && Ext.getCmp('loginLanguage').isValid()) { Ext.getCmp('loginSubmit').disable(); Ext.getCmp('nonce').setValue(submitStr); var tmp_pwd_md5 = md5( Ext.getCmp('loginPassword').getValue() ); Ext.getCmp('encoded').setValue( Ext.getCmp('loginUsername').getValue() + ":" + Ext.util.Format.uppercase( md5( Ext.util.Format.uppercase( tmp_pwd_md5 ) + ":" + submitStr) ) ); } var form = Ext.getCmp('loginForm'); if( smb.user.firstLogin==true) { form.submit({ timeout: 10, waitMsgTarget: smb.charset.tip.loginingIn, waitTitle: 'TP-Link', success: function(form, action) { if(true == Ext.getCmp('agreeTerm').checked) { Ext.getCmp('loginSubmit').enable(); } else { Ext.getCmp('loginSubmit').disable(); } // change Language if (action.result.status === smb.user.errorType.changePwd) { location = location; } else { smb.user.loginCallBack.call(this, action.result); } }, failure: function(form, action) { Ext.getCmp('loginSubmit').enable(); location = location; } }); } else { form.submit({ timeout: 3, waitMsgTarget: smb.charset.tip.loginingIn, waitTitle: 'TP-Link', success: function(form, action) { Ext.getCmp('loginSubmit').enable(); smb.user.loginCallBack.call(this, action.result); }, failure: function(form, action) { Ext.getCmp('loginSubmit').enable(); location = location; } }); } }; smb.user.showMain = function(){ //这部分只改变dom显示,没有request请求。 Ext.get('maskBody').show(); smb.user.loginFlag = true; if (smb.main.login) { smb.main.login.hide(); }; if (smb.main.Main) { location = location; // Ext.get('content').show(); // Ext.get('footer').show(); // smb.main.Main.show(); // smb.main.Main.doLayout(); } else { Ext.fly('header').show(); Ext.fly('content').show(); Ext.fly('footer').show(); Ext.fly('waiting').show(); Ext.fly('wrapperCnt').setStyle('display', 'block'); smb.main.Main = (function(){ /* var savetool = Ext.create('smb.view.savetool',{ id:'savetoolCnt', renderTo: Ext.fly('savetoolCnt') }); */ var savetool = Ext.create('Ext.container.Container',{ // id: 'savetoolCnt', layout: 'hbox', items:[ { xtype: 'displayfield', id: 'saveTip', hideLabel: true, width: 780 }, { xtype: 'button', text: smb.charset.button.saveToFlash, id: 'applyChange' } ], renderTo: Ext.get('savetoolCnt') }) Ext.create('smb.view.modeCombo',{ baseBodyCls: 'modeSlt', renderTo: Ext.get('modeSlt') }); Ext.create('Ext.form.field.ComboBox',{ id: 'toolCombo', baseBodyCls: 'modeSlt', hideLabel: true, width: 120, margin: '0 0 0 10', editable: false, renderTo: Ext.get('toolSlt'), store: Ext.create('Ext.data.Store',{ fields: ['value','name'], data: [ {value:'pingTool', name:smb.charset.comboBox.ping}, {value:'tracerouteTool', name:smb.charset.comboBox.traceRoute}, {value:'speedTestTool', name:smb.charset.comboBox.speedTest}, {value:'survey', name:smb.charset.comboBox.survey}, {value:'spectrumTool', name:smb.charset.comboBox.spectrumAnalysis} ] }), displayField: 'name', valueField: 'value', value: smb.charset.comboBox.tools }) var main = Ext.create('Ext.container.Container',{ layout: { type: 'fit', align: 'center' }, id:'totalCnt', style: 'background: none', renderTo: Ext.fly('content'), padding: '0 20 20 20', items: [ { xtype:'sysStatus', width: 960, items:[ {xtype:'info'}, {xtype:'monitor'} ] } ] }); /*** 屏蔽层 ***/ smb.user.bodyMask = new Ext.LoadMask(Ext.get('content'), {useMsg:false,msg:false}); smb.user.bodyMask2 = new Ext.LoadMask(Ext.get('header'), {msg:false}); /***直接加载首页的数据****/ var controller = smb.app.getController("main"); smb.modules.loadData.call(controller, Ext.getCmp("info")); //getThroughputChart(); //smb.user.bodyMask3 = new Ext.LoadMask(Ext.getBody(), {useMsg:false,msg:false}); //smb.user.bodyMask3.show(); Ext.getCmp('modeCombo').setValue(smb.mode.status); var s = setTimeout(resetApplyChanges, 1000); return main; })(); }; }; smb.user.showLogin = function(response) { smb.user.firstLogin = response.firstLogin; smb.user.loginFlag = false; var errotType = response.status; if (smb.main.Main){ smb.main.Main.hide(); switch(Ext.getCmp('toolCombo').getValue()) { case 'pingTool': Ext.getCmp('pingBox').hide(); break; case 'tracerouteTool': Ext.getCmp('tracerouteBox').hide(); break; case 'speedTestTool': Ext.getCmp('speedTestBox').hide(); break; case 'survey': Ext.getCmp('surveyBox').hide(); break; case 'spectrumTool': Ext.getCmp('spectrumAnalysisBox').hide(); break; } if( Ext.getCmp('daylightTime') ) { Ext.getCmp('daylightTime').hide(); } }; if (smb.main.login) { smb.main.login.show(); Ext.fly('header').hide(); Ext.fly('content').hide(); Ext.fly('footer').hide(); Ext.fly('waiting').hide(); Ext.get('maskBody').hide(); } else { Ext.fly('header').hide(); Ext.fly('content').hide(); Ext.fly('footer').hide(); Ext.fly('waiting').hide(); Ext.get('maskBody').hide(); smb.main.login = (function(){ return Ext.create('Ext.window.Window', { title: smb.charset.module.login, id: 'loginPanel', width: 700, height: 360, draggable: true, resizable: false, closable: false, plain: true, // header:{ // height:32, // }, bodyStyle: { background: '#fff', padding: 0 }, items: [ { xtype: 'fieldcontainer', width: 700, layout: 'hbox', items: [ { xtype: 'image', src: 'extjs/resources/themes/images/gray/custom/logo.png', width: 166, height: 63, id:'common_logo', margin: '35 0 0 39' }, { xtype: 'smbForm', id: 'loginForm', frame: false, width: 410, margin: 0, //126 layout: { type: 'vbox', align: 'center' }, defaults: { labelAlign: 'right', inputWidth: 180, width: 404, labelWidth: 200, allowBlank: false, msgTarget: 'side' }, padding: '20 0 0 1', url: './data/version.json', buttonAlign: 'center', items: [ { xtype: 'label', hideLabel: true, inputWidth: 280, id: 'loginErrorDisplay', margin: '0 0 10 0', style:{ color: 'red', display: 'block', textAlign: 'right' } }, { xtype: 'textfield', fieldLabel: smb.charset.label.username, name: 'username', id: 'loginUsername', submitValue: false, allowBlank: false, maxLength: 31, enforceMaxLength: true, vtype: 'adminName' }, { xtype: 'textfield', fieldLabel: smb.charset.label.password, inputType: 'password', id: 'loginPassword', submitValue: false, allowBlank: false, maxLength: 15, enforceMaxLength: true, vtype: 'userPwd' }, { xtype: 'hiddenfield', id: 'nonce', name: 'nonce', submitValue: true }, { xtype: 'hiddenfield', id: 'encoded', name: 'encoded', submitValue: true }, { xtype: 'combobox', fieldLabel: smb.charset.label.region, id: 'loginRegion', editable: false, forceSelection: true, typeAhead: false, emptyText: 'Please Select a Region', autoSelect: true, allowBlank: false, displayField: 'name', valueField: 'value', triggerAction: 'all', queryMode: 'local', name: 'region', store: Ext.create('Ext.data.Store',{ id: 'loginRegionStore', fields: ['name', 'value'] }) }, { xtype: 'combobox', fieldLabel: smb.charset.label.language, id: 'loginLanguage', editable: false, forceSelection: true, allowBlank: false, displayField: 'display', valueField: 'value', queryMode: 'local', name: 'language', store: Ext.create('Ext.data.Store',{ fields:['value', 'display'], data: [ {value:0, display: smb.charset.comboBox.english}, {value:1, display: smb.charset.comboBox.chinese}, {value:2, display: smb.charset.comboBox.russia}, {value:3, display: smb.charset.comboBox.spanish} ] }) } ], listeners: { afterRender: function(thisForm, options){ this.keyNav = Ext.create('Ext.util.KeyNav', this.el, { enter: function() { var formBasic = this.getForm(); if(formBasic.isValid() && (!Ext.getCmp('loginSubmit').isDisabled())) { smb.user.doLogin.call(this); } }, scope: this }); } } }, { xtype: 'smbForm', id: 'changePwdForm', frame: false, hidden: true, width: 410, margin: 0, url: './data/changePwd.json', layout: { type: 'vbox', align: 'center' }, defaults: { labelAlign: 'right', inputWidth: 180, width: 404, labelWidth: 200, allowBlank: false, msgTarget: 'side' }, padding: '20 0 0 1', buttonAlign: 'center', items: [ { xtype: 'textfield', fieldLabel: smb.charset.label.newUserName, id: 'newUserLogin', name: 'username', vtype: 'adminName', maxLength: 31, enforceMaxLength: true, value: 'admin' }, { xtype: 'textfield', fieldLabel: smb.charset.label.newPwd, inputType: 'password', id: 'newPwdLogin', submitValue: false, allowBlank: false, maxLength: 15, validator: function(value) { if( value && value.toUpperCase()=='ADMIN') { return smb.charset.validation.adminPwd; } return smb.verify.userPwd(value); } }, { xtype: 'textfield', fieldLabel: smb.charset.label.confirmPassword, id: 'confirmNewPwdLogin', inputType: 'password', submitValue: false, allowBlank: false, maxLength: 15, validator: function(value) { var newPwd = Ext.getCmp('newPwdLogin').getValue(); if(value == newPwd) { Ext.getCmp('newPwdMd5').setValue( Ext.util.Format.uppercase(md5(value)) ); return true; } else { return smb.charset.validation.pwdNotEqual; } } }, { xtype: 'hiddenfield', id: 'newPwdMd5', name: 'newpassword', submitValue: true } ], listeners: { afterRender: function(thisForm, options){ this.keyNav = Ext.create('Ext.util.KeyNav', this.el, { enter: function() { if( Ext.getCmp('newUserLogin').validate() && Ext.getCmp('newPwdLogin').validate() && Ext.getCmp('confirmNewPwdLogin').validate()) { Ext.Ajax.request({ url: './data/changePwd.json', params: { newusername: Ext.getCmp('newUserLogin').getValue(), newpassword: Ext.getCmp('newPwdMd5').getValue() }, success: function(response) { var data = Ext.JSON.decode(response.responseText); if(data.success) { smb.user.isLockCountryID = data.isLockCountryID; smb.user.showMain.call(this); } } }) } }, scope: this }); } } } ] }, { xtype: 'fieldset', width: 620, height: 120, id: 'userTerms', margin: '0 39 10 39', padding: 10, title: smb.charset.tip.regionConfirmUserTitle, html: smb.charset.tip.regionConfirmContent }, { xtype: 'fieldset', width: 620, height: 120, id: 'changePwdTerms', hidden: true, margin: '30 39 10 39', padding: 10, // title: 'TERMS OF USE', html: smb.charset.tip.changeDefaultPwd }, { xtype: 'fieldcontainer', layout: 'hbox', width: 640, id: 'loginCfmCnt', margin: '10 0 0 39', items: [ { xtype: 'checkbox', id: 'agreeTerm', checked: false, boxLabel: smb.charset.tip.regionConfirmAgree, width: 450 }, { xtype: 'button', id: 'loginSubmit', cls:'defaultBtn', disabled: true, text: smb.charset.button.login, width: 80 }, { xtype: 'button', id: 'loginClear', cls:'compareBtn', text: smb.charset.button.clear, width: 80, margin: '0 0 0 10' } ] }, { xtype: 'fieldcontainer', layout: 'hbox', width: 640, id: 'changePwdBtnCnt', margin: '10 0 0 39', items: [ { xtype: 'button', // id: 'loginSubmit', text: smb.charset.button.finish, cls:"defaultBtn", margin: '0 10 0 450', width: 80, listeners:{ click:function(button,event) { if( Ext.getCmp('newPwdLogin').validate() && Ext.getCmp('confirmNewPwdLogin').validate()) { button.disable(); Ext.Ajax.request({ url: './data/changePwd.json', params: { newusername: Ext.getCmp('newUserLogin').getValue(), newpassword: Ext.getCmp('newPwdMd5').getValue() }, success: function(response) { // button.enable(); // if(data.success) // { // smb.user.showMain.call(this); // } var data = Ext.JSON.decode(response.responseText); smb.user.loginCallBack.call(this, data); button.enable(); } }) } } } }, { xtype: 'button', // id: 'loginClear', text: smb.charset.button.clear, cls:'compareBtn', width: 80, listeners:{ click:function() { Ext.getCmp('newPwdLogin').setValue(''); Ext.getCmp('newPwdLogin').clearInvalid(); Ext.getCmp('confirmNewPwdLogin').setValue(''); Ext.getCmp('confirmNewPwdLogin').clearInvalid(); } } } ] }, { xtype: 'fieldcontainer', id: 'reLoginCnt', hidden: true, width: 680, items: [ { xtype: 'label', id: 'otherLoginText', cls: 'loginInfo' }, { xtype: 'label', id: 'otherLoginIp', cls: 'loginInfo', margin: '10 0 30 0' }, { xtype: 'label', text: smb.charset.label.pressContinue, cls: 'setCenter' }, { xtype: 'fieldcontainer', margin: '50 0 0 0', items: [ { xtype: 'button', id: 'loginContinue', cls:"defaultBtn", text: smb.charset.button.continueBtn, width: 80, height: 26, margin: '0 10 0 480' }, { xtype: 'button', id: 'loginCancel', cls:"compareBtn", text: smb.charset.button.cancel, width: 80, height: 26 } ] } ] } ] }) })(); smb.main.login.show(); }; var formPanel = smb.main.login; if(response.is2G == true) { Ext.getCmp('loginRegion').getStore().loadData(dataFor2G) } else { Ext.getCmp('loginRegion').getStore().loadData(dataFor5G) } if (response.devInfo.indexOf("TL-") != -1) { Ext.getCmp('loginLanguage').setReadOnly(true); } // 判断用户是否第一次登陆 if(response.firstLogin == true) { formPanel.query('combobox[id=loginRegion]')[0].removeCls('noVisible'); formPanel.query('combobox[id=loginRegion]')[0].enable(); formPanel.query('combobox[id=loginLanguage]')[0].removeCls('noVisible'); formPanel.query('combobox[id=loginLanguage]')[0].enable(); formPanel.query('checkbox[id=agreeTerm]')[0].removeCls('noVisible'); formPanel.query('checkbox[id=agreeTerm]')[0].enable(); } else { formPanel.query('combobox[id=loginRegion]')[0].addCls('noVisible'); formPanel.query('combobox[id=loginRegion]')[0].disable(); formPanel.query('combobox[id=loginLanguage]')[0].addCls('noVisible'); formPanel.query('combobox[id=loginLanguage]')[0].disable(); formPanel.query('checkbox[id=agreeTerm]')[0].addCls('noVisible'); formPanel.query('checkbox[id=agreeTerm]')[0].disable(); formPanel.query('button[id=loginSubmit]')[0].enable(); } var errInfor = null; if (errotType === smb.user.errorType.otherLogin) { // errInfor = '来自'+response.ip+'地址的用户'+response.username+'已登录!'; Ext.getCmp('changePwdForm').hide(); //Ext.getCmp('changePwdForm').show(); Ext.getCmp('changePwdTerms').hide(); Ext.getCmp('changePwdBtnCnt').hide(); formPanel.query('smbForm[id=loginForm]')[0].hide(); formPanel.query('fieldset[id=userTerms]')[0].hide(); formPanel.query('fieldcontainer[id=loginCfmCnt]')[0].hide(); formPanel.setTitle(''); formPanel.query('fieldcontainer[id=reLoginCnt]')[0].show(); formPanel.query('label[id=otherLoginText]')[0].setText(smb.charset.label.user+' "'+ response.username +'" '+smb.charset.label.hasLogFrom); formPanel.query('label[id=otherLoginIp]')[0].setText( response.ip ); Ext.getCmp('loginContinue').focus(); } else if(errotType === smb.user.errorType.changePwd) { Ext.getCmp('loginPanel').setTitle(smb.charset.module.changePwd); Ext.getCmp('reLoginCnt').hide(); Ext.getCmp('loginForm').hide(); Ext.getCmp('userTerms').hide(); Ext.getCmp('loginCfmCnt').hide(); Ext.getCmp('changePwdForm').show(); //Ext.getCmp('common_logo').margin = "22 0 0 27"; Ext.getCmp('changePwdTerms').show(); Ext.getCmp('changePwdBtnCnt').show(); } else { Ext.getCmp('loginPanel').setTitle(smb.charset.module.login); Ext.getCmp('loginForm').show(); //Ext.getCmp('common_logo').margin = "40 0 0 40"; Ext.getCmp('userTerms').show(); Ext.getCmp('loginCfmCnt').show(); Ext.getCmp('changePwdForm').hide(); //Ext.getCmp('changePwdForm').show(); Ext.getCmp('changePwdTerms').hide(); Ext.getCmp('changePwdBtnCnt').hide(); Ext.getCmp('reLoginCnt').hide(); formPanel.query('fieldcontainer[id=reLoginCnt]')[0].hide(); switch (errotType){ case smb.user.errorType.passError: { errInfor = smb.charset.validation.usernamePwdError; break; };case smb.user.errorType.timeout: { errInfor = smb.charset.validation.sessionTimeout; break; };case smb.user.errorType.convFull: { errInfor = smb.charset.tip.loginSessionlimit; break; };case smb.user.errorType.standby: { errInfor = ''; break; }; }; }; if(errotType != smb.user.errorType.passError){ Ext.getCmp('loginUsername').setValue(''); Ext.getCmp('loginPassword').setValue(''); Ext.getCmp('loginUsername').clearInvalid(); Ext.getCmp('loginPassword').clearInvalid(); } formPanel.query('[id=loginErrorDisplay]')[0].setText(errInfor); }; smb.user.doLogoutRequest = function(){ //登出操作,需设置一次cookie,若是超时,不设置 //跳转至login页面 Ext.Ajax.request({ url: './data/version.json', timeout: 10000, method: 'GET', params: { option: 'logout' }, success: function(response) { var data = Ext.JSON.decode(response.responseText); smb.user.loginCallBack.call(this, data); document.title = data.devInfo; clearInterval(smb.user.loop.station); clearInterval(smb.user.loop.interfaces); clearInterval(smb.user.loop.arpTable); clearInterval(smb.user.loop.routes); clearInterval(smb.user.loop.dhcpClients); clearInterval(smb.user.loop.dynamicWan); }, failure: function(response){ } }); }; smb.user.loginCallBack = function(response) { //这部分最好重构一些,dom对象用init生成,不再考虑main对象是否已经生成! var status = response.status; if (status === smb.user.errorType.success) { smb.version = response.version; smb.mode.status = response.mode; smb.user.showMain.call(this); } else { smb.user.showLogin.call(this, response); } } smb.user.goSupportWebsite = function(){ window.open(smb.charset.webSite.support); }; smb.format = { ipToInt: function(strIp){ var patternIp = /^\s*[0-9]{1,3}\.{1}[0-9]{1,3}\.{1}[0-9]{1,3}\.{1}[0-9]{1,3}\s*$/; var ip_array = strIp.split("."); if(ip_array.length != 4){ return -1; }; if(!patternIp.test(strIp)){ return -1; }; return (Number(ip_array[0])*(1<<24)+(Number(ip_array[1])<<16 |Number(ip_array[2])<<8 |Number(ip_array[3]))); }, timeToInt: function(data) { var tmTemp = data.split(':'); data = tmTemp[0].toString() + tmTemp[1].toString(); data = Number(data); if(data==0) { data = '0000'; } // else if(data<60) // { // data = '0'+data; // } return data; }, intToTime: function(data) { data = data.toString(); var tmTemp; switch(data.length) { case 1: tmTemp = '00:0'+ data; break; case 2: tmTemp = '00:'+ data; break; case 3: tmTemp = '0' + data.slice(0,1) +':'+ data.slice(1,3); break; case 4: tmTemp = data.slice(0,2) +':'+ data.slice(2,4); break; } return tmTemp; } }; smb.verify = { ip:function(value){ var pattern_ip = /^[0-9]{1,3}\.{1}[0-9]{1,3}\.{1}[0-9]{1,3}\.{1}[0-9]{1,3}$/; if(!pattern_ip.test(value)){ return smb.charset.validation.ipFormat; }; var sub_array = value.split('.'); for(i = 0; i < 4; i++ ){ if (sub_array[i] < 0 || sub_array[i] > 255){ return smb.charset.validation.ipFormat; }; }; if(!this.allowAllZero){ if((parseInt(sub_array[0],10) == 0) &&(parseInt(sub_array[1],10) == 0) &&(parseInt(sub_array[2],10) == 0) &&(parseInt(sub_array[3],10) == 0)){ return smb.charset.validation.ipAllZero; }; }; /************允许255.255.255.255为任意地址***********/ if(sub_array[0]==255){ if(!this.allowAny) { return smb.charset.validation.ipFormat; } else { if ( !((sub_array[1] == 255) && (sub_array[2] == 255) &&(sub_array[3] == 255)) ) { return smb.charset.validation.ipFormat; } } }; if(sub_array[0] >= 240 && sub_array[0] <=254){ return smb.charset.validation.ipEClass; }; if(sub_array[0] >= 224 && sub_array[0] <=239){ return smb.charset.validation.broadcastIp; }; if(sub_array[0]==127){ return smb.charset.validation.loopIp; }; return true; }, ipOrIpMask:function(value){ var index = value.indexOf('/'); if(index < 0) { return smb.verify.ip.call(this, value); } else { var ip = value.slice(0,index); var mask = value.slice(index+1, value.length); if( (mask <= 0) || (mask > 32) ) { return smb.charset.validation.ipMaskUnion; } if(true != smb.verify.ip.call(this, ip)) { return smb.charset.validation.ipMaskUnion; } } return true; }, mtu:function(value){ }, port:function(value){ var pattern_port = /^\s*[0-9]+\s*$/; var str_port_range = value.toString(); var sub_array = str_port_range.split('-'); var len = sub_array.length; if ( len > 2 ){ return smb.charset.validation.portRangeFormat; }; for ( var i = 0 ; i < len ; i++ ){ if(sub_array[i].length == 0 || !pattern_port.test(sub_array[i]) || ( parseInt(sub_array[i]) < 1 || parseInt(sub_array[i]) > 65535 )){ return smb.charset.validation.portRangeOut; }; }; return true; }, mac: function(value){ var pattern_mac = /^([A-Fa-f0-9]{2}\-){5}[A-Fa-f0-9]{2}$/; var pattern_mac_multi = /^[0-9A-Fa-f]{1}[13579bdfBDF]{1}(\-[A-Fa-f0-9]{2}){5}$/; var pattern_mac_broadcast = /^(((FF)|(ff))\-){5}((FF)|(ff)){1}$/; if(!pattern_mac.test(value)){ return smb.charset.validation.macFormat; }; if(!this.allowBroadcast){ if(pattern_mac_broadcast.test(value)){ return smb.charset.validation.macBroadcast; }; }; if(!this.allowMulticast){ if(pattern_mac_multi.test(value)){ return smb.charset.validation.macMulti; }; }; return true; }, timeStart: function(value){ var pattern_time = /^[0-9]{1,2}\:{1}[0-9]{1,2}$/g; if(!pattern_time.test(value)){ return smb.charset.validation.timeFormat; }; var time_slice = value.indexOf(":"); var hour = parseInt(value.slice(0,time_slice),10); var mins = parseInt(value.slice(time_slice+1),10); if(hour < 0 || hour >= 24){ return smb.charset.validation.timeFormat; }; if(mins < 0 || mins >= 60){ return smb.charset.validation.timeFormat; }; if(hour == 24 && mins > 0){ return smb.charset.validation.timeStart; }; return true; }, timeEnd: function(value){ var pattern_time = /^[0-9]{1,2}\:{1}[0-9]{1,2}$/g; if(!pattern_time.test(value)){ return smb.charset.validation.timeFormat; }; var time_slice = value.indexOf(":"); var hour = parseInt(value.slice(0,time_slice),10); var mins = parseInt(value.slice(time_slice+1),10); if(hour < 0 || hour > 24){ return smb.charset.validation.timeFormat; }; if(mins < 0 || mins >= 60){ return smb.charset.validation.timeFormat; }; if(hour == 0 && mins == 0){ return false; }; if(hour == 24 && mins > 0){ return smb.charset.validation.timeStart; }; return true; }, username: function(value){ var pattern_username = /^[A-Za-z0-9\`\~\!\@\#\$\%\^\&\*\(\)\-\=\_\+\[\]\{\}\;\:\'\"\\\|\/\?\.\,\<\>\ ]+$/; if(value && !pattern_username.test(value)){ return smb.charset.validation.username; }; return true; }, adminName: function(value){ var pattern_username = /^[A-Za-z0-9\-\_\@\.]+$/; if(value && !pattern_username.test(value)){ return smb.charset.validation.username; }; return true; }, securityPwd: function(value){ if(value.length >= 8 && value.length < 64) { var pattern_password = /^[A-Za-z0-9\`\~\!\@\#\$\&\*\(\)\-\=\_\+\[\]\{\}\;\:\'\"\\\|\/\?\.\,\<\>\%\^\ ]+$/; if(value && !pattern_password.test(value)){ return smb.charset.validation.illegalPwd; }; } else if(value.length == 64) { var pattern_password = /^[A-Fa-f0-9]+$/; if(value && !pattern_password.test(value)){ return smb.charset.validation.illegalPwd; }; } return true; }, wanPwd: function(value){ var pattern_password = /^[A-Za-z0-9\`\~\!\@\#\$\&\*\(\)\-\=\_\+\[\]\{\}\;\:\'\"\\\|\/\?\.\,\<\>\%\^\/\ ]+$/; if(value && !pattern_password.test(value)){ return smb.charset.validation.passwordFormat; }; return true; }, userPwd: function(value){ var pattern_userPwd = /^[A-Za-z0-9\`\~\!\@\#\$\&\*\(\)\-\=\_\+\[\]\{\}\;\:\'\"\\\|\/\?\.\,\<\>\%\^\/]+$/; if(value && !pattern_userPwd.test(value)){ return smb.charset.validation.passwordFormat; }; return true; }, serviceName: function(value){ var pattern_serviceName = /^[A-Za-z0-9\`\~\!\@\#\$\&\*\(\)\-\=\_\+\[\]\{\}\;\:\'\"\\\|\/\?\.\,\<\>\%\^\/\ ]+$/; if(value && !pattern_serviceName.test(value)){ return smb.charset.validation.serviceName; }; return true; }, acName: function(value){ var pattern_acName = /^[A-Za-z0-9\`\~\!\@\#\$\&\*\(\)\-\=\_\+\[\]\{\}\;\:\'\"\\\|\/\?\.\,\<\>\%\^\/\ ]+$/; if(value && !pattern_acName.test(value)){ return smb.charset.validation.acName; }; return true; }, name: function(value){ /****任意可输入字符******/ return true; }, mask: function(value){ var pattern_mask = /^[0-9]{1,3}\.{1}[0-9]{1,3}\.{1}[0-9]{1,3}\.{1}[0-9]{1,3}$/; if(!pattern_mask.test(value)){ return smb.charset.validation.maskFormat; }; var sub_array = value.split('.'); for(i = 0; i < 4; i++){ if (sub_array[i] < 0 || sub_array[i] > 255){ return smb.charset.validation.maskFormat; }; }; var find_zero = false; var intIp = parseInt(parseInt(parseInt(sub_array[0])<<24) + parseInt(parseInt(sub_array[1])<<16) + parseInt(parseInt(sub_array[2])<<8) + parseInt(sub_array[3])); for(i= 0; i < 32; ++i){ var flag = 1<<(31-i); if(parseInt(intIp & flag) == parseInt(0)){ find_zero = true; }else{ if(find_zero == true){ return smb.charset.validation.maskInValid; }; }; }; if(!this.allowAllZero){ if((parseInt(sub_array[0],10) == 0) &&(parseInt(sub_array[1],10) == 0) &&(parseInt(sub_array[2],10) == 0) &&(parseInt(sub_array[3],10) == 0)){ return smb.charset.validation.ipAllZero; }; }; return true; }, domain: function(value){ // var pattern_domain = /^\s*([A-Za-z0-9][A-Za-z0-9-]+\.)+([A-Za-z]{2,4})\s*$/; var pattern_domain = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/; if(value && !pattern_domain.test(value)){ return smb.charset.validation.domainFormat; }; return true; }, integer: function(value){ var pattern_int = /^[0-9]+$/; if(value && !pattern_int.test(value)){ return smb.charset.validation.integerInvalid; }; return true; }, mail: function(value){ var pattern_int = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; if(value && !pattern_int.test(value)){ return smb.charset.validation.mailInvalid; }; return true; }, groupKey: function(value){ if(value!=0 && value<30) { return smb.charset.validation.minThirty; } else if( value!=0 && value>1000000) { return smb.charset.validation.maxMillion; } return true; }, //联合验证部分 ipMask: function(ip, mask){ var intIp = smb.format.ipToInt.call(this, ip); var intMask = smb.format.ipToInt.call(this, mask); if(0x00000000 == (intIp&intMask)){ return '非法的ip地址或掩码'; } return true; }, netIp: function(strIp,strMask){ var intIp = ipToInt(strIp); var intMask = ipToInt(strMask); if(0x00000000 == (intIp&(~intMask))){ return true; } return false; } }; /* smb.mode.subItems = { tpNetwork:{ accessPoint: [{xtype:'lan'},{xtype:'ipMacBinding'}], client: [{xtype:'lan'},{xtype:'ipMacBinding'}], wdsRepeater: [{xtype:'lan'},{xtype:'ipMacBinding'}], bridgeWithAP: [{xtype:'lan'},{xtype:'ipMacBinding'}], apRouter: [{xtype:'wan'},{xtype:'lan'},{xtype:'nat'},{xtype:'networkSecurity'},{xtype:'accessControl'},{xtype:'staticRouting'},{xtype:'bandWidthControl'},{xtype:'ipMacBinding'}], apClientRouter: [{xtype:'wan'},{xtype:'lan'},{xtype:'nat'},{xtype:'networkSecurity'},{xtype:'accessControl'},{xtype:'staticRouting'},{xtype:'bandWidthControl'},{xtype:'ipMacBinding'}] }, wireless:{ accessPoint: [{xtype:'tdma'},{xtype:'wirelessApSettings'},{xtype:'multiSsid'},{xtype:'wireMacFilter'},{xtype:'wirelessAdv'}], //,{xtype:'spectrumAnalysis'} client: [{xtype:'tdma'},{xtype:'wirelessClientSettings'},{xtype:'wirelessAdv'}], //,{xtype:'survey'} wdsRepeater: [{xtype:'tdma'},{xtype:'wirelessClientSettings'},{xtype:'wireMacFilter'},{xtype:'wirelessAdv'}], //,{xtype:'survey'} bridgeWithAP: [{xtype:'tdma'},{xtype:'wirelessApSettings'},{xtype:'wirelessClientSettings'},{xtype:'wireMacFilter'},{xtype:'wirelessAdv'}], apRouter: [{xtype:'tdma'},{xtype:'wirelessApSettings'},{xtype:'wirelessClientSettings'},{xtype:'wireMacFilter'},{xtype:'wirelessAdv'}], apClientRouter: [{xtype:'tdma'},{xtype:'wirelessApSettings'},{xtype:'wirelessClientSettings'},{xtype:'wireMacFilter'},{xtype:'wirelessAdv'}] } } */ smb.mode.accessPoint = { quickSet: { quickSetup:1, qSetAC:2}, sysStatus: {info:1, monitor:2, quickSetup:3, qSetAC:4}, tpNetwork: { lan: 1, mgmt: 2, ipMacBinding:6}, wireless: {tdma: 1,wirelessApSettings: 2, multiSsid:3, wireMacFilter:4, wirelessAdv:5}, //, spectrumAnalysis:6 management: { log:1, miscellaneous:2, ping:3, ddns:4, webserver:5, snmp:6, sshServer:7, rssiLed:8, autoMail:9, openLog:10}, system: {deviceName:1, location:2, userAccount:3, time:4, firmware:5, configuration:6, rebootBar:7} }; smb.mode.client = { quickSet: { quickSetup:1, qSetAC:2}, sysStatus: {info:1, monitor:2, quickSetup:3, qSetAC:4}, tpNetwork: { lan: 1, mgmt: 2, ipMacBinding:6}, wireless: {tdma: 1, wirelessClientSettings: 2, wirelessAdv:3}, //, spectrumAnalysis:6, survey: 5 management: { log:1, miscellaneous:2, ping:3, ddns:4, webserver:5, snmp:6, sshServer:7, rssiLed:8, autoMail:9, openLog:10}, system: {deviceName:1, location:2, userAccount:3, time:4, firmware:5, configuration:6, rebootBar:7} }; smb.mode.wdsRepeater = { quickSet: { quickSetup:1, qSetAC:2}, sysStatus: {info:1, monitor:2, quickSetup:3, qSetAC:4}, tpNetwork: { lan: 1, mgmt: 2, ipMacBinding:6}, wireless: {tdma: 1,wirelessClientSettings: 2, wireMacFilter:3, wirelessAdv:4}, //, spectrumAnalysis:6, survey: 5 management: { log:1, miscellaneous:2, ping:3, ddns:4, webserver:5, snmp:6, sshServer:7, rssiLed:8, autoMail:9, openLog:10}, system: {deviceName:1, location:2, userAccount:3, time:4, firmware:5, configuration:6, rebootBar:7} }; smb.mode.bridgeWithAP = { quickSet: { quickSetup:1, qSetAC:2}, sysStatus: {info:1, monitor:2, quickSetup:3, qSetAC:4}, tpNetwork: { lan: 1, mgmt: 2, ipMacBinding:6}, wireless: {tdma: 1, wirelessClientSettings: 2, wirelessApSettings: 3, wireMacFilter:4, wirelessAdv:5}, //, spectrumAnalysis:7, survey: 6 management: { log:1, miscellaneous:2, ping:3, ddns:4, webserver:5, snmp:6, sshServer:7, rssiLed:8, autoMail:9, openLog:10}, system: {deviceName:1, location:2, userAccount:3, time:4, firmware:5, configuration:6, rebootBar:7} }; smb.mode.apRouter = { quickSet: { quickSetup:1, qSetAC:2}, sysStatus: {info:1, monitor:2, quickSetup:3, qSetAC:4}, tpNetwork: {wan: 1, lan: 2, mgmt: 3, nat:4, networkSecurity:5, accessControl:6, staticRouting:7, bandWidthControl:8, ipMacBinding:9, dosList:10}, wireless: {tdma: 1, wirelessApSettings: 2, wireMacFilter:3, wirelessAdv:4}, //, survey: 6, spectrumAnalysis:7 management: { log:1, miscellaneous:2, ping:3, ddns:4, webserver:5, snmp:6, sshServer:7, rssiLed:8, autoMail:9, openLog:10}, system: {deviceName:1, location:2, userAccount:3, time:4, firmware:5, configuration:6, rebootBar:7} }; smb.mode.apClientRouter = { quickSet: { quickSetup:1, qSetAC:2}, sysStatus: {info:1, monitor:2, quickSetup:3, qSetAC:4}, tpNetwork: {wan: 1, lan: 2, mgmt: 3, nat:4, networkSecurity:5, accessControl:6, staticRouting:7, bandWidthControl:8, ipMacBinding:9, dosList:10}, wireless: {tdma: 1,wirelessClientSettings: 2, wirelessApSettings: 3, wireMacFilter:4, wirelessAdv:5}, //, survey: 6, spectrumAnalysis:7 management: { log:1, miscellaneous:2, ping:3, ddns:4, webserver:5, snmp:6, sshServer:7, rssiLed:8, autoMail:9, openLog:10}, system: {deviceName:1, location:2, userAccount:3, time:4, firmware:5, configuration:6, rebootBar:7} }; smb.mode.status = 'accessPoint'; smb.mode.getMode = function(){ //这个值返回给status! //ext.ajax return 'accessPoint'; }; smb.mode.changeMode = function(newMode, oldMode){ //注册 smb.mode.status = newMode; refreshChannel(); //修改modules的注册 for (var page in smb.modules){ for (var module in smb.modules[page]){ var moduleInfo = smb.modules[page][module]; if(moduleInfo.id) { if (moduleInfo.id in smb.mode[newMode][page]){ var status = moduleInfo.status; switch (status){ case 'on': { break; };/* case 'off': { smb.modules[page][module].status = 'toAdd'; break; }; */default: { smb.modules[page][module].status = 'toAdd'; } } }else{ smb.modules[page][module].status = 'toDestory'; }; } } } //由client模式切换为其他模式时,需要去刷新txrate的值 // console.log(smb.pages.currentCmpId); if(smb.pages.currentCmpId == "wireless") { /* if(smb.mode.status == "wdsRepeater") { Ext.getCmp('tdmaEnableTotalCnt').hide(); } else if(smb.mode.status == "accessPoint" || smb.mode.status == "apRouter")//只有开关,没有模式选择。 { Ext.getCmp('tdmaEnableTotalCnt').show(); Ext.getCmp('tdmaEnable').show(); Ext.getCmp('tdmaEnable').enable(); Ext.getCmp('tdmaPriority').hide(); Ext.getCmp('tdmaPriority').disable(); } else { Ext.getCmp('tdmaEnableTotalCnt').show(); Ext.getCmp('tdmaEnable').hide(); Ext.getCmp('tdmaEnable').disable(); Ext.getCmp('tdmaPriority').show(); Ext.getCmp('tdmaPriority').enable(); } */ Ext.defer(smb.app.getController('wireless').setTxRateValue,1000,[1]); if(smb.mode.status == "apRouter" || smb.mode.status == "client") { if(Ext.getCmp('clientWirelessEnable')) { Ext.getCmp('clientWirelessEnable').show(); Ext.getCmp('clientWirelessEnable').enable(); } } else { if(Ext.getCmp('clientWirelessEnable')) { Ext.getCmp('clientWirelessEnable').hide(); Ext.getCmp('clientWirelessEnable').disable(); } } } if(smb.pages.currentCmpId == "sysStatus") { Ext.Ajax.request({ url: './data/getThroughputIfList.json', timeout: 10000, params: { }, success: function(response) { if(!smb.user.timeout.call(this, response, response)) { var data = Ext.JSON.decode(response.responseText); var ifList = new Array; for( var i=0; i