var FR = { windowHeight: 190, windowWidth: 300, logoAreaWidth: 193, initForm: function() { if (Ext.isAndroid) { Settings.ui_login_logo = false; Settings.ui_login_text = false; } if (Settings.ui_login_logo.length || Settings.ui_login_text.length) { this.windowWidth += this.logoAreaWidth; this.windowHeight += 30; } if (Settings.ui_login_title.length) { this.windowHeight += 30; } if (Settings.passwordRecoveryEnabled || Settings.signUpEnabled) { this.windowHeight += 21; } this.formPanel = new Ext.form.FormPanel({ labelAlign: 'right', ref: '../frm', defaultType: 'textfield', autoHeight: true, hideLabels: true, bodyStyle: 'padding:23px', cls: 'loginForm', standardSubmit: true, url: URLRoot+'/?module=fileman&page=login&action=login', listeners: { 'render': function() { this.getForm().el.set({ 'action': URLRoot+'/?module=fileman&page=login&action=login', 'target': 'submitIframe', 'onSubmit': 'FR.submitForm();return false;' }); } }, items: [ { ref: 'usrField', name: 'username', value: prefilledUsername, width: '100%', tabIndex: 1, height:'34px', cls: 'loginFormField', autoCreate: {tag: 'input', type: 'text', placeholder: FR.T('Username'), autocomplete: 'on', required: 'true'} }, { xtype: 'textfield', id: 'pass', tabIndex: 2, value: prefilledPassword, width: '100%', name: 'password', inputType: 'password', height:'34px', cls: 'loginFormField', autoCreate: {tag: 'input', type: 'password', placeholder: FR.T('Password'), autocomplete: 'on'} }, {xtype: 'component', html: ''}, { xtype: 'textfield', ref: 'otp', hidden: true, id: 'otp', value: '', width: '100%', name: 'otp', height:'34px', cls: 'loginFormField', autoCreate: {tag: 'input', type: 'text', placeholder: FR.T('Verification code')} }, {xtype: 'hidden', name: 'two_step_secret', ref: 'two_step_secret', value: ''}, {xtype: 'hidden', name: 'language', ref: 'language', value: ''}, { xtype: 'panel', layout: {type: 'hbox'}, items: [ {xtype: 'displayfield', value: ''+FR.T('Create account')+'', style:'padding-top:5px;text-align:right', hidden: !Settings.signUpEnabled}, {xtype: 'displayfield', flex:1, value: ''+FR.T('Forgot password?')+'', style:'padding-top:5px;text-align:right', hidden: !Settings.passwordRecoveryEnabled} ] } ] }); this.iframe = Ext.DomHelper.append(document.body, { tag: 'iframe', name: 'submitIframe', id:'submitIframe', frameBorder: 0, width: 0, height: 0, css: 'display:none;visibility:hidden;height:0px;', src: 'about:blank' }); Ext.get('submitIframe').on('load', function() { this.win.body.unmask(); var frameDoc; if (this.iframe.contentDocument) { if (this.iframe.contentDocument.document) { frameDoc = this.iframe.contentDocument.document; } else { frameDoc = this.iframe.contentDocument; } } else { if (this.iframe.contentWindow.document) { frameDoc = this.iframe.contentWindow.document; } } var responseText = frameDoc.body.innerHTML; if (responseText.length == 0) { return false; } try { var rs = Ext.util.JSON.decode(responseText); } catch (er) { if (confirm(FR.T('Unexpected server reply. Press "OK" to display it.'))) { document.write(responseText); } return false; } if (rs.success) { FR.win.body.mask(FR.T('Loading...')); if (rs.redirect_url) { document.location.href = decodeURIComponent(rs.redirect_url); } else { document.location.href = URLRoot; } } else if (rs.success == false) { FR.win.frm.otp.setValue(''); if (rs.twoStepSecret) { FR.win.frm.two_step_secret.setValue(rs.twoStepSecret); FR.showQR(rs.twoStepSecret, rs.keyURI); } else { if (rs.ask_otp) { new Ext.ux.prompt({ text: rs.error, placeHolder: FR.T('6 digit verification code'), confirmHandler: function(code) { FR.win.frm.otp.setValue(code); FR.submitForm(); } }); } else { new Ext.ux.prompt({text: rs.error, callback: function() {FR.win.frm.usrField.focus(true);}}); } } } }, this); var lang = []; Ext.each(Settings.languages, function(l) { var t = l[1], v = l[0]; lang.push({ text: t, handler: function () { FR.win.body.mask(FR.T('Changing language...')); document.location.href = URLRoot+'/?language='+encodeURIComponent(v); } }); }); this.win = new Ext.Window({ title: FR.T(Settings.ui_login_title), cls:'login'+(Settings.ui_bg?' transparent':''), layout: 'border', width: this.windowWidth, height: this.windowHeight, buttonAlign: 'left', closable: false, resizable: false, draggable: false, listeners: {'show': function(){ this.frm.usrField.focus(false, 20); if (Settings.ui_login_logo.length) { Ext.fly('loginLogoImage').show().setStyle('background-image', 'url("'+Settings.ui_login_logo+'")') .setHeight(this.body.getHeight()); /* adjust small logos */ Ext.get(document.createElement('img')).on('load', function () {if (this.dom) { if (this.dom.width < 169 && this.dom.height < 158) { Ext.fly('loginLogoImage').setStyle('background-size', 'auto'); } }}).set({src: Settings.ui_login_logo}); if (Settings.ui_login_text.length) { new Ext.Window({ cls: 'loginTextFooter'+(Settings.ui_bg?' transparent':false), unstyled: !Settings.ui_bg, html: Settings.ui_login_text, autoHeight: true, closable: false, resizable: false, draggable: false, width: FR.windowWidth }).show().anchorTo(this.getEl(), 'tr-br', [0,10]); } } else { if (Settings.ui_login_text.length) { Ext.get('loginText').show(); } } }}, items: [ { region: 'west', width: this.logoAreaWidth, id: 'logoArea', html:'