Ext.SSL_SECURE_URL="/images/s.gif"; Ext.BLANK_IMAGE_URL="/images/s.gif"; Login = function(){ var win, form, submitUrl = 'system/login/login.php'; function detectCapsLock(e) { if(e.getKey()!=13 && e.getKey()!=10 && e.getKey()!=127){ if((!e.shiftKey && (e.getKey() >= 65 && e.getKey() <= 90)) || ((e.getKey() >= 97 && e.getKey() <= 122) && e.shiftKey)){ return true; } else { return false; } } } function onSubmit() { form.submit({ waitMsg: 'Vennligst vent...', failure: function(form, action) { Ext.MessageBox.alert('Feil', action.result.errorInfo); }, reset: true, success: function(result, data){ if(typeof data.result.unconfirmed_tems != 'undefined') { document.location.href = 'confirm-terms.html?token='+data.result.sessionId; } else { if (data.result.showTfaEmailForm) { document.location.href = '/confirm-tfa-email.php?token='+data.result.sessionId; } else if (data.result.showTfaForm) { document.location.href = '/confirm-tfa.html?token='+data.result.sessionId; } else if (data.result.showTfaSetupForm){ document.location.href = '/setup-tfa.php?token='+data.result.sessionId; } else { location.reload(); } } }, scope: Login }); } function lostPassword() { Ext.Msg.prompt('Glemt passord', 'Brukernavn (medl.nr.):', function(btn, text){ if (text != "") { Ext.Ajax.request({ url : 'content/lostpassword/lostpassword.php?mode=lostPassword', params : { txtUsername : text }, method: 'POST', success: function ( result, request ) { if(result.responseText=="MailSent") { Ext.MessageBox.alert('Melding', 'Vennligst sjekk din Epost. Ditt passord er sendt dit.'); } else if(result.responseText=="MailNotSent" || result.responseText=="NoEmailAddress") { Ext.MessageBox.alert('Feil', 'Ingen Epost er tilknyttet dette medlemsnummer. Vennligst ta kontakt med organisasjonen'); } else { Ext.MessageBox.alert('Feil', 'Ugyldig brukernavn'); } }, failure: function ( result, request) { Ext.MessageBox.alert('Feil', 'Ugyldig brukernavn'); } }); } }); } return{ Init:function(){ Ext.QuickTips.init(); var logoPanel = new Ext.Panel({ baseCls: 'x-plain', id: 'login-logo', region: 'center' }); var formPanel = new Ext.form.FormPanel({ baseCls: 'x-plain', baseParams: { module: 'login' }, defaults: { width: 200 }, defaultType: 'textfield', frame: false, height: 92, id: 'login-form', items: [ { fieldLabel: 'Brukernavn (medl.nr.)', name: 'user', value: '', enableKeyEvents: true, listeners: { keypress: function(f, e) { if (detectCapsLock(e)) { Ext.getCmp('check-caps-lock').setVisible(true); } else { Ext.getCmp('check-caps-lock').setVisible(false); } } } },{ fieldLabel: 'Passord', inputType: 'password', name: 'pass', value: '', enableKeyEvents: true, listeners: { keypress: function(f, e) { if (detectCapsLock(e)) { Ext.getCmp('check-caps-lock').setVisible(true); } else { Ext.getCmp('check-caps-lock').setVisible(false); } } } },{ xtype: 'panel', id: 'check-caps-lock', bodyStyle: 'padding-top: 4px;background-color:#CBCD7C; text-align: right;color: #FF0000;font-size: 12px; font-weight: bold;', border: false, width: 290, html: 'Caps-Lock er på', hidden: true }], labelWidth:141, region: 'south', url: submitUrl }); win = new Ext.Window({ buttons: [ { handler: lostPassword, text: 'Glemt passord' },{ handler: onSubmit, scope: Login, text: 'Logg inn' }], buttonAlign: 'right', closable: false, draggable: false, height: 260, id: 'login-win', keys: { key: [13], fn: onSubmit, scope:this }, layout: 'border', minHeight: 250, minWidth: 530, plain: false, resizable: false, items: [ logoPanel, formPanel ], title: 'Logg inn (RegWeb v. 1.9. (CORE-S4) - af)', width: 530 }); form = formPanel.getForm(); formPanel.on('render', function(){ var f = form.findField('user'); if(f){ f.focus(); } }, this, {delay: 200}); win.show(); }, Success: function(f,a){ if(a && a.result){ /************* JOOMLA CODE ***********************/ win.destroy(true); var path = window.location.pathname; path = path.substring(0, path.lastIndexOf('/') + 1); /* set_cookie('sessionId', a.result.sessionId, '', path, '', '' ); set_cookie('memberName', a.result.name, '', path, '', '' ); set_cookie('memberGroup', a.result.group, '', path, '', '' ); */ var urlParamString = window.location.search.length > 0 ? window.location.search.substring(1) : ''; var urlParams = Ext.urlDecode(urlParamString); /*if (urlParams['returnUrl']) { window.location = urlParams['returnUrl']; } else { window.location = path; }*/ } } }; }(); Ext.BasicForm.prototype.afterAction=function(action, success){ this.activeAction = null; var o = action.options; if(o.waitMsg){ Ext.MessageBox.updateProgress(1); Ext.MessageBox.hide(); } if(success){ if(o.reset){ this.reset(); } Ext.callback(o.success, o.scope, [this, action]); this.fireEvent('actioncompleted', this, action); }else{ Ext.callback(o.failure, o.scope, [this, action]); this.fireEvent('actionfailed', this, action); } } Ext.onReady(Login.Init, Login, true);