From 816fc35420a434b1d54ae5833d617608f7456048 Mon Sep 17 00:00:00 2001 From: Clipperz Date: Tue, 08 Jan 2013 15:21:04 +0000 Subject: Updated version of /gamma Tons of changes, included a new draft of the mobile version (still VERY rough) --- (limited to 'frontend/gamma/js/Clipperz/PM') diff --git a/frontend/gamma/js/Clipperz/PM/Connection.js b/frontend/gamma/js/Clipperz/PM/Connection.js index b4e8aaa..a05a310 100644 --- a/frontend/gamma/js/Clipperz/PM/Connection.js +++ b/frontend/gamma/js/Clipperz/PM/Connection.js @@ -41,6 +41,7 @@ Clipperz.PM.Connection = function (args) { this._clipperz_pm_crypto_version = null; this._connectionId = null; this._sharedSecret = null; + this._serverLockValue = null; return this; } @@ -146,6 +147,16 @@ MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString this._connectionId = aValue; }, + //------------------------------------------------------------------------- + + 'serverLockValue': function () { + return this._serverLockValue; + }, + + 'setServerLockValue': function (aValue) { + this._serverLockValue = aValue; + }, + //========================================================================= /* // TODO: ????? @@ -320,13 +331,12 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. ], {trace:false}) }, - 'login': function(/*anUsername, aPassphrase*/) { + 'login': function(isReconnecting) { var deferredResult; var cryptoVersion; var srpConnection; cryptoVersion = this.clipperz_pm_crypto_version(); - deferredResult = new Clipperz.Async.Deferred("Connection.login", {trace:false}); deferredResult.addCallback(this.getCredentialsFunction()); deferredResult.addMethod(this, 'normalizedCredentials'); @@ -399,6 +409,13 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. // if (this.oneTimePassword() != null) { /// ?? result = this.user().oneTimePasswordManager().archiveOneTimePassword(this.oneTimePassword())); // } + + if ((isReconnecting == true) && (this.serverLockValue() != someParameters['lock'])) { + throw Clipperz.PM.Connection.exception.StaleData; + } else { + this.setServerLockValue(someParameters['lock']); + } + return someParameters; }, this)); // deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'updatedProgressState', 'connection_loggedIn'); @@ -429,12 +446,19 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. 'message': function(aMessageName, someParameters) { var args; + var parameters; + + parameters = someParameters || {}; + if (typeof(parameters['user']) != 'undefined') { + parameters['user']['lock'] = this.serverLockValue(); + } //console.log(">>> Connection.message", aMessageName, someParameters); args = { message: aMessageName, srpSharedSecret: this.sharedSecret(), - parameters: (someParameters || {}) +// parameters: (someParameters || {}) + parameters: parameters } return this.sendMessage(args); @@ -449,8 +473,7 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz. deferredResult.addMethod(this.proxy(), 'message', someArguments); deferredResult.addCallback(MochiKit.Base.bind(function(res) { if (typeof(res['lock']) != 'undefined') { -// TODO: ????? -// ?? this.user().setLock(res['lock']); + this.setServerLockValue(res['lock']); } return res; }, this)); @@ -587,6 +610,7 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz. Clipperz.PM.Connection.exception = { WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"), + StaleData: new MochiKit.Base.NamedError("Stale data"), UnexpectedRequest: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.UnexpectedRequest") }; diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index 72d4006..646ce21 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js @@ -44,7 +44,7 @@ Clipperz.PM.DataModel.User = function (args) { this._connectionVersion = 'current'; this._serverData = null; - this._serverLockValue = null; +// this._serverLockValue = null; this._transientState = null; this._deferredLocks = { @@ -93,7 +93,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { }, //------------------------------------------------------------------------- - +/* 'serverLockValue': function () { return this._serverLockValue; }, @@ -101,7 +101,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { 'setServerLockValue': function (aValue) { this._serverLockValue = aValue; }, - +*/ //------------------------------------------------------------------------- 'transientState': function () { @@ -220,8 +220,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this.connection(), 'register'); - deferredResult.addCallback(MochiKit.Base.itemgetter('lock')); - deferredResult.addMethod(this, 'setServerLockValue'); +// deferredResult.addCallback(MochiKit.Base.itemgetter('lock')); +// deferredResult.addMethod(this, 'setServerLockValue'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered'); // deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure')); @@ -247,7 +247,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { MochiKit.Base.method(this.data(), 'setValue', 'passphrase') ], [])); deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase')); - deferredResult.addMethod(this.connection(), 'login'); + deferredResult.addMethod(this.connection(), 'login', false); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn'); deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback')); @@ -329,7 +329,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { var oneTimePasswords; //console.log(">>> ***************** user.unpackServerData", someServerData); - this.setServerLockValue(someServerData['lock']); +// this.setServerLockValue(someServerData['lock']); headerVersion = this.headerFormatVersion(someServerData['header']); @@ -662,8 +662,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'), MochiKit.Base.method(this, 'transientState'), - MochiKit.Base.itemgetter('lock'), - MochiKit.Base.method(this, 'setServerLockValue'), +// MochiKit.Base.itemgetter('lock'), +// MochiKit.Base.method(this, 'setServerLockValue'), MochiKit.Base.method(this, 'resetTransientState', true) ], {trace:false}); }, @@ -740,7 +740,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { return aResult; }, this), result); deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion); - deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue()); +// deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue()); deferredResult.callback(); return deferredResult; diff --git a/frontend/gamma/js/Clipperz/PM/PIN.js b/frontend/gamma/js/Clipperz/PM/PIN.js new file mode 100644 index 0000000..bc932b2 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/PIN.js @@ -0,0 +1,134 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +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. + +* 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. + +* 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 Clipperz Community Edition. If not, see + . + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } +if (typeof(Clipperz.PM.PIN) == 'undefined') { Clipperz.PM.PIN = {}; } + +MochiKit.Base.update(Clipperz.PM.PIN, { + + //------------------------------------------------------------------------- + + '__repr__': function () { + return "[" + this.NAME + " " + this.VERSION + "]"; + }, + + //------------------------------------------------------------------------- + + 'toString': function () { + return this.__repr__(); + }, + + 'CREDENTIALS': 'CLIPPERZ.CREDENTIALS', + 'FAILURE_COUNT': 'CLIPPERZ.FAILED_LOGIN_COUNT', + 'ALLOWED_RETRY': 3, + + //------------------------------------------------------------------------- + + 'isSet': function () { + return (this.storedCredentials() != null); + }, + + 'storedCredentials': function () { + return localStorage[this.CREDENTIALS]; + }, + + //------------------------------------------------------------------------- + + 'recordFailedAttempt': function () { + var failureCount; + var result; + + failureCount = localStorage[this.FAILURE_COUNT]; + + if (failureCount == null) { + failureCount = 0 + } + + failureCount ++; + + if (failureCount < this.ALLOWED_RETRY) { + localStorage[this.FAILURE_COUNT] = failureCount; + result = failureCount; + } else { + this.removeLocalCredentials(); + result = -1; + } + + return result; + }, + + 'resetFailedAttemptCount': function () { + localStorage.removeItem(this.FAILURE_COUNT); + }, + + 'failureCount': function () { + return localStorage[this.FAILURE_COUNT]; + }, + + //------------------------------------------------------------------------- + + 'deriveKeyFromPin': function (aPIN) { + return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aPIN)); + }, + + 'credentialsWithPIN': function (aPIN) { + var byteArrayValue; + var decryptedValue; + var result; + + byteArrayValue = (new Clipperz.ByteArray()).appendBase64String(localStorage[this.CREDENTIALS]); + decryptedValue = Clipperz.Crypto.AES.decrypt(this.deriveKeyFromPin(aPIN), byteArrayValue).asString(); + try { + result = Clipperz.Base.evalJSON(decryptedValue); + } catch (error) { + result = {'username':'fakeusername', 'passphrase':'fakepassphrase'}; + } + + return result; + }, + + 'setCredentialsWithPIN': function (aPIN, someCredentials) { + var encodedValue; + var byteArrayValue; + var encryptedValue; + + encodedValue = Clipperz.Base.serializeJSON(someCredentials); + byteArrayValue = new Clipperz.ByteArray(encodedValue); + encryptedValue = Clipperz.Crypto.AES.encrypt(this.deriveKeyFromPin(aPIN), byteArrayValue).toBase64String(); + + localStorage[this.CREDENTIALS] = encryptedValue; + }, + + 'removeLocalCredentials': function () { + localStorage.removeItem(this.CREDENTIALS); + localStorage.removeItem(this.FAILURE_COUNT); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" + +}); + diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js new file mode 100644 index 0000000..803c590 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js @@ -0,0 +1,65 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +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. + +* 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. + +* 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 Clipperz Community Edition. If not, see + . + +*/ + +if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } +if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } + +//============================================================================= + +Clipperz.PM.Proxy.OfflineCache = function(args) { + args = args || {}; + + Clipperz.PM.Proxy.Offline.superclass.constructor.call(this, args); + +// this._dataStore = args.dataStore || new Clipperz.PM.Proxy.Offline.DataStore(args); + + return this; +} + +Clipperz.Base.extend(Clipperz.PM.Proxy.OfflineCache, Clipperz.PM.Proxy, { + + 'toString': function () { + return "Clipperz.PM.Proxy.OfflineCache"; + }, + + //------------------------------------------------------------------------- + +// 'dataStore': function () { +// return this._dataStore; +// }, + + //------------------------------------------------------------------------- + + 'sendMessage': function(aFunctionName, someParameters) { + throw Clipperz.Base.exception.MethodNotImplementedYet; +// return this.dataStore().processMessage(aFunctionName, someParameters); + }, + + //------------------------------------------------------------------------- + + __syntaxFix__: "syntax fix" + +}); + diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js index 2a03fdf..b9d7adf 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js @@ -406,6 +406,10 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Compo return result; }, + 'getAnchor': function (aValue) { + return '#' + this.getId(aValue); + }, + //------------------------------------------------------------------------- 'getElement': function(aValue) { diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js index 716d851..1010c9d 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js @@ -62,7 +62,8 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Button, Clipperz.PM.UI.Com //------------------------------------------------------------------------- 'renderSelf': function () { - this.append(this.element(), {tag:'div', id:this.getId('wrapper'), cls:'button_wrapper', children:[ +/* + this.append(this.element(), {tag:'div', id:this.getId('button'), cls:'button_wrapper', children:[ {tag:'div', id:this.getId('bodyWrapper'), cls:'button_bodyWrapper', children:[ {tag:'div', id:this.getId('body'), cls:'button_body', children:[ {tag:'span', html:this.text()} @@ -70,36 +71,43 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Button, Clipperz.PM.UI.Com {tag:'div', id:this.getId('footer'), cls:'button_footer'} ]} ]}); +*/ +/* + this.append(this.element(), {tag:'div', id:this.getId('button'), cls:'button', children:[ + {tag:'span', html:this.text()} + ]}); +*/ + this.append(this.element(), {tag:'a', id:this.getId('button'), cls:'button', html:this.text()}); if (this.isDefault()) { - MochiKit.DOM.addElementClass(this.getId('wrapper'), 'default'); + MochiKit.DOM.addElementClass(this.getId('button'), 'default'); } - MochiKit.Signal.connect(this.getId('wrapper'), 'onmouseenter', this, 'handleOnMouseEnter'); - MochiKit.Signal.connect(this.getId('wrapper'), 'onmouseleave', this, 'handleOnMouseLeave'); - MochiKit.Signal.connect(this.getId('wrapper'), 'onmousedown', this, 'handleOnMouseDown'); - MochiKit.Signal.connect(this.getId('wrapper'), 'onclick', this, 'handleOnClick'); +// MochiKit.Signal.connect(this.getId('button'), 'onmouseenter', this, 'handleOnMouseEnter'); +// MochiKit.Signal.connect(this.getId('button'), 'onmouseleave', this, 'handleOnMouseLeave'); +// MochiKit.Signal.connect(this.getId('button'), 'onmousedown', this, 'handleOnMouseDown'); + MochiKit.Signal.connect(this.getId('button'), 'onclick', this, 'handleOnClick'); }, //------------------------------------------------------------------------- - +/* 'handleOnMouseEnter': function (anEvent) { - MochiKit.DOM.addElementClass(this.getId('wrapper'), 'hover'); + MochiKit.DOM.addElementClass(this.getId('button'), 'hover'); }, 'handleOnMouseLeave': function (anEvent) { - MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'hover'); - MochiKit.DOM.removeElementClass(this.getId('wrapper'), 'clicked'); + MochiKit.DOM.removeElementClass(this.getId('button'), 'hover'); + MochiKit.DOM.removeElementClass(this.getId('button'), 'clicked'); }, 'handleOnMouseDown': function (anEvent) { - MochiKit.DOM.addElementClass(this.getId('wrapper'), 'clicked'); + MochiKit.DOM.addElementClass(this.getId('button'), 'clicked'); }, - +*/ 'handleOnClick': function (anEvent) { MochiKit.Signal.signal(this, 'onclick', anEvent); }, - + //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js index 1992154..1d816a9 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js @@ -98,14 +98,29 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clippe }, 'setType': function (aValue) { - if (this.getElement('icon') != null) { - MochiKit.DOM.removeElementClass(this.getId('icon'), this._type); - MochiKit.DOM.addElementClass(this.getId('icon'), aValue); - } +// if (this.getElement('icon') != null) { +// MochiKit.DOM.removeElementClass(this.getId('icon'), this._type); +// MochiKit.DOM.addElementClass(this.getId('icon'), aValue); +// } this._type = aValue; }, + 'icon': function () { + var type = this.type(); + var result; + + if (type == 'ALERT') { + result = '!'; + } else if (type == 'INFO') { + result = 'i'; + } else if (type == 'ERROR') { + result = '!'; + } + + return result; + }, + //------------------------------------------------------------------------- 'buttons': function () { @@ -132,17 +147,20 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clippe 'renderSelf': function() { this.append(this.element(), {tag:'div', cls:'SimpleMessagePanel', id:this.getId('panel'), children: [ - {tag:'div', cls:'header', children:[]}, +// {tag:'div', cls:'header', children:[]}, {tag:'div', cls:'body', children:[ - {tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]}, +// {tag:'div', id:this.getId('icon'), cls:'img ' + this.type(), children:[{tag:'div'}]}, + {tag:'div', /*id:this.getId('icon'),*/ cls:'img ' + this.type(), children:[{tag:'canvas', id:this.getId('icon')}]}, {tag:'h3', id:this.getId('title'), html:this.title()}, {tag:'p', id:this.getId('text'), html:this.text()}, {tag:'div', id:this.getId('container')}, {tag:'div', id:this.getId('buttonArea'), cls:'buttonArea', children:[]} - ]}, - {tag:'div', cls:'footer', children:[]} + ]} +// {tag:'div', cls:'footer', children:[]} ]}); + Clipperz.PM.UI.Canvas.marks[this.icon()](this.getElement('icon'), "#ffffff"); + MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'keyDownHandler'); this.renderButtons(); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js new file mode 100644 index 0000000..32dfa63 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js @@ -0,0 +1,299 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +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. + +* 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. + +* 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 Clipperz Community Edition. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components'); + +Clipperz.PM.UI.Mobile.Components.CardDetail = function(args) { + args = args || {}; + + Clipperz.PM.UI.Mobile.Components.CardDetail.superclass.constructor.apply(this, arguments); + +// this._cardReference = null; + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Mobile.Components.CardDetail component"; + }, + + //------------------------------------------------------------------------- +/* + 'cardReference': function () { + return this._cardReference; + }, + + 'setCardReference': function (aValue) { + this._cardReference = aValue; + }, +*/ + //------------------------------------------------------------------------- + + 'renderSelf': function () { +console.log("CardDetail.renderSelf"); + this.append(this.element(), {tag:'div', cls:'cardDetail', children:[ + {tag:'div', cls:'toolbar', children:[ + {tag:'a', href:'#', cls:'back', html:"List"}, + {tag:'h1', id:this.getId('cardTitle'), html:"…"} + ]}, + {tag:'div', cls:'scroll', id:this.getId('cardDetails'), children:[ + ]} + ]}); + }, +/* + 'renderSelf': function() { + this.append(this.element(), [ + {tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[ + {tag:'div', id:this.getId('progressBar')} //, + ]} + ]); + + this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); + MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0); + }, +*/ + + 'setTitle': function (aValue) { + this.getElement('cardTitle').innerHTML = aValue; + }, + + 'fieldListElement': function () { + var result; + + result = this.getElement('fieldList'); + if (result == null) { + result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('fieldList')}); + } + + return result; + }, + + 'renderFieldValues': function (someFieldValues) { + var fieldClass; + + if ((someFieldValues['actionType'] != 'NONE') || (someFieldValues['label'] != '') && (someFieldValues['value'] != '')) { + if (someFieldValues['isHidden'] == true) { + fieldClass = 'password'; + } else { + fieldClass = ''; + } + + this.append(this.fieldListElement(), {tag:'li', cls:'cardField', children:[ + {tag:'a', href:'#', cls:fieldClass, html:someFieldValues['value'], children:[ + {tag:'small', cls:'label', html:someFieldValues['label']} + ]} + ]}) + } + }, + + 'addField': function (aField) { + var deferredResult; + var fieldValues; + + fieldValues = {}; + deferredResult = new Clipperz.Async.Deferred("CardDetail.addField", {trace:false}); + deferredResult.addMethod(aField, 'label'); + deferredResult.addCallback(function (aValue) { fieldValues['label'] = aValue; }); + deferredResult.addMethod(aField, 'value'); + deferredResult.addCallback(function (aValue) { fieldValues['value'] = aValue; }); + deferredResult.addMethod(aField, 'actionType'); + deferredResult.addCallback(function (aValue) { fieldValues['actionType'] = aValue; }); + deferredResult.addMethod(aField, 'isHidden'); + deferredResult.addCallback(function (aValue) { fieldValues['isHidden'] = aValue; }); + deferredResult.addMethod(this, 'renderFieldValues', fieldValues); + deferredResult.callback(); + + return deferredResult; + }, + + //------------------------------------------------------------------------- + + 'directLoginElement': function () { + var result; + + result = this.getElement('directLoginList'); + if (result == null) { + this.append(this.getElement('cardDetails'), {tag:'h2', html:"Direct login"}); + result = this.append(this.getElement('cardDetails'), {tag:'ul', cls:'rounded', id:this.getId('directLoginList')}); + } + + return result; + }, + + 'addDirectLogin': function (aDirectLogin) { + this.append(this.directLoginElement(), {tag:'li', cls:'directLogin forward', children:[ + {tag:'a', href:'#', html:"direct login", children:[ + {tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:'http://www.clipperz.com/favicon.ico'}]} + ]} + ]}) + +console.log("ADD DIRECT LOGIN", aDirectLogin); + }, + + //========================================================================= + + 'showCard': function (aCard) { + var deferredResult; + +// this.render(); + +console.log("CardDetail.showCard", aCard); + deferredResult = new Clipperz.Async.Deferred("CardDetail.showCard", {trace:false}); + deferredResult.addMethod(aCard, 'label'); + deferredResult.addMethod(this, 'setTitle'); + + deferredResult.addMethod(aCard, 'fields'); + deferredResult.addCallback(MochiKit.Base.values); + deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addField')); + + deferredResult.addMethod(aCard, 'directLogins'); + deferredResult.addCallback(MochiKit.Base.values); + deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'addDirectLogin')); + + + deferredResult.callback(); + + return deferredResult; +// return Clipperz.Async.callbacks("CardDialogController.updateComponentState", [ +// MochiKit.Base.method(this.record(), 'hasPendingChanges'), +// MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving'), +// +// MochiKit.Base.method(this.record(), 'label'), +// MochiKit.Base.method(this.cardDialogComponent(), 'setTitle'), +// MochiKit.Base.method(this.record(), 'notes'), +// MochiKit.Base.method(this.cardDialogComponent(), 'setNotes'), +// +// MochiKit.Base.method(this.record(), 'fields'), +// MochiKit.Base.values, +// MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithField')), +// +// MochiKit.Base.method(this.record(), 'directLogins'), +// MochiKit.Base.values, +// MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin')), +// +// MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'), +// MochiKit.Base.noop +// ], {trace:false}); + + }, + + //========================================================================= + + 'showCardDetails': function (someData) { + this.element().innerHTML = ''; + this.append(this.element(), [ + {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) { + return {tag:'div', cls:'row', children:[ + {tag:'label', html:aFieldData['label']}, +// {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), html:aFieldData['value']} + {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), children:[ + {tag:'div', children:[{tag:'p', html:aFieldData['value']}]} + ]} +// {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), value:aFieldData['value'], disabled:true} + + ]} + }, someData['fields'])} + ]); + + MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) { + MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); }) + }, this)); + + if (someData['directLogins'].length > 0) { + this.append(this.element(), [ + {tag:'h2', html:"Direct logins"}, + {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) { + return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[ + {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']}, +// {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']} + {tag:'span', cls:'directLogin', html:aDirectLoginData['label']} + ]} + }, someData['directLogins'])} + ]); + + MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) { + MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler'); + }, this), + MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row']) + ) + }; + + if (someData['notes'] != '') { + this.append(this.element(), [ + {tag:'h2', html:"Notes"}, + {tag:'fieldset', id:this.getId('fieldset'), children:[ + {tag:'div', cls:'row notes', children:[ + {tag:'span', html:someData['notes']} + ]} + ]} + ]); + }; + + return true; + }, + + //------------------------------------------------------------------------- +/* + 'toggleClickHandler': function (anEvent) { + var nextState; + var fieldValue; + +//console.log("TOGGLE"); + anEvent.preventDefault; + fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0]; + + nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true'); + if (nextState) { + MochiKit.DOM.removeElementClass(fieldValue, 'clear'); + } else { + MochiKit.DOM.addElementClass(fieldValue, 'clear'); + } + + MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState); + }, +* / + //========================================================================= +/* + 'directLoginClickHandler': function (anEvent) { + anEvent.preventDefault(); + + if (/(directLogin_)/.test(anEvent.src().id)) { + var directLoginReference; + + directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2]; + MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference}); + } + }, +*/ + //========================================================================= + + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js index c3f2701..a4aa212 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardList.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js @@ -23,12 +23,12 @@ refer to http://www.clipperz.com. */ -Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); +Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components'); -Clipperz.PM.UI.iPhone.Components.CardList = function(args) { +Clipperz.PM.UI.Mobile.Components.CardList = function(args) { args = args || {}; - Clipperz.PM.UI.iPhone.Components.CardList.superclass.constructor.apply(this, arguments); + Clipperz.PM.UI.Mobile.Components.CardList.superclass.constructor.apply(this, arguments); this._cardDetail = null; @@ -37,44 +37,97 @@ Clipperz.PM.UI.iPhone.Components.CardList = function(args) { //============================================================================= -Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, { +Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { - return "Clipperz.PM.UI.iPhone.Components.CardList component"; + return "Clipperz.PM.UI.Mobile.Components.CardList component"; }, //------------------------------------------------------------------------- - 'renderSelf': function(/*aContainer, aPosition*/) { - this.append(this.element(), [ - {tag:'div', cls:'toolbar', id:'toolbar', children:[ - {tag:'h1', id:'pageTitle', html:"cards"}, - {tag:'a', id:'backButton', cls:'button', href:'#', html:"cards"} + 'renderSelf': function () { + this.append(this.element(), {tag:'div', cls:'cardList', children:[ + {tag:'div', cls:'toolbar', children:[ + {tag:'h1', html:"clipperz"}, +// {tag:'input', name:'search', type:'search', autocomplete:'off', placeholder:"search", id:this.getId('search')}, + {tag:'a', href:'#', id:'settings', cls:'button', html:"*"} ]}, - {tag:'div', cls:'cardList', id:this.getId('cardList'), children:[ - {tag:'form', title:'search', cls:'panel cardListSearchForm', id:this.getId('cardListSearchForm'), children:[ - {tag:'input', type:'search', name:'search', value:"", placeholder:"search", id:this.getId('searchField')} - ]}, - {tag:'ul', cls:'panel cardListPanel', id:this.getId('cardListPanel'), children:[]} - ]}, - {tag:'div', cls:'panel cardDetailPanel', id:this.getId('cardDetail')} - ]); - - MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this, 'searchHandler'); - MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this, 'searchHandler'); - MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this, 'searchHandler'); + {tag:'div', cls:'scroll', id:this.getId('listBox'), children:[ + {tag:'ul', cls:'rounded', id:this.getId('list'), children:[ + {tag:'li', html:'loading'} + ]} + ]} + ]}); + + MochiKit.Signal.connect(this.getElement('list'), 'onclick', this, 'cardSelectionHandler'); + MochiKit.Signal.connect(this.getElement('list'), 'ontouchstart', this, 'cardSelectionHandler'); +// MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onsubmit', this, 'searchHandler'); +// MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeydown', this, 'searchHandler'); +// MochiKit.Signal.connect(this.getElement('cardListSearchForm'), 'onkeyup', this, 'searchHandler'); - MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this, 'cardListClickHandler'); - MochiKit.Signal.connect('backButton', 'onclick', this, 'backButtonClickHandler'); +// MochiKit.Signal.connect(this.getElement('cardListPanel'), 'onclick', this, 'cardListClickHandler'); +// MochiKit.Signal.connect('backButton', 'onclick', this, 'backButtonClickHandler'); - MochiKit.Style.hideElement('backButton'); - MochiKit.Style.hideElement(this.getElement('cardDetail')); +// MochiKit.Style.hideElement('backButton'); +// MochiKit.Style.hideElement(this.getElement('cardDetail')); }, - //------------------------------------------------------------------------- + 'showCards': function (someCards) { + var cardListElement; + if (this.isFullyRendered() == false) { + this.render(); + }; + + cardListElement = this.getElement('list') + + cardInfo = { + '_rowObject': MochiKit.Async.succeed, + '_reference': MochiKit.Base.methodcaller('reference'), + '_searchableContent': MochiKit.Base.methodcaller('searchableContent'), + 'label': MochiKit.Base.methodcaller('label'), + 'favicon': MochiKit.Base.methodcaller('favicon') + }; + +//console.log("someCards", someCards); + deferredResult = new Clipperz.Async.Deferred("CardList.showCards", {trace:false}); + deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("CardList.value - collectResults", cardInfo, {trace:false})); + deferredResult.addCallback(Clipperz.Async.collectAll); + deferredResult.addCallback(MochiKit.Base.methodcaller('sort', Clipperz.Base.caseInsensitiveKeyComparator('label'))); + deferredResult.addCallbackPass(MochiKit.DOM.replaceChildNodes, cardListElement); +// deferredResult.addCallbackPass(MochiKit.DOM.removeElementClass, cardListElement, 'loading'); + deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'appendCardToList', cardListElement)); + deferredResult.callback(someCards); + }, + + 'appendCardToList': function (aCardListElement, aCardInfo) { +//console.log("appendCardToList", aCardInfo); + this.append(aCardListElement, {tag:'li', cls:'cardListItem arrow', cardreference:aCardInfo['_reference'], children:[ + {tag:'a', href:'#', html:aCardInfo['label'], children:[ + {tag:'small', cls:'favicon', children:[{tag:'img', cls:'favicon', src:aCardInfo['favicon']}]} + ]} + ]}); + }, + + 'cardSelectionHandler': function (anEvent) { + var listElement; + var cardReference; + + anEvent.preventDefault(); + + listElement = anEvent.target(); + if (MochiKit.DOM.getNodeAttribute(listElement, 'cardreference') == null) { + listElement = MochiKit.DOM.getFirstParentByTagAndClassName(anEvent.target(), tagName='li', className='cardListItem'); + } + cardReference = MochiKit.DOM.getNodeAttribute(listElement, 'cardreference'); +console.log("###", listElement, cardReference); + // TODO: Notify card with reference MochiKit.DOM.getNodeAttribute(listElement, 'cardreference') has been selected + MochiKit.Signal.signal(this, 'selectedCard', cardReference); + }, + //------------------------------------------------------------------------- +/* 'searchHandler': function (anEvent) { if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { // RETURN anEvent.preventDefault(); @@ -127,7 +180,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.C 'cardDetail': function (someData) { if (this._cardDetail == null) { - this._cardDetail = new Clipperz.PM.UI.iPhone.Components.CardDetail({element:this.getElement('cardDetail')}); + this._cardDetail = new Clipperz.PM.UI.Mobile.Components.CardDetail({element:this.getElement('cardDetail')}); } return this._cardDetail; @@ -195,7 +248,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardList, Clipperz.PM.UI.C ], {duration:1, afterFinish:MochiKit.Base.method(this, 'removeCardDetail')}) }, - +*/ //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js new file mode 100644 index 0000000..eafcdbc --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js @@ -0,0 +1,356 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +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. + +* 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. + +* 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 Clipperz Community Edition. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components'); + +Clipperz.PM.UI.Mobile.Components.LoginForm = function(args) { + args = args || {}; + + this._pin = ''; + + this._message = null; + this._steps = 0; + this._actualSteps = 0; + + this._callback = null; + this._errorCallback = null; + + this._mode = 'CREDENTIALS'; + + Clipperz.PM.UI.Mobile.Components.LoginForm.superclass.constructor.apply(this, arguments); + + return this; +} + +//============================================================================= + +Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { + + //------------------------------------------------------------------------- + + 'toString': function () { + return "Clipperz.PM.UI.Mobile.Components.LoginForm component"; + }, + + //------------------------------------------------------------------------- + + 'callback': function () { + return this._callback; + }, + + 'errorCallback': function () { + return this._errorCallback; + }, + + //------------------------------------------------------------------------- + + 'mode': function () { + return this._mode; + }, + + 'setMode': function (aValue) { + this._mode = aValue; + }, + + //.......................................................................... + + 'pin': function () { + return this._pin; + }, + + 'setPin': function (aValue) { + this._pin = aValue; + }, + + //.......................................................................... + + 'username': function () { + return this._username; + }, + + 'setUsername': function (aValue) { + this._username = aValue; + }, + + //.......................................................................... + + 'passphrase': function () { + return this._passphrase; + }, + + 'setPassphrase': function (aValue) { + this._passphrase = aValue; + }, + + //------------------------------------------------------------------------- + + 'message': function () { + return this._message; + }, + + '_setMessage': function (aValue) { + this._message = aValue; + + if (aValue == null) { + MochiKit.Style.hideElement(this.getElement('credentialsMessage')); + } else { + this.getElement('message').innerHTML = aValue; + MochiKit.Style.showElement(this.getElement('credentialsMessage')); + } + }, + + 'setMessage': function (aValue) { + this._setMessage(aValue); + MochiKit.DOM.removeElementClass(this.getElement('credentialsMessage'), 'error'); + }, + + 'setErrorMessage': function (aValue) { + this._setMessage(aValue); + MochiKit.DOM.addElementClass(this.getElement('credentialsMessage'), 'error'); + }, + + //------------------------------------------------------------------------- + + 'setCallbacks': function (args) { + this._callback = args['callback']; + this._errorCallback = args['errorCallback']; + }, + + 'showErrors': function (args) { +//console.log("LoginForm.showErrors", args); + if (args['previousFailedAttempt'] == 'LOGIN') { + this.setErrorMessage("Wrong credentials"); + } else if (args['previousFailedAttempt'] == 'PIN') { + if (args['failedAttempts'] == -1) { + this.setErrorMessage("Wrong PIN - Resetted"); + } else { + this.setErrorMessage("Wrong PIN"); + } + } else { + this.setMessage(null); + } + }, + + 'updateWithArgs': function (args) { + this.renderIfNeeded(); + this.setCallbacks(args); + this.showErrors(args); + this.updateRendering(); + }, + + 'showPinLogin': function (args) { + this.setPin(''); + this.setMode('PIN'); + this.updateWithArgs(args); + +// $(this.getAnchor('PIN')).focus(); + this.getElement('PIN').focus(); + }, + + 'showCredentialsLogin': function (args) { + this.setMode('CREDENTIALS'); + this.updateWithArgs(args); + + if (this.getElement('usernameField').value.length == 0) { +// $(this.getAnchor('usernameField')).focus(); + this.getElement('usernameField').focus(); + } else { +// $(this.getAnchor('passphraseField')).focus(); + this.getElement('passphraseField').focus(); + this.getElement('passphraseField').select(); + } + }, + + //------------------------------------------------------------------------- + + 'renderIfNeeded': function () { + if (this.isFullyRendered() == false) { + this.render(); + }; + this.updateRendering(); + }, + + 'updateRendering': function () { + MochiKit.Style.showElement(this.getElement('credentialsBody')); + MochiKit.Style.hideElement(this.getElement('validating')); + +// this.hideAllPanes(); + MochiKit.Base.map(function (aNode) { MochiKit.Style.hideElement(aNode); }, MochiKit.Selector.findDocElements('div.credentialsBody > div')); + if (this.mode() == 'CREDENTIALS') { + selectedPanel = this.getElement('credentials') + } else if (this.mode() == 'PIN') { + selectedPanel = this.getElement('pin') +// this.updatePinDisplay(); + } else { + throw 'Unhandled login form mode'; + } + MochiKit.Style.showElement(selectedPanel); + + MochiKit.Style.hideElement(this.getElement('validating')); + }, + + 'renderSelf': function() { + var selectedPanel; + this.append(this.element(), {tag:'div', id:'login', children:[ + {tag:'div', cls:'toolbar', children:[ + {tag:'h1', html:"clipperz"} + ]}, + {tag:'div', cls:'scroll', children:[ + //================================================================== + {tag:'div', cls:'credentialsMessage', id:this.getId('credentialsMessage'), children:[ + {tag:'h1', cls:'message', id:this.getId('message'), html:"Message"} + ]}, + //================================================================== + {tag:'div', cls:'credentialsBody', id:this.getId('credentialsBody'), children:[ + //-------------------------------------------------------------- + {tag:'div', cls:'pin', id:this.getId('pin'), children:[ + {tag:'form', cls:'scroll', id:this.getId('pinForm'), children:[ + {tag:'ul', cls:'edit rounded', children:[ + {tag:'li', children:[{tag:'input', type:'number', name:'PIN', placeholder:"PIN", id:this.getId('PIN') }]}, + ]}, + {tag:'a', href:'#', cls:'greenButton', id:this.getId('pinSubmitButton'), html:"Login"} + ]} + ]}, + //-------------------------------------------------------------- + {tag:'div', cls:'credentials', id:this.getId('credentials'), children:[ + {tag:'form', cls:'scroll', id:this.getId('credentialsForm'), children:[ + {tag:'ul', cls:'edit rounded', children:[ + {tag:'li', children:[{tag:'input', type:'email', name:'name', /*value:'joe',*/ placeholder:"username", id:this.getId('usernameField') }]}, + {tag:'li', children:[{tag:'input', type:'password', name:'passphrase', /*value:'clipperz',*/ placeholder:"passphrase", id:this.getId('passphraseField') }]} + ]}, + {tag:'a', href:'#', cls:'greenButton', id:this.getId('credentialsSubmitButton'), html:"Login"} +// {tag:'input', type:'submit', cls:'greenButton', id:this.getId('credentialsSubmitButton'), value:"Login"} + + ]} + ]}, + //-------------------------------------------------------------- + ]}, + //================================================================== + {tag:'div', cls:'validating', id:this.getId('validating'), children:[ + {tag:'div', cls:'loading', children:[ + {tag:'div', cls:'spinner', children:[ + {tag:'div', cls:'bar01'}, + {tag:'div', cls:'bar02'}, + {tag:'div', cls:'bar03'}, + {tag:'div', cls:'bar04'}, + {tag:'div', cls:'bar05'}, + {tag:'div', cls:'bar06'}, + {tag:'div', cls:'bar07'}, + {tag:'div', cls:'bar08'}, + {tag:'div', cls:'bar09'}, + {tag:'div', cls:'bar10'}, + {tag:'div', cls:'bar11'}, + {tag:'div', cls:'bar12'} + ]} + ]}, + {tag:'div', id:this.getId('loadingMessage')}, + {tag:'a', href:'#', cls:'grayButton', id:this.getId('loginCancelButton'), html:"Cancel"} + ]} + //================================================================== + ]} + ]}); + + MochiKit.Signal.connect(this.getElement('credentialsForm'), 'onsubmit', this, 'submitCredentialsHandler'); + MochiKit.Signal.connect(this.getElement('credentialsSubmitButton'), 'onclick', this, 'submitCredentialsHandler'); + + MochiKit.Signal.connect(this.getElement('pinForm'), 'onsubmit', this, 'submitPinHandler'); + MochiKit.Signal.connect(this.getElement('pinSubmitButton'), 'onclick', this, 'submitPinHandler'); + + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress', this, 'updateProgressHandle'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress', this, 'advanceProgressHandle'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle'); + }, + + //------------------------------------------------------------------------- + + 'submitPinHandler': function (anEvent) { + var pin; + + this.setMessage(null); + pin = this.getElement('PIN').value; +// $(this.getAnchor('PIN')).blur(); + this.getElement('PIN').blur(); + + credentials = Clipperz.PM.PIN.credentialsWithPIN(pin); + this.loginWithCredentials(credentials); + }, + + 'submitCredentialsHandler': function (anEvent) { +//console.log("submitCredentialsHandler"); + var credentials; + + this.setMessage(null); + + credentials = {}; + credentials['username'] = this.getElement('usernameField').value; + credentials['passphrase'] = this.getElement('passphraseField').value; +// $(this.getAnchor('passphraseField')).blur(); + this.getElement('passphraseField').blur(); + + this.loginWithCredentials(credentials); + }, + + //------------------------------------------------------------------------- + + 'loginWithCredentials': function (someCredentials) { + var args; + + args = {}; + args['credentials'] = someCredentials; + args['errorCallback'] = this.errorCallback(); + + MochiKit.Style.hideElement(this.getElement('credentialsBody')); + MochiKit.Style.showElement(this.getElement('validating')); + + MochiKit.Async.callLater(0.1, this.callback(), args); + }, + + //------------------------------------------------------------------------- + + 'initProgressHandle': function (anEvent) { +//console.log("** initProgressHandle", anEvent); + this._steps = anEvent['steps']; + this._actualSteps = 0; + }, + + 'updateProgressHandle': function (anEvent) { +//console.log("** updateProgressHandle", anEvent); + this._steps += anEvent['extraSteps']; + }, + + 'advanceProgressHandle': function (anEvent) { +//console.log("** advanceProgressHandle", anEvent); + this._actualSteps ++; +//console.log("STEPS: " + this._actualSteps + "/" + this._steps); + }, + + 'progressDoneHandle': function (anEvent) { +//console.log("** progressDoneHandle", anEvent); + }, + + //------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Controllers/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Controllers/MainController.js new file mode 100644 index 0000000..12a61f7 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Controllers/MainController.js @@ -0,0 +1,393 @@ +/* + +Copyright 2008-2011 Clipperz Srl + +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. + +* 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. + +* 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 Clipperz Community Edition. If not, see + . + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Mobile.Controllers'); + +Clipperz.PM.UI.Mobile.Controllers.MainController = function() { + this._jQTouch = null; + this._user = null; + this._proxy = null; + this._loginForm = null; + this._cardList = null; + this._cardDetail = null; + + return this; +} + +MochiKit.Base.update(Clipperz.PM.UI.Mobile.Controllers.MainController.prototype, { + + 'toString': function () { + return "Clipperz.PM.UI.Mobile.Controllers.MainController"; + }, + + //------------------------------------------------------------------------- + + 'user': function () { + return this._user; + }, + + 'setUser': function (aValue) { + this._user = aValue; + }, + + //------------------------------------------------------------------------- + + 'jQTouch': function () { + return this._jQTouch; + }, + + 'setJQTouch': function (aValue) { + this._jQTouch = aValue; + }, + + //========================================================================= + + 'run': function () { + console.log("MainController.run"); + + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'doLogin', MochiKit.Base.method(this, 'doLogin')); + Clipperz.DOM.Helper.overwrite(MochiKit.DOM.currentDocument().body, {tag:'div', id:'jqt', children:[ + {tag:'div', id:'loginForm'}, + {tag:'div', id:'cardList'}, + {tag:'div', id:'cardDetail'}, + {tag:'div', id:'preferences'} + ]}); + + this.showLoginForm(); + + this.initjQTouch(); + + +// this.showAddToHomeScreenBaloon(); +// this.selectInitialProxy(); + }, + + 'initjQTouch': function () { + var jqt; + + jqt = new $.jQTouch({ + icon: 'data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAAHIAAAByCAIAAAAAvxIqAAAD8GlDQ1BJQ0MgUHJvZmlsZQAAKJGNVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIux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9MszVy6aqVldluVEjYDh8CrNlAYKAkNMlzojiipnDvRO/u5jJ12nAhNMzl/oleuuXzU1nUzoloOmmsG+xHEphoOdLJZgnCjgD5z3tf3Nr1Mv7dhPojIDRajwyCuJw0dP7OmkhUtWTQpGLD2SsNRYRgkqtk8pinsYbAdHLjLbMS25+euPGT2XRu8cynD4RN/Cm5ZNVbqiCfKpqCoWWQZBONHFjp1llg0Z5K+d/Fp0ydf+/cjp06crVQEPlZ9+0dvb+7td56qmrVw0Q6X0qYzt9qXBmQj7Csv4Tvay3hQF/P5/293y0q5KTot0Xftwl7tx1Vw10xVNsoYqaJq3bAO6gYOd7HwfANIkJuoX/6i98YeP7zbSiSsWO1KMy2Qh28rs2HOsy565csnsoHPaMs1omqUtVPkgK+hLoLOXaRIO9c9+6JdnnUo0/2Ik4vE+0brhBl8mEUtnWEs9uISLEXScYHEdEigYCp1V277+ZPy1nW+P07+FG7+JmPRe55nfH8W8m9ZPr07YeiJlskiKSRyne5ltk6O2fuMJ58LFykx7KcPJsxfrpy++qSHSnzCFYLEEjp5ljoDCyF8/7YWLi/7m3w+eO3duPE7tYXynDff3x17YdU5qWr1kTg1Lnzcs9CWY7SDg9/3f/a0v7By/WdHU0RlbvWJJI85GkoimGAP5ZG7XLf2nndU//tVu0xjHya24CpPcXcfae+D48cSU5cuWVotuy7RUiR1NXvfQ4+ccp8Izn4phW8a7vcqWldOYfoERgqGqTrnta4/3vrn3ICqUdL8MrsZKFwBnz51/9VBm+oL1cxuMjKt+8zfifE/Fxr6GQl8kmvHNXD9HSP7a57pv/NvtHd3dw82N/SGBy75P/cmW//rA6qv1xAwwSf2fn77z3ttXXBP/FGiccTXW2L1/p5vABCYwgQlMYAL/2fH/AdkCEQl+/Ar/AAAAAElFTkSuQmCCCg==', +// icon4: 'jqtouch4.png', +// startupScreen: null, // Pass a string path to a 320px x 460px startup screen for full screen apps. + statusBar: 'black-translucent', // Styles the status bar when running as a fullscreen app. Other options are `default`, `black`, and `black-translucent`. +// addGlossToIcon: true, // Set to 'false' to prevent automatic glossy button effect on icon. + preloadImages: false, // Pass an array of image paths to load them before page loads. Ex: `['images/link_over.png', 'images/link_select.png']` + fixedViewport: true, // Removes the user's ability to scale the page. Ensures the site behaves more like an application. +// fullScreen: true, // The website will become a fullscreen application when saved to a user's home screen. Set to `false` to disable. +// fullScreenClass: 'fullscreen' // Adds a class to the `` when running in full-screen mode, to allow for easy detection and styling. Set to `false` to disable. +// themeSelectionSelector: '#jqt #themes ul', // ??? + +// useAnimations: true, // Set to `false` to disable all animations. +// useFastTouch: true, // Removes ~350ms onClick delay when tapping a link (use in conjunction with the .tap() event) **Experimental** +// useTouchScroll: true, // Adds support for iOS5 scrolling. Set to false to disable. **Experimental** + + cacheGetRequests: false, // Automatically caches GET requests, so subsequent taps reference the pre-loaded views. (default: true) + +// backSelector: '.back, .cancel, .goback', // A CSS selector for back links/buttons. When clicked, the page history goes back one, automatically reversing whichever entrance animation was used. + +// cubeSelector: '.cube', // Link selector for a cube animation. +// dissolveSelector: '.dissolve', // Link selector for a dissolve animation. +// fadeSelector: '.fade', // Link selector for a fade animation. +// flipSelector: '.flip', // Link selector for a 3d flip animation. + formSelector: null, // Sets which forms are automatically submitted via Ajax. (default: 'form') +// popSelector: '.pop', // Link selector for a pop animation. (default: '.pop') +// slideSelector: 'body > * > ul li a', // Link selector for the default slide-left transition. By default applies to all links within an unordered list. Accepts any jQuery-capable selector `'li > a, a:not(.dontslide)'`, etc. (default: 'body > * > ul li a') +// slideupSelector: '.slideup', // Link selector for a slide up animation. (default: '.slideup') +// submitSelector: '.submit', // Selector which, when clicked, will submit its parent form (and close keyboard if open). (default: '.submit') +// swapSelector: '.swap', // Link selector for 3d swap animation. (default: '.swap') +// touchSelector: 'a, .touch', // Selector for items which are automatically given expanded touch events. This makes ordinary links more responsive and provides trigger events like `swipe` (default: 'a, .touch') + + debug: false + }); + + this.setJQTouch(jqt); + }, + + //========================================================================= + + 'showAddToHomeScreenBaloon': function () { +console.log(">>> showAddToHomeScreenBaloon"); + }, + + //------------------------------------------------------------------------- + + 'selectInitialProxy': function () { +//console.log(">>> selectInitialProxy"); + if (this.isOnline()) { +//console.log("--- selectInitialProxy: using default proxy"); + this._proxy = Clipperz.PM.Proxy.defaultProxy; + } else { + if (this.hasLocalData()) { +//console.log("--- selectInitialProxy: using local cache proxy"); + this._proxy = new Clipperz.PM.Proxy.OfflineCache({'shouldPayTolls':false}); + } else { + this.showOfflineError(); + } + } + }, + + //------------------------------------------------------------------------- + + 'showLoginForm': function (args) { + args = args || {}; + + args['callback'] = MochiKit.Base.method(this, 'doLogin'); + + if (Clipperz.PM.PIN.isSet()) { + args['errorCallback'] = MochiKit.Base.method(this, 'handleFailedPinLogin'); + this.loginForm().showPinLogin(args); + } else { + args['errorCallback'] = MochiKit.Base.method(this, 'handleFailedCredentialsLogin'); + this.loginForm().showCredentialsLogin(args); + } + }, + + //......................................................................... + + 'handleFailedCredentialsLogin': function () { +console.log("LOGIN FAILED"); + this.showLoginForm({'previousFailedAttempt':'LOGIN'}); + }, + + //......................................................................... + + 'handleFailedPinLogin': function () { + var failedAttempts; + var status; + + failedAttempts = Clipperz.PM.PIN.recordFailedAttempt(); + this.showLoginForm({'previousFailedAttempt':'PIN', 'failedAttempts': failedAttempts}); + }, + + //------------------------------------------------------------------------- + + 'doLogin': function (someArgs) { + var deferredResult; + var credentials; + var errorCallback; + var user; + var getPassphraseDelegate; + +//console.log(">>> MainController.doLogin", someArgs); + credentials = someArgs['credentials']; + errorCallback = someArgs['errorCallback'] || MochiKit.Base.noop; + + getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, credentials.passphrase); + user = new Clipperz.PM.DataModel.User({'username':credentials.username, 'getPassphraseFunction':getPassphraseDelegate}); + + deferredResult = new Clipperz.Async.Deferred('MainController.doLogin', {trace:false}); + deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); + deferredResult.addCallback(MochiKit.Async.wait, 0.1); + deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); + deferredResult.addMethod(user, 'login'); + deferredResult.addCallbacks( + MochiKit.Base.method(this, 'processSuccessfulLogin', user), + errorCallback + ); + deferredResult.callback(); + + return deferredResult; + }, + + //.......................................................................... + + 'processSuccessfulLogin': function (aUser) { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred('MainController.processSuccessfulLogin', {trace:false}); + deferredResult.addMethod(Clipperz.PM.PIN, 'resetFailedAttemptCount'); +// deferredResult.addMethod(this, 'removeLoginForm'); + deferredResult.addMethod(this, 'setUser', aUser); + deferredResult.addMethod(this, 'setupApplication'); + deferredResult.addMethod(this, 'runApplication'); + deferredResult.callback(); + + return deferredResult; + }, + + //------------------------------------------------------------------------- + + 'setupApplication': function () { + var deferredResult; + +console.log(">>> setupApplication"); + deferredResult = new Clipperz.Async.Deferred("MainController.setupApplication", {trace:false}); + deferredResult.addMethod(this, 'welcomeFirstTimeUser'); + deferredResult.addMethod(this, 'showPaymentReminder'); + deferredResult.addMethod(this, 'copyDataLocally'); + deferredResult.callback(arguments); + + return deferredResult; + }, + + + //.......................................................................... + + 'isFirstTimeUser': function () { + return false; + }, + + 'welcomeFirstTimeUser': function () { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred('MainController.welcomeFirstTimeUser', {trace:false}); + + if (this.isFirstTimeUser()) { + deferredResult.addCallback(function () { console.log("--> welcome"); }); + } + deferredResult.callback(); + + return deferredResult; + }, + + //.......................................................................... + + 'shouldShowPaymentReminder': function () { + return true; + }, + + 'showPaymentReminder': function () { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred('MainController.showPaymentReminder', {trace:false}); + + if (this.shouldShowPaymentReminder()) { + deferredResult.addCallback(function () { console.log("--> payment reminder"); }); + } + deferredResult.callback(); + + return deferredResult; + }, + + //.......................................................................... + + 'canCopyDataLocally': function () { + return false; + }, + + 'copyDataLocally': function () { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred('MainController.copyDataLocally', {trace:false}); + + if (this.canCopyDataLocally()) { + deferredResult.addCallback(function () { console.log("--> copy data locally"); }); + } + deferredResult.callback(); + + return deferredResult; + + }, + + //------------------------------------------------------------------------- + + 'runApplication': function () { + var deferredResult; + +//console.log(">>> runApplication"); + deferredResult = new Clipperz.Async.Deferred('MainController.runApplication', {trace:true}); + deferredResult.addMethod(this.user(), 'getRecords'); + deferredResult.addMethod(this, 'showCards'); + deferredResult.callback(); + + return deferredResult; + }, + + //========================================================================= + + 'showOfflineError': function (anException) { + alert("Error: " + anException); + throw anException; + }, + + //========================================================================= + + 'isOnline': function() { + return navigator.onLine; + }, + + 'hasLocalData': function() { + return false; + }, + + //========================================================================= + + 'loginForm': function() { + if (this._loginForm == null) { + this._loginForm = new Clipperz.PM.UI.Mobile.Components.LoginForm({element:MochiKit.DOM.getElement('loginForm')}); + } + + return this._loginForm; + }, + + 'removeLoginForm': function () { + if (this._loginForm != null) { + this._loginForm.remove(); + this._loginForm = null; + } + }, + + //------------------------------------------------------------------------- + + 'cardList': function () { + if (this._cardList == null) { + this._cardList = new Clipperz.PM.UI.Mobile.Components.CardList({element:MochiKit.DOM.getElement('cardList')}); + MochiKit.Signal.connect(this._cardList, 'selectedCard', this, 'selectCardHandler'); + } + + return this._cardList; + }, + + 'showCards': function (someCards) { + this.cardList().showCards(someCards); + this.jQTouch().goTo('#cardList', 'slideleft'); + }, + + //------------------------------------------------------------------------- + + 'cardDetail': function () { + if (this._cardDetail == null) { + this._cardDetail = new Clipperz.PM.UI.Mobile.Components.CardDetail({element:MochiKit.DOM.getElement('cardDetail')}); + } + + return this._cardDetail; + }, + + 'selectCardHandler': function (aCardReference) { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred("MainController.selectCardHandler", {trace:true}); + deferredResult.addMethod(this.cardDetail(), 'render'); + deferredResult.addMethod(this.jQTouch(), 'goTo', '#cardDetail', 'slideleft'); + deferredResult.addMethod(this.user(), 'getRecord', aCardReference); + deferredResult.addMethod(this.cardDetail(), 'showCard'); + deferredResult.callback(); + + return deferredResult; + }, + + //========================================================================= + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AccountPanel.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AccountPanel.js index ee6d7a3..d6b0574 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AccountPanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AccountPanel.js @@ -41,6 +41,10 @@ Clipperz.PM.UI.Web.Components.AccountPanel = function(args) { tab: 'passphraseTab', panel: 'passphrasePanel' }, + 'OTP': { + tab: 'OTPTab', + panel: 'OTPPanel' + }, 'PREFERENCES': { tab: 'preferencesTab', panel: 'preferencesPanel' @@ -74,6 +78,7 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.AccountPanel, Clipperz.PM.UI. {tag:'ul', children:[ // {tag:'li', id:this.getId('accountTab'), children:[{tag:'a', href:'#', html:'Account'}], cls:'first'}, {tag:'li', id:this.getId('passphraseTab'), children:[{tag:'a', href:'#', html:'Passphrase'}], cls:'first'}, + {tag:'li', id:this.getId('OTPTab'), children:[{tag:'a', href:'#', html:'One Time Passwords'}]}, {tag:'li', id:this.getId('preferencesTab'), children:[{tag:'a', href:'#', html:'Preferences'}]}, {tag:'li', id:this.getId('loginHistoryTab'), children:[{tag:'a', href:'#', html:'Login history'}]} ]} @@ -117,16 +122,16 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.AccountPanel, Clipperz.PM.UI. {tag:'div', cls:'clear'}, {tag:'div', cls:'confirmButton', id:this.getId('confirmationButton'), children:[ {tag:'span', html:"change passphrase"} - ]}, - - {tag:'h3', cls:'manageOTP', html:"Manage One-Time Passphrases"}, - {} + ]} + ]}, + {tag:'li', id:this.getId('OTPPanel'), children:[ +// {tag:'h3', html:"Manage One-Time Passphrases"} ]}, {tag:'li', id:this.getId('preferencesPanel'), children:[ - {tag:'h3', html:"-- Preferences --"} +// {tag:'h3', html:"-- Preferences --"} ]}, {tag:'li', id:this.getId('loginHistoryPanel'), children:[ - {tag:'h3', html:"-- Login History --"} +// {tag:'h3', html:"-- Login History --"} ]} ]} ]} diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DataPanel.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DataPanel.js index d2f1045..462d864 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DataPanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DataPanel.js @@ -82,16 +82,18 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DataPanel, Clipperz.PM.UI.Com {tag:'div', cls:'subPanelContent', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('offlineCopyPanel'), children:[ - {tag:'h3', html:"Offline copy"} +// {tag:'h3', html:"Offline copy"}, + {tag:'p', html:"With just one click you can dump all your encrypted data from Clipperz servers to your hard disk and create a read-only offline version of Clipperz to be used when you are not connected to the Internet."}, + {tag:'a', id:this.getId('offlineCopyDownloadLink'), href:'#', html:"Download", cls:'downloadOfflineCopy'} ]}, {tag:'li', id:this.getId('sharingPanel'), children:[ - {tag:'h3', html:"Sharing"} +// {tag:'h3', html:"Sharing"} ]}, {tag:'li', id:this.getId('importPanel'), children:[ - {tag:'h3', html:"Import"} +// {tag:'h3', html:"Import"} ]}, {tag:'li', id:this.getId('exportPanel'), children:[ - {tag:'h3', html:"Export"} +// {tag:'h3', html:"Export"} ]} ]} ]} @@ -101,8 +103,14 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DataPanel, Clipperz.PM.UI.Com ]); this.tabPanelController().setup({selected:this.initiallySelectedTab()}); + MochiKit.Signal.connect(this.getId('offlineCopyDownloadLink'), 'onclick', this, 'downloadOfflineCopy'); }, - + + 'downloadOfflineCopy': function (anEvent) { + anEvent.preventDefault(); + MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy', anEvent.src()); + }, + //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginProgress.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginProgress.js index 5d082b5..26506e7 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginProgress.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginProgress.js @@ -82,9 +82,10 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI ]}, {tag:'div', cls:'footer', children:[ {tag:'div', cls:'buttonArea', id:this.getId('buttonArea'), children:[ - {tag:'div', cls:'button', id:this.getId('button'), children:[ - {tag:'a', href:'#', id:this.getId('buttonLink'), html:"cancel"} - ]} +// {tag:'div', cls:'button', id:this.getId('button'), children:[ +// {tag:'a', href:'#', id:this.getId('buttonLink'), html:"cancel"} +// ]} + {tag:'a', cls:'button', id:this.getId('button'), html:"cancel"} ]} ]} ]}); @@ -95,7 +96,8 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); MochiKit.Style.hideElement(this.getElement('errorBox')); - MochiKit.Signal.connect(this.getId('buttonLink'), 'onclick', this, 'cancelEventHandler'); +// MochiKit.Signal.connect(this.getId('buttonLink'), 'onclick', this, 'cancelEventHandler'); + MochiKit.Signal.connect(this.getId('button'), 'onclick', this, 'cancelEventHandler'); }, //------------------------------------------------------------------------- @@ -121,7 +123,9 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI //------------------------------------------------------------------------- 'showErrorMessage': function() { - this.getElement('buttonLink').innerHTML = "close"; +// this.getElement('buttonLink').innerHTML = "close"; + this.getElement('button').innerHTML = "close"; + MochiKit.DOM.addElementClass(this.getElement('button'), 'default'); MochiKit.Style.hideElement(this.getElement('progressBar')); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ToolsPanel.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ToolsPanel.js index 3ee6189..0fa369f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ToolsPanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ToolsPanel.js @@ -82,16 +82,16 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.ToolsPanel, Clipperz.PM.UI.Co {tag:'div', cls:'subPanelContent', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('passwordGeneratorPanel'), children:[ - {tag:'h3', html:"Password generator"} +// {tag:'h3', html:"Password generator"} ]}, {tag:'li', id:this.getId('bookmarkletPanel'), children:[ - {tag:'h3', html:"Bookmarklet"} +// {tag:'h3', html:"Bookmarklet"} ]}, {tag:'li', id:this.getId('compactEditionPanel'), children:[ - {tag:'h3', html:"Compact edition"} +// {tag:'h3', html:"Compact edition"} ]}, {tag:'li', id:this.getId('httpAuthPanel'), children:[ - {tag:'h3', html:"HTTP Auth"} +// {tag:'h3', html:"HTTP Auth"} ]} ]} ]} diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js index 9a0e744..1ab2e69 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js @@ -231,9 +231,11 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, { this.hideAllAppPageTabSlots(); this.appPage().showSlot(this.slotNameForTab('cards')); - MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected', this, 'handleTabSelected'); - MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard'); - MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard'); + MochiKit.Signal.connect(this.tabSidePanel(), 'tabSelected', this, 'handleTabSelected'); + MochiKit.Signal.connect(this.tabSidePanel(), 'addCard', this, 'handleAddCard'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'addCard', this, 'handleAddCard'); + + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy', this, 'handleDownloadOfflineCopy'); deferredResult = new Clipperz.Async.Deferred("AppController.run", {trace:false}); @@ -321,6 +323,29 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, { ], {trace:false}); }, + 'handleDownloadOfflineCopy': function (anEvent) { +console.log("AppController.handleDownloadOfflineCopy"); + var downloadHref; + + downloadHref = window.location.href.replace(/\/[^\/]*$/,'') + Clipperz_dumpUrl; + + if (Clipperz_IEisBroken == true) { + window.open(downloadHref, ""); + } else { + var deferredResult; + var newWindow; + + newWindow = window.open("", ""); + + deferredResult = new Clipperz.Async.Deferred("AppController.handleDownloadOfflineCopy", {trace:true}); + deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'echo', {'echo':"echo"}); + deferredResult.addCallback(function(aWindow) { + aWindow.location.href = downloadHref; + }, newWindow); + deferredResult.callback(); + } + }, + //============================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js deleted file mode 100644 index 5380aa1..0000000 --- a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/CardDetail.js +++ b/dev/null @@ -1,163 +0,0 @@ -/* - -Copyright 2008-2011 Clipperz Srl - -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. - -* 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. - -* 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 Clipperz Community Edition. If not, see - . - -*/ - -Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); - -Clipperz.PM.UI.iPhone.Components.CardDetail = function(args) { - args = args || {}; - - Clipperz.PM.UI.iPhone.Components.CardDetail.superclass.constructor.apply(this, arguments); - - this._cardReference = null; - - return this; -} - -//============================================================================= - -Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.CardDetail, Clipperz.PM.UI.Common.Components.BaseComponent, { - - //------------------------------------------------------------------------- - - 'toString': function () { - return "Clipperz.PM.UI.iPhone.Components.CardDetail component"; - }, - - //------------------------------------------------------------------------- - - 'cardReference': function () { - return this._cardReference; - }, - - 'setCardReference': function (aValue) { - this._cardReference = aValue; - }, - - //------------------------------------------------------------------------- - - 'renderSelf': function(/*aContainer, aPosition*/) { - this.append(this.element(), [ - {tag:'div', cls:'cardDetail', id:this.getId('cardDetail'), children:[ - {tag:'div', id:this.getId('progressBar')} //, -// {tag:'h1', cls:'loading', html:"loading"} - ]} - ]); - - this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); - MochiKit.Signal.signal(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', 0); - }, - - //========================================================================= - - 'showCardDetails': function (someData) { - this.element().innerHTML = ''; - this.append(this.element(), [ - {tag:'fieldset', id:this.getId('fields'), children:MochiKit.Base.map(function (aFieldData) { - return {tag:'div', cls:'row', children:[ - {tag:'label', html:aFieldData['label']}, -// {tag:'span', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), html:aFieldData['value']} - {tag:'div', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), children:[ - {tag:'div', children:[{tag:'p', html:aFieldData['value']}]} - ]} -// {tag:'input', type:'text', cls:('fieldValue ' + (aFieldData['isHidden'] ? 'password' : 'text')), value:aFieldData['value'], disabled:true} - - ]} - }, someData['fields'])} - ]); - - MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.element(), ['span.password']), MochiKit.Base.bind(function (aPasswordElement) { - MochiKit.Signal.connect(aPasswordElement, 'onclick', function (anEvent) { alert(MochiKit.DOM.scrapeText(anEvent.src())); }) - }, this)); - - if (someData['directLogins'].length > 0) { - this.append(this.element(), [ - {tag:'h2', html:"Direct logins"}, - {tag:'fieldset', id:this.getId('directLogins'), children:MochiKit.Base.map(function (aDirectLoginData) { - return {tag:'div', cls:'row', id:('directLogin_' + aDirectLoginData['_reference']), children:[ - {tag:'img', cls:'favicon', src:aDirectLoginData['favicon']}, -// {tag:'input', cls:'directLogin', disabled:'disabled', type:'text', name:aDirectLoginData['label'], value:aDirectLoginData['label']} - {tag:'span', cls:'directLogin', html:aDirectLoginData['label']} - ]} - }, someData['directLogins'])} - ]); - - MochiKit.Base.map(MochiKit.Base.bind(function (aRowNode) { - MochiKit.Signal.connect(aRowNode, 'onclick', this, 'directLoginClickHandler'); - }, this), - MochiKit.Selector.findChildElements(this.getElement('directLogins'), ['div.row']) - ) - }; - - if (someData['notes'] != '') { - this.append(this.element(), [ - {tag:'h2', html:"Notes"}, - {tag:'fieldset', id:this.getId('fieldset'), children:[ - {tag:'div', cls:'row notes', children:[ - {tag:'span', html:someData['notes']} - ]} - ]} - ]); - }; - - return true; - }, - - //------------------------------------------------------------------------- -/* - 'toggleClickHandler': function (anEvent) { - var nextState; - var fieldValue; - -//console.log("TOGGLE"); - anEvent.preventDefault; - fieldValue = MochiKit.Selector.findChildElements(anEvent.src().parentNode.parentNode, ['span.password'])[0]; - - nextState = (MochiKit.DOM.getNodeAttribute(anEvent.src(), 'toggled') != 'true'); - if (nextState) { - MochiKit.DOM.removeElementClass(fieldValue, 'clear'); - } else { - MochiKit.DOM.addElementClass(fieldValue, 'clear'); - } - - MochiKit.DOM.setNodeAttribute(anEvent.src(), 'toggled', nextState); - }, -*/ - //========================================================================= - - 'directLoginClickHandler': function (anEvent) { - anEvent.preventDefault(); - - if (/(directLogin_)/.test(anEvent.src().id)) { - var directLoginReference; - - directLoginReference = anEvent.src().id.match(/(directLogin_)(.*)/)[2]; - MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', {cardReference:this.cardReference(), directLoginReference:directLoginReference}); - } - }, - - //========================================================================= - - __syntaxFix__: "syntax fix" -}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js deleted file mode 100644 index 5341878..0000000 --- a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Components/LoginForm.js +++ b/dev/null @@ -1,178 +0,0 @@ -/* - -Copyright 2008-2011 Clipperz Srl - -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. - -* 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. - -* 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 Clipperz Community Edition. If not, see - . - -*/ - -Clipperz.Base.module('Clipperz.PM.UI.iPhone.Components'); - -Clipperz.PM.UI.iPhone.Components.LoginForm = function(args) { - args = args || {}; - - Clipperz.PM.UI.iPhone.Components.LoginForm.superclass.constructor.apply(this, arguments); - - return this; -} - -//============================================================================= - -Clipperz.Base.extend(Clipperz.PM.UI.iPhone.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { - - //------------------------------------------------------------------------- - - 'toString': function () { - return "Clipperz.PM.UI.iPhone.Components.LoginForm component"; - }, - - //------------------------------------------------------------------------- - - 'focusOnUsername': function () { - this.getElement('username').focus(); - }, - - //------------------------------------------------------------------------- - - 'username': function () { - return this.getElement('username').value; - }, - - 'passphrase': function () { - return this.getElement('passphrase').value; - }, - - //------------------------------------------------------------------------- - - 'renderSelf': function(/*aContainer, aPosition*/) { - this.append(this.element(), [ - {tag:'div', cls:'toolbar iPhoneClipperzToolbar', children:[ - {tag:'h1', id:'pageTitle', html:'Clipperz'}, - {tag:'a', id:'backButton', cls:'button', href:'#', html:"back"} - ]}, - {tag:'form', title:'Theaters', cls:'panel toolbarlessPanel loginForm', id:this.getId('loginFormPanel'), children:[ - {tag:'fieldset', id:this.getId('fieldset'), children:[ - {tag:'div', cls:'row', children:[ - {tag:'label', html:"username"}, - {tag:'input', type:'text', name:'username', value:"", autocorrect:'off', autocapitalize:'off', id:this.getId('username')} - ]}, - {tag:'div', cls:'row', children:[ - {tag:'label', html:"passphrase"}, - {tag:'input', type:'password', name:'passphrase', value:"", id:this.getId('passphrase')} - ]} - ]}, - {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Login", id:this.getId('submit')} - ]}, - {tag:'div', cls:'panel toolbarlessPanel loginProgressPanel', id:this.getId('loginProgressPanel'), children:[ - {tag:'div', id:this.getId('progressBar')} //, -// {tag:'a', cls:'whiteButton', type:'submit', href:'#', html:"Cancel", id:this.getId('cancel')} - ]}, - {tag:'div', cls:'panel loginErrorPanel', id:this.getId('loginErrorPanel'), children:[ - {tag:'div', cls:'errorMessage', id:this.getId('errorMessageBox'), children:[ - {tag:'h2', id:this.getId('errorMessage'), html:"Login failed"} - ]} - ]} - ]); - - MochiKit.Signal.connect(this.getElement('submit'), 'onclick', this, 'submitHandler'); - MochiKit.Signal.connect(this.getElement('loginFormPanel'), 'onsubmit', this, 'submitHandler'); - -// MochiKit.Signal.connect(this.getElement('cancel'), 'onclick', this, 'cancelHandler'); - MochiKit.Signal.connect('backButton', 'onclick', this, 'backHandler'); - - this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); - -// MochiKit.Style.hideElement(this.getElement('errorMessage')); - - this.showLoginForm(); -// MochiKit.Async.callLater(0.2, MochiKit.Base.method(this, 'focusOnUsername')); - }, - - //------------------------------------------------------------------------- - - 'showLoginForm': function () { - MochiKit.Style.showElement(this.getElement('loginFormPanel')); - MochiKit.Style.hideElement(this.getElement('loginProgressPanel')); - MochiKit.Style.hideElement(this.getElement('loginErrorPanel')); - MochiKit.Style.hideElement('backButton'); - }, - - 'slideInLoginForm': function () { - var offset; - - offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); - - MochiKit.Style.showElement(this.getElement('loginFormPanel')); - MochiKit.Style.setElementPosition(this.getElement('loginFormPanel'), {x:-offset, y:0}); - - new MochiKit.Visual.Sequence([ - new MochiKit.Visual.Parallel([ - new MochiKit.Visual.Move(this.getElement('loginErrorPanel'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), - new MochiKit.Visual.Move(this.getElement('loginFormPanel'), {x:0, y:0, mode:'absolute', transition:MochiKit.Visual.Transitions.linear, sync:true}), - MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) - ], {duration:0.5, sync:true}), - MochiKit.Visual.fade(this.getElement('loginErrorPanel'), {duration:0, sync:true}) - ], {}) - }, - - 'showLoginProgress': function () { - MochiKit.Style.hideElement(this.getElement('loginFormPanel')); - MochiKit.Style.showElement(this.getElement('loginProgressPanel')); - }, - - 'showLoginError': function (anError) { - this.getElement('errorMessage').innerHTML = "Login error"; - - MochiKit.Style.showElement('backButton'); - MochiKit.Style.hideElement(this.getElement('loginProgressPanel')); - MochiKit.Style.showElement(this.getElement('loginErrorPanel')); - MochiKit.Style.setElementPosition(this.getElement('loginErrorPanel'), {x:0, y:45}); - }, - - //------------------------------------------------------------------------- -/* - 'disableCancelButton': function () { - MochiKit.DOM.hideElement(this.getElement('cancel')); - }, -*/ - //------------------------------------------------------------------------- - - 'submitHandler': function (anEvent) { - anEvent.preventDefault(); - - MochiKit.Signal.signal(this, 'doLogin', {'username':this.username(), 'passphrase':this.passphrase()}); - }, - - 'cancelHandler': function (anEvent) { - anEvent.preventDefault(); - -//console.log("CANCEL"); - }, - - 'backHandler': function (anEvent) { - anEvent.preventDefault(); - - this.slideInLoginForm(); - }, - - //------------------------------------------------------------------------- - - __syntaxFix__: "syntax fix" -}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js deleted file mode 100644 index 3fcaae1..0000000 --- a/frontend/gamma/js/Clipperz/PM/UI/iPhone/Controllers/MainController.js +++ b/dev/null @@ -1,369 +0,0 @@ -/* - -Copyright 2008-2011 Clipperz Srl - -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. - -* 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. - -* 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 Clipperz Community Edition. If not, see - . - -*/ - -Clipperz.Base.module('Clipperz.PM.UI.iPhone.Controllers'); - -// Some parts of this controller have been derived from the iUI library. - -Clipperz.PM.UI.iPhone.Controllers.MainController = function() { - this._loginForm = null; - this._cardList = null; - this._cachedValues = null; - this._user = null; - - if (typeof window.onorientationchange == 'object') { - MochiKit.Signal.connect(window, 'onorientationchange', this, 'orientationChangeHandler'); - MochiKit.Async.callLater(0, MochiKit.Base.method(this, 'orientationChangeHandler')); - } else { - this.setOrientation('portrait'); -// this.setOrientation('landscape'); - } - - this.addMetaTag('viewport', 'width=devicewidth; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'); - this.addMetaTag('apple-mobile-web-app-capable', 'yes'); - this.addMetaTag('apple-mobile-web-app-status-bar-style', 'black'); - - this.addLinkTag('apple-touch-icon', 'data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAAF8AAABfCAYAAACOTBv1AAAACXBIWXMAAAsTAAALEwEAmpwYAAAQC0lEQVR4nO2ce3wU1b3AvzOzz2TzBpKQhIS3CnLxgYoPqAgiQS8igiAqiFprtT571YpKUa9tvVgrVvhc7IXS4lUUvGgR5CWIoiAIYoQgJGDI+0k2yW42szNz7h8pGBHIPmazqeb7+UD4DHt+vzPfPTnnzJkzIwGCLqKCHO0K/JTpkh9FuuRHkS75UaRLfhTpkh9FuuRHkS75UaRLfhTpkh9FLNGuwKnIzc3l9WXLQAIhQILWvwQnjn3vUNtjkoQQ4kSZr77KY+TIkR1/EgHQKeWnp6eTkJiI0P2gqyeOnxD7T+ttxf/wp4SwOOnTp0/UzqM9OqV8oFXygSVIm3/xvePSKf59up/cWfO9z3c2OnmfH646qVMv2XZa+RKtrT8cWruoztv2O6384/15OLSODZ237Xda+W1nMKEiROe+U9Rp5ZtFJ+51Oq/8E/P7MOjE3oFOLL/1Iik8fUJoCF03pT6RoNPKF4Q/2zF0P0J0yQ8aM/pqoesIXQs/UITotPKFYRDuXMXQ/dDV8oNECIShgRGmOKFjGIY5dYoAnVK+QCB0DSNM+Ybmb/0SOylhy8/NzWXYsGFm1OU7hGhd0RThtdrW2Y758kdcdhGLX30h7Dhhr2ouWrSI9PQ0ykrLeHn+fBYsWIDX6w0zqsAwNOQwW77QtbBnTMdJSkzgkfvuZPqkXOJi7SAMLhl2Htt37gk5ZlgtPycnh7TU7oiGo6TH6zz/3DPUVpXz3qp3+Lch54YeWLR2OyLcbkcPf9wY/bNL2fjuMg7uWM09t11PnE1FaSwADB65746wYofV8ufMeQph6MhfvoT09atIWWORBt7GNaOv5urRWyktLeWll//MXxb/FZ/PF3BcgcDQVeRwux1DQxjBz1m7JSfx2IM/Z/J1Y3A5LUiShF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mXF2tDemRMOUdur6XA4WPDUbWRVr0D11CNbY5i3pzebPjNn7f9U9M7O5LWpyTSV5CFJYB08hbvmf0RpWUXEcp6JDunzT4Wmabz74ReIjBEMH9iNQwzhleWRbX317gbktCGcn6ZzICGX2597i4aGxojmbA8R7T/ZvTKF3W7rsHwDB/SL+jkDIqpbxH/qdMrX+f5U6JIfRbrkR5Eu+VGkS34U6ZIfRbrkR5Eu+VGkS34U6ZIfRbrkR5H/Bx8z6HmTXnicAAAAAElFTkSuQmCCCg=='); -// this.addLinkTag('apple-touch-startup-image', 'default.png'); - -// if (!window.navigator.standalone) // not running as an installed app - - MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'selectedDirectLogin', this, 'selectedDirectLoginHandler'); - - MochiKit.DOM.addElementClass(document.body, 'iPhone'); - return this; -} - -MochiKit.Base.update(Clipperz.PM.UI.iPhone.Controllers.MainController.prototype, { - - 'toString': function () { - return "Clipperz.PM.UI.iPhone.Controllers.MainController"; - }, - - //========================================================================= - - 'user': function () { - return this._user; - }, - - 'setUser': function (aValue) { - this._user = aValue; - }, - - //========================================================================= - - 'loginForm': function() { - if (this._loginForm == null) { - MochiKit.DOM.removeElement('mainDiv'); - this._loginForm = new Clipperz.PM.UI.iPhone.Components.LoginForm({element:MochiKit.DOM.currentDocument().body}); - MochiKit.Signal.connect(this._loginForm, 'doLogin', this, 'doLoginHandler') - } - - return this._loginForm; - }, - - 'removeLoginForm': function () { - if (this._loginForm != null) { - this._loginForm.remove(); - this._loginForm = null; - } - }, - - //----------------------------------------------------------------------------- - - 'cardList': function () { - if (this._cardList == null) { - this._cardList = new Clipperz.PM.UI.iPhone.Components.CardList({element:MochiKit.DOM.currentDocument().body}); - MochiKit.Signal.connect(this._cardList, 'searchEvent', this, 'searchEventHandler') - MochiKit.Signal.connect(this._cardList, 'selectedCard', this, 'selecetedCardHandler') - } - - return this._cardList; - }, - - //========================================================================= - - 'currentWidth': function () { - return this._currentWidth; - }, - - 'setCurrentWidth': function (aValue) { - this._currentWidth = aValue; - }, - - //========================================================================= - - 'orientationChangeHandler': function () { - switch(window.orientation) { - case 0: - this.setOrientation('portrait'); - break; - case 90: - case -90: - this.setOrientation('landscape'); - break; - } - }, - - //------------------------------------------------------------------------- - - 'setOrientation': function (anOrientation) { - document.body.setAttribute('orientation', anOrientation); - setTimeout(scrollTo, 100, 0, 1); - }, - - //------------------------------------------------------------------------- - - 'slidePages': function (fromPage, toPage, backwards) { - var axis; - var slideDone; - - slideDone = function () { - // console.log("slideDone"); - if (!hasClass(toPage, "dialog")) { - fromPage.removeAttribute("selected"); - } - checkTimer = setInterval(checkOrientAndLocation, 300); - setTimeout(updatePage, 0, toPage, fromPage); - fromPage.removeEventListener('webkitTransitionEnd', slideDone, false); - } - - axis = (backwards ? fromPage : toPage).getAttribute("axis"); - - clearInterval(checkTimer); - - if (canDoSlideAnim() && axis != 'y') { - slide2(fromPage, toPage, backwards, slideDone); - } else { - slide1(fromPage, toPage, backwards, axis, slideDone); - } - }, - - //------------------------------------------------------------------------- - - 'getCachedValues': function () { - var deferredResult; - - if (this._cachedObjects != null) { - deferredResult = MochiKit.Async.succeed(this._cachedObjects); - } else { - deferredResult = new Clipperz.Async.Deferred("MainController.getCachedValues", {trace:false}); - deferredResult.addMethod(this.user(), 'getRecords'); - deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.getCachedValues - collectResults", { - '_rowObject': MochiKit.Async.succeed, - '_reference': MochiKit.Base.methodcaller('reference'), - 'label': MochiKit.Base.methodcaller('label'), - 'favicon': MochiKit.Base.methodcaller('favicon'), - '_searchableContent': MochiKit.Base.methodcaller('searchableContent') - }, {trace:false})); - deferredResult.addCallback(Clipperz.Async.collectAll); - deferredResult.addCallback(MochiKit.Base.bind(function (someRows) { - this._cachedObjects = someRows; - return this._cachedObjects; - }, this)); - deferredResult.callback(); - } - - return deferredResult; - }, - //========================================================================= - - 'run': function(shouldShowRegistrationForm) { - this.loginForm().render(); - MochiKit.Async.callLater(1, MochiKit.Base.method(this.loginForm(), 'focusOnUsername')); - }, - - //========================================================================= - - 'doLoginHandler': function (someArgs) { - var deferredResult; - var parameters; - var shouldUseOTP; -// var loginProgress; - var user; - var getPassphraseDelegate; - - parameters = someArgs; - shouldUseOTP = (typeof(parameters.passphrase) == 'undefined'); - - getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); - user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':getPassphraseDelegate}); - - deferredResult = new Clipperz.Async.Deferred("MainController.doLogin", {trace:false}); - deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); - deferredResult.addMethod(this.loginForm(), 'showLoginProgress'); - deferredResult.addCallback(MochiKit.Async.wait, 0.1); - deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); - deferredResult.addMethod(user, 'login'); - deferredResult.addMethod(this, 'setUser', user); - deferredResult.addMethod(user, 'getRecords'); - deferredResult.addMethod(this, 'removeLoginForm'); - deferredResult.addMethod(this.cardList(), 'render'); - deferredResult.addMethod(this, 'displaySelectedRecords', ''); - deferredResult.addErrback(MochiKit.Base.method(this.loginForm(), 'showLoginError')); - deferredResult.callback(); - - return deferredResult; - }, - - //========================================================================= - - 'searchEventHandler': function (aValue) { -//console.log("searching for ... " + aValue); - return this.displaySelectedRecords(aValue); - }, - - //========================================================================= - - '_displaySelectedRows': function (aFilter, someRows) { - var result; - - result = someRows; - - if (aFilter != null) { - var filter; - var filterRegExp; - - filter = aFilter.replace(/[^A-Za-z0-9]/g, "\\$&"); - filterRegExp = new RegExp(filter, "i"); - result = MochiKit.Base.filter(function (aCachedResult) { return filterRegExp.test(aCachedResult['_searchableContent'])}, result); - } - - - result.sort(MochiKit.Base.partial(function (aKey, aComparator, aObject, bObject) { - return aComparator(aObject[aKey], bObject[aKey]); - }, 'label', Clipperz.Base.caseInsensitiveCompare)); - - this.cardList().update(result); - }, - - //------------------------------------------------------------------------- - - 'displaySelectedRecords': function (aFilter) { - return Clipperz.Async.callbacks("MainController.displaySelectedrows", [ - MochiKit.Base.method(this, 'getCachedValues'), - MochiKit.Base.method(this, '_displaySelectedRows', aFilter) - ], {trace:false}); - }, - - //========================================================================= - - 'selecetedCardHandler': function (aRecordReference) { - var deferredResult; - var recordData; - - recordData = {}; -//console.log("Showing detail for card with reference", aRecordReference); - deferredResult = new Clipperz.Async.Deferred("MainController.selectedCardHandler", {trace:false}); - deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); - deferredResult.collectResults({ - '_reference': MochiKit.Base.methodcaller('reference'), - 'title': MochiKit.Base.methodcaller('label'), - 'favicon': MochiKit.Base.methodcaller('favicon') - }); - deferredResult.addCallback(function (someData) { - MochiKit.Base.update(recordData, someData); - }) - deferredResult.addMethod(this.cardList(), 'showCard', recordData); - - deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); - deferredResult.addMethodcaller('notes'); - deferredResult.addCallback(function (someNotes) { - recordData['notes'] = someNotes; - }) - - deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); - deferredResult.addMethodcaller('getCurrentRecordVersion'); - deferredResult.addMethodcaller('fields'); - deferredResult.addCallback(MochiKit.Base.values); - deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.selectedCardHandler - fields", { - 'label': MochiKit.Base.methodcaller('label'), - 'value': MochiKit.Base.methodcaller('value'), - 'isHidden': MochiKit.Base.methodcaller('isHidden') - }, {trace:false})); - deferredResult.addCallback(Clipperz.Async.collectAll); - deferredResult.addCallback(function (someData) { - recordData['fields'] = someData; - }); - - deferredResult.addMethod(this.user(), 'getRecord', aRecordReference); - deferredResult.addMethodcaller('directLogins'); - deferredResult.addCallback(MochiKit.Base.values); - deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("MainController.selectedCardHandler - directLogins", { - 'label': MochiKit.Base.methodcaller('label'), - 'favicon': MochiKit.Base.methodcaller('favicon'), - '_reference': MochiKit.Base.methodcaller('reference') - }, {trace:false})); - deferredResult.addCallback(Clipperz.Async.collectAll); - deferredResult.addCallback(function (someData) { - recordData['directLogins'] = someData; - }); - - deferredResult.addMethod(this.cardList(), 'showCardDetails', recordData); - deferredResult.callback(); - - return deferredResult; - }, - - //========================================================================= - - 'selectedDirectLoginHandler': function (someData) { - var deferredResult; - -//console.log("<<< signal - directLogin"); - deferredResult = new Clipperz.Async.Deferred("MainController.selectedDirectLoginHandler", {trace:false}); - deferredResult.addMethod(this.user(), 'getRecord', someData['cardReference']); - deferredResult.addMethodcaller('directLogins'); - deferredResult.addCallback(MochiKit.Base.itemgetter(someData['directLoginReference'])); -// deferredResult.addMethodcaller('runDirectLogin'); - deferredResult.addCallback(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin); - deferredResult.callback(); - - return deferredResult; - }, - - //========================================================================= - - 'addMetaTag': function (aName, aContent) { - var metaTag; - - metaTag = document.createElement('meta'); - metaTag.name = aName; - metaTag.content = aContent; - document.getElementsByTagName('head')[0].appendChild(metaTag); - }, - - 'addLinkTag': function (aRel, anHref) { - var linkTag; - - linkTag = document.createElement('link'); - linkTag.rel = aRel; - linkTag.href = anHref; - document.getElementsByTagName('head')[0].appendChild(linkTag); - }, - - //========================================================================= - __syntaxFix__: "syntax fix" -}); \ No newline at end of file -- cgit v0.9.0.2