Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js index 84b2475..ef2b91c 100644 --- a/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js @@ -1,408 +1,405 @@ /* Copyright 2008-2011 Clipperz Srl -This file is part of Clipperz's Javascript Crypto Library. -Javascript Crypto Library provides web developers with an extensive -and efficient set of cryptographic functions. The library aims to -obtain maximum execution speed while preserving modularity and -reusability. +This file is part of Clipperz Community Edition. +Clipperz Community Edition is an online password manager. For further information about its features and functionalities please -refer to http://www.clipperz.com +refer to http://www.clipperz.com. -* Javascript Crypto Library is free software: you can redistribute +* Clipperz Community Edition is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -* Javascript Crypto Library is distributed in the hope that it will +* Clipperz Community Edition is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public - License along with Javascript Crypto Library. If not, see + License along with Clipperz Community Edition. If not, see <http://www.gnu.org/licenses/>. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } Clipperz.PM.Components.Panels.LoginPanel = function(anElement, args) { args = args || {}; Clipperz.PM.Components.Panels.LoginPanel.superclass.constructor.call(this, anElement, args); this._showLoginFormAnimator = null; this._showRegistrationFormAnimator = null; this._shouldShowRegistrationAlert = true; this._visibleForm = null; // this._isPassphraseVisible = true; Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); this.render(); return this; } //============================================================================= //MochiKit.Base.update(Clipperz.PM.Components.Panels.LoginPanel.prototype, { YAHOO.extendX(Clipperz.PM.Components.Panels.LoginPanel, Clipperz.PM.Components.Panels.BasePanel, { 'toString': function() { return "Clipperz.PM.Components.LoginPanel component"; }, //------------------------------------------------------------------------- 'render': function() { var result; var layout; var registerButton; MochiKit.Signal.disconnectAllTo(this); this.element().update(""); //MochiKit.Logging.logDebug(">>> LoginPanel.initPanel"); Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ {tag:'table', children:[ {tag:'thead'}, {tag:'tbody', children:[ {tag:'tr', children:[ {tag:'td', valign:'top', children:[ {tag:'div', cls:'clipperzServiceDescription', htmlString:Clipperz.PM.Strings['clipperzServiceDescription']} ]}, {tag:'td', valign:'top', align:'right', children:[ {tag:'div', id:this.getId('forms'), cls:'clipperzLoginForm', children:[ {tag:'div', id:this.getId('loginForm'), cls:'loginForm', children:[ {tag:'div', cls:'loginFormHeaderBox', children:[{tag:'h3', htmlString:Clipperz.PM.Strings['loginFormTitle']}]}, {tag:'form', id:this.getId('loginForm_form'), autocomplete:'off', children:[ {tag:'table', cls:'formLayout', children:[ {tag:'thead'}, {tag:'tbody', children:[ {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', width:'90', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, {tag:'td', children:[ {tag:'input', id:this.getId('login_username'), cls:'loginFormField', type:'text', name:'username'} ]} ]}, {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, {tag:'td', children:[ {tag:'div', id:this.getId('passphraseDIV'), children:[ {tag:'input', id:this.getId('login_passphrase'), cls:'loginFormField', type:'password', name:'passphrase'} ]}, {tag:'div', cls:'oneTimePassword', id:this.getId('oneTimePasswordDIV'), children:[ {tag:'input', type:'text', id:this.getId('oneTimePassword_1'), name:'passphrase'}, {tag:'span', html:'-'}, {tag:'input', type:'text', id:this.getId('oneTimePassword_2'), name:'passphrase'}, {tag:'span', html:'-'}, {tag:'input', type:'text', id:this.getId('oneTimePassword_3'), name:'passphrase'}, {tag:'span', html:'-'}, {tag:'input', type:'text', id:this.getId('oneTimePassword_4'), name:'passphrase'} ]} ]} ]}, {tag:'tr', cls:'formFieldTR', id:this.getId('passwordTypeChooserTR'), children:[ {tag:'td', valign:'top', align:'right', children:[ {tag:'input', type:'checkbox', cls:'passwordTypeCheckbox', id:this.getId('useOneTimePasswordCheckbox')} ]}, {tag:'td', children:[ {tag:'div', cls:'passwordTypeChooser', children:[ {tag:'h4', htmlString:Clipperz.PM.Strings['loginFormOneTimePasswordCheckboxLabel']}, {tag:'span', htmlString:Clipperz.PM.Strings['loginFormOneTimePasswordCheckboxDescription']} ]} ]} ]}, {tag:'tr', children:[ {tag:'td'}, {tag:'td', children:[ {tag:'div', id:this.getId('login_submit')} ]} ]} ]}, {tag:'tfoot'} ]} ]}, {tag:'div', cls:'loginFormFooterBox', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('showRegistrationLI'), children:[ {tag:'span', htmlString:Clipperz.PM.Strings['loginFormDontHaveAnAccountLabel']}, {tag:'a', href:'.', id:this.getId('showRegistration'), cls:'clipperzActionLink', htmlString:Clipperz.PM.Strings['loginFormCreateOneLabel']} ]}, {tag:'li', children:[ {tag:'span', htmlString:Clipperz.PM.Strings['loginFormForgotYourCredentialsLabel']}, {tag:'a', href:Clipperz.PM.Strings['loginFormAarghThatsBadUrl'], target:'Clipperz_Help', htmlString:Clipperz.PM.Strings['loginFormAarghThatsBadLabel']} ]}, {tag:'li', children:[ {tag:'span', htmlString:Clipperz.PM.Strings['loginFormAfraidOfMaliciousScriptsLabel']}, {tag:'a', href:Clipperz.PM.Strings['loginFormVerifyTheCodeUrl'], target:'Clipperz_Help', htmlString:Clipperz.PM.Strings['loginFormVerifyTheCodeLabel']} ]} ]} ]} ]}, {tag:'div', id:this.getId('registrationForm'), cls:'registrationForm', children:[ {tag:'div', cls:'loginFormHeaderBox', children:[{tag:'h3', htmlString:Clipperz.PM.Strings['registrationFormTitle']}]}, {tag:'form', id:this.getId('registrationForm_form'), children:[ {tag:'h5', cls:'errorMessage', id:this.getId('registration_errorMessage')}, {tag:'table', cls:'formLayout', children:[ {tag:'thead'}, {tag:'tbody', children:[ {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', width:'90', htmlString:Clipperz.PM.Strings['registrationFormUsernameLabel']}, {tag:'td', children:[ {tag:'input', id:this.getId('registration_username'), cls:'loginFormField', type:'text', name:'username'} ]} ]}, {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormPassphraseLabel']}, {tag:'td', children:[ {tag:'input', id:this.getId('registration_passphrase'), cls:'loginFormField', type:'password', name:'passphrase'} ]} ]}, {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormRetypePassphraseLabel']}, {tag:'td', children:[ {tag:'input', id:this.getId('registration_repassphrase'), cls:'loginFormField', type:'password', name:'repeat-passphrase'} ]} ]}, {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', align:'right', valign:'top', children:[ {tag:'input', id:this.getId('registration_check'), type:'checkbox', name:'safetyCheck'} ]}, {tag:'td', children:[ {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormSafetyCheckLabel']} ]} ]}, {tag:'tr', cls:'formFieldTR', children:[ {tag:'td', align:'right', valign:'top', children:[ {tag:'input', id:this.getId('registration_termsOfServiceCheck'), type:'checkbox', name:'termsOfServiceCheck'} ]}, {tag:'td', children:[ {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormTermsOfServiceCheckLabel']} ]} ]}, // {tag:'tr', cls:'formFieldTR', children:[ // {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormInvitationCodeLabel']}, // {tag:'td', children:[ // {tag:'input', id:this.getId('registration_invitationCode'), type:'text', size:'30', name:'invitationCode'} // ]} // ]}, {tag:'tr', children:[ {tag:'td'}, {tag:'td', children:[ {tag:'div', id:this.getId('registration_submit')} ]} ]} ]}, {tag:'tfoot'} ]} ]}, {tag:'div', cls:'loginFormFooterBox', children:[ {tag:'ul', children:[ {tag:'li', children:[ {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormDoYouAlreadyHaveAnAccountLabel']}, {tag:'a', href:'.', id:this.getId('showLogin'), cls:'clipperzActionLink', htmlString:Clipperz.PM.Strings['registrationFormSimplyLoginLabel']} ]} ]} ]} ]} ]}, {tag:'div', cls:'loginPanelSwitchLanguageBox', children:[ {tag:'div', cls:'loginPanelSwitchLanguageDescription', htmlString:Clipperz.PM.Strings['loginPanelSwithLanguageDescription']}, {tag:'div', cls:'loginPanelSwitchLanguageSelect', children:[ {tag:'select', id:this.getId('languageSelector'), children:Clipperz.PM.Strings['loginPanelSwitchLanguageSelectOptions']} ]} ]}, {tag:'div', cls:'browserCompatibilityBox', htmlString:Clipperz.PM.Strings['browserCompatibilityDescription']} ]} ]} ]} ]} ]}); MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', function(e){e.stop();}); MochiKit.Signal.connect(this.getId('registrationForm_form'), 'onsubmit', function(e){e.stop();}); MochiKit.Signal.connect(this.getId('showRegistration'), 'onclick', this, 'showRegistrationFormEventHandler'); MochiKit.Signal.connect(this.getId('showLogin'), 'onclick', this, 'showLoginFormEventHandler'); new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); registerButton = new YAHOO.ext.Button(this.getId('registration_submit'), {text:Clipperz.PM.Strings['registrationFormButtonLabel'], handler:this.doRegister, scope:this, minWidth:0}) if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { // this.getElement('showRegistrationLI').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); this.getElement('registrationForm_form').addClass('read-only'); registerButton.disable(); this.getElement('passwordTypeChooserTR').addClass('read-only'); this.getDom('useOneTimePasswordCheckbox').disabled = true; } MochiKit.Signal.connect(this.getId('loginForm'), 'onkeydown', this, 'onkeydown'); MochiKit.Signal.connect(this.getId('registrationForm'), 'onkeydown', this, 'onkeydown'); // MochiKit.Signal.connect(this.getId('useOneTimePasswordCheckbox'), 'onchange', this, 'renderPasswordField'); MochiKit.Signal.connect(this.getId('useOneTimePasswordCheckbox'), 'onclick', this, 'renderPasswordField'); this.renderPasswordField(); this.selectSelectedLanguageOption(); MochiKit.Signal.connect(this.getId('languageSelector'), 'onchange', this, 'switchLanguage'); MochiKit.Signal.connect(this.getId('oneTimePassword_1'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); MochiKit.Signal.connect(this.getId('oneTimePassword_2'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); MochiKit.Signal.connect(this.getId('oneTimePassword_3'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); MochiKit.Signal.connect(this.getId('oneTimePassword_4'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); MochiKit.Signal.connect(this.getId('oneTimePassword_1'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); MochiKit.Signal.connect(this.getId('oneTimePassword_2'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); MochiKit.Signal.connect(this.getId('oneTimePassword_3'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); MochiKit.Signal.connect(this.getId('oneTimePassword_4'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('registration_passphrase')); //MochiKit.Logging.logDebug("<<< LoginPanel.initPanel"); return result; }, //------------------------------------------------------------------------- 'renderPasswordField': function() { if (this.getDom('useOneTimePasswordCheckbox').checked == false) { this.getElement('oneTimePasswordDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(false); this.getElement('passphraseDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(false); this.getElement('login_passphrase').focus(); } else { this.getElement('passphraseDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); this.getElement('oneTimePasswordDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); this.getElement('oneTimePassword_1').focus(); } }, //......................................................................... 'handleOneTimePasswordFieldKeyPress': function(anEvent) { if (anEvent.key().string == '-') { switch (anEvent.src().id) { case this.getId('oneTimePassword_1'): this.getElement('oneTimePassword_2').focus(); break; case this.getId('oneTimePassword_2'): this.getElement('oneTimePassword_3').focus(); break; case this.getId('oneTimePassword_3'): this.getElement('oneTimePassword_4').focus(); break; } anEvent.stop(); } }, /* var ctrl = document.getElementById("txtTargetText"); var saveText = ctrl.value; ctrl.focus(); var range = document.selection.createRange(); var specialchar = String.fromCharCode(1); range.text = specialchar; var pos = ctrl.value.indexOf(specialchar); ctrl.value = saveText; range = ctrl.createTextRange(); range.move('character', pos); range.select(); range.text = document.getElementById("txtSourceText").value; document.getElementById("txtTargetText").focus(); window.event.returnValue = false; */ 'handleOneTimePasswordFieldKeyUp': function(anEvent) { var field; var fieldValue; var key; //console.log("keyUp", anEvent); field = anEvent.src(); fieldValue = field.value; key = anEvent.key(); // && (key.string != 'KEY_TAB') // && (key.string != 'KEY_SHIFT') // && (key.string != 'KEY_BACKSPACE') // && (key.string != 'KEY_DELETE') // && (key.string.indexOf('KEY_ARROW') != 0) if ((fieldValue.replace(/\s/g, '').length == 8) && (key.string == 'KEY_SPACEBAR')) { // field.value = Clipperz.Base.trim(fieldValue).replace(/.{4}/g, '$&' + ' '); switch (field.id) { case this.getId('oneTimePassword_1'): this.getElement('oneTimePassword_2').focus(); break; case this.getId('oneTimePassword_2'): this.getElement('oneTimePassword_3').focus(); break; case this.getId('oneTimePassword_3'): this.getElement('oneTimePassword_4').focus(); break; } // } else if (fieldValue.replace(/\s/g, '').length > 8) { } //MochiKit.Logging.logDebug("-- fieldValue: " + fieldValue); }, //......................................................................... 'doLogin': function() { //MochiKit.Logging.logDebug(">>> LoginPanel.doLogin"); if (this.checkLoginForm()) { if (this.getDom('useOneTimePasswordCheckbox').checked == false) { this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); } else { var oneTimePasswordValue; oneTimePasswordValue = this.getDom('oneTimePassword_1').value + this.getDom('oneTimePassword_2').value + this.getDom('oneTimePassword_3').value + this.getDom('oneTimePassword_4').value; this.doLoginWithUsernameAndOneTimePassword(this.getDom('login_username').value, oneTimePasswordValue); } } //MochiKit.Logging.logDebug("<<< LoginPanel.doLogin"); }, //......................................................................... 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { var deferredResult; var user; var loginPanel; //MochiKit.Logging.logDebug(">>> LoginPanel.doLoginWithUsernameAndPassphrase"); user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); loginPanel = this; deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("0 - LoginPanel.doLogin - 0: "/* + res*/); return res;}); //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), { title: "", text: "", width:240, showProgressBar:true, showCloseButton:false, fn:MochiKit.Base.method(deferredResult, 'cancel'), |