Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Main.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Main.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Main.js b/frontend/beta/js/Clipperz/PM/Main.js index 9a068e1..989e0a4 100644 --- a/frontend/beta/js/Clipperz/PM/Main.js +++ b/frontend/beta/js/Clipperz/PM/Main.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.PM) == 'undefined') { Clipperz.PM = {}; } Clipperz.PM.VERSION = "0.1"; Clipperz.PM.NAME = "Clipperz.PM"; //############################################################################# Clipperz.PM.Main = function() { this._loginPanel = null; this._user = null; this._isRunningCompact = false; Clipperz.NotificationCenter.register(null, 'userConnected', this, 'userConnectedCallback'); Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); Clipperz.NotificationCenter.register(null, 'EXCEPTION', this, 'reportException'); return this; } //============================================================================= MochiKit.Base.update(Clipperz.PM.Main.prototype, { 'toString': function() { return "Clipperz.PM.Main"; }, 'switchLanguageHandler': function() { //MochiKit.Logging.logDebug(">>> main.switchLanguageHandler"); YAHOO.ext.Element.get('donateHeaderIconLink').dom.href = Clipperz.PM.Strings['donateHeaderLinkUrl']; YAHOO.ext.Element.get('donateHeaderLink').update(Clipperz.PM.Strings['donateHeaderLinkLabel']).dom.href = Clipperz.PM.Strings['donateHeaderLinkUrl']; YAHOO.ext.Element.get('creditsHeaderLink').update(Clipperz.PM.Strings['creditsHeaderLinkLabel']).dom.href = Clipperz.PM.Strings['creditsHeaderLinkUrl']; YAHOO.ext.Element.get('feedbackHeaderLink').update(Clipperz.PM.Strings['feedbackHeaderLinkLabel']).dom.href = Clipperz.PM.Strings['feedbackHeaderLinkUrl']; YAHOO.ext.Element.get('helpHeaderLink').update(Clipperz.PM.Strings['helpHeaderLinkLabel']).dom.href = Clipperz.PM.Strings['helpHeaderLinkUrl']; YAHOO.ext.Element.get('forumHeaderLink').update(Clipperz.PM.Strings['forumHeaderLinkLabel']).dom.href = Clipperz.PM.Strings['forumHeaderLinkUrl']; if (YAHOO.ext.Element.get('logout') != null) { YAHOO.ext.Element.get('logout').update(Clipperz.PM.Strings['logoutMenuLabel']); YAHOO.ext.Element.get('lock').update(Clipperz.PM.Strings['lockMenuLabel']); YAHOO.ext.Element.get('recordsTabAnchor').update(Clipperz.PM.Strings['recordMenuLabel']); YAHOO.ext.Element.get('accountTabAnchor').update(Clipperz.PM.Strings['accountMenuLabel']); YAHOO.ext.Element.get('dataTabAnchor').update(Clipperz.PM.Strings['dataMenuLabel']); // YAHOO.ext.Element.get('contactsTabAnchor').update(Clipperz.PM.Strings['contactsMenuLabel']); YAHOO.ext.Element.get('toolsTabAnchor').update(Clipperz.PM.Strings['toolsMenuLabel']); } //MochiKit.Logging.logDebug("<<< main.switchLanguageHandler"); }, //------------------------------------------------------------------------- 'fixToDrawTheMainTabsCorrectlyOnSafari': function() { this.switchLanguageHandler(); }, //------------------------------------------------------------------------- 'run': function(shouldShowRegistrationForm) { var mainElement; Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'updateProgressDialogStatus'); YAHOO.ext.Element.get('recordDetailEditModeHeaderMask').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide().unmask(); YAHOO.ext.Element.get('recordDetailEditModeVerticalMask').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide().unmask(); //MochiKit.Logging.logDebug(">>> Main.run"); mainElement = YAHOO.ext.Element.get('main'); if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { YAHOO.ext.Element.get('applicationVersionType').dom.className = "readOnly"; } mainElement.update(""); Clipperz.YUI.DomHelper.append(mainElement.dom, {tag:'ul', cls:'clipperzTabPanels', children:[ {tag:'li', id:'loginPanel'} ]}) this.setLoginPanel(new Clipperz.PM.Components.Panels.LoginPanel(YAHOO.ext.Element.get('loginPanel'))); //MochiKit.Logging.logDebug("--- Main.run - selecting active form to show ..."); if (shouldShowRegistrationForm == true) { this.loginPanel().showRegistrationForm(false); } else { this.loginPanel().showLoginForm(false); } this.switchLanguageHandler(); //MochiKit.Logging.logDebug("--- Main.run - selecting active form to show. done."); //MochiKit.Logging.logDebug("<<< Main.run"); }, //------------------------------------------------------------------------- 'runCompact': function() { this.setIsRunningCompact(true); YAHOO.ext.Element.get(document.body).addClass("compact"); new Clipperz.PM.Components.Compact.LoginForm(YAHOO.ext.Element.get('mainDiv')); }, 'showCompactInterface': function() { //MochiKit.Logging.logDebug(">>> main.showCompactInterface"); new Clipperz.PM.Components.Compact.CompactInterface(YAHOO.ext.Element.get('compactBody'), {user:this.user()}); //MochiKit.Logging.logDebug("<<< main.showCompactInterface"); }, //------------------------------------------------------------------------- 'mainPage': function() { if (this._mainPage == null) { this._mainPage = new Clipperz.PM.Components.MainPage(); } return this._mainPage; }, //------------------------------------------------------------------------- 'loginPanel': function() { return this._loginPanel; }, 'setLoginPanel': function(aValue) { this._loginPanel = aValue; }, //------------------------------------------------------------------------- 'showMainPanels': function() { var mainElement; var logoutBlock; var lockBlock; var menusTRElement; this.loginPanel().remove(); this.setLoginPanel(null); logoutBlock = YAHOO.ext.Element.get('logoutLI'); Clipperz.YUI.DomHelper.append(logoutBlock.dom, {tag:'a', href:"#", id:'logout', htmlString:Clipperz.PM.Strings['logoutMenuLabel']}); MochiKit.Signal.connect('logout', 'onclick', this, 'doLogoutEventHandler'); lockBlock = YAHOO.ext.Element.get('lockLI'); Clipperz.YUI.DomHelper.append(lockBlock.dom, {tag:'a', href:"#", id:'lock', htmlString:Clipperz.PM.Strings['lockMenuLabel']}); MochiKit.Signal.connect('lock', 'onclick', this, 'doLockEventHandler'); menusTRElement = YAHOO.ext.Element.get('menusTR'); Clipperz.YUI.DomHelper.append(menusTRElement.dom, {tag:'td', id:'recordsTab', children:[{tag:'div', children:[{tag:'a', id:'recordsTabAnchor', htmlString:Clipperz.PM.Strings['recordMenuLabel']}]}]}); Clipperz.YUI.DomHelper.append(menusTRElement.dom, {tag:'td', id:'accountTab', children:[{tag:'div', children:[{tag:'a', id:'accountTabAnchor', htmlString:Clipperz.PM.Strings['accountMenuLabel']}]}]}); Clipperz.YUI.DomHelper.append(menusTRElement.dom, {tag:'td', id:'dataTab', children:[{tag:'div', children:[{tag:'a', id:'dataTabAnchor', htmlString:Clipperz.PM.Strings['dataMenuLabel']}]}]}); // Clipperz.YUI.DomHelper.append(menusTRElement.dom, {tag:'td', id:'contactsTab', children:[{tag:'div', children:[{tag:'a', id:'contactsTabAnchor', htmlString:Clipperz.PM.Strings['contactsMenuLabel']}]}]}); Clipperz.YUI.DomHelper.append(menusTRElement.dom, {tag:'td', id:'toolsTab', children:[{tag:'div', children:[{tag:'a', id:'toolsTabAnchor', htmlString:Clipperz.PM.Strings['toolsMenuLabel']}]}]}); mainElement = YAHOO.ext.Element.get('main'); mainElement.update(""); Clipperz.YUI.DomHelper.append(mainElement.dom, {tag:'ul', cls:'clipperzTabPanels', children:[ {tag:'li', id:'recordsPanel'}, {tag:'li', id:'accountPanel'}, {tag:'li', id:'dataPanel'}, // {tag:'li', id:'contactsPanel'}, {tag:'li', id:'toolsPanel'} ]}, true) new Clipperz.PM.Components.TabPanel.TabPanelController({ name: 'mainTabPanel', config:{ 'recordsTab':'recordsPanel', 'accountTab':'accountPanel', 'dataTab':'dataPanel', // 'contactsTab':'contactsPanel', 'toolsTab':'toolsPanel'}, selectedTab:'recordsTab' }).setUp(); new Clipperz.PM.Components.Panels.MainPanel(YAHOO.ext.Element.get('recordsPanel'), {user:this.user()}); new Clipperz.PM.Components.Panels.AccountPanel(YAHOO.ext.Element.get('accountPanel'), {user:this.user()}); new Clipperz.PM.Components.Panels.DataPanel(YAHOO.ext.Element.get('dataPanel'), {user:this.user()}); // new Clipperz.PM.Components.Panels.ContactsPanel(YAHOO.ext.Element.get('contactsPanel'), {user:this.user()}); new Clipperz.PM.Components.Panels.ToolsPanel(YAHOO.ext.Element.get('toolsPanel'), {user:this.user()}); this.fixToDrawTheMainTabsCorrectlyOnSafari(); // fix to //MochiKit.Logging.logDebug("<<< Main.showMainPanels"); }, //------------------------------------------------------------------------- 'userConnectedCallback': function(anEvent) { //MochiKit.Logging.logDebug(">>> Main.userConnectedCallback"); //MochiKit.Logging.logDebug(">>> doConnect - user: " + this.user()); this.setUser(anEvent.source()); if (this.isRunningCompact()) { this.showCompactInterface(); } else { this.showMainPanels(); } //MochiKit.Logging.logDebug("<<< Main.userConnectedCallback"); }, //----------------------------------------------------------------------------- 'user': function() { return this._user; }, 'setUser': function(aValue) { this._user = aValue; }, //----------------------------------------------------------------------------- 'doLogoutEventHandler': function(anEvent) { var deferred; anEvent.stop(); deferred = new MochiKit.Async.Deferred(); //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("Main.doLogoutEventHandler - 1: " + res); return res;}); deferred.addCallback(MochiKit.Base.method(this.user(), 'doLogout')); //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("Main.doLogoutEventHandler - 2: " + res); return res;}); deferred.addCallback(Clipperz.PM.exit, 'logout.html'); //deferred.addBoth(function(res) {MochiKit.Logging.logDebug("Main.doLogoutEventHandler - 3: " + res); return res;}); deferred.callback(); }, //----------------------------------------------------------------------------- 'doLockEventHandler': function(anEvent) { var deferredResult; var lockDialogElement; var lockDialog; var unlockButton; anEvent.stop(); Clipperz.NotificationCenter.notify(this, 'accountLocked', null, true); lockDialogElement = Clipperz.YUI.DomHelper.append(document.body, {tag:'div', id:'lockDialog', children:[ {tag:'div', cls:'ydlg-hd', htmlString:Clipperz.PM.Strings['lockTitle']}, {tag:'div', cls:'ydlg-bd', children:[ {tag:'div', cls:'alert-message', id:'lockMessage', children:[ {tag:'div', htmlString:Clipperz.PM.Strings['lockDescription']}, {tag:'form', id:'lockDialogForm', children:[ {tag:'input', type:'password', id:'lockPassphrase'} ]} ]} ]}, {tag:'div', cls:'ydlg-ft'} ]}, true); new Clipperz.PM.Components.PasswordEntropyDisplay(YAHOO.ext.Element.get('lockPassphrase')); lockDialog = new YAHOO.ext.BasicDialog( lockDialogElement, { closable:false, modal:true, autoTabs:false, resizable:false, fixedcenter:true, constraintoviewport:false, width:350, height:130, shadow:true } ); unlockButton = lockDialog.addButton(Clipperz.PM.Strings['unlockButtonLabel'], MochiKit.Base.method(this, 'exitLock', lockDialog)); //MochiKit.Logging.logDebug("--- Main.showAlertDialog - 5"); lockDialog.setDefaultButton(unlockButton); MochiKit.Signal.connect('lockDialogForm', 'onsubmit', MochiKit.Base.method(this, 'exitLock', lockDialog)); lockDialog.on('show', function() {YAHOO.ext.Element.get('lockPassphrase').focus();}); lockDialog.show('main'); // this.user().lock(); }, 'exitLock': function(aLockDialog, anEvent) { // var deferredResult; //MochiKit.Logging.logDebug(">>> Exiting lock"); if (typeof(anEvent.stop) != 'undefined') { anEvent.stop(); } if (this.user().passphrase() == YAHOO.ext.Element.get('lockPassphrase').dom.value) { aLockDialog.hide(MochiKit.Base.method(aLockDialog, 'destroy', true)); Clipperz.NotificationCenter.notify(this, 'accountUnlocked', null, true); } else { YAHOO.ext.Element.get('lockPassphrase').dom.value = ""; YAHOO.ext.Element.get('lockPassphrase').focus(); } // deferredResult = new MochiKit.Async.Deferred(); // deferredResult.addCallback(MochiKit.Base.method(this.user(), 'unlockWithPassphrase')); // deferredResult.addCallback(MochiKit.Base.method(aLockDialog, 'hide', MochiKit.Base.method(aLockDialog, 'destroy', true))); // deferredResult.addCallback(MochiKit.Base.method(Clipperz.NotificationCenter, 'notify', this, 'accountUnlocked', null, true)); // deferredResult.addErrback(function() { // YAHOO.ext.Element.get('lockPassphrase').dom.value = ""; // YAHOO.ext.Element.get('lockPassphrase').focus(); // }); // deferredResult.callback(YAHOO.ext.Element.get('lockPassphrase').dom.value); return false; }, //----------------------------------------------------------------------------- 'updateProgressDialogStatus': function(anEvent) { //MochiKit.Logging.logDebug(">>> main.updateProgressDialogStatus - " + anEvent.parameters()); //try { if (Clipperz.Base.objectType(anEvent.parameters()) == 'string') { Clipperz.PM.Components.MessageBox().update(Clipperz.PM.Strings.messagePanelConfigurations[anEvent.parameters()]()); } else { Clipperz.PM.Components.MessageBox().update(anEvent.parameters()); } //} catch (exception) { //console.log("updateProgressDialogStatus - anEvent", anEvent); // MochiKit.Logging.logError("Main.updateProgressDialogStatus: " + exception); // throw exception; //} //MochiKit.Logging.logDebug("<<< main.updateProgressDialogStatus"); }, //----------------------------------------------------------------------------- 'defaultErrorHandler': function(anErrorString, anException) { MochiKit.Logging.logDebug(">>> DEFAULT ERROR HANDLER: " + anErrorString + " (exception: " + Clipperz.Base.serializeJSON(anException) + ")"); }, //----------------------------------------------------------------------------- 'isRunningCompact': function() { return this._isRunningCompact; }, 'setIsRunningCompact': function(aValue) { this._isRunningCompact = aValue; }, //----------------------------------------------------------------------------- 'reportException': function(anError) { /* var deferredResult; deferredResult = new MochiKit.Async.Deferred(); Clipperz.PM.Components.MessageBox().show( { title:Clipperz.PM.Strings['fatalErrorMessageTitle'], text:Clipperz.PM.Strings['fatalErrorMessageText'], width:240, showProgressBar:false, showCloseButton:false, fn:MochiKit.Base.method(deferredResult, 'callback'), scope:this, buttons:{ 'ok': Clipperz.PM.Strings['fatalErrorMessageCloseButtonLabel'] } } ); deferredResult.addCallback(function() { window.document.body.innerHTML = ""; window.location.reload(true); }); */ Clipperz.PM.exit('error.html'); }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# MochiKit.Base.update(Clipperz.PM, { __repr__: function() { return "[" + this.NAME + " " + this.VERSION + "]"; }, |