138 files changed, 1512 insertions, 2169 deletions
diff --git a/frontend/gamma/js/Clipperz/Async.js b/frontend/gamma/js/Clipperz/Async.js index f7a9517..d525453 100644 --- a/frontend/gamma/js/Clipperz/Async.js +++ b/frontend/gamma/js/Clipperz/Async.js @@ -1,711 +1,701 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //Clipperz.Async = MochiKit.Async; if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Async) == 'undefined') { Clipperz.Async = {}; } Clipperz.Async.VERSION = "0.1"; Clipperz.Async.NAME = "Clipperz.Async"; Clipperz.Async.Deferred = function(aName, args) { args = args || {}; Clipperz.Async.Deferred.superclass.constructor.call(this, args.canceller); this._args = args; this._name = aName || "Anonymous deferred"; this._count = 0; this._shouldTrace = ((CLIPPERZ_DEFERRED_TRACING_ENABLED === true) || (args.trace === true)); this._vars = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { 'name': function () { return this._name; }, 'args': function () { return this._args; }, //----------------------------------------------------------------------------- 'callback': function (aValue) { if (this._shouldTrace) { - // Clipperz.log("CALLBACK " + this._name, aValue); - console.log("CALLBACK " + this._name, aValue); + Clipperz.log("CALLBACK " + this._name, aValue); } if (this.chained == false) { var message; message = "ERROR [" + this._name + "]"; this.addErrback(function(aResult) { if (! (aResult instanceof MochiKit.Async.CancelledError)) { Clipperz.log(message, aResult); } return aResult; }); if (this._shouldTrace) { var resultMessage; resultMessage = "RESULT " + this._name + " <=="; // this.addCallback(function(aResult) { Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) { - // Clipperz.log(resultMessage, aResult); - console.log(resultMessage, aResult); - + Clipperz.log(resultMessage, aResult); return aResult; }); } } if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) { Clipperz.log("callback " + this._name, this); } return Clipperz.Async.Deferred.superclass.callback.apply(this, arguments); }, //----------------------------------------------------------------------------- 'addCallback': function () { var message; if (this._shouldTrace) { this._count ++; message = "[" + this._count + "] " + this._name + " "; // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;}); this.addCallbacks( - // function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, - function(aResult) {console.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, - // function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} - function(aResult) {console.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} + function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, + function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} ); } Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments); if (this._shouldTrace) { // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;}); this.addCallbacks( - // function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, - function(aResult) {console.log("-OK- " + message + "<--", aResult); return aResult;}, - // function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} - function(aResult) {console.log("FAIL " + message + "<--", aResult); return aResult;} + function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, + function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} ); } }, //============================================================================= 'addCallbackPass': function() { var passFunction; passFunction = MochiKit.Base.partial.apply(null, arguments); this.addCallback(function() { var result; result = arguments[arguments.length -1]; passFunction(); return result; }); }, //----------------------------------------------------------------------------- 'addErrbackPass': function() { var passFunction; passFunction = MochiKit.Base.partial.apply(null, arguments); this.addErrback(function() { var result; result = arguments[arguments.length -1]; passFunction(); return result; }); }, //----------------------------------------------------------------------------- 'addBothPass': function() { var passFunction; passFunction = MochiKit.Base.partial.apply(null, arguments); this.addBoth(function() { var result; result = arguments[arguments.length -1]; passFunction(); return result; }); }, //----------------------------------------------------------------------------- 'addIf': function (aThenBlock, anElseBlock) { this.addCallback(MochiKit.Base.bind(function (aValue) { var deferredResult; if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) { deferredResult = Clipperz.Async.callbacks(this._name + " <then>", aThenBlock, null, aValue); } else { deferredResult = Clipperz.Async.callbacks(this._name + " <else>", anElseBlock, null, aValue); } return deferredResult; })) }, //----------------------------------------------------------------------------- 'addMethod': function () { this.addCallback(MochiKit.Base.method.apply(this, arguments)); }, //----------------------------------------------------------------------------- 'addMethodcaller': function () { this.addCallback(MochiKit.Base.methodcaller.apply(this, arguments)); }, //============================================================================= 'addLog': function (aLog) { if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) { this.addBothPass(function(res) {Clipperz.log(aLog + " ", res);}); -// this.addBothPass(function(res) {console.log(aLog + " ", res);}); } }, //============================================================================= 'acquireLock': function (aLock) { // this.addCallback(function (aResult) { // return Clipperz.Async.callbacks("Clipperz.Async.acquireLock", [ // MochiKit.Base.method(aLock, 'acquire'), // MochiKit.Base.partial(MochiKit.Async.succeed, aResult) // ], {trace:false}); // }); this.addCallback(MochiKit.Base.method(aLock, 'acquire')); }, 'releaseLock': function (aLock) { // this.addCallback(function (aResult) { // return Clipperz.Async.callbacks("Clipperz.Async.release <ok>", [ // MochiKit.Base.method(aLock, 'release'), // MochiKit.Base.partial(MochiKit.Async.succeed, aResult) // ], {trace:false}); // }); // this.addErrback(function (aResult) { -///console.log("releaseLock.addErrback:", aResult); +///Clipperz.log("releaseLock.addErrback:", aResult); // return Clipperz.Async.callbacks("Clipperz.Async.release <fail>", [ // MochiKit.Base.method(aLock, 'release'), // MochiKit.Base.partial(MochiKit.Async.fail, aResult) // ], {trace:false}); // }); // this.addBothPass(MochiKit.Base.method(aLock, 'release')); this.addCallbackPass(MochiKit.Base.method(aLock, 'release')); this.addErrback(function (anError) { aLock.release(); return anError; }); }, //============================================================================= 'collectResults': function (someRequests) { this.addCallback(Clipperz.Async.collectResults(this._name + " <collect results>", someRequests, this._args)); }, 'addCallbackList': function (aRequestList) { this.addCallback(Clipperz.Async.callbacks, this._name + " <callback list>", aRequestList, this._args); }, //============================================================================= 'vars': function () { if (this._vars == null) { this._vars = {} } return this._vars; }, 'setValue': function (aKey) { this.addCallback(MochiKit.Base.bind(function (aValue) { this.vars()[aKey] = aValue; return aValue; }, this)); }, 'getValue': function (aKey) { this.addCallback(MochiKit.Base.bind(function () { return this.vars()[aKey]; }, this)); }, //============================================================================= __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Async.DeferredSynchronizer = function(aName, someMethods) { this._name = aName || "Anonymous deferred Synchronizer"; this._methods = someMethods; this._numberOfMethodsDone = 0; this._methodResults = []; this._result = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer # " + this.name(), {trace:false}); this._result.addMethod(this, 'methodResults'); this._result.addCallback(function(someResults) { var cancels; var errors; var result; cancels = MochiKit.Base.filter(function(aResult) { return (aResult instanceof MochiKit.Async.CancelledError)}, someResults); if (cancels.length == 0) { errors = MochiKit.Base.filter(function(aResult) { return (aResult instanceof Error)}, someResults); if (errors.length == 0) { // result = MochiKit.Async.succeed(someResults); result = someResults; } else { result = MochiKit.Async.fail(someResults); } } else { result = MochiKit.Async.fail(cancels[0]); } return result; }/*, this._methodResults */); return this; } MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, { //----------------------------------------------------------------------------- 'name': function() { return this._name; }, //----------------------------------------------------------------------------- 'methods': function() { return this._methods; }, 'methodResults': function() { return this._methodResults; }, //----------------------------------------------------------------------------- 'result': function() { return this._result; }, //----------------------------------------------------------------------------- 'numberOfMethodsDone':function() { return this._numberOfMethodsDone; }, 'incrementNumberOfMethodsDone': function() { this._numberOfMethodsDone ++; }, //----------------------------------------------------------------------------- 'run': function(args, aValue) { var deferredResults; var i, c; deferredResults = []; args = args || {}; c = this.methods().length; for (i=0; i<c; i++) { var deferredResult; var methodCalls; var ii, cc; -//console.log("TYPEOF", typeof(this.methods()[i])); +//Clipperz.log("TYPEOF", typeof(this.methods()[i])); if (typeof(this.methods()[i]) == 'function') { methodCalls = [ this.methods()[i] ]; } else { methodCalls = this.methods()[i]; } cc = methodCalls.length; deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.DeferredSynchronizer.run => " + this.name() + "[" + i + "]", args); for (ii=0; ii<cc; ii++) { deferredResult.addCallback(methodCalls[ii]); } deferredResult.addBoth(MochiKit.Base.method(this, 'handleMethodCallDone', i)); deferredResults.push(deferredResult); } for (i=0; i<c; i++) { deferredResults[i].callback(aValue); } return this.result(); }, //----------------------------------------------------------------------------- 'handleMethodCallDone': function(anIndexValue, aResult) { this.incrementNumberOfMethodsDone(); this.methodResults()[anIndexValue] = aResult; if (this.numberOfMethodsDone() < this.methods().length) { // nothing to do here other than possibly log something } else if (this.numberOfMethodsDone() == this.methods().length) { this.result().callback(); } else if (this.numberOfMethodsDone() > this.methods().length) { alert("Clipperz.Async.Deferred.handleMethodCallDone -> WTF!"); // WTF!!! :( } }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# MochiKit.Base.update(Clipperz.Async, { 'callbacks': function (aName, someFunctions, someArguments, aCallbackValue) { var deferredResult; var i, c; deferredResult = new Clipperz.Async.Deferred(aName, someArguments); c = someFunctions.length; for (i=0; i<c; i++) { deferredResult.addCallback(someFunctions[i]); } deferredResult.callback(aCallbackValue); return deferredResult; }, //------------------------------------------------------------------------- 'forkAndJoin': function (aName, someMethods, args) { return MochiKit.Base.partial(function (aName, someMethods, args, aValue) { var synchronizer; var result; args = args || {}; synchronizer = new Clipperz.Async.DeferredSynchronizer(aName, someMethods); result = synchronizer.run(args, aValue); return result; }, aName, someMethods, args); }, //------------------------------------------------------------------------- 'collectResults': function(aName, someRequests, args) { return MochiKit.Base.partial(function(aName, someRequests, args, aValue) { var deferredResult; var requestKeys; var methods; requestKeys = MochiKit.Base.keys(someRequests); methods = MochiKit.Base.values(someRequests); deferredResult = new Clipperz.Async.Deferred(aName, args); deferredResult.addCallback(Clipperz.Async.forkAndJoin(aName + " [inner forkAndJoin]", methods, args)); deferredResult.addBoth(function(someResults) { var returnFunction; var results; var i,c; var result; if (someResults instanceof MochiKit.Async.CancelledError) { returnFunction = MochiKit.Async.fail; result = someResults; } else { if (someResults instanceof Error) { returnFunction = MochiKit.Async.fail; results = someResults['message']; } else { returnFunction = MochiKit.Async.succeed; results = someResults; } result = {}; c = requestKeys.length; for (i=0; i<c; i++) { result[requestKeys[i]] = results[i]; } } return returnFunction.call(null, result); }); deferredResult.callback(aValue); return deferredResult; }, aName, someRequests, args); }, //------------------------------------------------------------------------- 'collectAll': function (someDeferredObjects) { var deferredResult; deferredResult = new MochiKit.Async.DeferredList(someDeferredObjects, false, false, false); deferredResult.addCallback(function (aResultList) { return MochiKit.Base.map(function (aResult) { if (aResult[0]) { return aResult[1]; } else { throw aResult[1]; } }, aResultList); }); return deferredResult; }, //------------------------------------------------------------------------- 'setItem': function (anObject, aKey, aValue) { anObject[aKey] = aValue; return anObject; }, 'setItemOnObject': function (aKey, aValue, anObject) { anObject[aKey] = aValue; return anObject; }, 'setDeferredItemOnObject': function (aKey, aDeferredFunction, anObject) { return Clipperz.Async.callbacks("Clipperz.Async.setDeferredItemOnObject", [ aDeferredFunction, MochiKit.Base.partial(Clipperz.Async.setItem, anObject, aKey) ], {trace:false}, anObject); }, //------------------------------------------------------------------------- 'deferredIf': function (aName, aThenBlock, anElseBlock) { return function (aValue) { var deferredResult; if (!MochiKit.Base.isUndefinedOrNull(aValue) && aValue) { deferredResult = Clipperz.Async.callbacks(aName + " <then>", aThenBlock, null, aValue); } else { deferredResult = Clipperz.Async.callbacks(aName + " <else>", anElseBlock, null, aValue); } return deferredResult; } }, //------------------------------------------------------------------------- 'log': function(aMessage, aResult) { if (CLIPPERZ_DEFERRED_LOGGING_ENABLED) { Clipperz.log(aMessage + " ", aResult); } return aResult; }, //========================================================================= 'deferredCompare': function (aComparator, aDeferred, bDeferred) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredCompare", {trace:false}); deferredResult.addCallback(Clipperz.Async.collectAll, [aDeferred, bDeferred]); deferredResult.addCallback(function (someResults) { var result; if (aComparator(someResults[0], someResults[1]) > 0) { result = MochiKit.Async.succeed(); } else { result = MochiKit.Async.fail(); }; return result; }); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'insertIntoSortedArray': function (anObject, aDeferredComparator, aSortedResult) { var deferredResult; var i, c; if (aSortedResult.length == 0) { deferredResult = MochiKit.Async.succeed([anObject]); } else { deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.insertIntoSortedArray", {trace:false}); c = aSortedResult.length + 1; for (i=0; i<c; i++) { deferredResult.addCallback(function (aDeferredComparator, aObject, bObject, aContext) { var innerDeferredResult; innerDeferredResult = new Clipperz.Async.Deferred("Clipperz.Async.insertIntoSortedArray <inner compare>", {trace:false}); innerDeferredResult.addCallback(aDeferredComparator, aObject, bObject); innerDeferredResult.addErrback(MochiKit.Async.fail, aContext); innerDeferredResult.callback(); return innerDeferredResult; }, aDeferredComparator, anObject, aSortedResult[i], i); } deferredResult.addMethod(aSortedResult, 'push', anObject); deferredResult.addErrback(function (anError) { aSortedResult.splice(anError.message, 0, anObject); }) deferredResult.addBoth(MochiKit.Async.succeed, aSortedResult); deferredResult.callback(); } return deferredResult; }, //------------------------------------------------------------------------- 'deferredSort': function (aDeferredComparator, someObjects) { var deferredResult; var i, c; deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredSort", {trace:false}); c = someObjects.length; for (i=0; i<c; i++) { deferredResult.addCallback(Clipperz.Async.insertIntoSortedArray, someObjects[i], aDeferredComparator); if ((i % 50) == 0) { -// console.log("######### sort wait ##########"); +// Clipperz.log("######### sort wait ##########"); deferredResult.addCallback(MochiKit.Async.wait, 0.5); } } deferredResult.callback([]); return deferredResult; }, //========================================================================= 'deferredFilter': function (aFunction, someObjects) { var deferredResult; var i, c; deferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredFilter", {trace:false}); c = someObjects.length; for (i=0; i<c; i++) { deferredResult.addCallback(function (aFunction, anObject, anIndex, aResult) { var innerDeferredResult; innerDeferredResult = new Clipperz.Async.Deferred("Clipperz.Async.deferredFilter <inner - " + anIndex + ">", {trace:false}); innerDeferredResult.addCallback(aFunction, anObject); innerDeferredResult.addCallback(function (aFilterResult) { if (aFilterResult) { aResult.push(anObject); }; }); innerDeferredResult.addBoth(MochiKit.Async.succeed, aResult); innerDeferredResult.callback(); return innerDeferredResult; }, aFunction, someObjects[i], i); } deferredResult.callback([]); return deferredResult; }, 'forEach': function (aFunction) { return MochiKit.Base.partial(function (aFunction, anIterable) { MochiKit.Iter.forEach(anIterable, aFunction); }, aFunction); }, //========================================================================= 'or': function (someValues) { return Clipperz.Async.callbacks("Clipperz.Async.or", [ MochiKit.Base.values, MochiKit.Base.flattenArguments, -//function (aValue) { console.log("Record.hasAnyCleanTextData - flatten", aValue); return aValue; }, +//function (aValue) { Clipperz.log("Record.hasAnyCleanTextData - flatten", aValue); return aValue; }, function(someInnerValues) { return MochiKit.Iter.some(someInnerValues, MochiKit.Base.operator.identity); } ], {trace:false}, someValues); }, //========================================================================= 'clearResult': function () {}, //========================================================================= __syntaxFix__: "syntax fix" }); //############################################################################# CLIPPERZ_DEFERRED_LOGGING_ENABLED = true; CLIPPERZ_DEFERRED_TRACING_ENABLED = false; CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED = false; diff --git a/frontend/gamma/js/Clipperz/Base.js b/frontend/gamma/js/Clipperz/Base.js index 9d399d9..84b2172 100644 --- a/frontend/gamma/js/Clipperz/Base.js +++ b/frontend/gamma/js/Clipperz/Base.js @@ -1,533 +1,514 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Base) == 'undefined') { Clipperz.Base = {}; } Clipperz.Base.VERSION = "0.2"; Clipperz.Base.NAME = "Clipperz.Base"; MochiKit.Base.update(Clipperz.Base, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'itemgetter': function (aKeyPath) { // return MochiKit.Base.compose.apply(null, [MochiKit.Base.itemgetter('key3')]); return MochiKit.Base.compose.apply(null, MochiKit.Base.map( MochiKit.Base.itemgetter, MochiKit.Iter.reversed( aKeyPath.split('.') ) ) ); }, //------------------------------------------------------------------------- 'isUrl': function (aValue) { return (MochiKit.Base.urlRegExp.test(aValue)); }, 'isEmail': function (aValue) { return (MochiKit.Base.emailRegExp.test(aValue)); }, //------------------------------------------------------------------------- 'caseInsensitiveCompare': function (a, b) { return MochiKit.Base.compare(a.toLowerCase(), b.toLowerCase()); }, 'reverseComparator': function (aComparator) { return MochiKit.Base.compose(function(aResult) { return -aResult; }, aComparator); }, 'caseInsensitiveKeyComparator': function (aKey) { return function (a, b) { return MochiKit.Base.compare(a[aKey].toLowerCase(), b[aKey].toLowerCase()); } }, //------------------------------------------------------------------------- /* 'dependsOn': function(module, deps) { if (!(module in Clipperz)) { MochiKit[module] = {}; } if (typeof(dojo) != 'undefined') { dojo.provide('Clipperz.' + module); } for (var i = 0; i < deps.length; i++) { if (typeof(dojo) != 'undefined') { dojo.require('Clipperz.' + deps[i]); } if (typeof(JSAN) != 'undefined') { JSAN.use('Clipperz.' + deps[i], []); } if (!(deps[i] in Clipperz)) { throw 'Clipperz.' + module + ' depends on Clipperz.' + deps[i] + '!' } } }, */ //------------------------------------------------------------------------- 'trim': function (aValue) { return aValue.replace(/^\s+|\s+$/g, ""); }, //------------------------------------------------------------------------- 'stringToByteArray': function (aValue) { var result; var i, c; result = []; c = aValue.length; for (i=0; i<c; i++) { result[i] = aValue.charCodeAt(i); } return result; }, //......................................................................... 'byteArrayToString': function (anArrayOfBytes) { var result; var i, c; result = ""; c = anArrayOfBytes.length; for (i=0; i<c; i++) { result += String.fromCharCode(anArrayOfBytes[i]); } return result; }, //------------------------------------------------------------------------- 'getValueForKeyInFormContent': function (aFormContent, aKey) { return aFormContent[1][MochiKit.Base.find(aFormContent[0], aKey)]; }, //------------------------------------------------------------------------- 'indexOfObjectInArray': function(anObject, anArray) { var result; var i, c; result = -1; c = anArray.length; for (i=0; ((i<c) && (result < 0)); i++) { if (anArray[i] === anObject) { result = i; } } return result; }, //------------------------------------------------------------------------- 'removeObjectAtIndexFromArray': function(anIndex, anArray) { anArray.splice(anIndex, 1); }, //------------------------------------------------------------------------- 'removeObjectFromArray': function(anObject, anArray) { var objectIndex; objectIndex = Clipperz.Base.indexOfObjectInArray(anObject, anArray); if (objectIndex > -1) { Clipperz.Base.removeObjectAtIndexFromArray(objectIndex, anArray); } else { Clipperz.log("Trying to remove an object not present in the array"); throw Clipperz.Base.exception.ObjectNotFound; } }, 'removeFromArray': function(anArray, anObject) { return Clipperz.Base.removeObjectFromArray(anObject, anArray); }, //------------------------------------------------------------------------- 'splitStringAtFixedTokenSize': function(aString, aTokenSize) { var result; var stringToProcess; stringToProcess = aString; result = []; if (stringToProcess != null) { while (stringToProcess.length > aTokenSize) { result.push(stringToProcess.substring(0, aTokenSize)); stringToProcess = stringToProcess.substring(aTokenSize); } result.push(stringToProcess); } return result; }, //------------------------------------------------------------------------- 'objectType': function(anObject) { var result; if (anObject == null) { result = null; } else { result = typeof(anObject); if (result == "object") { if (anObject instanceof Array) { result = 'array' } else if (anObject.constructor == Boolean) { result = 'boolean' } else if (anObject instanceof Date) { result = 'date' } else if (anObject instanceof Error) { result = 'error' } else if (anObject instanceof Function) { result = 'function' } else if (anObject.constructor == Number) { result = 'number' } else if (anObject.constructor == String) { result = 'string' } else if (anObject instanceof Object) { result = 'object' } else { throw Clipperz.Base.exception.UnknownType; } } } return result; }, //------------------------------------------------------------------------- 'escapeHTML': function(aValue) { var result; result = aValue; result = result.replace(/</g, "<"); result = result.replace(/>/g, ">"); return result; }, //------------------------------------------------------------------------- 'deepClone': function(anObject) { var result; result = Clipperz.Base.evalJSON(Clipperz.Base.serializeJSON(anObject)); return result; }, //------------------------------------------------------------------------- // 'deepCompare': function (aObject, bObject) { // return (Clipperz.Base.serializeJSON(aObject) == Clipperz.Base.serializeJSON(bObject)); // }, //------------------------------------------------------------------------- 'evalJSON': function(aString) { return JSON.parse(aString); }, 'serializeJSON': function(anObject) { return JSON.stringify(anObject); }, 'formatJSON': function (anObject, sIndent) { var realTypeOf = function (v) { if (typeof(v) == "object") { if (v === null) return "null"; if (v.constructor == (new Array).constructor) return "array"; if (v.constructor == (new Date).constructor) return "date"; if (v.constructor == (new RegExp).constructor) return "regex"; return "object"; } return typeof(v); }; // function FormatJSON(oData, sIndent) { if (arguments.length < 2) { var sIndent = ""; } // var sIndentStyle = " "; var sIndentStyle = " "; var sDataType = realTypeOf(anObject); // open object if (sDataType == "array") { if (anObject.length == 0) { return "[]"; } var sHTML = "["; } else if (sDataType == "object") { var sHTML = "{"; } else { return "{}"; } // } else { // var iCount = 0; // $.each(anObject, function() { // iCount++; // return; // }); // if (iCount == 0) { // object is empty // return "{}"; // } // var sHTML = "{"; // } // loop through items var iCount = 0; // $.each(anObject, function(sKey, vValue) { MochiKit.Iter.forEach(MochiKit.Base.keys(anObject), function(sKey) { var vValue = anObject[sKey]; if (iCount > 0) { sHTML += ","; } if (sDataType == "array") { sHTML += ("\n" + sIndent + sIndentStyle); } else { sHTML += ("\n" + sIndent + sIndentStyle + "\"" + sKey + "\"" + ": "); } // display relevant data type switch (realTypeOf(vValue)) { case "array": case "object": sHTML += Clipperz.Base.formatJSON(vValue, (sIndent + sIndentStyle)); break; case "boolean": case "number": sHTML += vValue.toString(); break; case "null": sHTML += "null"; break; case "string": sHTML += ("\"" + vValue + "\""); break; default: sHTML += ("TYPEOF: " + typeof(vValue)); } // loop iCount++; }); // close object if (sDataType == "array") { sHTML += ("\n" + sIndent + "]"); } else { sHTML += ("\n" + sIndent + "}"); } // return return sHTML; }, //------------------------------------------------------------------------- 'mergeItems': function (anArrayOfValues) { var result; var i, c; result = {}; c = anArrayOfValues.length; for (i=0; i<c; i++) { result[anArrayOfValues[i][0]] = anArrayOfValues[i][1]; } return result; }, //------------------------------------------------------------------------- 'map': function (fn, lstObj/*, lst... */) { var result; if (MochiKit.Base.isArrayLike(lstObj)) { result = MochiKit.Base.map.apply(this, arguments); } else { var keys; var values; var computedValues; keys = MochiKit.Base.keys(lstObj); values = MochiKit.Base.values(lstObj); computedValues = MochiKit.Base.map(fn, values); result = Clipperz.Base.mergeItems(MochiKit.Base.zip(keys, computedValues)); } return result; }, //------------------------------------------------------------------------- 'sanitizeString': function(aValue) { var result; if (Clipperz.Base.objectType(aValue) == 'string') { result = aValue; result = result.replace(/</img,"<"); result = result.replace(/>/img,">"); } else { result = aValue; } return result; }, //------------------------------------------------------------------------- 'module': function(aValue) { // aValue = 'Clipperz.PM.Compact' // // if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } // if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } // if (typeof(Clipperz.PM.UI.Common.Components) == 'undefined') { Clipperz.PM.UI.Common.Components = {}; } -//console.log(">>> module: " + aValue); var currentScope; var pathElements; var i,c; currentScope = window; pathElements = aValue.split('.'); c = pathElements.length; for (i=0; i<c; i++) { -//console.log("--- current path element: " + pathElements[i]); -//console.log("--- current scope", currentScope); if (typeof(currentScope[pathElements[i]]) == 'undefined') { currentScope[pathElements[i]] = {}; } currentScope = currentScope[pathElements[i]]; } }, //------------------------------------------------------------------------- 'exception': { 'AbstractMethod': new MochiKit.Base.NamedError("Clipperz.Base.exception.AbstractMethod"), 'UnknownType': new MochiKit.Base.NamedError("Clipperz.Base.exception.UnknownType"), 'VulnerabilityIssue': new MochiKit.Base.NamedError("Clipperz.Base.exception.VulnerabilityIssue"), 'MandatoryParameter': new MochiKit.Base.NamedError("Clipperz.Base.exception.MandatoryParameter"), 'ObjectNotFound': new MochiKit.Base.NamedError("Clipperz.Base.exception.ObjectNotFound"), 'raise': function (aName) { throw Clipperz.Base.exception[aName]; } }, //------------------------------------------------------------------------- 'extend': YAHOO.extendX, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); // Original regExp courtesy of John Gruber: http://daringfireball.net/2009/11/liberal_regex_for_matching_urls // Updated to match Clipperz usage pattern. //MochiKit.Base.urlRegExp = new RegExp(/\b(([\w-]+:\/\/?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|\/)))/); MochiKit.Base.urlRegExp = new RegExp(/^((([\w-]+:\/\/?)|(www\.))[^\s()<>]+((?:\([\w\d]+\)|([^[:punct:]\s]|\/)))?)/); // RegExp found here: http://www.tipsntracks.com/117/validate-an-email-address-using-regular-expressions.html MochiKit.Base.emailRegExp = new RegExp(/^([a-zA-Z0-9_\-\.]+)@(([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3}))|(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|25[0-5]|2[0-4]\d))$/); MochiKit.Base.registerComparator('Object dummy comparator', function(a, b) { return ((a.constructor == Object) && (b.constructor == Object)); }, function(a, b) { var result; var aKeys; var bKeys; -//MochiKit.Logging.logDebug(">>> comparator"); -//MochiKit.Logging.logDebug("- a: " + Clipperz.Base.serializeJSON(a)); -//MochiKit.Logging.logDebug("- b: " + Clipperz.Base.serializeJSON(a)); aKeys = MochiKit.Base.keys(a).sort(); bKeys = MochiKit.Base.keys(b).sort(); - result = MochiKit.Base.compare(aKeys, bKeys); -//if (result != 0) { -// MochiKit.Logging.logDebug("- comparator 'keys':"); -// MochiKit.Logging.logDebug("- comparator aKeys: " + Clipperz.Base.serializeJSON(aKeys)); -// MochiKit.Logging.logDebug("- comparator bKeys: " + Clipperz.Base.serializeJSON(bKeys)); -//} + if (result == 0) { var i, c; c = aKeys.length; for (i=0; (i<c) && (result == 0); i++) { result = MochiKit.Base.compare(a[aKeys[i]], b[bKeys[i]]); -//if (result != 0) { -// MochiKit.Logging.logDebug("- comparator 'values':"); -// MochiKit.Logging.logDebug("- comparator a[aKeys[i]]: " + Clipperz.Base.serializeJSON(a[aKeys[i]])); -// MochiKit.Logging.logDebug("- comparator b[bKeys[i]]: " + Clipperz.Base.serializeJSON(b[bKeys[i]])); -//} } } -//MochiKit.Logging.logDebug("<<< comparator - result: " + result); return result; }, true ); diff --git a/frontend/gamma/js/Clipperz/ByteArray.js b/frontend/gamma/js/Clipperz/ByteArray.js index ae586e7..22c7c6e 100644 --- a/frontend/gamma/js/Clipperz/ByteArray.js +++ b/frontend/gamma/js/Clipperz/ByteArray.js @@ -1,1498 +1,1459 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } //============================================================================= Clipperz.ByteArray_abstract = function(args) { return this; } Clipperz.ByteArray_abstract.prototype = MochiKit.Base.update(null, { //------------------------------------------------------------------------- 'toString': function() { return "Clipperz.ByteArray_abstract"; }, //------------------------------------------------------------------------- 'equals': function(aValue) { return (this.compare(aValue) == 0); }, //------------------------------------------------------------------------- 'compare': function(aValue) { var result; var i; result = MochiKit.Base.compare(this.length(), aValue.length()); i = this.length(); while ((result == 0) && (i>0)) { i--; result = MochiKit.Base.compare(this.byteAtIndex(i), aValue.byteAtIndex(i)); } return result; }, //------------------------------------------------------------------------- 'clone': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'newInstance': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'reset': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'length': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'checkByteValue': function(aValue) { -//Clipperz.log("aValue", aValue.toString(16)); -//Clipperz.log("(aValue & 0xff)", (aValue & 0xff).toString(16)); - if ((aValue & 0xff) != aValue) { - MochiKit.Logging.logError("Clipperz.ByteArray.appendByte: the provided value (0x" + aValue.toString(16) + ") is not a byte value."); + Clipperz.logError("Clipperz.ByteArray.appendByte: the provided value (0x" + aValue.toString(16) + ") is not a byte value."); throw Clipperz.ByteArray.exception.InvalidValue; } }, //------------------------------------------------------------------------- 'xorMergeWithBlock': function(aBlock, anAllignment, paddingMode) { var result; var a, b; var aLength; var bLength; var i, c; if (this.length() > aBlock.length()) { a = this; b = aBlock; } else { a = aBlock; b = this; } aLength = a.length(); bLength = b.length(); if (aLength != bLength) { if (paddingMode == 'truncate') { if (anAllignment == 'left') { a = a.split(0, bLength); } else { a = a.split(aLength - bLength); } } else { var ii, cc; var padding; // padding = new Clipperz.ByteArray(); padding = this.newInstance(); cc = aLength - bLength; for (ii=0; ii<cc; ii++) { padding.appendByte(0); } if (anAllignment == 'left') { b = b.appendBlock(padding); } else { b = padding.appendBlock(b); } } } - -// result = new Clipperz.ByteArray(); result = this.newInstance(); c = a.length(); for (i=0; i<c; i++) { result.appendByte(a.byteAtIndex(i) ^ b.byteAtIndex(i)); } return result; }, //------------------------------------------------------------------------- -/* - 'shiftLeft': function(aNumberOfBitsToShift) { - var result; - - result = this.clone(); // ??????????? - - return result; - }, -*/ - //------------------------------------------------------------------------- 'appendBlock': function(aBlock) { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'appendByte': function(aValue) { throw Clipperz.Base.exception.AbstractMethod; }, 'appendBytes': function(args) { var values; var i,c; if (args.constructor == Array) { values = args; } else { values = arguments; } c = values.length; for (i=0; i<c; i++) { this.appendByte(values[i]); } return this; }, //------------------------------------------------------------------------- 'appendWord': function(aValue, isLittleEndian) { var result; var processAsLittleEndian; processAsLittleEndian = isLittleEndian === true ? true : false; if (processAsLittleEndian) { result = this.appendBytes( (aValue) & 0xff, (aValue >> 8) & 0xff, (aValue >> 16) & 0xff, (aValue >> 24) & 0xff ); // little endian } else { result = this.appendBytes( (aValue >> 24) & 0xff, (aValue >> 16) & 0xff, (aValue >> 8) & 0xff, (aValue) & 0xff ); // big endian - DEFAULT } return result; }, 'appendWords': function(args) { var values; var i,c; if (args.constructor == Array) { values = args; } else { values = arguments; } c = values.length; for (i=0; i<c; i++) { this.appendWord(values[i], false); } return this; }, //------------------------------------------------------------------------- 'appendBigEndianWords': function(args) { var values; var i,c; if (args.constructor == Array) { values = args; } else { values = arguments; } c = values.length; for (i=0; i<c; i++) { this.appendWord(values[i], true); } return this; }, //------------------------------------------------------------------------- 'appendBinaryString': function (aBinaryString) { var i,c; c = aBinaryString.length; for (i=0; i<c; i++) { this.appendByte(aBinaryString.charCodeAt(i)); }; return this; }, //------------------------------------------------------------------------- 'byteAtIndex': function(anIndex) { throw Clipperz.Base.exception.AbstractMethod; }, 'setByteAtIndex': function(aValue, anIndex) { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'bitAtIndex': function(aBitPosition) { var result; var bytePosition; var bitPositionInSelectedByte; var selectedByte; var selectedByteMask; bytePosition = this.length() - Math.ceil((aBitPosition + 1)/ 8); bitPositionInSelectedByte = aBitPosition % 8; selectedByte = this.byteAtIndex(bytePosition); if (bitPositionInSelectedByte > 0) { selectedByteMask = (1 << bitPositionInSelectedByte); } else { selectedByteMask = 1; } result = selectedByte & selectedByteMask ? 1 : 0; -//console.log("aBitPosition: " + aBitPosition + ", length: " + this.length() + ", bytePosition: " + bytePosition + ", bitPositionInSelectedByte: " + bitPositionInSelectedByte + ", selectedByteMask: " + selectedByteMask); return result; }, //------------------------------------------------------------------------- 'bitBlockAtIndexWithSize': function(aBitPosition, aSize) { var result; var bitValue; var i,c; result = 0; c = aSize; for (i=0; i<c; i++) { bitValue = this.bitAtIndex(aBitPosition + i); result = result | bitValue << i; } return result; }, //------------------------------------------------------------------------- 'asString': function() { var result; var length; var i; -//var startTime = new Date(); - -//# result = ""; result = []; i = 0; length = this.length(); while (i < length) { var currentCharacter; var currentByte; var unicode; currentByte = this.byteAtIndex(i); if ((currentByte & 0x80) == 0x00 ) { // 0xxxxxxx unicode = currentByte; currentCharacter = String.fromCharCode(unicode); } else if ((currentByte & 0xe0) == 0xc0 ) { // 110xxxxx 10xxxxxx unicode = (currentByte & 0x1f) << 6; i++; currentByte = this.byteAtIndex(i); unicode = unicode | (currentByte & 0x3f); currentCharacter = String.fromCharCode(unicode); } else if ((currentByte & 0xf0) == 0xe0 ) { // 1110xxxx 10xxxxxx 10xxxxxx unicode = (currentByte & 0x0f) << (6+6); i++; currentByte = this.byteAtIndex(i); unicode = unicode | ((currentByte & 0x3f) << 6); i++; currentByte = this.byteAtIndex(i); unicode = unicode | (currentByte & 0x3f); currentCharacter = String.fromCharCode(unicode); } else { // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx unicode = (currentByte & 0x07) << (6+6+6); i++; currentByte = this.byteAtIndex(i); unicode = unicode | ((currentByte & 0x3f) << (6+6)); i++; currentByte = this.byteAtIndex(i); unicode = unicode | ((currentByte & 0x3f) << 6); i++; currentByte = this.byteAtIndex(i); unicode = unicode | (currentByte & 0x3f); currentCharacter = String.fromCharCode(unicode); } -// result += currentCharacter; result.push(currentCharacter); i++; } -//MochiKit.Logging.logDebug("[" + (new Date() - startTime) + "] ByteArray.asString"); - -// return result; return result.join(""); }, //------------------------------------------------------------------------- 'toHexString': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'base64map': "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 'base64mapIndex': "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(''), -// 'base64mapInvertedIndex': { -// 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, -// 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, -// 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25, 'a': 26, 'b': 27, 'c': 28, 'd': 29, -// 'e': 30, 'f': 31, 'g': 32, 'h': 33, 'i': 34, 'j': 35, 'k': 36, 'l': 37, 'm': 38, 'n': 39, -// 'o': 40, 'p': 41, 'q': 42, 'r': 43, 's': 44, 't': 45, 'u': 46, 'v': 47, 'w': 48, 'x': 49, -// 'y': 50, 'z': 51, '0': 52, '1': 53, '2': 54, '3': 55, '4': 56, '5': 57, '6': 58, '7': 59, -// '8': 60, '9': 61, '+': 62, '/': 63, -// "=": -1}, //------------------------------------------------------------------------- 'appendBase64String': function(aValue) { var i; var length; length = aValue.length; if ((length % 4) != 0) { - MochiKit.Logging.logError("the value passed to the 'ByteArray.setBase64Value' is not correct"); + Clipperz.logError("the value passed to the 'ByteArray.setBase64Value' is not correct"); throw Clipperz.ByteArray.exception.InvalidValue; } i = 0; while (i<length) { var value1, value2, value3, value4; var byte1, byte2, byte3; value1 = this.base64map.indexOf(aValue.charAt(i)); value2 = this.base64map.indexOf(aValue.charAt(i+1)); value3 = this.base64map.indexOf(aValue.charAt(i+2)); value4 = this.base64map.indexOf(aValue.charAt(i+3)); -// value1 = this.base64mapInvertedIndex[aValue.charAt(i)]; -// value2 = this.base64mapInvertedIndex[aValue.charAt(i+1)]; -// value3 = this.base64mapInvertedIndex[aValue.charAt(i+2)]; -// value4 = this.base64mapInvertedIndex[aValue.charAt(i+3)]; - byte1 = (value1 << 2) | ((value2 & 0x30) >> 4); if (value3 != -1) { byte2 = ((value2 & 0x0f) << 4) | ((value3 & 0x3c) >> 2); if (value4 != -1) { byte3 = ((value3 & 0x03) << 6) | (value4); } else { byte3 = null; } } else { byte2 = null; byte3 = null; } this.appendByte(byte1); this.appendByte(byte2); this.appendByte(byte3); i += 4; } return this; }, //------------------------------------------------------------------------- 'toBase64String': function() { var result; var length; var i; var byte1, byte2, byte3; var char1, char2, char3, char4; i = 0; length = this.length(); result = new Array(Math.ceil(length/3)); while (i < length) { byte1 = this.byteAtIndex(i); if ((i+2) < length) { byte2 = this.byteAtIndex(i+1); byte3 = this.byteAtIndex(i+2); } else if ((i+2) == length) { byte2 = this.byteAtIndex(i+1); byte3 = null; } else { byte2 = null; byte3 = null; } char1 = this.base64mapIndex[byte1 >> 2]; if (byte2 != null) { char2 = this.base64mapIndex[((byte1 & 0x03) << 4) | ((byte2 & 0xf0) >> 4)]; if (byte3 != null) { char3 = this.base64mapIndex[((byte2 & 0x0f) << 2) | ((byte3 & 0xc0) >> 6)]; char4 = this.base64mapIndex[(byte3 & 0x3f)]; } else { char3 = this.base64mapIndex[(byte2 & 0x0f) << 2]; char4 = "="; } } else { char2 = this.base64mapIndex[(byte1 & 0x03) << 4]; char3 = "="; char4 = "="; } result.push(char1 + char2 + char3 + char4); i += 3; } return result.join(""); }, //------------------------------------------------------------------------- 'base32map': "0123456789abcdefghjkmnpqrstvwxyz", 'base32mapIndex': "0123456789abcdefghjkmnpqrstvwxyz".split(''), //------------------------------------------------------------------------- 'appendBase32String': function(aValue) { var value; var i; var length; var value1, value2, value3, value4, value5, value6, value7, value8; var byte1, byte2, byte3, byte4, byte5; value = aValue.toLowerCase(); value = value.replace(/[\s\-]/g, ''); value = value.replace(/[0o]/g, '0'); value = value.replace(/[1il]/g, '1'); length = value.length; if ((length % 8) != 0) { - MochiKit.Logging.logError("the value passed to the 'ByteArray.setBase32Value' is not correct"); + Clipperz.logError("the value passed to the 'ByteArray.setBase32Value' is not correct"); throw Clipperz.ByteArray.exception.InvalidValue; } i = 0; while (i<length) { value1 = this.base32map.indexOf(value.charAt(i)); value2 = this.base32map.indexOf(value.charAt(i+1)); value3 = this.base32map.indexOf(value.charAt(i+2)); value4 = this.base32map.indexOf(value.charAt(i+3)); value5 = this.base32map.indexOf(value.charAt(i+4)); value6 = this.base32map.indexOf(value.charAt(i+5)); value7 = this.base32map.indexOf(value.charAt(i+6)); value8 = this.base32map.indexOf(value.charAt(i+7)); byte1 = byte2 = byte3 = byte4 = byte5 = null; byte1 = (value1 << 3) | ((value2 & 0x1c) >> 2); if (value3 != -1) { byte2 = ((value2 & 0x03) << 6) | (value3 << 1) | ((value4 & 0x10) >> 4); if (value5 != -1) { byte3 = ((value4 & 0x0f) << 4) | ((value5 & 0x1e) >> 1); if (value6 != -1) { byte4 = ((value5 & 0x01) << 7) | (value6 << 2) | ((value7 & 0x18) >> 3); if (value8 != -1) { byte5 = ((value7 & 0x07) << 5) | (value8); } } } } this.appendByte(byte1); this.appendByte(byte2); this.appendByte(byte3); this.appendByte(byte4); this.appendByte(byte5); i += 8; } return this; }, //------------------------------------------------------------------------- 'toBase32String': function() { var result; var length; var i; var byte1, byte2, byte3, byte4, byte5; var char1, char2, char3, char4, char5, char6, char7, char8; i = 0; length = this.length(); result = new Array(Math.ceil(length/5)); while (i < length) { byte1 = this.byteAtIndex(i); if ((i+4) < length) { byte2 = this.byteAtIndex(i+1); byte3 = this.byteAtIndex(i+2); byte4 = this.byteAtIndex(i+3); byte5 = this.byteAtIndex(i+4); } else if ((i+4) == length) { byte2 = this.byteAtIndex(i+1); byte3 = this.byteAtIndex(i+2); byte4 = this.byteAtIndex(i+3); byte5 = null; } else if ((i+3) == length) { byte2 = this.byteAtIndex(i+1); byte3 = this.byteAtIndex(i+2); byte4 = null; byte5 = null; } else if ((i+2) == length) { byte2 = this.byteAtIndex(i+1); byte3 = null; byte4 = null; byte5 = null; } else { byte2 = null; byte3 = null; byte4 = null; byte5 = null; } char1 = this.base32mapIndex[byte1 >> 3]; char2 = char3 = char4 = char5 = char6 = char7 = char8 = "="; if (byte2 != null) { char2 = this.base32mapIndex[((byte1 & 0x07) << 2) | ((byte2 & 0xc0) >> 6)]; char3 = this.base32mapIndex[((byte2 & 0x3e) >> 1)]; if (byte3 != null) { char4 = this.base32mapIndex[((byte2 & 0x01) << 4) | ((byte3 & 0xf0) >> 4)]; if (byte4 != null) { char5 = this.base32mapIndex[((byte3 & 0x0f) << 1) | ((byte4 & 0x80) >> 7)]; char6 = this.base32mapIndex[(byte4 & 0x7c) >> 2]; if (byte5 != null) { char7 = this.base32mapIndex[((byte4 & 0x03) << 3) | ((byte5 & 0xe0) >> 5)]; char8 = this.base32mapIndex[(byte5 & 0x1f)]; } else { char7 = this.base32mapIndex[(byte4 & 0x03) << 3]; } } else { char5 = this.base32mapIndex[(byte3 & 0x0f) << 1]; } } else { char4 = this.base32mapIndex[(byte2 & 0x01) << 4]; } } else { char2 = this.base32mapIndex[(byte1 & 0x07) << 2]; } result.push(char1 + char2 + char3 + char4 + char5 + char6 + char7 + char8); i += 5; } return result.join(""); }, //------------------------------------------------------------------------- 'toBinaryString': function () { var i, c; var result; result = ''; c = this.length(); for (i=0; i<c; i++) { result += String.fromCharCode(this.byteAtIndex(i)); } return result; }, //------------------------------------------------------------------------- 'split': function(aStartingIndex, anEndingIndex) { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'increment': function() { var i; var done; done = false; i = this.length() - 1; while ((i>=0) && (done == false)) { var currentByteValue; currentByteValue = this.byteAtIndex(i); if (currentByteValue == 0xff) { this.setByteAtIndex(0, i); if (i>= 0) { i --; } else { done = true; } } else { this.setByteAtIndex(currentByteValue + 1, i); done = true; } } }, //------------------------------------------------------------------------- 'arrayValues': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //============================================================================= // // Clipperz.ByteArray_hex // //============================================================================= /* Clipperz.ByteArray_hex = function (args) { this._value = ""; if (typeof(args) != 'undefined') { if (args.constructor == Array) { this.appendBytes(args); } else if (args.constructor == String) { if (args.indexOf("0x") == 0) { var value; value = args.substring(2).toLowerCase(); if (/[0123456789abcdef]* /.test(value)) { the space in the regexp shoud be removed if the code is activate if ((value.length % 2) == 0) { this._value = value; } else { this._value = "0" + value; } } else { -MochiKit.Logging.logError("Clipperz.ByteArray should be inizialized with an hex string."); +Clipperz.logError("Clipperz.ByteArray should be inizialized with an hex string."); throw Clipperz.ByteArray.exception.InvalidValue; } } else { var value; var i,c; c = args.length; value = new Array(c); for (i=0; i<c; i++) { value.push(Clipperz.ByteArray.unicodeToUtf8HexString(args.charCodeAt(i))); } this._value = value.join(""); } } else { this.appendBytes(MochiKit.Base.extend(null, arguments)); } } return this; } Clipperz.ByteArray_hex.prototype = MochiKit.Base.update(new Clipperz.ByteArray_abstract(), { //------------------------------------------------------------------------- 'toString': function() { return "Clipperz.ByteArray_hex"; }, //------------------------------------------------------------------------- 'clone': function() { var result; result = this.newInstance(); result._value = this._value; return result; }, //------------------------------------------------------------------------- 'newInstance': function() { return new Clipperz.ByteArray_hex(); }, //------------------------------------------------------------------------- 'reset': function() { this._value = ""; }, //------------------------------------------------------------------------- 'length': function() { return (this._value.length / 2); }, //------------------------------------------------------------------------- 'appendBlock': function(aBlock) { this._value = this._value += aBlock.toHexString().substring(2); return this; }, //------------------------------------------------------------------------- 'appendByte': function(aValue) { if (aValue != null) { this.checkByteValue(aValue); this._value += Clipperz.ByteArray.byteToHex(aValue); } return this; }, //------------------------------------------------------------------------- 'byteAtIndex': function(anIndex) { return parseInt(this._value.substr(anIndex*2, 2), 16); }, 'setByteAtIndex': function(aValue, anIndex) { var missingBytes; this.checkByteValue(aValue); missingBytes = anIndex - this.length(); if (missingBytes < 0) { var currentValue; var firstCutIndex; var secondCutIndex; firstCutIndex = anIndex * 2; secondCutIndex = firstCutIndex + 2; currentValue = this._value; this._value = currentValue.substring(0, firstCutIndex) + Clipperz.ByteArray.byteToHex(aValue) + currentValue.substring(secondCutIndex); } else if (missingBytes == 0) { this.appendByte(aValue); } else { var i,c; c = missingBytes; for (i=0; i<c; i++) { this.appendByte(0); } this.appendByte(aValue); } }, //------------------------------------------------------------------------- 'toHexString': function() { return "0x" + this._value; }, //------------------------------------------------------------------------- 'split': function(aStartingIndex, anEndingIndex) { var result; var startingIndex; var endingIndex; result = this.newInstance(); startingIndex = aStartingIndex * 2; if (typeof(anEndingIndex) != 'undefined') { endingIndex = anEndingIndex * 2; result._value = this._value.substring(startingIndex, endingIndex); } else { result._value = this._value.substring(startingIndex); } return result; }, //------------------------------------------------------------------------- 'arrayValues': function() { var result; var i,c; c = this.length(); result = new Array(c); for (i=0; i<c; i++) { result[i] = this.byteAtIndex(i); } return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); */ //============================================================================= // // Clipperz.ByteArray_array // //============================================================================= Clipperz.ByteArray_array = function (args) { if (typeof(args) != 'undefined') { if (args.constructor == Array) { this._value = args.slice(0); } else if (args.constructor == String) { var result; var value; var i, c; if (args.indexOf("0x") == 0) { value = args.substring(2).toLowerCase(); if (/[0123456789abcdef]*/.test(value)) { if ((value.length % 2) != 0) { value = "0" + value; } } else { -MochiKit.Logging.logError("Clipperz.ByteArray should be inizialized with an hex string."); + Clipperz.logError("Clipperz.ByteArray should be inizialized with an hex string."); throw Clipperz.ByteArray.exception.InvalidValue; } c = value.length / 2 result = new Array(c); for (i=0; i<c; i++) { result[i] = parseInt(value.substr(i*2, 2), 16); } } else { var unicode; result = []; c = args.length; for (i=0; i<c; i++) { // Clipperz.ByteArray.pushUtf8BytesOfUnicodeChar(result, args.charCodeAt(i)); unicode = args.charCodeAt(i); if (unicode <= 0x7f) { // 0x00000000 - 0x0000007f -> 0xxxxxxx result.push(unicode); // } else if ((unicode >= 0x80) && (unicode <= 0x7ff)) { // 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx } else if (unicode <= 0x7ff) { // 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx result.push((unicode >> 6) | 0xc0); result.push((unicode & 0x3F) | 0x80); // } else if ((unicode >= 0x0800) && (unicode <= 0xffff)) { // 0x00000800 - 0x0000ffff -> 1110xxxx 10xxxxxx 10xxxxxx } else if (unicode <= 0xffff) { // 0x00000800 - 0x0000ffff -> 1110xxxx 10xxxxxx 10xxxxxx result.push((unicode >> 12) | 0xe0); result.push(((unicode >> 6) & 0x3f) | 0x80); result.push((unicode & 0x3f) | 0x80); } else { // 0x00010000 - 0x001fffff -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx result.push((unicode >> 18) | 0xf0); result.push(((unicode >> 12) & 0x3f) | 0x80); result.push(((unicode >> 6) & 0x3f) | 0x80); result.push((unicode & 0x3f) | 0x80); } } } this._value = result; } else { this._value = []; this.appendBytes(MochiKit.Base.extend(null, arguments)); } } else { this._value = []; } return this; } Clipperz.ByteArray_array.prototype = MochiKit.Base.update(new Clipperz.ByteArray_abstract(), { //------------------------------------------------------------------------- 'toString': function() { return "Clipperz.ByteArray_array"; }, //------------------------------------------------------------------------- 'clone': function() { var result; result = this.newInstance(); result.appendBytes(this._value); return result; }, //------------------------------------------------------------------------- 'newInstance': function() { return new Clipperz.ByteArray_array(); }, //------------------------------------------------------------------------- 'reset': function() { this._value = []; }, //------------------------------------------------------------------------- 'length': function() { return (this._value.length); }, //------------------------------------------------------------------------- 'appendBlock': function(aBlock) { MochiKit.Base.extend(this._value, aBlock._value); return this; }, //------------------------------------------------------------------------- 'appendByte': function(aValue) { if (aValue != null) { this.checkByteValue(aValue); this._value.push(aValue); } return this; }, //------------------------------------------------------------------------- 'byteAtIndex': function(anIndex) { return this._value[anIndex]; }, 'setByteAtIndex': function(aValue, anIndex) { var missingBytes; this.checkByteValue(aValue); missingBytes = anIndex - this.length(); if (missingBytes < 0) { this._value[anIndex] = aValue; } else if (missingBytes == 0) { this._value.push(aValue); } else { var i,c; c = missingBytes; for (i=0; i<c; i++) { this._value.push(0); } this._value.push(aValue); } }, //------------------------------------------------------------------------- 'toHexString': function() { var result; var i, c; result = "0x"; c = this.length(); for (i=0; i<c; i++) { result += Clipperz.ByteArray.byteToHex(this._value[i]); } return result; }, //------------------------------------------------------------------------- 'split': function(aStartingIndex, anEndingIndex) { var result; result = this.newInstance(); result._value = this._value.slice(aStartingIndex, anEndingIndex ? anEndingIndex : this.length()); return result; }, //------------------------------------------------------------------------- 'arrayValues': function() { return this._value.slice(0); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //============================================================================= // // Clipperz.ByteArray_string // //============================================================================= /* Clipperz.ByteArray_string = function (args) { this._value = ""; if (typeof(args) != 'undefined') { if (args.constructor == Array) { this.appendBytes(args); } else if (args.constructor == String) { var result; var value; var i, c; if (args.indexOf("0x") == 0) { value = args.substring(2).toLowerCase(); if (/[0123456789abcdef]* /.test(value)) { the space in the regexp shoud be removed if the code is activated if ((value.length % 2) != 0) { value = "0" + value; } } else { -MochiKit.Logging.logError("Clipperz.ByteArray should be inizialized with an hex string."); +Clipperz.logError("Clipperz.ByteArray should be inizialized with an hex string."); throw Clipperz.ByteArray.exception.InvalidValue; } } else { value = ""; c = args.length; for (i=0; i<c; i++) { value += Clipperz.ByteArray.unicodeToUtf8HexString(args.charCodeAt(i)); } } c = value.length / 2 for (i=0; i<c; i++) { this.appendByte(parseInt(value.substr(i*2, 2), 16)); } } else { this.appendBytes(MochiKit.Base.extend(null, arguments)); } } return this; } Clipperz.ByteArray_string.prototype = MochiKit.Base.update(new Clipperz.ByteArray_abstract(), { //------------------------------------------------------------------------- 'toString': function() { return "Clipperz.ByteArray_string"; }, //------------------------------------------------------------------------- 'clone': function() { var result; result = this.newInstance(); result._value = this._value; return result; }, //------------------------------------------------------------------------- 'newInstance': function() { return new Clipperz.ByteArray_string(); }, //------------------------------------------------------------------------- 'reset': function() { this._value = ""; }, //------------------------------------------------------------------------- 'length': function() { return (this._value.length); }, //------------------------------------------------------------------------- 'appendBlock': function(aBlock) { this._value += aBlock._value; return this; }, //------------------------------------------------------------------------- 'appendByte': function(aValue) { if (aValue != null) { this.checkByteValue(aValue); this._value += String.fromCharCode(aValue); } return this; }, //------------------------------------------------------------------------- 'byteAtIndex': function(anIndex) { return this._value.charCodeAt(anIndex); }, 'setByteAtIndex': function(aValue, anIndex) { var missingBytes; this.checkByteValue(aValue); missingBytes = anIndex - this.length(); if (missingBytes < 0) { this._value = this._value.substring(0, anIndex) + String.fromCharCode(aValue) + this._value.substring(anIndex + 1); } else if (missingBytes == 0) { this.appendByte(aValue); } else { var i,c; c = missingBytes; for (i=0; i<c; i++) { this.appendByte(0); } this.appendByte(aValue); } }, //------------------------------------------------------------------------- 'toHexString': function() { var result; var i, c; result = "0x"; c = this.length(); for (i=0; i<c; i++) { result += Clipperz.ByteArray.byteToHex(this.byteAtIndex(i)); } return result; }, //------------------------------------------------------------------------- 'split': function(aStartingIndex, anEndingIndex) { var result; result = this.newInstance(); result._value = this._value.substring(aStartingIndex, anEndingIndex ? anEndingIndex : this.length()); return result; }, //------------------------------------------------------------------------- 'arrayValues': function() { var result; var i,c; c = this.length(); result = new Array(c); for (i=0; i<c; i++) { result[i] = this.byteAtIndex(i); } return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); */ //============================================================================= // // Clipperz.ByteArray // //============================================================================= Clipperz.ByteArray = Clipperz.ByteArray_array; //Clipperz.ByteArray = Clipperz.ByteArray_string; //Clipperz.ByteArray = Clipperz.ByteArray_hex; //############################################################################# Clipperz.ByteArray.byteToHex = function(aByte) { return ((aByte < 16) ? "0" : "") + aByte.toString(16); } Clipperz.ByteArray.unicodeToUtf8HexString = function(aUnicode) { var result; var self; self = Clipperz.ByteArray; if (aUnicode <= 0x7f) { // 0x00000000 - 0x0000007f -> 0xxxxxxx result = self.byteToHex(aUnicode); // } else if ((aUnicode >= 0x80) && (aUnicode <= 0x7ff)) { // 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx } else if (aUnicode <= 0x7ff) { // 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx result = self.byteToHex((aUnicode >> 6) | 0xc0); result += self.byteToHex((aUnicode & 0x3F) | 0x80); // } else if ((aUnicode >= 0x0800) && (aUnicode <= 0xffff)) { // 0x00000800 - 0x0000ffff -> 1110xxxx 10xxxxxx 10xxxxxx } else if (aUnicode <= 0xffff) { // 0x00000800 - 0x0000ffff -> 1110xxxx 10xxxxxx 10xxxxxx result = self.byteToHex((aUnicode >> 12) | 0xe0); result += self.byteToHex(((aUnicode >> 6) & 0x3f) | 0x80); result += self.byteToHex((aUnicode & 0x3f) | 0x80); } else { // 0x00010000 - 0x001fffff -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx result = self.byteToHex((aUnicode >> 18) | 0xf0); result += self.byteToHex(((aUnicode >> 12) & 0x3f) | 0x80); result += self.byteToHex(((aUnicode >> 6) & 0x3f) | 0x80); result += self.byteToHex((aUnicode & 0x3f) | 0x80); } return result; } Clipperz.ByteArray.pushUtf8BytesOfUnicodeChar = function(anArray, aUnicode) { var self; self = Clipperz.ByteArray; if (aUnicode <= 0x7f) { // 0x00000000 - 0x0000007f -> 0xxxxxxx anArray.push(aUnicode); // } else if ((aUnicode >= 0x80) && (aUnicode <= 0x7ff)) { // 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx } else if (aUnicode <= 0x7ff) { // 0x00000080 - 0x000007ff -> 110xxxxx 10xxxxxx anArray.push((aUnicode >> 6) | 0xc0); anArray.push((aUnicode & 0x3F) | 0x80); // } else if ((aUnicode >= 0x0800) && (aUnicode <= 0xffff)) { // 0x00000800 - 0x0000ffff -> 1110xxxx 10xxxxxx 10xxxxxx } else if (aUnicode <= 0xffff) { // 0x00000800 - 0x0000ffff -> 1110xxxx 10xxxxxx 10xxxxxx anArray.push((aUnicode >> 12) | 0xe0); anArray.push(((aUnicode >> 6) & 0x3f) | 0x80); anArray.push((aUnicode & 0x3f) | 0x80); } else { // 0x00010000 - 0x001fffff -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx anArray.push((aUnicode >> 18) | 0xf0); anArray.push(((aUnicode >> 12) & 0x3f) | 0x80); anArray.push(((aUnicode >> 6) & 0x3f) | 0x80); anArray.push((aUnicode & 0x3f) | 0x80); } } Clipperz.ByteArray.prefixMatchingBits = function (aValue, bValue) { var result; var i,c; result = 0; c = Math.min(aValue.length(), bValue.length()); i = 0; while (i<c && (aValue.byteAtIndex(i) == bValue.byteAtIndex(i))) { result += 8; i++; } if (i<c) { var xorValue; xorValue = (aValue.byteAtIndex(i) ^ bValue.byteAtIndex(i)); if (xorValue >= 128) { result += 0; } else if (xorValue >= 64) { result += 1; } else if (xorValue >= 32) { result += 2; } else if (xorValue >= 16) { result += 3; } else if (xorValue >= 8) { result += 4; } else if (xorValue >= 4) { result += 5; } else if (xorValue >= 2) { result += 6; } else if (xorValue >= 1) { result += 7; } } return result; }; Clipperz.ByteArray.exception = { InvalidValue: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue") }; //############################################################################# Clipperz.ByteArrayIterator = function(args) { args = args || {}; this._byteArray = args.byteArray; this._blockSize = args.blockSize; this._finalPadding = args.finalPadding || false; this._currentPosition = 0; return this; } Clipperz.ByteArrayIterator.prototype = MochiKit.Base.update(null, { //------------------------------------------------------------------------- 'toString': function() { return "Clipperz.ByteArrayIterator"; }, //------------------------------------------------------------------------- 'blockSize': function() { var result; result = this._blockSize; return result; }, //------------------------------------------------------------------------- 'currentPosition': function() { var result; result = this._currentPosition; return result; }, //------------------------------------------------------------------------- 'byteArray': function() { var result; result = this._byteArray; return result; }, //------------------------------------------------------------------------- 'finalPadding': function() { var result; result = this._finalPadding; return result; }, //------------------------------------------------------------------------- 'nextBlock': function() { var result; var currentPosition; var byteArrayLength; currentPosition = this._currentPosition; byteArrayLength = this.byteArray().length(); if (currentPosition < byteArrayLength) { var i,c; c = this.blockSize(); result = new Array(c); for (i=0; i<c; i++) { if (currentPosition < byteArrayLength) { result[i] = this.byteArray().byteAtIndex(currentPosition); currentPosition++; } else if (this.finalPadding() == true) { result[i] = 0; } } this._currentPosition = currentPosition; } else { result = null; } return result; }, //------------------------------------------------------------------------- 'nextBlockArray': function() { var result; var nextBlock; nextBlock = this.nextBlock(); if (nextBlock != null) { result = new Clipperz.ByteArray(nextBlock); } else { result = null; } return result; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/CSVProcessor.js b/frontend/gamma/js/Clipperz/CSVProcessor.js index 0b18731..1288ed7 100644 --- a/frontend/gamma/js/Clipperz/CSVProcessor.js +++ b/frontend/gamma/js/Clipperz/CSVProcessor.js @@ -1,346 +1,344 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } Clipperz.CSVProcessor = function(args) { args = args || {}; // this._status = undefined; // this._error_input = undefined; // this._string = undefined; // this._fields = undefined; this._quoteChar = args['quoteChar'] || "\042"; this._eol = args['eol'] || ""; this._escapeChar = args['escapeChar'] || "\042"; this._separatorChar = args['separatorChar'] || ","; this._binary = args['binary'] || false; this._alwaysQuote = args['alwaysQuote'] || false; return this; } //============================================================================= Clipperz.CSVProcessor.prototype = MochiKit.Base.update(null, { //------------------------------------------------------------------------- 'quoteChar': function() { return this._quoteChar; }, //------------------------------------------------------------------------- 'eol': function() { return this._eol; }, //------------------------------------------------------------------------- 'escapeChar': function() { return this._escapeChar; }, //------------------------------------------------------------------------- 'separatorChar': function() { return this._separatorChar; }, 'setSeparatorChar': function(aValue) { this._separatorChar = aValue; }, //------------------------------------------------------------------------- 'binary': function() { return this._binary; }, //------------------------------------------------------------------------- 'alwaysQuote': function() { return this._alwaysQuote; }, //------------------------------------------------------------------------- /* 'parse': function(aValue) { var result; var lines; var parameter; -//MochiKit.Logging.logDebug(">>> CSVProcessor.parse"); +//Clipperz.logDebug(">>> CSVProcessor.parse"); result = []; lines = aValue.replace(/\r?\n/g, "\n").replace(/^\n* /g, "").replace(/\n$/g, "");; parameter = { line: lines } do { var fields; fields = this.parseLine(parameter); if (fields != null) { result.push(fields); } parameter.line = parameter.line.replace(/^\n* /g, "").replace(/\n$/g, ""); -//MochiKit.Logging.logDebug("line: '" + parameter.line + "'"); +//Clipperz.logDebug("line: '" + parameter.line + "'"); } while (parameter.line != ""); -//MochiKit.Logging.logDebug("--- CSVProcessor.parse - result: " + Clipperz.Base.serializeJSON(result)); -//MochiKit.Logging.logDebug("<<< CSVProcessor.parse"); +//Clipperz.logDebug("--- CSVProcessor.parse - result: " + Clipperz.Base.serializeJSON(result)); +//Clipperz.logDebug("<<< CSVProcessor.parse"); return result; }, */ //------------------------------------------------------------------------- 'deferredParse_core': function(aContext) { var deferredResult; if (aContext.line == "") { deferredResult = MochiKit.Async.succeed(aContext.result); } else { var fields; fields = this.parseLine(aContext); if (fields != null) { aContext.result.push(fields); } aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, ""); deferredResult = new Clipperz.Async.Deferred("CVSProcessor.deferredParse_core"); // deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); deferredResult.addCallback(MochiKit.Async.wait, 0.2); deferredResult.addMethod(this, 'deferredParse_core') deferredResult.callback(aContext); } return deferredResult; }, //......................................................................... 'deferredParse': function(aValue) { var deferredResult; var lines; var context; lines = aValue.replace(/\r?\n/g, "\n").replace(/^\n*/g, "").replace(/\n$/g, ""); context = { line: lines, size: lines.length, result: [] } deferredResult = new Clipperz.Async.Deferred("CSVProcessor.deferredParse"); deferredResult.addMethod(this, 'deferredParse_core'); deferredResult.callback(context); return deferredResult; }, //------------------------------------------------------------------------- 'parseLine': function(aParameter) { var result; var palatable; var line; var processedField; result = []; do { processedField = this.parseField(aParameter); if (processedField != null) { result.push(processedField) }; } while (processedField != null); return result; }, //------------------------------------------------------------------------- 'parseField': function(aParameter) { var result; var inQuotes; var validRegExp; var singleQuoteBeginRegexp; var escapedQuoteBeginRegexp; var singleQuoteCommaEndRegexp; var singleQuoteNewLineEndRegexp; var commaBeginRegexp; var newlineRegexp; singleQuoteBeginRegexp = new RegExp("^" + '\\' + this.quoteChar()); escapedQuoteBeginRegexp = new RegExp("^" + '\\' + this.escapeChar() + '\\' + this.quoteChar()); singleQuoteCommaEndRegexp = new RegExp("^" + '\\' + this.quoteChar() + '\\' + this.separatorChar()); singleQuoteNewLineEndRegexp = new RegExp("^" + '\\' + this.quoteChar() + "\n"); commaBeginRegexp = new RegExp("^" + '\\' + this.separatorChar()); newlineRegexp = new RegExp("^\n"); inQuotes = false; -//MochiKit.Logging.logDebug("#################################### '" + aParameter.line + "'"); +//Clipperz.logDebug("#################################### '" + aParameter.line + "'"); if (aParameter.line == "") { if (aParameter.isThereAnEmptyFinalField == true) { aParameter.isThereAnEmptyFinalField = false; result = ""; } else { result = null; } } else { if (this.binary()) { validRegexp = /^./; // validRegexp = /^[^\\]/; } else { validRegexp = /^[\t\040-\176]/; } try { var done; done = false; result = ""; while (!done) { if (aParameter.line.length < 1) { -//MochiKit.Logging.logDebug("---> 1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); if (inQuotes == true) { -//MochiKit.Logging.logDebug("---> 1.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 1.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); throw new Error("CSV Parsing error; end of string, missing closing double-quote..."); } else { -//MochiKit.Logging.logDebug("---> 1.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 1.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); done = true; } } else if (escapedQuoteBeginRegexp.test(aParameter.line)) { -//MochiKit.Logging.logDebug("---> 2.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 2.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); result += this.quoteChar(); aParameter.line = aParameter.line.substr(2, aParameter.line.length - 1); -//MochiKit.Logging.logDebug("<--- 2.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("<--- 2.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); } else if (singleQuoteBeginRegexp.test(aParameter.line)) { -//MochiKit.Logging.logDebug("---> 3: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 3: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); if (inQuotes == true) { if (aParameter.line.length == 1) { -//MochiKit.Logging.logDebug("---> 3.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 3.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); aParameter.line = ''; done = true; } else if (singleQuoteCommaEndRegexp.test(aParameter.line)) { -//MochiKit.Logging.logDebug("---> 3.3: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 3.3: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); aParameter.line = aParameter.line.substr(2, aParameter.line.length - 1); done = true; -//MochiKit.Logging.logDebug("<--- 3.3: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("<--- 3.3: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); } else if (singleQuoteNewLineEndRegexp.test(aParameter.line)) { aParameter.line = aParameter.line.substr(1, aParameter.line.length - 1); done = true; } else { throw new Error("CSV Parsing error; double-quote, followed by undesirable character (bad character sequence)... " + aParameter.line); } } else { -//MochiKit.Logging.logDebug("---> 4: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 4: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); if (result == "") { -//MochiKit.Logging.logDebug("---> 4.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 4.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); inQuotes = true; aParameter.line = aParameter.line.substr(1, aParameter.line.length - 1); -//MochiKit.Logging.logDebug("<--- 4.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("<--- 4.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); } else { throw new Error("CSV Parsing error; double-quote, outside of double-quotes (bad character sequence)..."); } } } else if (commaBeginRegexp.test(aParameter.line)) { -//MochiKit.Logging.logDebug("---> 5: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 5: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); if (inQuotes) { -//MochiKit.Logging.logDebug("---> 5.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 5.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); result += aParameter.line.substr(0 ,1); aParameter.line = aParameter.line.substr(1, aParameter.line.length - 1); -//MochiKit.Logging.logDebug("<--- 5.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("<--- 5.1: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); } else { -//MochiKit.Logging.logDebug("---> 5.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 5.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); aParameter.line = aParameter.line.substr(1, aParameter.line.length - 1); if (newlineRegexp.test(aParameter.line) || aParameter.line == "") { -//MochiKit.Logging.logDebug("######"); +//Clipperz.logDebug("######"); aParameter.isThereAnEmptyFinalField = true; }; done = true; -//MochiKit.Logging.logDebug("<--- 5.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("<--- 5.2: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); } } else if (validRegexp.test(aParameter.line)) { -//MochiKit.Logging.logDebug("---> 6: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("---> 6: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); result += aParameter.line.substr(0, 1); aParameter.line = aParameter.line.substr(1, aParameter.line.length - 1); -//MochiKit.Logging.logDebug("<--- 6: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); +//Clipperz.logDebug("<--- 6: '" + aParameter.line.replace(/\n/g, "\\n") + "'"); } else if (newlineRegexp.test(aParameter.line)) { if (inQuotes == true) { result += aParameter.line.substr(0 ,1); aParameter.line = aParameter.line.substr(1, aParameter.line.length - 1); } else { if (result == "") { if (aParameter.isThereAnEmptyFinalField == true) { aParameter.isThereAnEmptyFinalField = false; } else { result = null; } } done = true; } } else { throw new Error("CSV Parsing error; an undesirable character... '" + aParameter.line.substr(0,1) + "'"); } } } catch(exception) { - MochiKit.Logging.logError(exception.message); + Clipperz.logError(exception.message); // result = null; throw exception; } } //if (result != null) { -// MochiKit.Logging.logDebug("<=== result: '" + result.replace(/\n/g, "\\n") + "'"); +// Clipperz.logDebug("<=== result: '" + result.replace(/\n/g, "\\n") + "'"); //} else { -// MochiKit.Logging.logDebug("<=== result: NULL"); +// Clipperz.logDebug("<=== result: NULL"); //} return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Crypto/AES.js b/frontend/gamma/js/Clipperz/Crypto/AES.js index c811f1c..cb56f11 100644 --- a/frontend/gamma/js/Clipperz/Crypto/AES.js +++ b/frontend/gamma/js/Clipperz/Crypto/AES.js @@ -1,866 +1,859 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.AES depends on Clipperz.ByteArray!"; } // Dependency commented to avoid a circular reference //try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.AES depends on Clipperz.Crypto.PRNG!"; //} if (typeof(Clipperz.Crypto.AES) == 'undefined') { Clipperz.Crypto.AES = {}; } //############################################################################# Clipperz.Crypto.AES.DeferredExecutionContext = function(args) { args = args || {}; this._key = args.key; this._message = args.message; this._result = args.message.clone(); this._nonce = args.nonce; this._messageLength = this._message.length(); this._messageArray = this._message.arrayValues(); this._resultArray = this._result.arrayValues(); this._nonceArray = this._nonce.arrayValues(); this._executionStep = 0; // this._elaborationChunkSize = 1024; // 4096; // 16384; // 4096; this._elaborationChunks = 10; this._pauseTime = 0.02; // 0.02 // 0.2; return this; } Clipperz.Crypto.AES.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { 'key': function() { return this._key; }, 'message': function() { return this._message; }, 'messageLength': function() { return this._messageLength; }, 'result': function() { return new Clipperz.ByteArray(this.resultArray()); }, 'nonce': function() { return this._nonce; }, 'messageArray': function() { return this._messageArray; }, 'resultArray': function() { return this._resultArray; }, 'nonceArray': function() { return this._nonceArray; }, 'elaborationChunkSize': function() { // return Clipperz.Crypto.AES.DeferredExecution.chunkSize; // return this._elaborationChunkSize; return (this._elaborationChunks * 1024); }, 'executionStep': function() { return this._executionStep; }, 'setExecutionStep': function(aValue) { this._executionStep = aValue; }, 'tuneExecutionParameters': function (anElapsedTime) { //var originalChunks = this._elaborationChunks; if (anElapsedTime > 0) { this._elaborationChunks = Math.round(this._elaborationChunks * ((anElapsedTime + 1000)/(anElapsedTime * 2))); } //Clipperz.log("tuneExecutionParameters - elapsedTime: " + anElapsedTime + /*originalChunks,*/ " chunks # " + this._elaborationChunks + " [" + this._executionStep + " / " + this._messageLength + "]"); }, 'pause': function(aValue) { // return MochiKit.Async.wait(Clipperz.Crypto.AES.DeferredExecution.pauseTime, aValue); return MochiKit.Async.wait(this._pauseTime, aValue); }, 'isDone': function () { -//console.log("isDone", this.executionStep(), this.messageLength()); return (this._executionStep >= this._messageLength); }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.AES.Key = function(args) { args = args || {}; this._key = args.key; this._keySize = args.keySize || this.key().length(); if (this.keySize() == 128/8) { this._b = 176; this._numberOfRounds = 10; } else if (this.keySize() == 256/8) { this._b = 240; this._numberOfRounds = 14; } else { - MochiKit.Logging.logError("AES unsupported key size: " + (this.keySize() * 8) + " bits"); + Clipperz.logError("AES unsupported key size: " + (this.keySize() * 8) + " bits"); throw Clipperz.Crypto.AES.exception.UnsupportedKeySize; } this._stretchedKey = null; return this; } Clipperz.Crypto.AES.Key.prototype = MochiKit.Base.update(null, { 'asString': function() { return "Clipperz.Crypto.AES.Key (" + this.key().toHexString() + ")"; }, //----------------------------------------------------------------------------- 'key': function() { return this._key; }, 'keySize': function() { return this._keySize; }, 'b': function() { return this._b; }, 'numberOfRounds': function() { return this._numberOfRounds; }, //========================================================================= 'keyScheduleCore': function(aWord, aRoundConstantsIndex) { var result; var sbox; sbox = Clipperz.Crypto.AES.sbox(); result = [ sbox[aWord[1]] ^ Clipperz.Crypto.AES.roundConstants()[aRoundConstantsIndex], sbox[aWord[2]], sbox[aWord[3]], sbox[aWord[0]] ]; return result; }, //----------------------------------------------------------------------------- 'xorWithPreviousStretchValues': function(aKey, aWord, aPreviousWordIndex) { var result; var i,c; result = []; c = 4; for (i=0; i<c; i++) { result[i] = aWord[i] ^ aKey.byteAtIndex(aPreviousWordIndex + i); } return result; }, //----------------------------------------------------------------------------- 'sboxShakeup': function(aWord) { var result; var sbox; var i,c; result = []; sbox = Clipperz.Crypto.AES.sbox(); c =4; for (i=0; i<c; i++) { result[i] = sbox[aWord[i]]; } return result; }, //----------------------------------------------------------------------------- 'stretchKey': function(aKey) { var currentWord; var keyLength; var previousStretchIndex; var i,c; keyLength = aKey.length(); previousStretchIndex = keyLength - this.keySize(); currentWord = [ aKey.byteAtIndex(keyLength - 4), aKey.byteAtIndex(keyLength - 3), aKey.byteAtIndex(keyLength - 2), aKey.byteAtIndex(keyLength - 1) ]; currentWord = this.keyScheduleCore(currentWord, keyLength / this.keySize()); if (this.keySize() == 256/8) { c = 8; } else if (this.keySize() == 128/8){ c = 4; } for (i=0; i<c; i++) { if (i == 4) { // fifth streatch word currentWord = this.sboxShakeup(currentWord); } currentWord = this.xorWithPreviousStretchValues(aKey, currentWord, previousStretchIndex + (i*4)); aKey.appendBytes(currentWord); } return aKey; }, //----------------------------------------------------------------------------- 'stretchedKey': function() { if (this._stretchedKey == null) { var stretchedKey; stretchedKey = this.key().clone(); while (stretchedKey.length() < this.keySize()) { stretchedKey.appendByte(0); } while (stretchedKey.length() < this.b()) { stretchedKey = this.stretchKey(stretchedKey); } this._stretchedKey = stretchedKey.split(0, this.b()); } return this._stretchedKey; }, //========================================================================= __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.AES.State = function(args) { args = args || {}; this._data = args.block; this._key = args.key; return this; } Clipperz.Crypto.AES.State.prototype = MochiKit.Base.update(null, { 'key': function() { return this._key; }, //----------------------------------------------------------------------------- 'data': function() { return this._data; }, 'setData': function(aValue) { this._data = aValue; }, //========================================================================= 'addRoundKey': function(aRoundNumber) { // each byte of the state is combined with the round key; each round key is derived from the cipher key using a key schedule. var data; var stretchedKey; var firstStretchedKeyIndex; var i,c; data = this.data(); stretchedKey = this.key().stretchedKey(); firstStretchedKeyIndex = aRoundNumber * (128/8); c = 128/8; for (i=0; i<c; i++) { data[i] = data[i] ^ stretchedKey.byteAtIndex(firstStretchedKeyIndex + i); } }, //----------------------------------------------------------------------------- 'subBytes': function() { // a non-linear substitution step where each byte is replaced with another according to a lookup table. var i,c; var data; var sbox; data = this.data(); sbox = Clipperz.Crypto.AES.sbox(); c = 16; for (i=0; i<c; i++) { data[i] = sbox[data[i]]; } }, //----------------------------------------------------------------------------- 'shiftRows': function() { // a transposition step where each row of the state is shifted cyclically a certain number of steps. var newValue; var data; var shiftMapping; var i,c; newValue = new Array(16); data = this.data(); shiftMapping = Clipperz.Crypto.AES.shiftRowMapping(); // [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]; c = 16; for (i=0; i<c; i++) { newValue[i] = data[shiftMapping[i]]; } for (i=0; i<c; i++) { data[i] = newValue[i]; } }, //----------------------------------------------------------------------------- /* 'mixColumnsWithValues': function(someValues) { var result; var a; var i,c; c = 4; result = []; a = []; for (i=0; i<c; i++) { a[i] = []; a[i][1] = someValues[i] if ((a[i][1] & 0x80) == 0x80) { a[i][2] = (a[i][1] << 1) ^ 0x11b; } else { a[i][2] = a[i][1] << 1; } a[i][3] = a[i][2] ^ a[i][1]; } for (i=0; i<c; i++) { var x; x = Clipperz.Crypto.AES.mixColumnsMatrix()[i]; result[i] = a[0][x[0]] ^ a[1][x[1]] ^ a[2][x[2]] ^ a[3][x[3]]; } return result; }, 'mixColumns': function() { // a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation. var data; var i, c; data = this.data(); c = 4; for(i=0; i<c; i++) { var blockIndex; var mixedValues; blockIndex = i * 4; mixedValues = this.mixColumnsWithValues([ data[blockIndex + 0], data[blockIndex + 1], data[blockIndex + 2], data[blockIndex + 3]]); data[blockIndex + 0] = mixedValues[0]; data[blockIndex + 1] = mixedValues[1]; data[blockIndex + 2] = mixedValues[2]; data[blockIndex + 3] = mixedValues[3]; } }, */ 'mixColumns': function() { // a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation. var data; var i, c; var a_1; var a_2; a_1 = new Array(4); a_2 = new Array(4); data = this.data(); c = 4; for(i=0; i<c; i++) { var blockIndex; var ii, cc; blockIndex = i * 4; cc = 4; for (ii=0; ii<cc; ii++) { var value; value = data[blockIndex + ii]; a_1[ii] = value; a_2[ii] = (value & 0x80) ? ((value << 1) ^ 0x011b) : (value << 1); } data[blockIndex + 0] = a_2[0] ^ a_1[1] ^ a_2[1] ^ a_1[2] ^ a_1[3]; data[blockIndex + 1] = a_1[0] ^ a_2[1] ^ a_1[2] ^ a_2[2] ^ a_1[3]; data[blockIndex + 2] = a_1[0] ^ a_1[1] ^ a_2[2] ^ a_1[3] ^ a_2[3]; data[blockIndex + 3] = a_1[0] ^ a_2[0] ^ a_1[1] ^ a_1[2] ^ a_2[3]; } }, //========================================================================= 'spinRound': function(aRoundNumber) { this.addRoundKey(aRoundNumber); this.subBytes(); this.shiftRows(); this.mixColumns(); }, 'spinLastRound': function() { this.addRoundKey(this.key().numberOfRounds() - 1); this.subBytes(); this.shiftRows(); this.addRoundKey(this.key().numberOfRounds()); }, //========================================================================= 'encrypt': function() { var i,c; c = this.key().numberOfRounds() - 1; for (i=0; i<c; i++) { this.spinRound(i); } this.spinLastRound(); }, //========================================================================= __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.AES.VERSION = "0.1"; Clipperz.Crypto.AES.NAME = "Clipperz.Crypto.AES"; MochiKit.Base.update(Clipperz.Crypto.AES, { // http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-AES.html // http://en.wikipedia.org/wiki/Advanced_Encryption_Standard // http://en.wikipedia.org/wiki/Rijndael_key_schedule // http://en.wikipedia.org/wiki/Rijndael_S-box '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, 'toString': function () { return this.__repr__(); }, //============================================================================= '_sbox': null, 'sbox': function() { if (Clipperz.Crypto.AES._sbox == null) { Clipperz.Crypto.AES._sbox = [ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 ]; } return Clipperz.Crypto.AES._sbox; }, //----------------------------------------------------------------------------- // // 0 4 8 12 0 4 8 12 // 1 5 9 13 => 5 9 13 1 // 2 6 10 14 10 14 2 6 // 3 7 11 15 15 3 7 11 // '_shiftRowMapping': null, 'shiftRowMapping': function() { if (Clipperz.Crypto.AES._shiftRowMapping == null) { Clipperz.Crypto.AES._shiftRowMapping = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]; } return Clipperz.Crypto.AES._shiftRowMapping; }, //----------------------------------------------------------------------------- '_mixColumnsMatrix': null, 'mixColumnsMatrix': function() { if (Clipperz.Crypto.AES._mixColumnsMatrix == null) { Clipperz.Crypto.AES._mixColumnsMatrix = [ [2, 3, 1 ,1], [1, 2, 3, 1], [1, 1, 2, 3], [3, 1, 1, 2] ]; } return Clipperz.Crypto.AES._mixColumnsMatrix; }, '_roundConstants': null, 'roundConstants': function() { if (Clipperz.Crypto.AES._roundConstants == null) { Clipperz.Crypto.AES._roundConstants = [ , 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154]; // Clipperz.Crypto.AES._roundConstants = [ , 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a]; } return Clipperz.Crypto.AES._roundConstants; }, //============================================================================= 'incrementNonce': function(aNonce) { //Clipperz.Profile.start("Clipperz.Crypto.AES.incrementNonce"); var i; var done; done = false; i = aNonce.length - 1; while ((i>=0) && (done == false)) { var currentByteValue; currentByteValue = aNonce[i]; if (currentByteValue == 0xff) { aNonce[i] = 0; if (i>= 0) { i --; } else { done = true; } } else { aNonce[i] = currentByteValue + 1; done = true; } } //Clipperz.Profile.stop("Clipperz.Crypto.AES.incrementNonce"); }, //----------------------------------------------------------------------------- 'encryptBlock': function(aKey, aBlock) { var result; var state; state = new Clipperz.Crypto.AES.State({block:aBlock, key:aKey}); //is(state.data(), 'before'); state.encrypt(); result = state.data(); return result; }, //----------------------------------------------------------------------------- 'encryptBlocks': function(aKey, aMessage, aNonce) { var result; var nonce; var self; var messageIndex; var messageLength; var blockSize; self = Clipperz.Crypto.AES; blockSize = 128/8; messageLength = aMessage.length; nonce = aNonce; result = aMessage; messageIndex = 0; while (messageIndex < messageLength) { var encryptedBlock; var i,c; self.incrementNonce(nonce); encryptedBlock = self.encryptBlock(aKey, nonce); if ((messageLength - messageIndex) > blockSize) { c = blockSize; } else { c = messageLength - messageIndex; } for (i=0; i<c; i++) { result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i]; } messageIndex += blockSize; } return result; }, //----------------------------------------------------------------------------- 'encrypt': function(aKey, someData, aNonce) { var result; var nonce; var encryptedData; var key; key = new Clipperz.Crypto.AES.Key({key:aKey}); nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8); encryptedData = Clipperz.Crypto.AES.encryptBlocks(key, someData.arrayValues(), nonce.arrayValues()); result = nonce.appendBytes(encryptedData); return result; }, //----------------------------------------------------------------------------- 'decrypt': function(aKey, someData) { var result; var nonce; var encryptedData; var decryptedData; var dataIterator; var key; key = new Clipperz.Crypto.AES.Key({key:aKey}); encryptedData = someData.arrayValues(); nonce = encryptedData.slice(0, (128/8)); encryptedData = encryptedData.slice(128/8); decryptedData = Clipperz.Crypto.AES.encryptBlocks(key, encryptedData, nonce); result = new Clipperz.ByteArray(decryptedData); return result; }, //============================================================================= 'deferredEncryptExecutionChunk': function(anExecutionContext) { var result; var nonce; var self; var messageIndex; var messageLength; var blockSize; var executionLimit; var startTime, endTime; self = Clipperz.Crypto.AES; startTime = new Date(); blockSize = 128/8; messageLength = anExecutionContext.messageArray().length; nonce = anExecutionContext.nonceArray(); result = anExecutionContext.resultArray(); messageIndex = anExecutionContext.executionStep(); executionLimit = messageIndex + anExecutionContext.elaborationChunkSize(); executionLimit = Math.min(executionLimit, messageLength); while (messageIndex < executionLimit) { var encryptedBlock; var i,c; self.incrementNonce(nonce); encryptedBlock = self.encryptBlock(anExecutionContext.key(), nonce); if ((executionLimit - messageIndex) > blockSize) { c = blockSize; } else { c = executionLimit - messageIndex; } for (i=0; i<c; i++) { result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i]; } messageIndex += blockSize; } anExecutionContext.setExecutionStep(messageIndex); endTime = new Date(); anExecutionContext.tuneExecutionParameters(endTime - startTime); return anExecutionContext; }, //----------------------------------------------------------------------------- /* 'deferredEncryptBlocks': function(anExecutionContext) { var deferredResult; var messageSize; var i,c; messageSize = anExecutionContext.messageLength(); deferredResult = new Clipperz.Async.Deferred("AES.deferredEncryptBloks"); c = Math.ceil(messageSize / anExecutionContext.elaborationChunkSize()); for (i=0; i<c; i++) { deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncryptExecutionChunk); deferredResult.addMethod(anExecutionContext, 'pause'); } deferredResult.callback(anExecutionContext); return deferredResult; }, */ 'deferredEncryptBlocks': function(anExecutionContext) { var deferredResult; if (! anExecutionContext.isDone()) { deferredResult = Clipperz.Async.callbacks("Clipperz.Crypto.AES.deferredEncryptBloks", [ Clipperz.Crypto.AES.deferredEncryptExecutionChunk, MochiKit.Base.method(anExecutionContext, 'pause'), Clipperz.Crypto.AES.deferredEncryptBlocks ], {trace:false}, anExecutionContext); } else { deferredResult = MochiKit.Async.succeed(anExecutionContext); } return deferredResult; }, //----------------------------------------------------------------------------- 'deferredEncrypt': function(aKey, someData, aNonce) { var deferredResult; var executionContext; var result; var nonce; var key; key = new Clipperz.Crypto.AES.Key({key:aKey}); nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8); executionContext = new Clipperz.Crypto.AES.DeferredExecutionContext({key:key, message:someData, nonce:nonce}); deferredResult = new Clipperz.Async.Deferred("AES.deferredEncrypt"); -//deferredResult.addCallback(function (aValue) { console.log(">>> deferredEncrypt"); return aValue; }); deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncryptBlocks); deferredResult.addCallback(function(anExecutionContext) { var result; result = anExecutionContext.nonce().clone(); result.appendBytes(anExecutionContext.resultArray()); return result; }); -//deferredResult.addCallback(function (aValue) { console.log("<<< deferredEncrypt"); return aValue; }); deferredResult.callback(executionContext) return deferredResult; }, //----------------------------------------------------------------------------- 'deferredDecrypt': function(aKey, someData) { var deferredResult var nonce; var message; var key; key = new Clipperz.Crypto.AES.Key({key:aKey}); nonce = someData.split(0, (128/8)); message = someData.split(128/8); executionContext = new Clipperz.Crypto.AES.DeferredExecutionContext({key:key, message:message, nonce:nonce}); deferredResult = new Clipperz.Async.Deferred("AES.deferredDecrypt"); -//deferredResult.addCallback(function (aValue) { console.log(">>> deferredDecrypt"); return aValue; }); deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncryptBlocks); deferredResult.addCallback(function(anExecutionContext) { return anExecutionContext.result(); }); -//deferredResult.addCallback(function (aValue) { console.log("<<< deferredDecrypt"); return aValue; }); deferredResult.callback(executionContext); return deferredResult; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# //Clipperz.Crypto.AES.DeferredExecution = { // 'chunkSize': 16384, // 4096, // 1024 4096 8192 16384 32768; // 'pauseTime': 0.02 // 0.2 //} Clipperz.Crypto.AES.exception = { 'UnsupportedKeySize': new MochiKit.Base.NamedError("Clipperz.Crypto.AES.exception.UnsupportedKeySize") }; diff --git a/frontend/gamma/js/Clipperz/Crypto/Base.js b/frontend/gamma/js/Clipperz/Crypto/Base.js index d3a8e36..9acfc49 100644 --- a/frontend/gamma/js/Clipperz/Crypto/Base.js +++ b/frontend/gamma/js/Clipperz/Crypto/Base.js @@ -1,534 +1,532 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.Base) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.Base depends on Clipperz.Base!"; } if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } if (typeof(Clipperz.Crypto.Base) == 'undefined') { Clipperz.Crypto.Base = {}; } Clipperz.Crypto.Base.VERSION = "0.1"; Clipperz.Crypto.Base.NAME = "Clipperz.Crypto.Base"; //############################################################################# // Downloaded on March 30, 2006 from http://anmar.eu.org/projects/jssha2/files/jssha2-0.3.zip (jsSha2/sha256.js) //############################################################################# /* A JavaScript implementation of the Secure Hash Algorithm, SHA-256 * Version 0.3 Copyright Angel Marin 2003-2004 - http://anmar.eu.org/ * Distributed under the BSD License * Some bits taken from Paul Johnston's SHA-1 implementation */ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ function safe_add (x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function S (X, n) {return ( X >>> n ) | (X << (32 - n));} function R (X, n) {return ( X >>> n );} function Ch(x, y, z) {return ((x & y) ^ ((~x) & z));} function Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));} function Sigma0256(x) {return (S(x, 2) ^ S(x, 13) ^ S(x, 22));} function Sigma1256(x) {return (S(x, 6) ^ S(x, 11) ^ S(x, 25));} function Gamma0256(x) {return (S(x, 7) ^ S(x, 18) ^ R(x, 3));} function Gamma1256(x) {return (S(x, 17) ^ S(x, 19) ^ R(x, 10));} function core_sha256 (m, l) { var K = new Array(0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x6CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2); var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19); var W = new Array(64); var a, b, c, d, e, f, g, h, i, j; var T1, T2; /* append padding */ m[l >> 5] |= 0x80 << (24 - l % 32); m[((l + 64 >> 9) << 4) + 15] = l; for ( var i = 0; i<m.length; i+=16 ) { a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; for ( var j = 0; j<64; j++) { if (j < 16) W[j] = m[j + i]; else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]); T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]); T2 = safe_add(Sigma0256(a), Maj(a, b, c)); h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2); } HASH[0] = safe_add(a, HASH[0]); HASH[1] = safe_add(b, HASH[1]); HASH[2] = safe_add(c, HASH[2]); HASH[3] = safe_add(d, HASH[3]); HASH[4] = safe_add(e, HASH[4]); HASH[5] = safe_add(f, HASH[5]); HASH[6] = safe_add(g, HASH[6]); HASH[7] = safe_add(h, HASH[7]); } return HASH; } function str2binb (str) { var bin = Array(); var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32); return bin; } function binb2hex (binarray) { var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for (var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); } return str; } function hex_sha256(s){return binb2hex(core_sha256(str2binb(s),s.length * chrsz));} //############################################################################# // Downloaded on March 30, 2006 from http://www.fourmilab.ch/javascrypt/javascrypt.zip (entropy.js) //############################################################################# // Entropy collection utilities /* Start by declaring static storage and initialise the entropy vector from the time we come through here. */ var entropyData = new Array(); // Collected entropy data var edlen = 0; // Keyboard array data length addEntropyTime(); // Start entropy collection with page load time ce(); // Roll milliseconds into initial entropy // Add a byte to the entropy vector function addEntropyByte(b) { entropyData[edlen++] = b; } /* Capture entropy. When the user presses a key or performs various other events for which we can request notification, add the time in 255ths of a second to the entropyData array. The name of the function is short so it doesn't bloat the form object declarations in which it appears in various "onXXX" events. */ function ce() { addEntropyByte(Math.floor((((new Date).getMilliseconds()) * 255) / 999)); } // Add a 32 bit quantity to the entropy vector function addEntropy32(w) { var i; for (i = 0; i < 4; i++) { addEntropyByte(w & 0xFF); w >>= 8; } } /* Add the current time and date (milliseconds since the epoch, truncated to 32 bits) to the entropy vector. */ function addEntropyTime() { addEntropy32((new Date()).getTime()); } /* Start collection of entropy from mouse movements. The argument specifies the number of entropy items to be obtained from mouse motion, after which mouse motion will be ignored. Note that you can re-enable mouse motion collection at any time if not already underway. */ var mouseMotionCollect = 0; var oldMoveHandler; // For saving and restoring mouse move handler in IE4 function mouseMotionEntropy(maxsamp) { if (mouseMotionCollect <= 0) { mouseMotionCollect = maxsamp; if ((document.implementation.hasFeature("Events", "2.0")) && document.addEventListener) { // Browser supports Document Object Model (DOM) 2 events document.addEventListener("mousemove", mouseMoveEntropy, false); } else { if (document.attachEvent) { // Internet Explorer 5 and above event model document.attachEvent("onmousemove", mouseMoveEntropy); } else { // Internet Explorer 4 event model oldMoveHandler = document.onmousemove; document.onmousemove = mouseMoveEntropy; } } //dump("Mouse enable", mouseMotionCollect); } } /* Collect entropy from mouse motion events. Note that this is craftily coded to work with either DOM2 or Internet Explorer style events. Note that we don't use every successive mouse movement event. Instead, we XOR the three bytes collected from the mouse and use that to determine how many subsequent mouse movements we ignore before capturing the next one. */ var mouseEntropyTime = 0; // Delay counter for mouse entropy collection function mouseMoveEntropy(e) { if (!e) { e = window.event; // Internet Explorer event model } if (mouseMotionCollect > 0) { if (mouseEntropyTime-- <= 0) { addEntropyByte(e.screenX & 0xFF); addEntropyByte(e.screenY & 0xFF); ce(); mouseMotionCollect--; mouseEntropyTime = (entropyData[edlen - 3] ^ entropyData[edlen - 2] ^ entropyData[edlen - 1]) % 19; //dump("Mouse Move", byteArrayToHex(entropyData.slice(-3))); } if (mouseMotionCollect <= 0) { if (document.removeEventListener) { document.removeEventListener("mousemove", mouseMoveEntropy, false); } else if (document.detachEvent) { document.detachEvent("onmousemove", mouseMoveEntropy); } else { document.onmousemove = oldMoveHandler; } //dump("Spung!", 0); } } } /* Compute a 32 byte key value from the entropy vector. We compute the value by taking the MD5 sum of the even and odd bytes respectively of the entropy vector, then concatenating the two MD5 sums. */ function keyFromEntropy() { var i, k = new Array(32); if (edlen == 0) { alert("Blooie! Entropy vector void at call to keyFromEntropy."); } //dump("Entropy bytes", edlen); md5_init(); for (i = 0; i < edlen; i += 2) { md5_update(entropyData[i]); } md5_finish(); for (i = 0; i < 16; i++) { k[i] = digestBits[i]; } md5_init(); for (i = 1; i < edlen; i += 2) { md5_update(entropyData[i]); } md5_finish(); for (i = 0; i < 16; i++) { k[i + 16] = digestBits[i]; } //dump("keyFromEntropy", byteArrayToHex(k)); return k; } //############################################################################# // Downloaded on March 30, 2006 from http://www.fourmilab.ch/javascrypt/javascrypt.zip (aesprng.js) //############################################################################# // AES based pseudorandom number generator /* Constructor. Called with an array of 32 byte (0-255) values containing the initial seed. */ function AESprng(seed) { this.key = new Array(); this.key = seed; this.itext = hexToByteArray("9F489613248148F9C27945C6AE62EECA3E3367BB14064E4E6DC67A9F28AB3BD1"); this.nbytes = 0; // Bytes left in buffer this.next = AESprng_next; this.nextbits = AESprng_nextbits; this.nextInt = AESprng_nextInt; this.round = AESprng_round; /* Encrypt the initial text with the seed key three times, feeding the output of the encryption back into the key for the next round. */ bsb = blockSizeInBits; blockSizeInBits = 256; var i, ct; for (i = 0; i < 3; i++) { this.key = rijndaelEncrypt(this.itext, this.key, "ECB"); } /* Now make between one and four additional key-feedback rounds, with the number determined by bits from the result of the first three rounds. */ var n = 1 + (this.key[3] & 2) + (this.key[9] & 1); for (i = 0; i < n; i++) { this.key = rijndaelEncrypt(this.itext, this.key, "ECB"); } blockSizeInBits = bsb; } function AESprng_round() { bsb = blockSizeInBits; blockSizeInBits = 256; this.key = rijndaelEncrypt(this.itext, this.key, "ECB"); this.nbytes = 32; blockSizeInBits = bsb; } // Return next byte from the generator function AESprng_next() { if (this.nbytes <= 0) { this.round(); } return(this.key[--this.nbytes]); } // Return n bit integer value (up to maximum integer size) function AESprng_nextbits(n) { var i, w = 0, nbytes = Math.floor((n + 7) / 8); for (i = 0; i < nbytes; i++) { w = (w << 8) | this.next(); } return w & ((1 << n) - 1); } // Return integer between 0 and n inclusive function AESprng_nextInt(n) { var p = 1, nb = 0; // Determine smallest p, 2^p > n // nb = log_2 p while (n >= p) { p <<= 1; nb++; } p--; /* Generate values from 0 through n by first generating values v from 0 to (2^p)-1, then discarding any results v > n. For the rationale behind this (and why taking values mod (n + 1) is biased toward smaller values, see Ferguson and Schneier, "Practical Cryptography", ISBN 0-471-22357-3, section 10.8). */ while (true) { var v = this.nextbits(nb) & p; if (v <= n) { return v; } } } //############################################################################# // Downloaded on March 30, 2006 from http://www.fourmilab.ch/javascrypt/javascrypt.zip (md5.js) //############################################################################# /* * md5.jvs 1.0b 27/06/96 * * Javascript implementation of the RSA Data Security, Inc. MD5 * Message-Digest Algorithm. * * Copyright (c) 1996 Henri Torgemane. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for any purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. * * Of course, this soft is provided "as is" without express or implied * warranty of any kind. This version contains some trivial reformatting modifications by John Walker. */ function array(n) { for (i = 0; i < n; i++) { this[i] = 0; } this.length = n; } /* Some basic logical functions had to be rewritten because of a bug in * Javascript.. Just try to compute 0xffffffff >> 4 with it.. * Of course, these functions are slower than the original would be, but * at least, they work! */ function integer(n) { return n % (0xffffffff + 1); } function shr(a, b) { a = integer(a); b = integer(b); if (a - 0x80000000 >= 0) { a = a % 0x80000000; a >>= b; a += 0x40000000 >> (b - 1); } else { a >>= b; } return a; } function shl1(a) { a = a % 0x80000000; if (a & 0x40000000 == 0x40000000) { a -= 0x40000000; a *= 2; a += 0x80000000; } else { a *= 2; } return a; } function shl(a, b) { a = integer(a); b = integer(b); for (var i = 0; i < b; i++) { a = shl1(a); } return a; } function and(a, b) { a = integer(a); b = integer(b); var t1 = a - 0x80000000; var t2 = b - 0x80000000; if (t1 >= 0) { if (t2 >= 0) { return ((t1 & t2) + 0x80000000); } else { return (t1 & b); } } else { if (t2 >= 0) { return (a & t2); } else { return (a & b); } } } function or(a, b) { a = integer(a); b = integer(b); var t1 = a - 0x80000000; var t2 = b - 0x80000000; if (t1 >= 0) { if (t2 >= 0) { return ((t1 | t2) + 0x80000000); } else { return ((t1 | b) + 0x80000000); } } else { if (t2 >= 0) { return ((a | t2) + 0x80000000); } else { return (a | b); } } } function xor(a, b) { a = integer(a); b = integer(b); var t1 = a - 0x80000000; var t2 = b - 0x80000000; if (t1 >= 0) { if (t2 >= 0) { return (t1 ^ t2); } else { return ((t1 ^ b) + 0x80000000); } } else { if (t2 >= 0) { return ((a ^ t2) + 0x80000000); } else { return (a ^ b); } } } function not(a) { a = integer(a); return 0xffffffff - a; } /* Here begin the real algorithm */ var state = new array(4); var count = new array(2); count[0] = 0; count[1] = 0; var buffer = new array(64); var transformBuffer = new array(16); var digestBits = new array(16); var S11 = 7; var S12 = 12; var S13 = 17; var S14 = 22; var S21 = 5; var S22 = 9; var S23 = 14; var S24 = 20; var S31 = 4; var S32 = 11; var S33 = 16; var S34 = 23; var S41 = 6; var S42 = 10; var S43 = 15; var S44 = 21; function F(x, y, z) { return or(and(x, y), and(not(x), z)); } function G(x, y, z) { return or(and(x, z), and(y, not(z))); } function H(x, y, z) { return xor(xor(x, y), z); } diff --git a/frontend/gamma/js/Clipperz/Crypto/BigInt.js b/frontend/gamma/js/Clipperz/Crypto/BigInt.js index 41483a3..031ed30 100644 --- a/frontend/gamma/js/Clipperz/Crypto/BigInt.js +++ b/frontend/gamma/js/Clipperz/Crypto/BigInt.js @@ -1,534 +1,532 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } //############################################################################# // Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js //############################################################################# //////////////////////////////////////////////////////////////////////////////////////// // Big Integer Library v. 5.0 // Created 2000, last modified 2006 // Leemon Baird // www.leemon.com // // This file is public domain. You can use it for any purpose without restriction. // I do not guarantee that it is correct, so use it at your own risk. If you use // it for something interesting, I'd appreciate hearing about it. If you find // any bugs or make any improvements, I'd appreciate hearing about those too. // It would also be nice if my name and address were left in the comments. // But none of that is required. // // This code defines a bigInt library for arbitrary-precision integers. // A bigInt is an array of integers storing the value in chunks of bpe bits, // little endian (buff[0] is the least significant word). // Negative bigInts are stored two's complement. // Some functions assume their parameters have at least one leading zero element. // Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, // so the caller must make sure overflow won't happen. // For each function where a parameter is modified, that same // variable must not be used as another argument too. // So, you cannot square x by doing multMod_(x,x,n). // You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). // // These functions are designed to avoid frequent dynamic memory allocation in the inner loop. // For most functions, if it needs a BigInt as a local variable it will actually use // a global, and will only allocate to it when it's not the right size. This ensures // that when a function is called repeatedly with same-sized parameters, it only allocates // memory on the first call. // // Note that for cryptographic purposes, the calls to Math.random() must // be replaced with calls to a better pseudorandom number generator. // // In the following, "bigInt" means a bigInt with at least one leading zero element, // and "integer" means a nonnegative integer less than radix. In some cases, integer // can be negative. Negative bigInts are 2s complement. // // The following functions do not modify their inputs, but dynamically allocate memory every time they are called: // // function bigInt2str(x,base) //convert a bigInt into a string in a given base, from base 2 up to base 95 // function dup(x) //returns a copy of bigInt x // function findPrimes(n) //return array of all primes less than integer n // function int2bigInt(t,n,m) //convert integer t to a bigInt with at least n bits and m array elements // function int2bigInt(s,b,n,m) //convert string s in base b to a bigInt with at least n bits and m array elements // function trim(x,k) //return a copy of x with exactly k leading zero elements // // The following functions do not modify their inputs, so there is never a problem with the result being too big: // // function bitSize(x) //returns how many bits long the bigInt x is, not counting leading zeros // function equals(x,y) //is the bigInt x equal to the bigint y? // function equalsInt(x,y) //is bigint x equal to integer y? // function greater(x,y) //is x>y? (x and y are nonnegative bigInts) // function greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y? // function isZero(x) //is the bigInt x equal to zero? // function millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime (as opposed to definitely composite)? // function modInt(x,n) //return x mod n for bigInt x and integer n. // function negative(x) //is bigInt x negative? // // The following functions do not modify their inputs, but allocate memory and call functions with underscores // // function add(x,y) //return (x+y) for bigInts x and y. // function addInt(x,n) //return (x+n) where x is a bigInt and n is an integer. // function expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed // function inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null // function mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n. // function mult(x,y) //return x*y for bigInts x and y. This is faster when y<x. // function multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. // function powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. // function randTruePrime(k) //return a new, random, k-bit, true prime using Maurer's algorithm. // function sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement // // The following functions write a bigInt result to one of the parameters, but // the result is never bigger than the original, so there can't be overflow problems: // // function divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder // function GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). // function halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement // function mod_(x,n) //do x=x mod n for bigInts x and n. // function rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. // // The following functions write a bigInt result to one of the parameters. The caller is responsible for // ensuring it is large enough to hold the result. // // function addInt_(x,n) //do x=x+n where x is a bigInt and n is an integer // function add_(x,y) //do x=x+y for bigInts x and y // function addShift_(x,y,ys) //do x=x+(y<<(ys*bpe)) // function copy_(x,y) //do x=y on bigInts x and y // function copyInt_(x,n) //do x=n on bigInt x and integer n // function carry_(x) //do carries and borrows so each element of the bigInt x fits in bpe bits. // function divide_(x,y,q,r) //divide_ x by y giving quotient q and remainder r // function eGCD_(x,y,d,a,b) //sets a,b,d to positive big integers such that d = GCD_(x,y) = a*x-b*y // function inverseMod_(x,n) //do x=x**(-1) mod n, for bigInts x and n. Returns 1 (0) if inverse does (doesn't) exist // function inverseModInt_(x,n) //return x**(-1) mod n, for integers x and n. Return 0 if there is no inverse // function leftShift_(x,n) //left shift bigInt x by n bits. n<bpe. // function linComb_(x,y,a,b) //do x=a*x+b*y for bigInts x and y and integers a and b // function linCombShift_(x,y,b,ys) //do x=x+b*(y<<(ys*bpe)) for bigInts x and y, and integers b and ys // function mont_(x,y,n,np) //Montgomery multiplication (see comments where the function is defined) // function mult_(x,y) //do x=x*y for bigInts x and y. // function multInt_(x,n) //do x=x*n where x is a bigInt and n is an integer. // function multMod_(x,y,n) //do x=x*y mod n for bigInts x,y,n. // function powMod_(x,y,n) //do x=x**y mod n, where x,y,n are bigInts (n is odd) and ** is exponentiation. 0**0=1. // function randBigInt_(b,n,s) //do b = an n-bit random BigInt. if s=1, then nth bit (most significant bit) is set to 1. n>=1. // function randTruePrime_(ans,k) //do ans = a random k-bit true random prime (not just probable prime) with 1 in the msb. // function squareMod_(x,n) //do x=x*x mod n for bigInts x,n // function sub_(x,y) //do x=x-y for bigInts x and y. Negative answers will be 2s complement. // function subShift_(x,y,ys) //do x=x-(y<<(ys*bpe)). Negative answers will be 2s complement. // // The following functions are based on algorithms from the _Handbook of Applied Cryptography_ // powMod_() = algorithm 14.94, Montgomery exponentiation // eGCD_,inverseMod_() = algorithm 14.61, Binary extended GCD_ // GCD_() = algorothm 14.57, Lehmer's algorithm // mont_() = algorithm 14.36, Montgomery multiplication // divide_() = algorithm 14.20 Multiple-precision division // squareMod_() = algorithm 14.16 Multiple-precision squaring // randTruePrime_() = algorithm 4.62, Maurer's algorithm // millerRabin() = algorithm 4.24, Miller-Rabin algorithm // // Profiling shows: // randTruePrime_() spends: // 10% of its time in calls to powMod_() // 85% of its time in calls to millerRabin() // millerRabin() spends: // 99% of its time in calls to powMod_() (always with a base of 2) // powMod_() spends: // 94% of its time in calls to mont_() (almost always with x==y) // // This suggests there are several ways to speed up this library slightly: // - convert powMod_ to use a Montgomery form of k-ary window (or maybe a Montgomery form of sliding window) // -- this should especially focus on being fast when raising 2 to a power mod n // - convert randTruePrime_() to use a minimum r of 1/3 instead of 1/2 with the appropriate change to the test // - tune the parameters in randTruePrime_(), including c, m, and recLimit // - speed up the single loop in mont_() that takes 95% of the runtime, perhaps by reducing checking // within the loop when all the parameters are the same length. // // There are several ideas that look like they wouldn't help much at all: // - replacing trial division in randTruePrime_() with a sieve (that speeds up something taking almost no time anyway) // - increase bpe from 15 to 30 (that would help if we had a 32*32->64 multiplier, but not with JavaScript's 32*32->32) // - speeding up mont_(x,y,n,np) when x==y by doing a non-modular, non-Montgomery square // followed by a Montgomery reduction. The intermediate answer will be twice as long as x, so that // method would be slower. This is unfortunate because the code currently spends almost all of its time // doing mont_(x,x,...), both for randTruePrime_() and powMod_(). A faster method for Montgomery squaring // would have a large impact on the speed of randTruePrime_() and powMod_(). HAC has a couple of poorly-worded // sentences that seem to imply it's faster to do a non-modular square followed by a single // Montgomery reduction, but that's obviously wrong. //////////////////////////////////////////////////////////////////////////////////////// //globals bpe=0; //bits stored per array element mask=0; //AND this with an array element to chop it down to bpe bits radix=mask+1; //equals 2^bpe. A single 1 bit to the left of the last bit of mask. //the digits for converting to different bases digitsStr='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_=!@#$%^&*()[]{}|;:,.<>/?`~ \\\'\"+-'; //initialize the global variables for (bpe=0; (1<<(bpe+1)) > (1<<bpe); bpe++); //bpe=number of bits in the mantissa on this platform bpe>>=1; //bpe=number of bits in one element of the array representing the bigInt mask=(1<<bpe)-1; //AND the mask with an integer to get its bpe least significant bits radix=mask+1; //2^bpe. a single 1 bit to the left of the first bit of mask one=int2bigInt(1,1,1); //constant used in powMod_() //the following global variables are scratchpad memory to //reduce dynamic memory allocation in the inner loop t=new Array(0); ss=t; //used in mult_() s0=t; //used in multMod_(), squareMod_() s1=t; //used in powMod_(), multMod_(), squareMod_() s2=t; //used in powMod_(), multMod_() s3=t; //used in powMod_() s4=t; s5=t; //used in mod_() s6=t; //used in bigInt2str() s7=t; //used in powMod_() T=t; //used in GCD_() sa=t; //used in mont_() mr_x1=t; mr_r=t; mr_a=t; //used in millerRabin() eg_v=t; eg_u=t; eg_A=t; eg_B=t; eg_C=t; eg_D=t; //used in eGCD_(), inverseMod_() md_q1=t; md_q2=t; md_q3=t; md_r=t; md_r1=t; md_r2=t; md_tt=t; //used in mod_() primes=t; pows=t; s_i=t; s_i2=t; s_R=t; s_rm=t; s_q=t; s_n1=t; s_a=t; s_r2=t; s_n=t; s_b=t; s_d=t; s_x1=t; s_x2=t, s_aa=t; //used in randTruePrime_() //////////////////////////////////////////////////////////////////////////////////////// //return array of all primes less than integer n function findPrimes(n) { var i,s,p,ans; s=new Array(n); for (i=0;i<n;i++) s[i]=0; s[0]=2; p=0; //first p elements of s are primes, the rest are a sieve for(;s[p]<n;) { //s[p] is the pth prime for(i=s[p]*s[p]; i<n; i+=s[p]) //mark multiples of s[p] s[i]=1; p++; s[p]=s[p-1]+1; for(; s[p]<n && s[s[p]]; s[p]++); //find next prime (where s[p]==0) } ans=new Array(p); for(i=0;i<p;i++) ans[i]=s[i]; return ans; } //does a single round of Miller-Rabin base b consider x to be a possible prime? //x is a bigInt, and b is an integer function millerRabin(x,b) { var i,j,k,s; if (mr_x1.length!=x.length) { mr_x1=dup(x); mr_r=dup(x); mr_a=dup(x); } copyInt_(mr_a,b); copy_(mr_r,x); copy_(mr_x1,x); addInt_(mr_r,-1); addInt_(mr_x1,-1); //s=the highest power of two that divides mr_r k=0; for (i=0;i<mr_r.length;i++) for (j=1;j<mask;j<<=1) if (x[i] & j) { s=(k<mr_r.length+bpe ? k : 0); i=mr_r.length; j=mask; } else k++; if (s) rightShift_(mr_r,s); powMod_(mr_a,mr_r,x); if (!equalsInt(mr_a,1) && !equals(mr_a,mr_x1)) { j=1; while (j<=s-1 && !equals(mr_a,mr_x1)) { squareMod_(mr_a,x); if (equalsInt(mr_a,1)) { return 0; } j++; } if (!equals(mr_a,mr_x1)) { return 0; } } return 1; } //returns how many bits long the bigInt is, not counting leading zeros. function bitSize(x) { var j,z,w; for (j=x.length-1; (x[j]==0) && (j>0); j--); for (z=0,w=x[j]; w; (w>>=1),z++); z+=bpe*j; return z; } //return a copy of x with at least n elements, adding leading zeros if needed function expand(x,n) { var ans=int2bigInt(0,(x.length>n ? x.length : n)*bpe,0); copy_(ans,x); return ans; } //return a k-bit true random prime using Maurer's algorithm. function randTruePrime(k) { var ans=int2bigInt(0,k,0); randTruePrime_(ans,k); return trim(ans,1); } //return a new bigInt equal to (x mod n) for bigInts x and n. function mod(x,n) { var ans=dup(x); mod_(ans,n); return trim(ans,1); } //return (x+n) where x is a bigInt and n is an integer. function addInt(x,n) { var ans=expand(x,x.length+1); addInt_(ans,n); return trim(ans,1); } //return x*y for bigInts x and y. This is faster when y<x. function mult(x,y) { var ans=expand(x,x.length+y.length); mult_(ans,y); return trim(ans,1); } //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. function powMod(x,y,n) { var ans=expand(x,n.length); powMod_(ans,trim(y,2),trim(n,2),0); //this should work without the trim, but doesn't return trim(ans,1); } //return (x-y) for bigInts x and y. Negative answers will be 2s complement function sub(x,y) { var ans=expand(x,(x.length>y.length ? x.length+1 : y.length+1)); sub_(ans,y); return trim(ans,1); } //return (x+y) for bigInts x and y. function add(x,y) { var ans=expand(x,(x.length>y.length ? x.length+1 : y.length+1)); add_(ans,y); return trim(ans,1); } //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null function inverseMod(x,n) { var ans=expand(x,n.length); var s; s=inverseMod_(ans,n); return s ? trim(ans,1) : null; } //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. function multMod(x,y,n) { var ans=expand(x,n.length); multMod_(ans,y,n); return trim(ans,1); } //generate a k-bit true random prime using Maurer's algorithm, //and put it into ans. The bigInt ans must be large enough to hold it. function randTruePrime_(ans,k) { var c,m,pm,dd,j,r,B,divisible,z,zz,recSize; if (primes.length==0) primes=findPrimes(30000); //check for divisibility by primes <=30000 if (pows.length==0) { pows=new Array(512); for (j=0;j<512;j++) { pows[j]=Math.pow(2,j/511.-1.); } } //c and m should be tuned for a particular machine and value of k, to maximize speed //this was: c=primes[primes.length-1]/k/k; //check using all the small primes. (c=0.1 in HAC) c=0.1; m=20; //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits recLimit=20; /*must be at least 2 (was 29)*/ //stop recursion when k <=recLimit if (s_i2.length!=ans.length) { s_i2=dup(ans); s_R =dup(ans); s_n1=dup(ans); s_r2=dup(ans); s_d =dup(ans); s_x1=dup(ans); s_x2=dup(ans); s_b =dup(ans); s_n =dup(ans); s_i =dup(ans); s_rm=dup(ans); s_q =dup(ans); s_a =dup(ans); s_aa=dup(ans); } if (k <= recLimit) { //generate small random primes by trial division up to its square root pm=(1<<((k+2)>>1))-1; //pm is binary number with all ones, just over sqrt(2^k) copyInt_(ans,0); for (dd=1;dd;) { dd=0; ans[0]= 1 | (1<<(k-1)) | Math.floor(Math.random()*(1<<k)); //random, k-bit, odd integer, with msb 1 for (j=1;(j<primes.length) && ((primes[j]&pm)==primes[j]);j++) { //trial division by all primes 3...sqrt(2^k) if (0==(ans[0]%primes[j])) { dd=1; break; } } } carry_(ans); return; } B=c*k*k; //try small primes up to B (or all the primes[] array if the largest is less than B). if (k>2*m) //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits for (r=1; k-k*r<=m; ) r=pows[Math.floor(Math.random()*512)]; //r=Math.pow(2,Math.random()-1); else r=.5; //simulation suggests the more complex algorithm using r=.333 is only slightly faster. recSize=Math.floor(r*k)+1; randTruePrime_(s_q,recSize); copyInt_(s_i2,0); s_i2[Math.floor((k-2)/bpe)] |= (1<<((k-2)%bpe)); //s_i2=2^(k-2) divide_(s_i2,s_q,s_i,s_rm); //s_i=floor((2^(k-1))/(2q)) z=bitSize(s_i); for (;;) { for (;;) { //generate z-bit numbers until one falls in the range [0,s_i-1] randBigInt_(s_R,z,0); if (greater(s_i,s_R)) break; } //now s_R is in the range [0,s_i-1] addInt_(s_R,1); //now s_R is in the range [1,s_i] add_(s_R,s_i); //now s_R is in the range [s_i+1,2*s_i] copy_(s_n,s_q); mult_(s_n,s_R); multInt_(s_n,2); addInt_(s_n,1); //s_n=2*s_R*s_q+1 copy_(s_r2,s_R); multInt_(s_r2,2); //s_r2=2*s_R //check s_n for divisibility by small primes up to B for (divisible=0,j=0; (j<primes.length) && (primes[j]<B); j++) if (modInt(s_n,primes[j])==0) { divisible=1; break; } if (!divisible) //if it passes small primes check, then try a single Miller-Rabin base 2 if (!millerRabin(s_n,2)) //this line represents 75% of the total runtime for randTruePrime_ divisible=1; if (!divisible) { //if it passes that test, continue checking s_n addInt_(s_n,-3); for (j=s_n.length-1;(s_n[j]==0) && (j>0); j--); //strip leading zeros for (zz=0,w=s_n[j]; w; (w>>=1),zz++); zz+=bpe*j; //zz=number of bits in s_n, ignoring leading zeros for (;;) { //generate z-bit numbers until one falls in the range [0,s_n-1] randBigInt_(s_a,zz,0); if (greater(s_n,s_a)) break; } //now s_a is in the range [0,s_n-1] addInt_(s_n,3); //now s_a is in the range [0,s_n-4] addInt_(s_a,2); //now s_a is in the range [2,s_n-2] copy_(s_b,s_a); copy_(s_n1,s_n); addInt_(s_n1,-1); powMod_(s_b,s_n1,s_n); //s_b=s_a^(s_n-1) modulo s_n addInt_(s_b,-1); if (isZero(s_b)) { copy_(s_b,s_a); powMod_(s_b,s_r2,s_n); addInt_(s_b,-1); copy_(s_aa,s_n); copy_(s_d,s_b); GCD_(s_d,s_n); //if s_b and s_n are relatively prime, then s_n is a prime if (equalsInt(s_d,1)) { copy_(ans,s_aa); return; //if we've made it this far, then s_n is absolutely guaranteed to be prime } } } } } //set b to an n-bit random BigInt. If s=1, then nth bit (most significant bit) is set to 1. //array b must be big enough to hold the result. Must have n>=1 function randBigInt_(b,n,s) { var i,a; for (i=0;i<b.length;i++) b[i]=0; a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt for (i=0;i<a;i++) { b[i]=Math.floor(Math.random()*(1<<(bpe-1))); } b[a-1] &= (2<<((n-1)%bpe))-1; if (s) b[a-1] |= (1<<((n-1)%bpe)); } //set x to the greatest common divisor of x and y. //x,y are bigInts with the same number of elements. y is destroyed. function GCD_(x,y) { var i,xp,yp,A,B,C,D,q,sing; if (T.length!=x.length) T=dup(x); sing=1; while (sing) { //while y has nonzero elements other than y[0] sing=0; for (i=1;i<y.length;i++) //check if y has nonzero elements other than 0 if (y[i]) { sing=1; break; } if (!sing) break; //quit when y all zero elements except possibly y[0] @@ -968,790 +966,789 @@ function isZero(x) { //convert a bigInt into a string in a given base, from base 2 up to base 95. //Base -1 prints the contents of the array representing the number. function bigInt2str(x,base) { var i,t,s=""; if (s6.length!=x.length) s6=dup(x); else copy_(s6,x); if (base==-1) { //return the list of array contents for (i=x.length-1;i>0;i--) s+=x[i]+','; s+=x[0]; } else { //return it in the given base while (!isZero(s6)) { t=divInt_(s6,base); //t=s6 % base; s6=floor(s6/base); s=digitsStr.substring(t,t+1)+s; } } if (s.length==0) s="0"; return s; } //returns a duplicate of bigInt x function dup(x) { var i; buff=new Array(x.length); copy_(buff,x); return buff; } //do x=y on bigInts x and y. x must be an array at least as big as y (not counting the leading zeros in y). function copy_(x,y) { var i; var k=x.length<y.length ? x.length : y.length; for (i=0;i<k;i++) x[i]=y[i]; for (i=k;i<x.length;i++) x[i]=0; } //do x=y on bigInt x and integer y. function copyInt_(x,n) { var i,c; for (c=n,i=0;i<x.length;i++) { x[i]=c & mask; c>>=bpe; } } //do x=x+n where x is a bigInt and n is an integer. //x must be large enough to hold the result. function addInt_(x,n) { var i,k,c,b; x[0]+=n; k=x.length; c=0; for (i=0;i<k;i++) { c+=x[i]; b=0; if (c<0) { b=-(c>>bpe); c+=b*radix; } x[i]=c & mask; c=(c>>bpe)-b; if (!c) return; //stop carrying as soon as the carry_ is zero } } //right shift bigInt x by n bits. 0 <= n < bpe. function rightShift_(x,n) { var i; var k=Math.floor(n/bpe); if (k) { for (i=0;i<x.length-k;i++) //right shift x by k elements x[i]=x[i+k]; for (;i<x.length;i++) x[i]=0; n%=bpe; } for (i=0;i<x.length-1;i++) { x[i]=mask & ((x[i+1]<<(bpe-n)) | (x[i]>>n)); } x[i]>>=n; } //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement function halve_(x) { var i; for (i=0;i<x.length-1;i++) { x[i]=mask & ((x[i+1]<<(bpe-1)) | (x[i]>>1)); } x[i]=(x[i]>>1) | (x[i] & (radix>>1)); //most significant bit stays the same } //left shift bigInt x by n bits. function leftShift_(x,n) { var i; var k=Math.floor(n/bpe); if (k) { for (i=x.length; i>=k; i--) //left shift x by k elements x[i]=x[i-k]; for (;i>=0;i--) x[i]=0; n%=bpe; } if (!n) return; for (i=x.length-1;i>0;i--) { x[i]=mask & ((x[i]<<n) | (x[i-1]>>(bpe-n))); } x[i]=mask & (x[i]<<n); } //do x=x*n where x is a bigInt and n is an integer. //x must be large enough to hold the result. function multInt_(x,n) { var i,k,c,b; if (!n) return; k=x.length; c=0; for (i=0;i<k;i++) { c+=x[i]*n; b=0; if (c<0) { b=-(c>>bpe); c+=b*radix; } x[i]=c & mask; c=(c>>bpe)-b; } } //do x=floor(x/n) for bigInt x and integer n, and return the remainder function divInt_(x,n) { var i,r=0,s; for (i=x.length-1;i>=0;i--) { s=r*radix+x[i]; x[i]=Math.floor(s/n); r=s%n; } return r; } //do the linear combination x=a*x+b*y for bigInts x and y, and integers a and b. //x must be large enough to hold the answer. function linComb_(x,y,a,b) { var i,c,k,kk; k=x.length<y.length ? x.length : y.length; kk=x.length; for (c=0,i=0;i<k;i++) { c+=a*x[i]+b*y[i]; x[i]=c & mask; c>>=bpe; } for (i=k;i<kk;i++) { c+=a*x[i]; x[i]=c & mask; c>>=bpe; } } //do the linear combination x=a*x+b*(y<<(ys*bpe)) for bigInts x and y, and integers a, b and ys. //x must be large enough to hold the answer. function linCombShift_(x,y,b,ys) { var i,c,k,kk; k=x.length<ys+y.length ? x.length : ys+y.length; kk=x.length; for (c=0,i=ys;i<k;i++) { c+=x[i]+b*y[i-ys]; x[i]=c & mask; c>>=bpe; } for (i=k;c && i<kk;i++) { c+=x[i]; x[i]=c & mask; c>>=bpe; } } //do x=x+(y<<(ys*bpe)) for bigInts x and y, and integers a,b and ys. //x must be large enough to hold the answer. function addShift_(x,y,ys) { var i,c,k,kk; k=x.length<ys+y.length ? x.length : ys+y.length; kk=x.length; for (c=0,i=ys;i<k;i++) { c+=x[i]+y[i-ys]; x[i]=c & mask; c>>=bpe; } for (i=k;c && i<kk;i++) { c+=x[i]; x[i]=c & mask; c>>=bpe; } } //do x=x-(y<<(ys*bpe)) for bigInts x and y, and integers a,b and ys. //x must be large enough to hold the answer. function subShift_(x,y,ys) { var i,c,k,kk; k=x.length<ys+y.length ? x.length : ys+y.length; kk=x.length; for (c=0,i=ys;i<k;i++) { c+=x[i]-y[i-ys]; x[i]=c & mask; c>>=bpe; } for (i=k;c && i<kk;i++) { c+=x[i]; x[i]=c & mask; c>>=bpe; } } //do x=x-y for bigInts x and y. //x must be large enough to hold the answer. //negative answers will be 2s complement function sub_(x,y) { var i,c,k,kk; k=x.length<y.length ? x.length : y.length; for (c=0,i=0;i<k;i++) { c+=x[i]-y[i]; x[i]=c & mask; c>>=bpe; } for (i=k;c && i<x.length;i++) { c+=x[i]; x[i]=c & mask; c>>=bpe; } } //do x=x+y for bigInts x and y. //x must be large enough to hold the answer. function add_(x,y) { var i,c,k,kk; k=x.length<y.length ? x.length : y.length; for (c=0,i=0;i<k;i++) { c+=x[i]+y[i]; x[i]=c & mask; c>>=bpe; } for (i=k;c && i<x.length;i++) { c+=x[i]; x[i]=c & mask; c>>=bpe; } } //do x=x*y for bigInts x and y. This is faster when y<x. function mult_(x,y) { var i; if (ss.length!=2*x.length) ss=new Array(2*x.length); copyInt_(ss,0); for (i=0;i<y.length;i++) if (y[i]) linCombShift_(ss,x,y[i],i); //ss=1*ss+y[i]*(x<<(i*bpe)) copy_(x,ss); } //do x=x mod n for bigInts x and n. function mod_(x,n) { if (s4.length!=x.length) s4=dup(x); else copy_(s4,x); if (s5.length!=x.length) s5=dup(x); divide_(s4,n,s5,x); //x = remainder of s4 / n } //do x=x*y mod n for bigInts x,y,n. //for greater speed, let y<x. function multMod_(x,y,n) { var i; if (s0.length!=2*x.length) s0=new Array(2*x.length); copyInt_(s0,0); for (i=0;i<y.length;i++) if (y[i]) linCombShift_(s0,x,y[i],i); //s0=1*s0+y[i]*(x<<(i*bpe)) mod_(s0,n); copy_(x,s0); } //do x=x*x mod n for bigInts x,n. function squareMod_(x,n) { var i,j,d,c,kx,kn,k; for (kx=x.length; kx>0 && !x[kx-1]; kx--); //ignore leading zeros in x k=kx>n.length ? 2*kx : 2*n.length; //k=# elements in the product, which is twice the elements in the larger of x and n if (s0.length!=k) s0=new Array(k); copyInt_(s0,0); for (i=0;i<kx;i++) { c=s0[2*i]+x[i]*x[i]; s0[2*i]=c & mask; c>>=bpe; for (j=i+1;j<kx;j++) { c=s0[i+j]+2*x[i]*x[j]+c; s0[i+j]=(c & mask); c>>=bpe; } s0[i+kx]=c; } mod_(s0,n); copy_(x,s0); } //return x with exactly k leading zero elements function trim(x,k) { var i,y; for (i=x.length; i>0 && !x[i-1]; i--); y=new Array(i+k); copy_(y,x); return y; } //do x=x**y mod n, where x,y,n are bigInts and ** is exponentiation. 0**0=1. //this is faster when n is odd. x usually needs to have as many elements as n. function powMod_(x,y,n) { var k1,k2,kn,np; if(s7.length!=n.length) s7=dup(n); //for even modulus, use a simple square-and-multiply algorithm, //rather than using the more complex Montgomery algorithm. if ((n[0]&1)==0) { copy_(s7,x); copyInt_(x,1); while(!equalsInt(y,0)) { if (y[0]&1) multMod_(x,s7,n); divInt_(y,2); squareMod_(s7,n); } return; } //calculate np from n for the Montgomery multiplications copyInt_(s7,0); for (kn=n.length;kn>0 && !n[kn-1];kn--); np=radix-inverseModInt_(modInt(n,radix),radix); s7[kn]=1; multMod_(x ,s7,n); // x = x * 2**(kn*bp) mod n if (s3.length!=x.length) s3=dup(x); else copy_(s3,x); for (k1=y.length-1;k1>0 & !y[k1]; k1--); //k1=first nonzero element of y if (y[k1]==0) { //anything to the 0th power is 1 copyInt_(x,1); return; } for (k2=1<<(bpe-1);k2 && !(y[k1] & k2); k2>>=1); //k2=position of first 1 bit in y[k1] for (;;) { if (!(k2>>=1)) { //look at next bit of y k1--; if (k1<0) { mont_(x,one,n,np); return; } k2=1<<(bpe-1); } mont_(x,x,n,np); if (k2 & y[k1]) //if next bit is a 1 mont_(x,s3,n,np); } } //do x=x*y*Ri mod n for bigInts x,y,n, // where Ri = 2**(-kn*bpe) mod n, and kn is the // number of elements in the n array, not // counting leading zeros. //x must be large enough to hold the answer. //It's OK if x and y are the same variable. //must have: // x,y < n // n is odd // np = -(n^(-1)) mod radix function mont_(x,y,n,np) { var i,j,c,ui,t; var kn=n.length; var ky=y.length; if (sa.length!=kn) sa=new Array(kn); for (;kn>0 && n[kn-1]==0;kn--); //ignore leading zeros of n //this function sometimes gives wrong answers when the next line is uncommented //for (;ky>0 && y[ky-1]==0;ky--); //ignore leading zeros of y copyInt_(sa,0); //the following loop consumes 95% of the runtime for randTruePrime_() and powMod_() for large keys for (i=0; i<kn; i++) { t=sa[0]+x[i]*y[0]; ui=((t & mask) * np) & mask; //the inner "& mask" is needed on Macintosh MSIE, but not windows MSIE c=(t+ui*n[0]) >> bpe; t=x[i]; //do sa=(sa+x[i]*y+ui*n)/b where b=2**bpe for (j=1;j<ky;j++) { c+=sa[j]+t*y[j]+ui*n[j]; sa[j-1]=c & mask; c>>=bpe; } for (;j<kn;j++) { c+=sa[j]+ui*n[j]; sa[j-1]=c & mask; c>>=bpe; } sa[j-1]=c & mask; } if (!greater(n,sa)) sub_(sa,n); copy_(x,sa); } //############################################################################# //############################################################################# //############################################################################# //############################################################################# //############################################################################# //############################################################################# //############################################################################# //############################################################################# Clipperz.Crypto.BigInt = function (aValue, aBase) { var base; var value; if (typeof(aValue) == 'object') { this._internalValue = aValue; } else { if (typeof(aValue) == 'undefined') { value = "0"; } else { value = aValue + ""; } if (typeof(aBase) == 'undefined') { base = 10; } else { base = aBase; } this._internalValue = str2bigInt(value, base, 1, 1); } return this; } //============================================================================= MochiKit.Base.update(Clipperz.Crypto.BigInt.prototype, { 'clone': function() { return new Clipperz.Crypto.BigInt(this.internalValue()); }, //------------------------------------------------------------------------- 'internalValue': function () { return this._internalValue; }, //------------------------------------------------------------------------- 'isBigInt': true, //------------------------------------------------------------------------- 'toString': function(aBase) { return this.asString(aBase); }, //------------------------------------------------------------------------- 'asString': function (aBase, minimumLength) { var result; var base; if (typeof(aBase) == 'undefined') { base = 10; } else { base = aBase; } result = bigInt2str(this.internalValue(), base).toLowerCase(); if ((typeof(minimumLength) != 'undefined') && (result.length < minimumLength)) { var i, c; -//MochiKit.Logging.logDebug(">>> FIXING BigInt.asString length issue") c = (minimumLength - result.length); for (i=0; i<c; i++) { result = '0' + result; } } return result; }, //------------------------------------------------------------------------- 'asByteArray': function() { return new Clipperz.ByteArray("0x" + this.asString(16), 16); }, //------------------------------------------------------------------------- 'equals': function (aValue) { var result; if (aValue.isBigInt) { result = equals(this.internalValue(), aValue.internalValue()); } else if (typeof(aValue) == "number") { result = equalsInt(this.internalValue(), aValue); } else { throw Clipperz.Crypt.BigInt.exception.UnknownType; } return result; }, //------------------------------------------------------------------------- 'compare': function(aValue) { /* var result; var thisAsString; var aValueAsString; thisAsString = this.asString(10); aValueAsString = aValue.asString(10); result = MochiKit.Base.compare(thisAsString.length, aValueAsString.length); if (result == 0) { result = MochiKit.Base.compare(thisAsString, aValueAsString); } return result; */ var result; if (equals(this.internalValue(), aValue.internalValue())) { result = 0; } else if (greater(this.internalValue(), aValue.internalValue())) { result = 1; } else { result = -1; } return result; }, //------------------------------------------------------------------------- 'add': function (aValue) { var result; if (aValue.isBigInt) { result = add(this.internalValue(), aValue.internalValue()); } else { result = addInt(this.internalValue(), aValue); } return new Clipperz.Crypto.BigInt(result); }, //------------------------------------------------------------------------- 'subtract': function (aValue) { var result; var value; if (aValue.isBigInt) { value = aValue; } else { value = new Clipperz.Crypto.BigInt(aValue); } result = sub(this.internalValue(), value.internalValue()); return new Clipperz.Crypto.BigInt(result); }, //------------------------------------------------------------------------- 'multiply': function (aValue, aModule) { var result; var value; if (aValue.isBigInt) { value = aValue; } else { value = new Clipperz.Crypto.BigInt(aValue); } if (typeof(aModule) == 'undefined') { result = mult(this.internalValue(), value.internalValue()); } else { if (greater(this.internalValue(), value.internalValue())) { result = multMod(this.internalValue(), value.internalValue(), aModule); } else { result = multMod(value.internalValue(), this.internalValue(), aModule); } } return new Clipperz.Crypto.BigInt(result); }, //------------------------------------------------------------------------- 'module': function (aModule) { var result; var module; if (aModule.isBigInt) { module = aModule; } else { module = new Clipperz.Crypto.BigInt(aModule); } result = mod(this.internalValue(), module.internalValue()); return new Clipperz.Crypto.BigInt(result); }, //------------------------------------------------------------------------- 'powerModule': function(aValue, aModule) { var result; var value; var module; if (aValue.isBigInt) { value = aValue; } else { value = new Clipperz.Crypto.BigInt(aValue); } if (aModule.isBigInt) { module = aModule; } else { module = new Clipperz.Crypto.BigInt(aModule); } if (aValue == -1) { result = inverseMod(this.internalValue(), module.internalValue()); } else { result = powMod(this.internalValue(), value.internalValue(), module.internalValue()); } return new Clipperz.Crypto.BigInt(result); }, //------------------------------------------------------------------------- 'xor': function(aValue) { var result; var thisByteArray; var aValueByteArray; var xorArray; thisByteArray = new Clipperz.ByteArray("0x" + this.asString(16), 16); aValueByteArray = new Clipperz.ByteArray("0x" + aValue.asString(16), 16); xorArray = thisByteArray.xorMergeWithBlock(aValueByteArray, 'right'); result = new Clipperz.Crypto.BigInt(xorArray.toHexString(), 16); return result; }, //------------------------------------------------------------------------- 'shiftLeft': function(aNumberOfBitsToShift) { var result; var internalResult; var wholeByteToShift; var bitsLeftToShift; wholeByteToShift = Math.floor(aNumberOfBitsToShift / 8); bitsLeftToShift = aNumberOfBitsToShift % 8; if (wholeByteToShift == 0) { internalResult = this.internalValue(); } else { var hexValue; var i,c; hexValue = this.asString(16); c = wholeByteToShift; for (i=0; i<c; i++) { hexValue += "00"; } internalResult = str2bigInt(hexValue, 16, 1, 1); } if (bitsLeftToShift > 0) { leftShift_(internalResult, bitsLeftToShift); } result = new Clipperz.Crypto.BigInt(internalResult); return result; }, //------------------------------------------------------------------------- 'bitSize': function() { return bitSize(this.internalValue()); }, //------------------------------------------------------------------------- 'isBitSet': function(aBitPosition) { var result; if (this.asByteArray().bitAtIndex(aBitPosition) == 0) { result = false; } else { result = true; }; return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.BigInt.randomPrime = function(aBitSize) { return new Clipperz.Crypto.BigInt(randTruePrime(aBitSize)); } //############################################################################# //############################################################################# Clipperz.Crypto.BigInt.ZERO = new Clipperz.Crypto.BigInt(0); //############################################################################# Clipperz.Crypto.BigInt.equals = function(a, b) { return a.equals(b); } Clipperz.Crypto.BigInt.add = function(a, b) { return a.add(b); } Clipperz.Crypto.BigInt.subtract = function(a, b) { return a.subtract(b); } Clipperz.Crypto.BigInt.multiply = function(a, b, module) { return a.multiply(b, module); } Clipperz.Crypto.BigInt.module = function(a, module) { return a.module(module); } Clipperz.Crypto.BigInt.powerModule = function(a, b, module) { return a.powerModule(b, module); } Clipperz.Crypto.BigInt.exception = { UnknownType: new MochiKit.Base.NamedError("Clipperz.Crypto.BigInt.exception.UnknownType") } diff --git a/frontend/gamma/js/Clipperz/Crypto/BigInt_scoped.js b/frontend/gamma/js/Clipperz/Crypto/BigInt_scoped.js index f91c7e9..bc60330 100644 --- a/frontend/gamma/js/Clipperz/Crypto/BigInt_scoped.js +++ b/frontend/gamma/js/Clipperz/Crypto/BigInt_scoped.js @@ -1,534 +1,532 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } if (typeof(Leemon) == 'undefined') { Leemon = {}; } if (typeof(Baird.Crypto) == 'undefined') { Baird.Crypto = {}; } if (typeof(Baird.Crypto.BigInt) == 'undefined') { Baird.Crypto.BigInt = {}; } //############################################################################# // Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js //############################################################################# //////////////////////////////////////////////////////////////////////////////////////// // Big Integer Library v. 5.0 // Created 2000, last modified 2006 // Leemon Baird // www.leemon.com // // This file is public domain. You can use it for any purpose without restriction. // I do not guarantee that it is correct, so use it at your own risk. If you use // it for something interesting, I'd appreciate hearing about it. If you find // any bugs or make any improvements, I'd appreciate hearing about those too. // It would also be nice if my name and address were left in the comments. // But none of that is required. // // This code defines a bigInt library for arbitrary-precision integers. // A bigInt is an array of integers storing the value in chunks of bpe bits, // little endian (buff[0] is the least significant word). // Negative bigInts are stored two's complement. // Some functions assume their parameters have at least one leading zero element. // Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, // so the caller must make sure overflow won't happen. // For each function where a parameter is modified, that same // variable must not be used as another argument too. // So, you cannot square x by doing multMod_(x,x,n). // You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). // // These functions are designed to avoid frequent dynamic memory allocation in the inner loop. // For most functions, if it needs a BigInt as a local variable it will actually use // a global, and will only allocate to it when it's not the right size. This ensures // that when a function is called repeatedly with same-sized parameters, it only allocates // memory on the first call. // // Note that for cryptographic purposes, the calls to Math.random() must // be replaced with calls to a better pseudorandom number generator. // // In the following, "bigInt" means a bigInt with at least one leading zero element, // and "integer" means a nonnegative integer less than radix. In some cases, integer // can be negative. Negative bigInts are 2s complement. // // The following functions do not modify their inputs, but dynamically allocate memory every time they are called: // // function bigInt2str(x,base) //convert a bigInt into a string in a given base, from base 2 up to base 95 // function dup(x) //returns a copy of bigInt x // function findPrimes(n) //return array of all primes less than integer n // function int2bigInt(t,n,m) //convert integer t to a bigInt with at least n bits and m array elements // function str2bigInt(s,b,n,m) //convert string s in base b to a bigInt with at least n bits and m array elements // function trim(x,k) //return a copy of x with exactly k leading zero elements // // The following functions do not modify their inputs, so there is never a problem with the result being too big: // // function bitSize(x) //returns how many bits long the bigInt x is, not counting leading zeros // function equals(x,y) //is the bigInt x equal to the bigint y? // function equalsInt(x,y) //is bigint x equal to integer y? // function greater(x,y) //is x>y? (x and y are nonnegative bigInts) // function greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y? // function isZero(x) //is the bigInt x equal to zero? // function millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime (as opposed to definitely composite)? // function modInt(x,n) //return x mod n for bigInt x and integer n. // function negative(x) //is bigInt x negative? // // The following functions do not modify their inputs, but allocate memory and call functions with underscores // // function add(x,y) //return (x+y) for bigInts x and y. // function addInt(x,n) //return (x+n) where x is a bigInt and n is an integer. // function expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed // function inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null // function mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n. // function mult(x,y) //return x*y for bigInts x and y. This is faster when y<x. // function multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. // function powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. // function randTruePrime(k) //return a new, random, k-bit, true prime using Maurer's algorithm. // function sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement // // The following functions write a bigInt result to one of the parameters, but // the result is never bigger than the original, so there can't be overflow problems: // // function divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder // function GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). // function halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement // function mod_(x,n) //do x=x mod n for bigInts x and n. // function rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. // // The following functions write a bigInt result to one of the parameters. The caller is responsible for // ensuring it is large enough to hold the result. // // function addInt_(x,n) //do x=x+n where x is a bigInt and n is an integer // function add_(x,y) //do x=x+y for bigInts x and y // function addShift_(x,y,ys) //do x=x+(y<<(ys*bpe)) // function copy_(x,y) //do x=y on bigInts x and y // function copyInt_(x,n) //do x=n on bigInt x and integer n // function carry_(x) //do carries and borrows so each element of the bigInt x fits in bpe bits. // function divide_(x,y,q,r) //divide_ x by y giving quotient q and remainder r // function eGCD_(x,y,d,a,b) //sets a,b,d to positive big integers such that d = GCD_(x,y) = a*x-b*y // function inverseMod_(x,n) //do x=x**(-1) mod n, for bigInts x and n. Returns 1 (0) if inverse does (doesn't) exist // function inverseModInt_(x,n) //return x**(-1) mod n, for integers x and n. Return 0 if there is no inverse // function leftShift_(x,n) //left shift bigInt x by n bits. n<bpe. // function linComb_(x,y,a,b) //do x=a*x+b*y for bigInts x and y and integers a and b // function linCombShift_(x,y,b,ys) //do x=x+b*(y<<(ys*bpe)) for bigInts x and y, and integers b and ys // function mont_(x,y,n,np) //Montgomery multiplication (see comments where the function is defined) // function mult_(x,y) //do x=x*y for bigInts x and y. // function multInt_(x,n) //do x=x*n where x is a bigInt and n is an integer. // function multMod_(x,y,n) //do x=x*y mod n for bigInts x,y,n. // function powMod_(x,y,n) //do x=x**y mod n, where x,y,n are bigInts (n is odd) and ** is exponentiation. 0**0=1. // function randBigInt_(b,n,s) //do b = an n-bit random BigInt. if s=1, then nth bit (most significant bit) is set to 1. n>=1. // function randTruePrime_(ans,k) //do ans = a random k-bit true random prime (not just probable prime) with 1 in the msb. // function squareMod_(x,n) //do x=x*x mod n for bigInts x,n // function sub_(x,y) //do x=x-y for bigInts x and y. Negative answers will be 2s complement. // function subShift_(x,y,ys) //do x=x-(y<<(ys*bpe)). Negative answers will be 2s complement. // // The following functions are based on algorithms from the _Handbook of Applied Cryptography_ // powMod_() = algorithm 14.94, Montgomery exponentiation // eGCD_,inverseMod_() = algorithm 14.61, Binary extended GCD_ // GCD_() = algorothm 14.57, Lehmer's algorithm // mont_() = algorithm 14.36, Montgomery multiplication // divide_() = algorithm 14.20 Multiple-precision division // squareMod_() = algorithm 14.16 Multiple-precision squaring // randTruePrime_() = algorithm 4.62, Maurer's algorithm // millerRabin() = algorithm 4.24, Miller-Rabin algorithm // // Profiling shows: // randTruePrime_() spends: // 10% of its time in calls to powMod_() // 85% of its time in calls to millerRabin() // millerRabin() spends: // 99% of its time in calls to powMod_() (always with a base of 2) // powMod_() spends: // 94% of its time in calls to mont_() (almost always with x==y) // // This suggests there are several ways to speed up this library slightly: // - convert powMod_ to use a Montgomery form of k-ary window (or maybe a Montgomery form of sliding window) // -- this should especially focus on being fast when raising 2 to a power mod n // - convert randTruePrime_() to use a minimum r of 1/3 instead of 1/2 with the appropriate change to the test // - tune the parameters in randTruePrime_(), including c, m, and recLimit // - speed up the single loop in mont_() that takes 95% of the runtime, perhaps by reducing checking // within the loop when all the parameters are the same length. // // There are several ideas that look like they wouldn't help much at all: // - replacing trial division in randTruePrime_() with a sieve (that speeds up something taking almost no time anyway) // - increase bpe from 15 to 30 (that would help if we had a 32*32->64 multiplier, but not with JavaScript's 32*32->32) // - speeding up mont_(x,y,n,np) when x==y by doing a non-modular, non-Montgomery square // followed by a Montgomery reduction. The intermediate answer will be twice as long as x, so that // method would be slower. This is unfortunate because the code currently spends almost all of its time // doing mont_(x,x,...), both for randTruePrime_() and powMod_(). A faster method for Montgomery squaring // would have a large impact on the speed of randTruePrime_() and powMod_(). HAC has a couple of poorly-worded // sentences that seem to imply it's faster to do a non-modular square followed by a single // Montgomery reduction, but that's obviously wrong. //////////////////////////////////////////////////////////////////////////////////////// // // The whole library has been moved into the Baird.Crypto.BigInt scope by Giulio Cesare Solaroli <giulio.cesare@clipperz.com> // Baird.Crypto.BigInt.VERSION = "5.0"; Baird.Crypto.BigInt.NAME = "Baird.Crypto.BigInt"; MochiKit.Base.update(Baird.Crypto.BigInt, { //globals 'bpe': 0, //bits stored per array element 'mask': 0, //AND this with an array element to chop it down to bpe bits 'radix': Baird.Crypto.BigInt.mask + 1, //equals 2^bpe. A single 1 bit to the left of the last bit of mask. //the digits for converting to different bases 'digitsStr': '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_=!@#$%^&*()[]{}|;:,.<>/?`~ \\\'\"+-', //initialize the global variables for (bpe=0; (1<<(bpe+1)) > (1<<bpe); bpe++); //bpe=number of bits in the mantissa on this platform bpe>>=1; //bpe=number of bits in one element of the array representing the bigInt mask=(1<<bpe)-1; //AND the mask with an integer to get its bpe least significant bits radix=mask+1; //2^bpe. a single 1 bit to the left of the first bit of mask one=int2bigInt(1,1,1); //constant used in powMod_() //the following global variables are scratchpad memory to //reduce dynamic memory allocation in the inner loop t=new Array(0); ss=t; //used in mult_() s0=t; //used in multMod_(), squareMod_() s1=t; //used in powMod_(), multMod_(), squareMod_() s2=t; //used in powMod_(), multMod_() s3=t; //used in powMod_() s4=t; s5=t; //used in mod_() s6=t; //used in bigInt2str() s7=t; //used in powMod_() T=t; //used in GCD_() sa=t; //used in mont_() mr_x1=t; mr_r=t; mr_a=t; //used in millerRabin() eg_v=t; eg_u=t; eg_A=t; eg_B=t; eg_C=t; eg_D=t; //used in eGCD_(), inverseMod_() md_q1=t; md_q2=t; md_q3=t; md_r=t; md_r1=t; md_r2=t; md_tt=t; //used in mod_() primes=t; pows=t; s_i=t; s_i2=t; s_R=t; s_rm=t; s_q=t; s_n1=t; s_a=t; s_r2=t; s_n=t; s_b=t; s_d=t; s_x1=t; s_x2=t, s_aa=t; //used in randTruePrime_() //////////////////////////////////////////////////////////////////////////////////////// //return array of all primes less than integer n 'findPrimes': function(n) { var i,s,p,ans; s=new Array(n); for (i=0;i<n;i++) s[i]=0; s[0]=2; p=0; //first p elements of s are primes, the rest are a sieve for(;s[p]<n;) { //s[p] is the pth prime for(i=s[p]*s[p]; i<n; i+=s[p]) //mark multiples of s[p] s[i]=1; p++; s[p]=s[p-1]+1; for(; s[p]<n && s[s[p]]; s[p]++); //find next prime (where s[p]==0) } ans=new Array(p); for(i=0;i<p;i++) ans[i]=s[i]; return ans; }, //does a single round of Miller-Rabin base b consider x to be a possible prime? //x is a bigInt, and b is an integer 'millerRabin': function(x,b) { var i,j,k,s; if (mr_x1.length!=x.length) { mr_x1=dup(x); mr_r=dup(x); mr_a=dup(x); } copyInt_(mr_a,b); copy_(mr_r,x); copy_(mr_x1,x); addInt_(mr_r,-1); addInt_(mr_x1,-1); //s=the highest power of two that divides mr_r k=0; for (i=0;i<mr_r.length;i++) for (j=1;j<mask;j<<=1) if (x[i] & j) { s=(k<mr_r.length+bpe ? k : 0); i=mr_r.length; j=mask; } else k++; if (s) rightShift_(mr_r,s); powMod_(mr_a,mr_r,x); if (!equalsInt(mr_a,1) && !equals(mr_a,mr_x1)) { j=1; while (j<=s-1 && !equals(mr_a,mr_x1)) { squareMod_(mr_a,x); if (equalsInt(mr_a,1)) { return 0; } j++; } if (!equals(mr_a,mr_x1)) { return 0; } } return 1; }, //returns how many bits long the bigInt is, not counting leading zeros. 'bitSize': function(x) { var j,z,w; for (j=x.length-1; (x[j]==0) && (j>0); j--); for (z=0,w=x[j]; w; (w>>=1),z++); z+=bpe*j; return z; }, //return a copy of x with at least n elements, adding leading zeros if needed 'expand': function(x,n) { var ans=int2bigInt(0,(x.length>n ? x.length : n)*bpe,0); copy_(ans,x); return ans; }, //return a k-bit true random prime using Maurer's algorithm. 'randTruePrime': function(k) { var ans=int2bigInt(0,k,0); randTruePrime_(ans,k); return trim(ans,1); }, //return a new bigInt equal to (x mod n) for bigInts x and n. 'mod': function(x,n) { var ans=dup(x); mod_(ans,n); return trim(ans,1); }, //return (x+n) where x is a bigInt and n is an integer. 'addInt': function(x,n) { var ans=expand(x,x.length+1); addInt_(ans,n); return trim(ans,1); }, //return x*y for bigInts x and y. This is faster when y<x. 'mult': function(x,y) { var ans=expand(x,x.length+y.length); mult_(ans,y); return trim(ans,1); }, //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. 'powMod': function(x,y,n) { var ans=expand(x,n.length); powMod_(ans,trim(y,2),trim(n,2),0); //this should work without the trim, but doesn't return trim(ans,1); }, //return (x-y) for bigInts x and y. Negative answers will be 2s complement 'sub': function(x,y) { var ans=expand(x,(x.length>y.length ? x.length+1 : y.length+1)); sub_(ans,y); return trim(ans,1); }, //return (x+y) for bigInts x and y. 'add': function(x,y) { var ans=expand(x,(x.length>y.length ? x.length+1 : y.length+1)); add_(ans,y); return trim(ans,1); }, //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null 'inverseMod': function(x,n) { var ans=expand(x,n.length); var s; s=inverseMod_(ans,n); return s ? trim(ans,1) : null; }, //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. 'multMod': function(x,y,n) { var ans=expand(x,n.length); multMod_(ans,y,n); return trim(ans,1); }, //generate a k-bit true random prime using Maurer's algorithm, //and put it into ans. The bigInt ans must be large enough to hold it. 'randTruePrime_': function(ans,k) { var c,m,pm,dd,j,r,B,divisible,z,zz,recSize; if (primes.length==0) primes=findPrimes(30000); //check for divisibility by primes <=30000 if (pows.length==0) { pows=new Array(512); for (j=0;j<512;j++) { pows[j]=Math.pow(2,j/511.-1.); } } //c and m should be tuned for a particular machine and value of k, to maximize speed //this was: c=primes[primes.length-1]/k/k; //check using all the small primes. (c=0.1 in HAC) c=0.1; m=20; //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits recLimit=20; /*must be at least 2 (was 29)*/ //stop recursion when k <=recLimit if (s_i2.length!=ans.length) { s_i2=dup(ans); s_R =dup(ans); s_n1=dup(ans); s_r2=dup(ans); s_d =dup(ans); s_x1=dup(ans); s_x2=dup(ans); s_b =dup(ans); s_n =dup(ans); s_i =dup(ans); s_rm=dup(ans); s_q =dup(ans); s_a =dup(ans); s_aa=dup(ans); } if (k <= recLimit) { //generate small random primes by trial division up to its square root pm=(1<<((k+2)>>1))-1; //pm is binary number with all ones, just over sqrt(2^k) copyInt_(ans,0); for (dd=1;dd;) { dd=0; ans[0]= 1 | (1<<(k-1)) | Math.floor(Math.random()*(1<<k)); //random, k-bit, odd integer, with msb 1 for (j=1;(j<primes.length) && ((primes[j]&pm)==primes[j]);j++) { //trial division by all primes 3...sqrt(2^k) if (0==(ans[0]%primes[j])) { dd=1; break; } } } carry_(ans); return; } B=c*k*k; //try small primes up to B (or all the primes[] array if the largest is less than B). if (k>2*m) //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits for (r=1; k-k*r<=m; ) r=pows[Math.floor(Math.random()*512)]; //r=Math.pow(2,Math.random()-1); else r=.5; //simulation suggests the more complex algorithm using r=.333 is only slightly faster. recSize=Math.floor(r*k)+1; randTruePrime_(s_q,recSize); copyInt_(s_i2,0); s_i2[Math.floor((k-2)/bpe)] |= (1<<((k-2)%bpe)); //s_i2=2^(k-2) divide_(s_i2,s_q,s_i,s_rm); //s_i=floor((2^(k-1))/(2q)) z=bitSize(s_i); for (;;) { for (;;) { //generate z-bit numbers until one falls in the range [0,s_i-1] randBigInt_(s_R,z,0); if (greater(s_i,s_R)) break; } //now s_R is in the range [0,s_i-1] addInt_(s_R,1); //now s_R is in the range [1,s_i] add_(s_R,s_i); //now s_R is in the range [s_i+1,2*s_i] copy_(s_n,s_q); mult_(s_n,s_R); multInt_(s_n,2); addInt_(s_n,1); //s_n=2*s_R*s_q+1 copy_(s_r2,s_R); multInt_(s_r2,2); //s_r2=2*s_R //check s_n for divisibility by small primes up to B for (divisible=0,j=0; (j<primes.length) && (primes[j]<B); j++) if (modInt(s_n,primes[j])==0) { divisible=1; break; } if (!divisible) //if it passes small primes check, then try a single Miller-Rabin base 2 if (!millerRabin(s_n,2)) //this line represents 75% of the total runtime for randTruePrime_ divisible=1; if (!divisible) { //if it passes that test, continue checking s_n addInt_(s_n,-3); for (j=s_n.length-1;(s_n[j]==0) && (j>0); j--); //strip leading zeros for (zz=0,w=s_n[j]; w; (w>>=1),zz++); zz+=bpe*j; //zz=number of bits in s_n, ignoring leading zeros for (;;) { //generate z-bit numbers until one falls in the range [0,s_n-1] randBigInt_(s_a,zz,0); if (greater(s_n,s_a)) break; } //now s_a is in the range [0,s_n-1] addInt_(s_n,3); //now s_a is in the range [0,s_n-4] addInt_(s_a,2); //now s_a is in the range [2,s_n-2] copy_(s_b,s_a); copy_(s_n1,s_n); addInt_(s_n1,-1); powMod_(s_b,s_n1,s_n); //s_b=s_a^(s_n-1) modulo s_n addInt_(s_b,-1); if (isZero(s_b)) { copy_(s_b,s_a); powMod_(s_b,s_r2,s_n); addInt_(s_b,-1); copy_(s_aa,s_n); copy_(s_d,s_b); GCD_(s_d,s_n); //if s_b and s_n are relatively prime, then s_n is a prime if (equalsInt(s_d,1)) { copy_(ans,s_aa); return; //if we've made it this far, then s_n is absolutely guaranteed to be prime } } } } }, //set b to an n-bit random BigInt. If s=1, then nth bit (most significant bit) is set to 1. //array b must be big enough to hold the result. Must have n>=1 'randBigInt_': function(b,n,s) { var i,a; for (i=0;i<b.length;i++) b[i]=0; a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt for (i=0;i<a;i++) { b[i]=Math.floor(Math.random()*(1<<(bpe-1))); } b[a-1] &= (2<<((n-1)%bpe))-1; if (s) b[a-1] |= (1<<((n-1)%bpe)); }, //set x to the greatest common divisor of x and y. //x,y are bigInts with the same number of elements. y is destroyed. 'GCD_': function(x,y) { var i,xp,yp,A,B,C,D,q,sing; if (T.length!=x.length) diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js index 19f19c2..0d76b9c 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Curve.js @@ -1,547 +1,500 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; //} if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } Clipperz.Crypto.ECC.BinaryField.Curve = function(args) { args = args || {}; this._modulus = args.modulus; this._a = args.a; this._b = args.b; this._G = args.G; this._r = args.r; this._h = args.h; this._finiteField = null; return this; } Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { 'asString': function() { return "Clipperz.Crypto.ECC.BinaryField.Curve"; }, //----------------------------------------------------------------------------- 'modulus': function() { return this._modulus; }, 'a': function() { return this._a; }, 'b': function() { return this._b; }, 'G': function() { return this._G; }, 'r': function() { return this._r; }, 'h': function() { return this._h; }, //----------------------------------------------------------------------------- 'finiteField': function() { if (this._finiteField == null) { this._finiteField = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:this.modulus()}) } return this._finiteField; }, //----------------------------------------------------------------------------- 'negate': function(aPointA) { var result; result = new Clipperz.Crypto.ECC.Point({x:aPointA.x(), y:this.finiteField().add(aPointA.y(), aPointA.x())}) return result; }, //----------------------------------------------------------------------------- 'add': function(aPointA, aPointB) { var result; -//console.log(">>> ECC.BinaryField.Curve.add"); if (aPointA.isZero()) { -//console.log("--- pointA == zero"); result = aPointB; } else if (aPointB.isZero()) { -//console.log("--- pointB == zero"); result = aPointA; } else if ( (aPointA.x().compare(aPointB.x()) == 0) && ((aPointA.y().compare(aPointB.y()) != 0) || aPointB.x().isZero())) { -//console.log("compare A.x - B.x: ", aPointA.x().compare(aPointB.x())); -//console.log("compare A.y - B.y: ", (aPointA.y().compare(aPointB.y()) != 0)); -//console.log("compare B.x.isZero(): ", aPointB.x().isZero()); - -//console.log("--- result = zero"); result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); } else { -//console.log("--- result = ELSE"); var f2m; var x, y; var lambda; var aX, aY, bX, bY; aX = aPointA.x()._value; aY = aPointA.y()._value; bX = aPointB.x()._value; bY = aPointB.y()._value; f2m = this.finiteField(); if (aPointA.x().compare(aPointB.x()) != 0) { -//console.log(" a.x != b.x"); lambda = f2m._fastMultiply( f2m._add(aY, bY), f2m._inverse(f2m._add(aX, bX)) ); x = f2m._add(this.a()._value, f2m._square(lambda)); f2m._overwriteAdd(x, lambda); f2m._overwriteAdd(x, aX); f2m._overwriteAdd(x, bX); } else { -//console.log(" a.x == b.x"); lambda = f2m._add(bX, f2m._fastMultiply(bY, f2m._inverse(bX))); -//console.log(" lambda: " + lambda.asString(16)); x = f2m._add(this.a()._value, f2m._square(lambda)); -//console.log(" x (step 1): " + x.asString(16)); f2m._overwriteAdd(x, lambda); -//console.log(" x (step 2): " + x.asString(16)); } y = f2m._fastMultiply(f2m._add(bX, x), lambda); -//console.log(" y (step 1): " + y.asString(16)); f2m._overwriteAdd(y, x); -//console.log(" y (step 2): " + y.asString(16)); f2m._overwriteAdd(y, bY); -//console.log(" y (step 3): " + y.asString(16)); result = new Clipperz.Crypto.ECC.BinaryField.Point({x:new Clipperz.Crypto.ECC.BinaryField.Value(x), y:new Clipperz.Crypto.ECC.BinaryField.Value(y)}) } -//console.log("<<< ECC.BinaryField.Curve.add"); return result; }, //----------------------------------------------------------------------------- 'addTwice': function(aPointA) { return this.add(aPointA, aPointA); }, //----------------------------------------------------------------------------- 'overwriteAdd': function(aPointA, aPointB) { if (aPointA.isZero()) { // result = aPointB; aPointA._x._value = aPointB._x._value; aPointA._y._value = aPointB._y._value; } else if (aPointB.isZero()) { // result = aPointA; } else if ( (aPointA.x().compare(aPointB.x()) == 0) && ((aPointA.y().compare(aPointB.y()) != 0) || aPointB.x().isZero())) { // result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); aPointA._x = Clipperz.Crypto.ECC.BinaryField.Value.O; aPointA._y = Clipperz.Crypto.ECC.BinaryField.Value.O; } else { var f2m; var x, y; var lambda; var aX, aY, bX, bY; aX = aPointA.x()._value; aY = aPointA.y()._value; bX = aPointB.x()._value; bY = aPointB.y()._value; f2m = this.finiteField(); if (aPointA.x().compare(aPointB.x()) != 0) { -//console.log(" a.x != b.x"); lambda = f2m._fastMultiply( f2m._add(aY, bY), f2m._inverse(f2m._add(aX, bX)) ); x = f2m._add(this.a()._value, f2m._square(lambda)); f2m._overwriteAdd(x, lambda); f2m._overwriteAdd(x, aX); f2m._overwriteAdd(x, bX); } else { -//console.log(" a.x == b.x"); lambda = f2m._add(bX, f2m._fastMultiply(bY, f2m._inverse(bX))); -//console.log(" lambda: " + lambda.asString(16)); x = f2m._add(this.a()._value, f2m._square(lambda)); -//console.log(" x (step 1): " + x.asString(16)); f2m._overwriteAdd(x, lambda); -//console.log(" x (step 2): " + x.asString(16)); } y = f2m._fastMultiply(f2m._add(bX, x), lambda); -//console.log(" y (step 1): " + y.asString(16)); f2m._overwriteAdd(y, x); -//console.log(" y (step 2): " + y.asString(16)); f2m._overwriteAdd(y, bY); -//console.log(" y (step 3): " + y.asString(16)); // result = new Clipperz.Crypto.ECC.BinaryField.Point({x:new Clipperz.Crypto.ECC.BinaryField.Value(x), y:new Clipperz.Crypto.ECC.BinaryField.Value(y)}) aPointA._x._value = x; aPointA._y._value = y; } -//console.log("<<< ECC.BinaryField.Curve.add"); return result; }, //----------------------------------------------------------------------------- 'multiply': function(aValue, aPoint) { var result; //console.profile(); result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); if (aValue.isZero() == false) { var k, Q; var i; var countIndex; countIndex = 0; if (aValue.compare(Clipperz.Crypto.ECC.BinaryField.Value.O) > 0) { k = aValue; Q = aPoint; } else { -MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); + Clipperz.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); k = aValue.negate(); Q = this.negate(aPoint); } -//console.log("k: " + k.toString(16)); -//console.log("k.bitSize: " + k.bitSize()); for (i=k.bitSize()-1; i>=0; i--) { result = this.add(result, result); // this.overwriteAdd(result, result); if (k.isBitSet(i)) { result = this.add(result, Q); // this.overwriteAdd(result, Q); } -// if (countIndex==100) {console.log("multiply.break"); break;} else countIndex++; +// if (countIndex==100) {Clipperz.log("multiply.break"); break;} else countIndex++; } } //console.profileEnd(); return result; }, //----------------------------------------------------------------------------- 'deferredMultiply': function(aValue, aPoint) { var deferredResult; var result; -MochiKit.Logging.logDebug(">>> deferredMultiply - value: " + aValue + ", point: " + aPoint); +Clipperz.log(">>> deferredMultiply - value: " + aValue + ", point: " + aPoint); //console.profile("ECC.Curve.multiply"); deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addCallback(function(res) {console.profile("ECC.Curve.deferredMultiply"); return res;} ); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 1: " + res); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("# 1: " + res); return res;}); result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 2: " + res); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("# 2: " + res); return res;}); if (aValue.isZero() == false) { var k, Q; var i; var countIndex; countIndex = 0; if (aValue.compare(Clipperz.Crypto.ECC.BinaryField.Value.O) > 0) { k = aValue; Q = aPoint; } else { -MochiKit.Logging.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); + Clipperz.logError("The Clipperz.Crypto.ECC.BinaryFields.Value does not work with negative values!!!!"); k = aValue.negate(); Q = this.negate(aPoint); } -//console.log("k: " + k.toString(16)); -//console.log("k.bitSize: " + k.bitSize()); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 3: " + res); return res;}); for (i=k.bitSize()-1; i>=0; i--) { -//MochiKit.Logging.logDebug("====> " + i); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 4 > i = " + i + ": " + res); return res;}); deferredResult.addMethod(this, "addTwice"); //# result = this.add(result, result); // this.overwriteAdd(result, result); if (k.isBitSet(i)) { deferredResult.addMethod(this, "add", Q); //# result = this.add(result, Q); // this.overwriteAdd(result, Q); } if (i%20 == 0) {deferredResult.addCallback(MochiKit.Async.wait, 0.1);} - -// if (countIndex==100) {console.log("multiply.break"); break;} else countIndex++; -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 4 < i = " + i + ": " + res); return res;}); } -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 4: " + res); return res;}); } //#console.profileEnd(); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 5: " + res); return res;}); //deferredResult.addBoth(function(res) {console.profileEnd(); return res;}); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("# 6: " + res); return res;}); deferredResult.callback(result); //# return result; return deferredResult; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.ECC.StandardCurves = {}; MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { /* '_K571': null, 'K571': function() { if (Clipperz.Crypto.ECC.StandardCurves._K571 == null) { Clipperz.Crypto.ECC.StandardCurves._K571 = new Clipperz.Crypto.ECC.BinaryField.Curve({ modulus: new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000425', 16), a: new Clipperz.Crypto.ECC.BinaryField.Value('0', 16), b: new Clipperz.Crypto.ECC.BinaryField.Value('1', 16), G: new Clipperz.Crypto.ECC.BinaryField.Point({ x: new Clipperz.Crypto.ECC.BinaryField.Value('026eb7a8 59923fbc 82189631 f8103fe4 ac9ca297 0012d5d4 60248048 01841ca4 43709584 93b205e6 47da304d b4ceb08c bbd1ba39 494776fb 988b4717 4dca88c7 e2945283 a01c8972', 16), y: new Clipperz.Crypto.ECC.BinaryField.Value('0349dc80 7f4fbf37 4f4aeade 3bca9531 4dd58cec 9f307a54 ffc61efc 006d8a2c 9d4979c0 ac44aea7 4fbebbb9 f772aedc b620b01a 7ba7af1b 320430c8 591984f6 01cd4c14 3ef1c7a3', 16) }), r: new Clipperz.Crypto.ECC.BinaryField.Value('02000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 131850e1 f19a63e4 b391a8db 917f4138 b630d84b e5d63938 1e91deb4 5cfe778f 637c1001', 16), h: new Clipperz.Crypto.ECC.BinaryField.Value('4', 16) }); } return Clipperz.Crypto.ECC.StandardCurves._K571; }, '_K283': null, 'K283': function() { // f(z) = z^283 + z^12 + z^7 + z^5 + 1 if (Clipperz.Crypto.ECC.StandardCurves._K283 == null) { Clipperz.Crypto.ECC.StandardCurves._K283 = new Clipperz.Crypto.ECC.BinaryField.Curve({ modulus: new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16), a: new Clipperz.Crypto.ECC.BinaryField.Value('0', 16), b: new Clipperz.Crypto.ECC.BinaryField.Value('1', 16), G: new Clipperz.Crypto.ECC.BinaryField.Point({ x: new Clipperz.Crypto.ECC.BinaryField.Value('0503213f 78ca4488 3f1a3b81 62f188e5 53cd265f 23c1567a 16876913 b0c2ac24 58492836', 16), y: new Clipperz.Crypto.ECC.BinaryField.Value('01ccda38 0f1c9e31 8d90f95d 07e5426f e87e45c0 e8184698 e4596236 4e341161 77dd2259', 16) }), r: new Clipperz.Crypto.ECC.BinaryField.Value('01ffffff ffffffff ffffffff ffffffff ffffe9ae 2ed07577 265dff7f 94451e06 1e163c61', 16), h: new Clipperz.Crypto.ECC.BinaryField.Value('4', 16) }); } return Clipperz.Crypto.ECC.StandardCurves._K283; }, */ //----------------------------------------------------------------------------- '_B571': null, 'B571': function() { // f(z) = z^571 + z^10 + z^5 + z^2 + 1 if (Clipperz.Crypto.ECC.StandardCurves._B571 == null) { Clipperz.Crypto.ECC.StandardCurves._B571 = new Clipperz.Crypto.ECC.BinaryField.Curve({ modulus: new Clipperz.Crypto.ECC.BinaryField.Value('80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425', 16), a: new Clipperz.Crypto.ECC.BinaryField.Value('1', 16), b: new Clipperz.Crypto.ECC.BinaryField.Value('02f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a', 16), G: new Clipperz.Crypto.ECC.BinaryField.Point({ x: new Clipperz.Crypto.ECC.BinaryField.Value('0303001d 34b85629 6c16c0d4 0d3cd775 0a93d1d2 955fa80a a5f40fc8 db7b2abd bde53950 f4c0d293 cdd711a3 5b67fb14 99ae6003 8614f139 4abfa3b4 c850d927 e1e7769c 8eec2d19', 16), y: new Clipperz.Crypto.ECC.BinaryField.Value('037bf273 42da639b 6dccfffe b73d69d7 8c6c27a6 009cbbca 1980f853 3921e8a6 84423e43 bab08a57 6291af8f 461bb2a8 b3531d2f 0485c19b 16e2f151 6e23dd3c 1a4827af 1b8ac15b', 16) }), r: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff e661ce18 ff559873 08059b18 6823851e c7dd9ca1 161de93d 5174d66e 8382e9bb 2fe84e47', 16), h: new Clipperz.Crypto.ECC.BinaryField.Value('2', 16) // S: new Clipperz.Crypto.ECC.BinaryField.Value('2aa058f73a0e33ab486b0f610410c53a7f132310', 10), // n: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47', 16) }); //----------------------------------------------------------------------------- // // Guide to Elliptic Curve Cryptography // Darrel Hankerson, Alfred Menezes, Scott Vanstone // - Pag: 56, Alorithm 2.45 (with a typo!!!) // //----------------------------------------------------------------------------- // // http://www.milw0rm.com/papers/136 // // ------------------------------------------------------------------------- // Polynomial Reduction Algorithm Modulo f571 // ------------------------------------------------------------------------- // // Input: Polynomial p(x) of degree 1140 or less, stored as // an array of 2T machinewords. // Output: p(x) mod f571(x) // // FOR i = T-1, ..., 0 DO // SET X := P[i+T] // P[i] := P[i] ^ (X<<5) ^ (X<<7) ^ (X<<10) ^ (X<<15) // P[i+1] := P[i+1] ^ (X>>17) ^ (X>>22) ^ (X>>25) ^ (X>>27) // // SET X := P[T-1] >> 27 // P[0] := P[0] ^ X ^ (X<<2) ^ (X<<5) ^ (X<<10) // P[T-1] := P[T-1] & 0x07ffffff // // RETURN P[T-1],...,P[0] // // ------------------------------------------------------------------------- // Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().slowModule = Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().module; Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().module = function(aValue) { var result; if (aValue.bitSize() > 1140) { - MochiKit.Logging.logWarning("ECC.StandarCurves.B571.finiteField().module: falling back to default implementation"); + Clipperz.logWarning("ECC.StandarCurves.B571.finiteField().module: falling back to default implementation"); result = Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().slowModule(aValue); } else { var C, T; var i; -//console.log(">>> binaryField.finiteField.(improved)module"); -// C = aValue.value().slice(0); C = aValue._value.slice(0); for (i=35; i>=18; i--) { T = C[i]; C[i-18] = (((C[i-18] ^ (T<<5) ^ (T<<7) ^ (T<<10) ^ (T<<15)) & 0xffffffff) >>> 0); C[i-17] = ((C[i-17] ^ (T>>>27) ^ (T>>>25) ^ (T>>>22) ^ (T>>>17)) >>> 0); } T = (C[17] >>> 27); C[0] = ((C[0] ^ T ^ ((T<<2) ^ (T<<5) ^ (T<<10)) & 0xffffffff) >>> 0); C[17] = (C[17] & 0x07ffffff); for(i=18; i<=35; i++) { C[i] = 0; } result = new Clipperz.Crypto.ECC.BinaryField.Value(C); -//console.log("<<< binaryField.finiteField.(improved)module"); } return result; }; } return Clipperz.Crypto.ECC.StandardCurves._B571; }, //----------------------------------------------------------------------------- '_B283': null, 'B283': function() { // f(z) = z^283 + z^12 + z^7 + z^5 + 1 if (Clipperz.Crypto.ECC.StandardCurves._B283 == null) { Clipperz.Crypto.ECC.StandardCurves._B283 = new Clipperz.Crypto.ECC.BinaryField.Curve({ // modulus: new Clipperz.Crypto.ECC.BinaryField.Value('10000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16), modulus: new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16), a: new Clipperz.Crypto.ECC.BinaryField.Value('1', 16), b: new Clipperz.Crypto.ECC.BinaryField.Value('027b680a c8b8596d a5a4af8a 19a0303f ca97fd76 45309fa2 a581485a f6263e31 3b79a2f5', 16), G: new Clipperz.Crypto.ECC.BinaryField.Point({ x: new Clipperz.Crypto.ECC.BinaryField.Value('05f93925 8db7dd90 e1934f8c 70b0dfec 2eed25b8 557eac9c 80e2e198 f8cdbecd 86b12053', 16), y: new Clipperz.Crypto.ECC.BinaryField.Value('03676854 fe24141c b98fe6d4 b20d02b4 516ff702 350eddb0 826779c8 13f0df45 be8112f4', 16) }), r: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffff ffffffff ffffffff ffffffff ffffef90 399660fc 938a9016 5b042a7c efadb307', 16), h: new Clipperz.Crypto.ECC.BinaryField.Value('2', 16) // S: new Clipperz.Crypto.ECC.BinaryField.Value('2aa058f73a0e33ab486b0f610410c53a7f132310', 10), // n: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47', 16) }); //----------------------------------------------------------------------------- // // Guide to Elliptic Curve Cryptography // Darrel Hankerson, Alfred Menezes, Scott Vanstone // - Pag: 56, Alorithm 2.43 // //----------------------------------------------------------------------------- Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().slowModule = Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().module; Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().module = function(aValue) { var result; if (aValue.bitSize() > 564) { - MochiKit.Logging.logWarning("ECC.StandarCurves.B283.finiteField().module: falling back to default implementation"); + Clipperz.logWarning("ECC.StandarCurves.B283.finiteField().module: falling back to default implementation"); result = Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().slowModule(aValue); } else { var C, T; var i; -//console.log(">>> binaryField.finiteField.(improved)module"); C = aValue._value.slice(0); for (i=17; i>=9; i--) { T = C[i]; C[i-9] = (((C[i-9] ^ (T<<5) ^ (T<<10) ^ (T<<12) ^ (T<<17)) & 0xffffffff) >>> 0); C[i-8] = ((C[i-8] ^ (T>>>27) ^ (T>>>22) ^ (T>>>20) ^ (T>>>15)) >>> 0); } T = (C[8] >>> 27); C[0] = ((C[0] ^ T ^ ((T<<5) ^ (T<<7) ^ (T<<12)) & 0xffffffff) >>> 0); C[8] = (C[8] & 0x07ffffff); for(i=9; i<=17; i++) { C[i] = 0; } result = new Clipperz.Crypto.ECC.BinaryField.Value(C); -//console.log("<<< binaryField.finiteField.(improved)module"); } return result; }; } return Clipperz.Crypto.ECC.StandardCurves._B283; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js index 56f257a..7b7c2c6 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js @@ -1,523 +1,519 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; //} if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } Clipperz.Crypto.ECC.BinaryField.FiniteField = function(args) { args = args || {}; this._modulus = args.modulus; return this; } Clipperz.Crypto.ECC.BinaryField.FiniteField.prototype = MochiKit.Base.update(null, { 'asString': function() { return "Clipperz.Crypto.ECC.BinaryField.FiniteField (" + this.modulus().asString() + ")"; }, //----------------------------------------------------------------------------- 'modulus': function() { return this._modulus; }, //----------------------------------------------------------------------------- '_module': function(aValue) { var result; var modulusComparison; -//console.log(">>> binaryField.finiteField.(standard)module"); modulusComparison = Clipperz.Crypto.ECC.BinaryField.Value._compare(aValue, this.modulus()._value); if (modulusComparison < 0) { result = aValue; } else if (modulusComparison == 0) { result = [0]; } else { var modulusBitSize; var resultBitSize; result = aValue; modulusBitSize = this.modulus().bitSize(); resultBitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(result); while (resultBitSize >= modulusBitSize) { Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(this.modulus()._value, resultBitSize - modulusBitSize)); resultBitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(result); } } -//console.log("<<< binaryField.finiteField.(standard)module"); - + return result; }, 'module': function(aValue) { return new Clipperz.Crypto.ECC.BinaryField.Value(this._module(aValue._value.slice(0))); }, //----------------------------------------------------------------------------- '_add': function(a, b) { return Clipperz.Crypto.ECC.BinaryField.Value._xor(a, b); }, '_overwriteAdd': function(a, b) { Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(a, b); }, 'add': function(a, b) { return new Clipperz.Crypto.ECC.BinaryField.Value(this._add(a._value, b._value)); }, //----------------------------------------------------------------------------- 'negate': function(aValue) { return aValue.clone(); }, //----------------------------------------------------------------------------- '_multiply': function(a, b) { var result; var valueToXor; var i,c; result = [0]; valueToXor = b; c = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(a); for (i=0; i<c; i++) { if (Clipperz.Crypto.ECC.BinaryField.Value._isBitSet(a, i) === true) { Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, valueToXor); } valueToXor = Clipperz.Crypto.ECC.BinaryField.Value._overwriteShiftLeft(valueToXor, 1); } result = this._module(result); return result; }, 'multiply': function(a, b) { return new Clipperz.Crypto.ECC.BinaryField.Value(this._multiply(a._value, b._value)); }, //----------------------------------------------------------------------------- '_fastMultiply': function(a, b) { var result; var B; var i,c; result = [0]; B = b.slice(0); // Is this array copy avoidable? c = 32; for (i=0; i<c; i++) { var ii, cc; cc = a.length; for (ii=0; ii<cc; ii++) { if (((a[ii] >>> i) & 0x01) == 1) { Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, B, ii); } } if (i < (c-1)) { B = Clipperz.Crypto.ECC.BinaryField.Value._overwriteShiftLeft(B, 1); } } result = this._module(result); return result; }, 'fastMultiply': function(a, b) { return new Clipperz.Crypto.ECC.BinaryField.Value(this._fastMultiply(a._value, b._value)); }, //----------------------------------------------------------------------------- // // Guide to Elliptic Curve Cryptography // Darrel Hankerson, Alfred Menezes, Scott Vanstone // - Pag: 49, Alorithm 2.34 // //----------------------------------------------------------------------------- '_square': function(aValue) { var result; var value; var c,i; var precomputedValues; value = aValue; result = new Array(value.length * 2); precomputedValues = Clipperz.Crypto.ECC.BinaryField.FiniteField.squarePrecomputedBytes; c = value.length; for (i=0; i<c; i++) { result[i*2] = precomputedValues[(value[i] & 0x000000ff)]; result[i*2] |= ((precomputedValues[(value[i] & 0x0000ff00) >>> 8]) << 16); result[i*2 + 1] = precomputedValues[(value[i] & 0x00ff0000) >>> 16]; result[i*2 + 1] |= ((precomputedValues[(value[i] & 0xff000000) >>> 24]) << 16); } return this._module(result); }, 'square': function(aValue) { return new Clipperz.Crypto.ECC.BinaryField.Value(this._square(aValue._value)); }, //----------------------------------------------------------------------------- '_inverse': function(aValue) { var result; var b, c; var u, v; // b = Clipperz.Crypto.ECC.BinaryField.Value.I._value; b = [1]; // c = Clipperz.Crypto.ECC.BinaryField.Value.O._value; c = [0]; u = this._module(aValue); v = this.modulus()._value.slice(0); while (Clipperz.Crypto.ECC.BinaryField.Value._bitSize(u) > 1) { var bitDifferenceSize; bitDifferenceSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(u) - Clipperz.Crypto.ECC.BinaryField.Value._bitSize(v); if (bitDifferenceSize < 0) { var swap; swap = u; u = v; v = swap; swap = c; c = b; b = swap; bitDifferenceSize = -bitDifferenceSize; } u = this._add(u, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(v, bitDifferenceSize)); b = this._add(b, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(c, bitDifferenceSize)); // this._overwriteAdd(u, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(v, bitDifferenceSize)); // this._overwriteAdd(b, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(c, bitDifferenceSize)); } result = this._module(b); return result; }, 'inverse': function(aValue) { return new Clipperz.Crypto.ECC.BinaryField.Value(this._inverse(aValue._value)); }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.Crypto.ECC.BinaryField.FiniteField.squarePrecomputedBytes = [ 0x0000, // 0 = 0000 0000 -> 0000 0000 0000 0000 0x0001, // 1 = 0000 0001 -> 0000 0000 0000 0001 0x0004, // 2 = 0000 0010 -> 0000 0000 0000 0100 0x0005, // 3 = 0000 0011 -> 0000 0000 0000 0101 0x0010, // 4 = 0000 0100 -> 0000 0000 0001 0000 0x0011, // 5 = 0000 0101 -> 0000 0000 0001 0001 0x0014, // 6 = 0000 0110 -> 0000 0000 0001 0100 0x0015, // 7 = 0000 0111 -> 0000 0000 0001 0101 0x0040, // 8 = 0000 1000 -> 0000 0000 0100 0000 0x0041, // 9 = 0000 1001 -> 0000 0000 0100 0001 0x0044, // 10 = 0000 1010 -> 0000 0000 0100 0100 0x0045, // 11 = 0000 1011 -> 0000 0000 0100 0101 0x0050, // 12 = 0000 1100 -> 0000 0000 0101 0000 0x0051, // 13 = 0000 1101 -> 0000 0000 0101 0001 0x0054, // 14 = 0000 1110 -> 0000 0000 0101 0100 0x0055, // 15 = 0000 1111 -> 0000 0000 0101 0101 0x0100, // 16 = 0001 0000 -> 0000 0001 0000 0000 0x0101, // 17 = 0001 0001 -> 0000 0001 0000 0001 0x0104, // 18 = 0001 0010 -> 0000 0001 0000 0100 0x0105, // 19 = 0001 0011 -> 0000 0001 0000 0101 0x0110, // 20 = 0001 0100 -> 0000 0001 0001 0000 0x0111, // 21 = 0001 0101 -> 0000 0001 0001 0001 0x0114, // 22 = 0001 0110 -> 0000 0001 0001 0100 0x0115, // 23 = 0001 0111 -> 0000 0001 0001 0101 0x0140, // 24 = 0001 1000 -> 0000 0001 0100 0000 0x0141, // 25 = 0001 1001 -> 0000 0001 0100 0001 0x0144, // 26 = 0001 1010 -> 0000 0001 0100 0100 0x0145, // 27 = 0001 1011 -> 0000 0001 0100 0101 0x0150, // 28 = 0001 1100 -> 0000 0001 0101 0000 0x0151, // 28 = 0001 1101 -> 0000 0001 0101 0001 0x0154, // 30 = 0001 1110 -> 0000 0001 0101 0100 0x0155, // 31 = 0001 1111 -> 0000 0001 0101 0101 0x0400, // 32 = 0010 0000 -> 0000 0100 0000 0000 0x0401, // 33 = 0010 0001 -> 0000 0100 0000 0001 0x0404, // 34 = 0010 0010 -> 0000 0100 0000 0100 0x0405, // 35 = 0010 0011 -> 0000 0100 0000 0101 0x0410, // 36 = 0010 0100 -> 0000 0100 0001 0000 0x0411, // 37 = 0010 0101 -> 0000 0100 0001 0001 0x0414, // 38 = 0010 0110 -> 0000 0100 0001 0100 0x0415, // 39 = 0010 0111 -> 0000 0100 0001 0101 0x0440, // 40 = 0010 1000 -> 0000 0100 0100 0000 0x0441, // 41 = 0010 1001 -> 0000 0100 0100 0001 0x0444, // 42 = 0010 1010 -> 0000 0100 0100 0100 0x0445, // 43 = 0010 1011 -> 0000 0100 0100 0101 0x0450, // 44 = 0010 1100 -> 0000 0100 0101 0000 0x0451, // 45 = 0010 1101 -> 0000 0100 0101 0001 0x0454, // 46 = 0010 1110 -> 0000 0100 0101 0100 0x0455, // 47 = 0010 1111 -> 0000 0100 0101 0101 0x0500, // 48 = 0011 0000 -> 0000 0101 0000 0000 0x0501, // 49 = 0011 0001 -> 0000 0101 0000 0001 0x0504, // 50 = 0011 0010 -> 0000 0101 0000 0100 0x0505, // 51 = 0011 0011 -> 0000 0101 0000 0101 0x0510, // 52 = 0011 0100 -> 0000 0101 0001 0000 0x0511, // 53 = 0011 0101 -> 0000 0101 0001 0001 0x0514, // 54 = 0011 0110 -> 0000 0101 0001 0100 0x0515, // 55 = 0011 0111 -> 0000 0101 0001 0101 0x0540, // 56 = 0011 1000 -> 0000 0101 0100 0000 0x0541, // 57 = 0011 1001 -> 0000 0101 0100 0001 0x0544, // 58 = 0011 1010 -> 0000 0101 0100 0100 0x0545, // 59 = 0011 1011 -> 0000 0101 0100 0101 0x0550, // 60 = 0011 1100 -> 0000 0101 0101 0000 0x0551, // 61 = 0011 1101 -> 0000 0101 0101 0001 0x0554, // 62 = 0011 1110 -> 0000 0101 0101 0100 0x0555, // 63 = 0011 1111 -> 0000 0101 0101 0101 0x1000, // 64 = 0100 0000 -> 0001 0000 0000 0000 0x1001, // 65 = 0100 0001 -> 0001 0000 0000 0001 0x1004, // 66 = 0100 0010 -> 0001 0000 0000 0100 0x1005, // 67 = 0100 0011 -> 0001 0000 0000 0101 0x1010, // 68 = 0100 0100 -> 0001 0000 0001 0000 0x1011, // 69 = 0100 0101 -> 0001 0000 0001 0001 0x1014, // 70 = 0100 0110 -> 0001 0000 0001 0100 0x1015, // 71 = 0100 0111 -> 0001 0000 0001 0101 0x1040, // 72 = 0100 1000 -> 0001 0000 0100 0000 0x1041, // 73 = 0100 1001 -> 0001 0000 0100 0001 0x1044, // 74 = 0100 1010 -> 0001 0000 0100 0100 0x1045, // 75 = 0100 1011 -> 0001 0000 0100 0101 0x1050, // 76 = 0100 1100 -> 0001 0000 0101 0000 0x1051, // 77 = 0100 1101 -> 0001 0000 0101 0001 0x1054, // 78 = 0100 1110 -> 0001 0000 0101 0100 0x1055, // 79 = 0100 1111 -> 0001 0000 0101 0101 0x1100, // 80 = 0101 0000 -> 0001 0001 0000 0000 0x1101, // 81 = 0101 0001 -> 0001 0001 0000 0001 0x1104, // 82 = 0101 0010 -> 0001 0001 0000 0100 0x1105, // 83 = 0101 0011 -> 0001 0001 0000 0101 0x1110, // 84 = 0101 0100 -> 0001 0001 0001 0000 0x1111, // 85 = 0101 0101 -> 0001 0001 0001 0001 0x1114, // 86 = 0101 0110 -> 0001 0001 0001 0100 0x1115, // 87 = 0101 0111 -> 0001 0001 0001 0101 0x1140, // 88 = 0101 1000 -> 0001 0001 0100 0000 0x1141, // 89 = 0101 1001 -> 0001 0001 0100 0001 0x1144, // 90 = 0101 1010 -> 0001 0001 0100 0100 0x1145, // 91 = 0101 1011 -> 0001 0001 0100 0101 0x1150, // 92 = 0101 1100 -> 0001 0001 0101 0000 0x1151, // 93 = 0101 1101 -> 0001 0001 0101 0001 0x1154, // 94 = 0101 1110 -> 0001 0001 0101 0100 0x1155, // 95 = 0101 1111 -> 0001 0001 0101 0101 0x1400, // 96 = 0110 0000 -> 0001 0100 0000 0000 0x1401, // 97 = 0110 0001 -> 0001 0100 0000 0001 0x1404, // 98 = 0110 0010 -> 0001 0100 0000 0100 0x1405, // 99 = 0110 0011 -> 0001 0100 0000 0101 0x1410, // 100 = 0110 0100 -> 0001 0100 0001 0000 0x1411, // 101 = 0110 0101 -> 0001 0100 0001 0001 0x1414, // 102 = 0110 0110 -> 0001 0100 0001 0100 0x1415, // 103 = 0110 0111 -> 0001 0100 0001 0101 0x1440, // 104 = 0110 1000 -> 0001 0100 0100 0000 0x1441, // 105 = 0110 1001 -> 0001 0100 0100 0001 0x1444, // 106 = 0110 1010 -> 0001 0100 0100 0100 0x1445, // 107 = 0110 1011 -> 0001 0100 0100 0101 0x1450, // 108 = 0110 1100 -> 0001 0100 0101 0000 0x1451, // 109 = 0110 1101 -> 0001 0100 0101 0001 0x1454, // 110 = 0110 1110 -> 0001 0100 0101 0100 0x1455, // 111 = 0110 1111 -> 0001 0100 0101 0101 0x1500, // 112 = 0111 0000 -> 0001 0101 0000 0000 0x1501, // 113 = 0111 0001 -> 0001 0101 0000 0001 0x1504, // 114 = 0111 0010 -> 0001 0101 0000 0100 0x1505, // 115 = 0111 0011 -> 0001 0101 0000 0101 0x1510, // 116 = 0111 0100 -> 0001 0101 0001 0000 0x1511, // 117 = 0111 0101 -> 0001 0101 0001 0001 0x1514, // 118 = 0111 0110 -> 0001 0101 0001 0100 0x1515, // 119 = 0111 0111 -> 0001 0101 0001 0101 0x1540, // 120 = 0111 1000 -> 0001 0101 0100 0000 0x1541, // 121 = 0111 1001 -> 0001 0101 0100 0001 0x1544, // 122 = 0111 1010 -> 0001 0101 0100 0100 0x1545, // 123 = 0111 1011 -> 0001 0101 0100 0101 0x1550, // 124 = 0111 1100 -> 0001 0101 0101 0000 0x1551, // 125 = 0111 1101 -> 0001 0101 0101 0001 0x1554, // 126 = 0111 1110 -> 0001 0101 0101 0100 0x1555, // 127 = 0111 1111 -> 0001 0101 0101 0101 0x4000, // 128 = 1000 0000 -> 0100 0000 0000 0000 0x4001, // 129 = 1000 0001 -> 0100 0000 0000 0001 0x4004, // 130 = 1000 0010 -> 0100 0000 0000 0100 0x4005, // 131 = 1000 0011 -> 0100 0000 0000 0101 0x4010, // 132 = 1000 0100 -> 0100 0000 0001 0000 0x4011, // 133 = 1000 0101 -> 0100 0000 0001 0001 0x4014, // 134 = 1000 0110 -> 0100 0000 0001 0100 0x4015, // 135 = 1000 0111 -> 0100 0000 0001 0101 0x4040, // 136 = 1000 1000 -> 0100 0000 0100 0000 0x4041, // 137 = 1000 1001 -> 0100 0000 0100 0001 0x4044, // 138 = 1000 1010 -> 0100 0000 0100 0100 0x4045, // 139 = 1000 1011 -> 0100 0000 0100 0101 0x4050, // 140 = 1000 1100 -> 0100 0000 0101 0000 0x4051, // 141 = 1000 1101 -> 0100 0000 0101 0001 0x4054, // 142 = 1000 1110 -> 0100 0000 0101 0100 0x4055, // 143 = 1000 1111 -> 0100 0000 0101 0101 0x4100, // 144 = 1001 0000 -> 0100 0001 0000 0000 0x4101, // 145 = 1001 0001 -> 0100 0001 0000 0001 0x4104, // 146 = 1001 0010 -> 0100 0001 0000 0100 0x4105, // 147 = 1001 0011 -> 0100 0001 0000 0101 0x4110, // 148 = 1001 0100 -> 0100 0001 0001 0000 0x4111, // 149 = 1001 0101 -> 0100 0001 0001 0001 0x4114, // 150 = 1001 0110 -> 0100 0001 0001 0100 0x4115, // 151 = 1001 0111 -> 0100 0001 0001 0101 0x4140, // 152 = 1001 1000 -> 0100 0001 0100 0000 0x4141, // 153 = 1001 1001 -> 0100 0001 0100 0001 0x4144, // 154 = 1001 1010 -> 0100 0001 0100 0100 0x4145, // 155 = 1001 1011 -> 0100 0001 0100 0101 0x4150, // 156 = 1001 1100 -> 0100 0001 0101 0000 0x4151, // 157 = 1001 1101 -> 0100 0001 0101 0001 0x4154, // 158 = 1001 1110 -> 0100 0001 0101 0100 0x4155, // 159 = 1001 1111 -> 0100 0001 0101 0101 0x4400, // 160 = 1010 0000 -> 0100 0100 0000 0000 0x4401, // 161 = 1010 0001 -> 0100 0100 0000 0001 0x4404, // 162 = 1010 0010 -> 0100 0100 0000 0100 0x4405, // 163 = 1010 0011 -> 0100 0100 0000 0101 0x4410, // 164 = 1010 0100 -> 0100 0100 0001 0000 0x4411, // 165 = 1010 0101 -> 0100 0100 0001 0001 0x4414, // 166 = 1010 0110 -> 0100 0100 0001 0100 0x4415, // 167 = 1010 0111 -> 0100 0100 0001 0101 0x4440, // 168 = 1010 1000 -> 0100 0100 0100 0000 0x4441, // 169 = 1010 1001 -> 0100 0100 0100 0001 0x4444, // 170 = 1010 1010 -> 0100 0100 0100 0100 0x4445, // 171 = 1010 1011 -> 0100 0100 0100 0101 0x4450, // 172 = 1010 1100 -> 0100 0100 0101 0000 0x4451, // 173 = 1010 1101 -> 0100 0100 0101 0001 0x4454, // 174 = 1010 1110 -> 0100 0100 0101 0100 0x4455, // 175 = 1010 1111 -> 0100 0100 0101 0101 0x4500, // 176 = 1011 0000 -> 0100 0101 0000 0000 0x4501, // 177 = 1011 0001 -> 0100 0101 0000 0001 0x4504, // 178 = 1011 0010 -> 0100 0101 0000 0100 0x4505, // 179 = 1011 0011 -> 0100 0101 0000 0101 0x4510, // 180 = 1011 0100 -> 0100 0101 0001 0000 0x4511, // 181 = 1011 0101 -> 0100 0101 0001 0001 0x4514, // 182 = 1011 0110 -> 0100 0101 0001 0100 0x4515, // 183 = 1011 0111 -> 0100 0101 0001 0101 0x4540, // 184 = 1011 1000 -> 0100 0101 0100 0000 0x4541, // 185 = 1011 1001 -> 0100 0101 0100 0001 0x4544, // 186 = 1011 1010 -> 0100 0101 0100 0100 0x4545, // 187 = 1011 1011 -> 0100 0101 0100 0101 0x4550, // 188 = 1011 1100 -> 0100 0101 0101 0000 0x4551, // 189 = 1011 1101 -> 0100 0101 0101 0001 0x4554, // 190 = 1011 1110 -> 0100 0101 0101 0100 0x4555, // 191 = 1011 1111 -> 0100 0101 0101 0101 0x5000, // 192 = 1100 0000 -> 0101 0000 0000 0000 0x5001, // 193 = 1100 0001 -> 0101 0000 0000 0001 0x5004, // 194 = 1100 0010 -> 0101 0000 0000 0100 0x5005, // 195 = 1100 0011 -> 0101 0000 0000 0101 0x5010, // 196 = 1100 0100 -> 0101 0000 0001 0000 0x5011, // 197 = 1100 0101 -> 0101 0000 0001 0001 0x5014, // 198 = 1100 0110 -> 0101 0000 0001 0100 0x5015, // 199 = 1100 0111 -> 0101 0000 0001 0101 0x5040, // 200 = 1100 1000 -> 0101 0000 0100 0000 0x5041, // 201 = 1100 1001 -> 0101 0000 0100 0001 0x5044, // 202 = 1100 1010 -> 0101 0000 0100 0100 0x5045, // 203 = 1100 1011 -> 0101 0000 0100 0101 0x5050, // 204 = 1100 1100 -> 0101 0000 0101 0000 0x5051, // 205 = 1100 1101 -> 0101 0000 0101 0001 0x5054, // 206 = 1100 1110 -> 0101 0000 0101 0100 0x5055, // 207 = 1100 1111 -> 0101 0000 0101 0101 0x5100, // 208 = 1101 0000 -> 0101 0001 0000 0000 0x5101, // 209 = 1101 0001 -> 0101 0001 0000 0001 0x5104, // 210 = 1101 0010 -> 0101 0001 0000 0100 0x5105, // 211 = 1101 0011 -> 0101 0001 0000 0101 0x5110, // 212 = 1101 0100 -> 0101 0001 0001 0000 0x5111, // 213 = 1101 0101 -> 0101 0001 0001 0001 0x5114, // 214 = 1101 0110 -> 0101 0001 0001 0100 0x5115, // 215 = 1101 0111 -> 0101 0001 0001 0101 0x5140, // 216 = 1101 1000 -> 0101 0001 0100 0000 0x5141, // 217 = 1101 1001 -> 0101 0001 0100 0001 0x5144, // 218 = 1101 1010 -> 0101 0001 0100 0100 0x5145, // 219 = 1101 1011 -> 0101 0001 0100 0101 0x5150, // 220 = 1101 1100 -> 0101 0001 0101 0000 0x5151, // 221 = 1101 1101 -> 0101 0001 0101 0001 0x5154, // 222 = 1101 1110 -> 0101 0001 0101 0100 0x5155, // 223 = 1101 1111 -> 0101 0001 0101 0101 0x5400, // 224 = 1110 0000 -> 0101 0100 0000 0000 0x5401, // 225 = 1110 0001 -> 0101 0100 0000 0001 0x5404, // 226 = 1110 0010 -> 0101 0100 0000 0100 0x5405, // 227 = 1110 0011 -> 0101 0100 0000 0101 0x5410, // 228 = 1110 0100 -> 0101 0100 0001 0000 0x5411, // 229 = 1110 0101 -> 0101 0100 0001 0001 0x5414, // 230 = 1110 0110 -> 0101 0100 0001 0100 0x5415, // 231 = 1110 0111 -> 0101 0100 0001 0101 0x5440, // 232 = 1110 1000 -> 0101 0100 0100 0000 0x5441, // 233 = 1110 1001 -> 0101 0100 0100 0001 0x5444, // 234 = 1110 1010 -> 0101 0100 0100 0100 0x5445, // 235 = 1110 1011 -> 0101 0100 0100 0101 0x5450, // 236 = 1110 1100 -> 0101 0100 0101 0000 0x5451, // 237 = 1110 1101 -> 0101 0100 0101 0001 0x5454, // 238 = 1110 1110 -> 0101 0100 0101 0100 0x5455, // 239 = 1110 1111 -> 0101 0100 0101 0101 0x5500, // 240 = 1111 0000 -> 0101 0101 0000 0000 0x5501, // 241 = 1111 0001 -> 0101 0101 0000 0001 0x5504, // 242 = 1111 0010 -> 0101 0101 0000 0100 0x5505, // 243 = 1111 0011 -> 0101 0101 0000 0101 0x5510, // 244 = 1111 0100 -> 0101 0101 0001 0000 0x5511, // 245 = 1111 0101 -> 0101 0101 0001 0001 0x5514, // 246 = 1111 0110 -> 0101 0101 0001 0100 0x5515, // 247 = 1111 0111 -> 0101 0101 0001 0101 0x5540, // 248 = 1111 1000 -> 0101 0101 0100 0000 0x5541, // 249 = 1111 1001 -> 0101 0101 0100 0001 0x5544, // 250 = 1111 1010 -> 0101 0101 0100 0100 0x5545, // 251 = 1111 1011 -> 0101 0101 0100 0101 0x5550, // 252 = 1111 1100 -> 0101 0101 0101 0000 0x5551, // 253 = 1111 1101 -> 0101 0101 0101 0001 0x5554, // 254 = 1111 1110 -> 0101 0101 0101 0100 0x5555 // 255 = 1111 1111 -> 0101 0101 0101 0101 ] diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Point.js b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Point.js index ffe287b..fef3220 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Point.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Point.js @@ -1,64 +1,62 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; //} if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } Clipperz.Crypto.ECC.BinaryField.Point = function(args) { args = args || {}; this._x = args.x; this._y = args.y; return this; } Clipperz.Crypto.ECC.BinaryField.Point.prototype = MochiKit.Base.update(null, { 'asString': function() { return "Clipperz.Crypto.ECC.BinaryField.Point (" + this.x() + ", " + this.y() + ")"; }, //----------------------------------------------------------------------------- 'x': function() { return this._x; }, 'y': function() { return this._y; }, //----------------------------------------------------------------------------- 'isZero': function() { return (this.x().isZero() && this.y().isZero()) }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js index b705a20..634772a 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js @@ -1,383 +1,379 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; //} if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } Clipperz.Crypto.ECC.BinaryField.Value = function(aValue, aBase, aBitSize) { if (aValue.constructor == String) { var value; var stringLength; var numberOfWords; var i,c; if (aBase != 16) { throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; } value = aValue.replace(/ /g, ''); stringLength = value.length; numberOfWords = Math.ceil(stringLength / 8); this._value = new Array(numberOfWords); c = numberOfWords; for (i=0; i<c; i++) { var word; if (i < (c-1)) { word = parseInt(value.substr(stringLength-((i+1)*8), 8), 16); } else { word = parseInt(value.substr(0, stringLength-(i*8)), 16); } this._value[i] = word; } } else if (aValue.constructor == Array) { var itemsToCopy; itemsToCopy = aValue.length; while (aValue[itemsToCopy - 1] == 0) { itemsToCopy --; } this._value = aValue.slice(0, itemsToCopy); } else if (aValue.constructor == Number) { this._value = [aValue]; } else { // throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedConstructorValueType; } this._bitSize == aBitSize || null; return this; } Clipperz.Crypto.ECC.BinaryField.Value.prototype = MochiKit.Base.update(null, { 'value': function() { return this._value; }, //----------------------------------------------------------------------------- 'wordSize': function() { return this._value.length }, //----------------------------------------------------------------------------- 'clone': function() { return new Clipperz.Crypto.ECC.BinaryField.Value(this._value.slice(0), null, this._bitSize); }, //----------------------------------------------------------------------------- 'isZero': function() { return (this.compare(Clipperz.Crypto.ECC.BinaryField.Value.O) == 0); }, //----------------------------------------------------------------------------- 'asString': function(aBase) { var result; var i,c; if (aBase != 16) { throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; } result = ""; c = this.wordSize(); for (i=0; i<c; i++) { var wordAsString; // wordAsString = ("00000000" + this.value()[i].toString(16)); wordAsString = ("00000000" + this._value[i].toString(16)); wordAsString = wordAsString.substring(wordAsString.length - 8); result = wordAsString + result; } result = result.replace(/^(00)*/, ""); if (result == "") { result = "0"; } return result; }, //----------------------------------------------------------------------------- 'shiftLeft': function(aNumberOfBitsToShift) { // this method seems like it is never called. :-( return new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(this._value, aNumberOfBitsToShift)); }, //----------------------------------------------------------------------------- 'bitSize': function() { if (this._bitSize == null) { this._bitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(this._value); } return this._bitSize; }, //----------------------------------------------------------------------------- 'isBitSet': function(aBitPosition) { return Clipperz.Crypto.ECC.BinaryField.Value._isBitSet(this._value, aBitPosition); }, //----------------------------------------------------------------------------- 'xor': function(aValue) { return new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(this._value, aValue._value)); }, //----------------------------------------------------------------------------- 'compare': function(aValue) { return Clipperz.Crypto.ECC.BinaryField.Value._compare(this._value, aValue._value); }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.Crypto.ECC.BinaryField.Value.O = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16); Clipperz.Crypto.ECC.BinaryField.Value.I = new Clipperz.Crypto.ECC.BinaryField.Value('1', 16); Clipperz.Crypto.ECC.BinaryField.Value._xor = function(a, b, aFirstItemOffset) { var result; var resultSize; var i,c; var firstItemOffset; firstItemOffset = aFirstItemOffset || 0; resultSize = Math.max((a.length - firstItemOffset), b.length) + firstItemOffset; result = new Array(resultSize); c = firstItemOffset; for (i=0; i<c; i++) { result[i] = a[i]; } c = resultSize; for (i=firstItemOffset; i<c; i++) { result[i] = (((a[i] || 0) ^ (b[i - firstItemOffset] || 0)) >>> 0); } return result; }; Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor = function(a, b, aFirstItemOffset) { var i,c; var firstItemOffset; firstItemOffset = aFirstItemOffset || 0; c = Math.max((a.length - firstItemOffset), b.length) + firstItemOffset; for (i=firstItemOffset; i<c; i++) { a[i] = (((a[i] || 0) ^ (b[i - firstItemOffset] || 0)) >>> 0); } }; Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft = function(aWordArray, aNumberOfBitsToShift) { var numberOfWordsToShift; var numberOfBitsToShift; var result; var overflowValue; var nextOverflowValue; var i,c; numberOfWordsToShift = Math.floor(aNumberOfBitsToShift / 32); numberOfBitsToShift = aNumberOfBitsToShift % 32; result = new Array(aWordArray.length + numberOfWordsToShift); c = numberOfWordsToShift; for (i=0; i<c; i++) { result[i] = 0; } overflowValue = 0; nextOverflowValue = 0; c = aWordArray.length; for (i=0; i<c; i++) { var value; var resultWord; // value = this.value()[i]; value = aWordArray[i]; if (numberOfBitsToShift > 0) { nextOverflowValue = (value >>> (32 - numberOfBitsToShift)); value = value & (0xffffffff >>> numberOfBitsToShift); resultWord = (((value << numberOfBitsToShift) | overflowValue) >>> 0); } else { resultWord = value; } result[i+numberOfWordsToShift] = resultWord; overflowValue = nextOverflowValue; } if (overflowValue != 0) { result[aWordArray.length + numberOfWordsToShift] = overflowValue; } return result; }; Clipperz.Crypto.ECC.BinaryField.Value._overwriteShiftLeft = function(aWordArray, aNumberOfBitsToShift) { var numberOfWordsToShift; var numberOfBitsToShift; var result; var overflowValue; var i,c; numberOfWordsToShift = Math.floor(aNumberOfBitsToShift / 32); numberOfBitsToShift = aNumberOfBitsToShift % 32; result = new Array(aWordArray.length + numberOfWordsToShift); c = numberOfWordsToShift; for (i=0; i<c; i++) { result[i] = 0; } overflowValue = 0; nextOverflowValue = 0; c = aWordArray.length; for (i=0; i<c; i++) { var value; var resultWord; // value = this.value()[i]; value = aWordArray[i]; if (numberOfBitsToShift > 0) { var nextOverflowValue; nextOverflowValue = (value >>> (32 - numberOfBitsToShift)); value = value & (0xffffffff >>> numberOfBitsToShift); resultWord = (((value << numberOfBitsToShift) | overflowValue) >>> 0); } else { resultWord = value; } result[i+numberOfWordsToShift] = resultWord; overflowValue = nextOverflowValue; } if (overflowValue != 0) { result[aWordArray.length + numberOfWordsToShift] = overflowValue; } return result; }; Clipperz.Crypto.ECC.BinaryField.Value._bitSize = function(aWordArray) { var result; var notNullElements; var mostValuableWord; var matchingBitsInMostImportantWord; var mask; var i,c; notNullElements = aWordArray.length; if ((aWordArray.length == 1) && (aWordArray[0] == 0)) { result = 0; } else { notNullElements --; while((notNullElements > 0) && (aWordArray[notNullElements] == 0)) { notNullElements --; } result = notNullElements * 32; mostValuableWord = aWordArray[notNullElements]; matchingBits = 32; mask = 0x80000000; while ((matchingBits > 0) && ((mostValuableWord & mask) == 0)) { matchingBits --; mask >>>= 1; } result += matchingBits; } return result; }; Clipperz.Crypto.ECC.BinaryField.Value._isBitSet = function(aWordArray, aBitPosition) { var result; var byteIndex; var bitIndexInSelectedByte; byteIndex = Math.floor(aBitPosition / 32); bitIndexInSelectedByte = aBitPosition % 32; if (byteIndex <= aWordArray.length) { result = ((aWordArray[byteIndex] & (1 << bitIndexInSelectedByte)) != 0); } else { result = false; } return result; }; Clipperz.Crypto.ECC.BinaryField.Value._compare = function(a,b) { var result; var i,c; result = MochiKit.Base.compare(a.length, b.length); c = a.length; for (i=0; (i<c) && (result==0); i++) { -//console.log("compare[" + c + " - " + i + " - 1] " + this.value()[c-i-1] + ", " + aValue.value()[c-i-1]); -// result = MochiKit.Base.compare(this.value()[c-i-1], aValue.value()[c-i-1]); result = MochiKit.Base.compare(a[c-i-1], b[c-i-1]); } return result; }; Clipperz.Crypto.ECC.BinaryField.Value['exception']= { 'UnsupportedBase': new MochiKit.Base.NamedError("Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase"), 'UnsupportedConstructorValueType': new MochiKit.Base.NamedError("Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedConstructorValueType") }; diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/StandardCurves.js b/frontend/gamma/js/Clipperz/Crypto/ECC/StandardCurves.js index be197e3..239e264 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/StandardCurves.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/StandardCurves.js @@ -1,236 +1,229 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //try { if (typeof(Clipperz.Crypto.ECC.BinaryField.Curve) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.ECC depends on Clipperz.Crypto.ECC.BinaryField.Curve!"; //} //try { if (typeof(Clipperz.Crypto.ECC.Koblitz.Curve) == 'undefined') { throw ""; }} catch (e) { // throw "Clipperz.Crypto.ECC depends on Clipperz.Crypto.ECC.Koblitz.Curve!"; //} Clipperz.Crypto.ECC.StandardCurves = {}; MochiKit.Base.update(Clipperz.Crypto.ECC.StandardCurves, { //============================================================================== '_K571': null, 'K571': function() { // f(z) = z^571 + z^10 + z^5 + z^2 + 1 if ((Clipperz.Crypto.ECC.StandardCurves._K571 == null) && (typeof(Clipperz.Crypto.ECC.Koblitz.Curve) != 'undefined')) { Clipperz.Crypto.ECC.StandardCurves._K571 = new Clipperz.Crypto.ECC.Koblitz.Curve({ modulus: new Clipperz.Crypto.ECC.Koblitz.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000425', 16), a: new Clipperz.Crypto.ECC.Koblitz.Value('0', 16), b: new Clipperz.Crypto.ECC.Koblitz.Value('1', 16), G: new Clipperz.Crypto.ECC.Koblitz.Point({ x: new Clipperz.Crypto.ECC.Koblitz.Value('026eb7a8 59923fbc 82189631 f8103fe4 ac9ca297 0012d5d4 60248048 01841ca4 43709584 93b205e6 47da304d b4ceb08c bbd1ba39 494776fb 988b4717 4dca88c7 e2945283 a01c8972', 16), y: new Clipperz.Crypto.ECC.Koblitz.Value('0349dc80 7f4fbf37 4f4aeade 3bca9531 4dd58cec 9f307a54 ffc61efc 006d8a2c 9d4979c0 ac44aea7 4fbebbb9 f772aedc b620b01a 7ba7af1b 320430c8 591984f6 01cd4c14 3ef1c7a3', 16) }), r: new Clipperz.Crypto.ECC.Koblitz.Value('02000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 131850e1 f19a63e4 b391a8db 917f4138 b630d84b e5d63938 1e91deb4 5cfe778f 637c1001', 16), h: new Clipperz.Crypto.ECC.Koblitz.Value('4', 16), primeFactor: new Clipperz.Crypto.ECC.Koblitz.Value('02000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 131850e1 f19a63e4 b391a8db 917f4138 b630d84b e5d63938 1e91deb4 5cfe778f 637c1001', 16) }); } return Clipperz.Crypto.ECC.StandardCurves._K571; }, //----------------------------------------------------------------------------- '_K283': null, 'K283': function() { // f(z) = z^283 + z^12 + z^7 + z^5 + 1 if ((Clipperz.Crypto.ECC.StandardCurves._K283 == null) && (typeof(Clipperz.Crypto.ECC.Koblitz.Curve) != 'undefined')) { Clipperz.Crypto.ECC.StandardCurves._K283 = new Clipperz.Crypto.ECC.Koblitz.Curve({ modulus: new Clipperz.Crypto.ECC.Koblitz.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16), a: new Clipperz.Crypto.ECC.Koblitz.Value('0', 16), b: new Clipperz.Crypto.ECC.Koblitz.Value('1', 16), G: new Clipperz.Crypto.ECC.Koblitz.Point({ x: new Clipperz.Crypto.ECC.Koblitz.Value('0503213f 78ca4488 3f1a3b81 62f188e5 53cd265f 23c1567a 16876913 b0c2ac24 58492836', 16), y: new Clipperz.Crypto.ECC.Koblitz.Value('01ccda38 0f1c9e31 8d90f95d 07e5426f e87e45c0 e8184698 e4596236 4e341161 77dd2259', 16) }), r: new Clipperz.Crypto.ECC.Koblitz.Value('01ffffff ffffffff ffffffff ffffffff ffffe9ae 2ed07577 265dff7f 94451e06 1e163c61', 16), h: new Clipperz.Crypto.ECC.Koblitz.Value('4', 16), primeFactor: new Clipperz.Crypto.ECC.Koblitz.Value('01ffffff ffffffff ffffffff ffffffff ffffe9ae 2ed07577 265dff7f 94451e06 1e163c61', 16) }); } return Clipperz.Crypto.ECC.StandardCurves._K283; }, //============================================================================== '_B571': null, 'B571': function() { // f(z) = z^571 + z^10 + z^5 + z^2 + 1 if ((Clipperz.Crypto.ECC.StandardCurves._B571 == null) && (typeof(Clipperz.Crypto.ECC.BinaryField.Curve) != 'undefined')) { Clipperz.Crypto.ECC.StandardCurves._B571 = new Clipperz.Crypto.ECC.BinaryField.Curve({ modulus: new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000425', 16), a: new Clipperz.Crypto.ECC.BinaryField.Value('1', 16), b: new Clipperz.Crypto.ECC.BinaryField.Value('02f40e7e 2221f295 de297117 b7f3d62f 5c6a97ff cb8ceff1 cd6ba8ce 4a9a18ad 84ffabbd 8efa5933 2be7ad67 56a66e29 4afd185a 78ff12aa 520e4de7 39baca0c 7ffeff7f 2955727a', 16), G: new Clipperz.Crypto.ECC.BinaryField.Point({ x: new Clipperz.Crypto.ECC.BinaryField.Value('0303001d 34b85629 6c16c0d4 0d3cd775 0a93d1d2 955fa80a a5f40fc8 db7b2abd bde53950 f4c0d293 cdd711a3 5b67fb14 99ae6003 8614f139 4abfa3b4 c850d927 e1e7769c 8eec2d19', 16), y: new Clipperz.Crypto.ECC.BinaryField.Value('037bf273 42da639b 6dccfffe b73d69d7 8c6c27a6 009cbbca 1980f853 3921e8a6 84423e43 bab08a57 6291af8f 461bb2a8 b3531d2f 0485c19b 16e2f151 6e23dd3c 1a4827af 1b8ac15b', 16) }), r: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff e661ce18 ff559873 08059b18 6823851e c7dd9ca1 161de93d 5174d66e 8382e9bb 2fe84e47', 16), h: new Clipperz.Crypto.ECC.BinaryField.Value('2', 16) // S: new Clipperz.Crypto.ECC.BinaryField.Value('2aa058f73a0e33ab486b0f610410c53a7f132310', 10), // n: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47', 16) }); //----------------------------------------------------------------------------- // // Guide to Elliptic Curve Cryptography // Darrel Hankerson, Alfred Menezes, Scott Vanstone // - Pag: 56, Alorithm 2.45 (with a typo!!!) // //----------------------------------------------------------------------------- // // http://www.milw0rm.com/papers/136 // // ------------------------------------------------------------------------- // Polynomial Reduction Algorithm Modulo f571 // ------------------------------------------------------------------------- // // Input: Polynomial p(x) of degree 1140 or less, stored as // an array of 2T machinewords. // Output: p(x) mod f571(x) // // FOR i = T-1, ..., 0 DO // SET X := P[i+T] // P[i] := P[i] ^ (X<<5) ^ (X<<7) ^ (X<<10) ^ (X<<15) // P[i+1] := P[i+1] ^ (X>>17) ^ (X>>22) ^ (X>>25) ^ (X>>27) // // SET X := P[T-1] >> 27 // P[0] := P[0] ^ X ^ (X<<2) ^ (X<<5) ^ (X<<10) // P[T-1] := P[T-1] & 0x07ffffff // // RETURN P[T-1],...,P[0] // // ------------------------------------------------------------------------- // Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().slowModule = Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().module; Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().module = function(aValue) { var result; if (aValue.bitSize() > 1140) { - MochiKit.Logging.logWarning("ECC.StandarCurves.B571.finiteField().module: falling back to default implementation"); + Clipperz.logWarning("ECC.StandarCurves.B571.finiteField().module: falling back to default implementation"); result = Clipperz.Crypto.ECC.StandardCurves._B571.finiteField().slowModule(aValue); } else { var C, T; var i; -//console.log(">>> binaryField.finiteField.(improved)module"); -// C = aValue.value().slice(0); C = aValue._value.slice(0); for (i=35; i>=18; i--) { T = C[i]; C[i-18] = (((C[i-18] ^ (T<<5) ^ (T<<7) ^ (T<<10) ^ (T<<15)) & 0xffffffff) >>> 0); C[i-17] = ((C[i-17] ^ (T>>>27) ^ (T>>>25) ^ (T>>>22) ^ (T>>>17)) >>> 0); } T = (C[17] >>> 27); C[0] = ((C[0] ^ T ^ ((T<<2) ^ (T<<5) ^ (T<<10)) & 0xffffffff) >>> 0); C[17] = (C[17] & 0x07ffffff); for(i=18; i<=35; i++) { C[i] = 0; } result = new Clipperz.Crypto.ECC.BinaryField.Value(C); -//console.log("<<< binaryField.finiteField.(improved)module"); } return result; }; } return Clipperz.Crypto.ECC.StandardCurves._B571; }, //----------------------------------------------------------------------------- '_B283': null, 'B283': function() { // f(z) = z^283 + z^12 + z^7 + z^5 + 1 if ((Clipperz.Crypto.ECC.StandardCurves._B283 == null) && (typeof(Clipperz.Crypto.ECC.BinaryField.Curve) != 'undefined')) { Clipperz.Crypto.ECC.StandardCurves._B283 = new Clipperz.Crypto.ECC.BinaryField.Curve({ modulus: new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16), a: new Clipperz.Crypto.ECC.BinaryField.Value('1', 16), b: new Clipperz.Crypto.ECC.BinaryField.Value('027b680a c8b8596d a5a4af8a 19a0303f ca97fd76 45309fa2 a581485a f6263e31 3b79a2f5', 16), G: new Clipperz.Crypto.ECC.BinaryField.Point({ x: new Clipperz.Crypto.ECC.BinaryField.Value('05f93925 8db7dd90 e1934f8c 70b0dfec 2eed25b8 557eac9c 80e2e198 f8cdbecd 86b12053', 16), y: new Clipperz.Crypto.ECC.BinaryField.Value('03676854 fe24141c b98fe6d4 b20d02b4 516ff702 350eddb0 826779c8 13f0df45 be8112f4', 16) }), r: new Clipperz.Crypto.ECC.BinaryField.Value('03ffffff ffffffff ffffffff ffffffff ffffef90 399660fc 938a9016 5b042a7c efadb307', 16), h: new Clipperz.Crypto.ECC.BinaryField.Value('2', 16) }); //----------------------------------------------------------------------------- // // Guide to Elliptic Curve Cryptography // Darrel Hankerson, Alfred Menezes, Scott Vanstone // - Pag: 56, Alorithm 2.43 // //----------------------------------------------------------------------------- Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().slowModule = Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().module; Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().module = function(aValue) { var result; if (aValue.bitSize() > 564) { - MochiKit.Logging.logWarning("ECC.StandarCurves.B283.finiteField().module: falling back to default implementation"); + Clipperz.logWarning("ECC.StandarCurves.B283.finiteField().module: falling back to default implementation"); result = Clipperz.Crypto.ECC.StandardCurves._B283.finiteField().slowModule(aValue); } else { var C, T; var i; -//console.log(">>> binaryField.finiteField.(improved)module"); C = aValue._value.slice(0); for (i=17; i>=9; i--) { T = C[i]; C[i-9] = (((C[i-9] ^ (T<<5) ^ (T<<10) ^ (T<<12) ^ (T<<17)) & 0xffffffff) >>> 0); C[i-8] = ((C[i-8] ^ (T>>>27) ^ (T>>>22) ^ (T>>>20) ^ (T>>>15)) >>> 0); } T = (C[8] >>> 27); C[0] = ((C[0] ^ T ^ ((T<<5) ^ (T<<7) ^ (T<<12)) & 0xffffffff) >>> 0); C[8] = (C[8] & 0x07ffffff); for(i=9; i<=17; i++) { C[i] = 0; } result = new Clipperz.Crypto.ECC.BinaryField.Value(C); -//console.log("<<< binaryField.finiteField.(improved)module"); } return result; }; } return Clipperz.Crypto.ECC.StandardCurves._B283; }, //============================================================================== __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Crypto/PRNG.js b/frontend/gamma/js/Clipperz/Crypto/PRNG.js index adfdb16..c539f06 100644 --- a/frontend/gamma/js/Clipperz/Crypto/PRNG.js +++ b/frontend/gamma/js/Clipperz/Crypto/PRNG.js @@ -1,852 +1,841 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; } try { if (typeof(Clipperz.Crypto.SHA) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.SHA!"; } try { if (typeof(Clipperz.Crypto.AES) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.AES!"; } if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { Clipperz.Crypto.PRNG = {}; } //############################################################################# Clipperz.Crypto.PRNG.EntropyAccumulator = function(args) { args = args || {}; // MochiKit.Base.bindMethods(this); this._stack = new Clipperz.ByteArray(); this._maxStackLengthBeforeHashing = args.maxStackLengthBeforeHashing || 256; return this; } Clipperz.Crypto.PRNG.EntropyAccumulator.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.Crypto.PRNG.EntropyAccumulator"; }, //------------------------------------------------------------------------- 'stack': function() { return this._stack; }, 'setStack': function(aValue) { this._stack = aValue; }, 'resetStack': function() { this.stack().reset(); }, 'maxStackLengthBeforeHashing': function() { return this._maxStackLengthBeforeHashing; }, //------------------------------------------------------------------------- 'addRandomByte': function(aValue) { this.stack().appendByte(aValue); if (this.stack().length() > this.maxStackLengthBeforeHashing()) { this.setStack(Clipperz.Crypto.SHA.sha_d256(this.stack())); } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.PRNG.RandomnessSource = function(args) { args = args || {}; MochiKit.Base.bindMethods(this); this._generator = args.generator || null; this._sourceId = args.sourceId || null; this._boostMode = args.boostMode || false; this._nextPoolIndex = 0; return this; } Clipperz.Crypto.PRNG.RandomnessSource.prototype = MochiKit.Base.update(null, { 'generator': function() { return this._generator; }, 'setGenerator': function(aValue) { this._generator = aValue; }, //------------------------------------------------------------------------- 'boostMode': function() { return this._boostMode; }, 'setBoostMode': function(aValue) { this._boostMode = aValue; }, //------------------------------------------------------------------------- 'sourceId': function() { return this._sourceId; }, 'setSourceId': function(aValue) { this._sourceId = aValue; }, //------------------------------------------------------------------------- 'nextPoolIndex': function() { return this._nextPoolIndex; }, 'incrementNextPoolIndex': function() { this._nextPoolIndex = ((this._nextPoolIndex + 1) % this.generator().numberOfEntropyAccumulators()); }, //------------------------------------------------------------------------- 'updateGeneratorWithValue': function(aRandomValue) { if (this.generator() != null) { this.generator().addRandomByte(this.sourceId(), this.nextPoolIndex(), aRandomValue); this.incrementNextPoolIndex(); } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.PRNG.TimeRandomnessSource = function(args) { args = args || {}; // MochiKit.Base.bindMethods(this); this._intervalTime = args.intervalTime || 1000; Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); this.collectEntropy(); return this; } Clipperz.Crypto.PRNG.TimeRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { 'intervalTime': function() { return this._intervalTime; }, //------------------------------------------------------------------------- 'collectEntropy': function() { var now; var entropyByte; var intervalTime; now = new Date(); entropyByte = (now.getTime() & 0xff); intervalTime = this.intervalTime(); if (this.boostMode() == true) { intervalTime = intervalTime / 9; } this.updateGeneratorWithValue(entropyByte); setTimeout(this.collectEntropy, intervalTime); }, //------------------------------------------------------------------------- 'numberOfRandomBits': function() { return 5; }, //------------------------------------------------------------------------- 'pollingFrequency': function() { return 10; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //***************************************************************************** Clipperz.Crypto.PRNG.MouseRandomnessSource = function(args) { args = args || {}; Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); this._numberOfBitsToCollectAtEachEvent = 4; this._randomBitsCollector = 0; this._numberOfRandomBitsCollected = 0; MochiKit.Signal.connect(document, 'onmousemove', this, 'collectEntropy'); return this; } Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { //------------------------------------------------------------------------- 'numberOfBitsToCollectAtEachEvent': function() { return this._numberOfBitsToCollectAtEachEvent; }, //------------------------------------------------------------------------- 'randomBitsCollector': function() { return this._randomBitsCollector; }, 'setRandomBitsCollector': function(aValue) { this._randomBitsCollector = aValue; }, 'appendRandomBitsToRandomBitsCollector': function(aValue) { var collectedBits; var numberOfRandomBitsCollected; numberOfRandomBitsCollected = this.numberOfRandomBitsCollected(); collectetBits = this.randomBitsCollector() | (aValue << numberOfRandomBitsCollected); this.setRandomBitsCollector(collectetBits); numberOfRandomBitsCollected += this.numberOfBitsToCollectAtEachEvent(); if (numberOfRandomBitsCollected == 8) { this.updateGeneratorWithValue(collectetBits); numberOfRandomBitsCollected = 0; this.setRandomBitsCollector(0); } this.setNumberOfRandomBitsCollected(numberOfRandomBitsCollected) }, //------------------------------------------------------------------------- 'numberOfRandomBitsCollected': function() { return this._numberOfRandomBitsCollected; }, 'setNumberOfRandomBitsCollected': function(aValue) { this._numberOfRandomBitsCollected = aValue; }, //------------------------------------------------------------------------- 'collectEntropy': function(anEvent) { var mouseLocation; var randomBit; var mask; mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); mouseLocation = anEvent.mouse().client; randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); this.appendRandomBitsToRandomBitsCollector(randomBit) }, //------------------------------------------------------------------------- 'numberOfRandomBits': function() { return 1; }, //------------------------------------------------------------------------- 'pollingFrequency': function() { return 10; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //***************************************************************************** Clipperz.Crypto.PRNG.KeyboardRandomnessSource = function(args) { args = args || {}; Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); this._randomBitsCollector = 0; this._numberOfRandomBitsCollected = 0; MochiKit.Signal.connect(document, 'onkeypress', this, 'collectEntropy'); return this; } Clipperz.Crypto.PRNG.KeyboardRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { //------------------------------------------------------------------------- 'randomBitsCollector': function() { return this._randomBitsCollector; }, 'setRandomBitsCollector': function(aValue) { this._randomBitsCollector = aValue; }, 'appendRandomBitToRandomBitsCollector': function(aValue) { var collectedBits; var numberOfRandomBitsCollected; numberOfRandomBitsCollected = this.numberOfRandomBitsCollected(); collectetBits = this.randomBitsCollector() | (aValue << numberOfRandomBitsCollected); this.setRandomBitsCollector(collectetBits); numberOfRandomBitsCollected ++; if (numberOfRandomBitsCollected == 8) { this.updateGeneratorWithValue(collectetBits); numberOfRandomBitsCollected = 0; this.setRandomBitsCollector(0); } this.setNumberOfRandomBitsCollected(numberOfRandomBitsCollected) }, //------------------------------------------------------------------------- 'numberOfRandomBitsCollected': function() { return this._numberOfRandomBitsCollected; }, 'setNumberOfRandomBitsCollected': function(aValue) { this._numberOfRandomBitsCollected = aValue; }, //------------------------------------------------------------------------- 'collectEntropy': function(anEvent) { /* var mouseLocation; var randomBit; mouseLocation = anEvent.mouse().client; randomBit = ((mouseLocation.x ^ mouseLocation.y) & 0x1); this.appendRandomBitToRandomBitsCollector(randomBit); */ }, //------------------------------------------------------------------------- 'numberOfRandomBits': function() { return 1; }, //------------------------------------------------------------------------- 'pollingFrequency': function() { return 10; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.PRNG.Fortuna = function(args) { var i,c; args = args || {}; this._key = args.seed || null; if (this._key == null) { this._counter = 0; this._key = new Clipperz.ByteArray(); } else { this._counter = 1; } this._aesKey = null; this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32; this._accumulators = []; c = this.numberOfEntropyAccumulators(); for (i=0; i<c; i++) { this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator()); } this._randomnessSources = []; this._reseedCounter = 0; return this; } Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.Crypto.PRNG.Fortuna"; }, //------------------------------------------------------------------------- 'key': function() { return this._key; }, 'setKey': function(aValue) { this._key = aValue; this._aesKey = null; }, 'aesKey': function() { if (this._aesKey == null) { this._aesKey = new Clipperz.Crypto.AES.Key({key:this.key()}); } return this._aesKey; }, 'accumulators': function() { return this._accumulators; }, 'firstPoolReseedLevel': function() { return this._firstPoolReseedLevel; }, //------------------------------------------------------------------------- 'reseedCounter': function() { return this._reseedCounter; }, 'incrementReseedCounter': function() { this._reseedCounter = this._reseedCounter +1; }, //------------------------------------------------------------------------- 'reseed': function() { var newKeySeed; var reseedCounter; var reseedCounterMask; var i, c; newKeySeed = this.key(); this.incrementReseedCounter(); reseedCounter = this.reseedCounter(); c = this.numberOfEntropyAccumulators(); reseedCounterMask = 0xffffffff >>> (32 - c); for (i=0; i<c; i++) { if ((i == 0) || ((reseedCounter & (reseedCounterMask >>> (c - i))) == 0)) { newKeySeed.appendBlock(this.accumulators()[i].stack()); this.accumulators()[i].resetStack(); } } if (reseedCounter == 1) { c = this.randomnessSources().length; for (i=0; i<c; i++) { this.randomnessSources()[i].setBoostMode(false); } } this.setKey(Clipperz.Crypto.SHA.sha_d256(newKeySeed)); if (reseedCounter == 1) { -//MochiKit.Logging.logDebug("### PRNG.readyToGenerateRandomBytes"); Clipperz.log("### PRNG.readyToGenerateRandomBytes"); MochiKit.Signal.signal(this, 'readyToGenerateRandomBytes'); } MochiKit.Signal.signal(this, 'reseeded'); }, //------------------------------------------------------------------------- 'isReadyToGenerateRandomValues': function() { return this.reseedCounter() != 0; }, //------------------------------------------------------------------------- 'entropyLevel': function() { return this.accumulators()[0].stack().length() + (this.reseedCounter() * this.firstPoolReseedLevel()); }, //------------------------------------------------------------------------- 'counter': function() { return this._counter; }, 'incrementCounter': function() { this._counter += 1; }, 'counterBlock': function() { var result; result = new Clipperz.ByteArray().appendWords(this.counter(), 0, 0, 0); return result; }, //------------------------------------------------------------------------- 'getRandomBlock': function() { var result; result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(this.aesKey(), this.counterBlock().arrayValues())); this.incrementCounter(); return result; }, //------------------------------------------------------------------------- 'getRandomBytes': function(aSize) { var result; if (this.isReadyToGenerateRandomValues()) { var i,c; var newKey; result = new Clipperz.ByteArray(); c = Math.ceil(aSize / (128 / 8)); for (i=0; i<c; i++) { result.appendBlock(this.getRandomBlock()); } if (result.length() != aSize) { result = result.split(0, aSize); } newKey = this.getRandomBlock().appendBlock(this.getRandomBlock()); this.setKey(newKey); } else { -MochiKit.Logging.logWarning("Fortuna generator has not enough entropy, yet!"); +Clipperz.logWarning("Fortuna generator has not enough entropy, yet!"); throw Clipperz.Crypto.PRNG.exception.NotEnoughEntropy; } return result; }, //------------------------------------------------------------------------- 'addRandomByte': function(aSourceId, aPoolId, aRandomValue) { var selectedAccumulator; selectedAccumulator = this.accumulators()[aPoolId]; selectedAccumulator.addRandomByte(aRandomValue); if (aPoolId == 0) { MochiKit.Signal.signal(this, 'addedRandomByte') if (selectedAccumulator.stack().length() > this.firstPoolReseedLevel()) { this.reseed(); } } }, //------------------------------------------------------------------------- 'numberOfEntropyAccumulators': function() { return this._numberOfEntropyAccumulators; }, //------------------------------------------------------------------------- 'randomnessSources': function() { return this._randomnessSources; }, 'addRandomnessSource': function(aRandomnessSource) { aRandomnessSource.setGenerator(this); aRandomnessSource.setSourceId(this.randomnessSources().length); this.randomnessSources().push(aRandomnessSource); if (this.isReadyToGenerateRandomValues() == false) { aRandomnessSource.setBoostMode(true); } }, //------------------------------------------------------------------------- 'deferredEntropyCollection': function(aValue) { var result; -//MochiKit.Logging.logDebug(">>> PRNG.deferredEntropyCollection"); if (this.isReadyToGenerateRandomValues()) { -//MochiKit.Logging.logDebug("--- PRNG.deferredEntropyCollection - 1"); result = aValue; } else { -//MochiKit.Logging.logDebug("--- PRNG.deferredEntropyCollection - 2"); var deferredResult; -// Clipperz.NotificationCenter.notify(this, 'updatedProgressState', 'collectingEntropy', true); - deferredResult = new Clipperz.Async.Deferred("PRNG.deferredEntropyCollection"); -// deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.1 - PRNG.deferredEntropyCollection - 1: " + res); return res;}); deferredResult.addCallback(MochiKit.Base.partial(MochiKit.Async.succeed, aValue)); -// deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.2 - PRNG.deferredEntropyCollection - 2: " + res); return res;}); MochiKit.Signal.connect(this, 'readyToGenerateRandomBytes', deferredResult, 'callback'); result = deferredResult; } -//MochiKit.Logging.logDebug("<<< PRNG.deferredEntropyCollection - result: " + result); return result; }, //------------------------------------------------------------------------- 'fastEntropyAccumulationForTestingPurpose': function() { while (! this.isReadyToGenerateRandomValues()) { this.addRandomByte(Math.floor(Math.random() * 32), Math.floor(Math.random() * 32), Math.floor(Math.random() * 256)); } }, //------------------------------------------------------------------------- 'dump': function(appendToDoc) { var tbl; var i,c; tbl = document.createElement("table"); tbl.border = 0; with (tbl.style) { border = "1px solid lightgrey"; fontFamily = 'Helvetica, Arial, sans-serif'; fontSize = '8pt'; //borderCollapse = "collapse"; } var hdr = tbl.createTHead(); var hdrtr = hdr.insertRow(0); // document.createElement("tr"); { var ntd; ntd = hdrtr.insertCell(0); ntd.style.borderBottom = "1px solid lightgrey"; ntd.style.borderRight = "1px solid lightgrey"; ntd.appendChild(document.createTextNode("#")); ntd = hdrtr.insertCell(1); ntd.style.borderBottom = "1px solid lightgrey"; ntd.style.borderRight = "1px solid lightgrey"; ntd.appendChild(document.createTextNode("s")); ntd = hdrtr.insertCell(2); ntd.colSpan = this.firstPoolReseedLevel(); ntd.style.borderBottom = "1px solid lightgrey"; ntd.style.borderRight = "1px solid lightgrey"; ntd.appendChild(document.createTextNode("base values")); ntd = hdrtr.insertCell(3); ntd.colSpan = 20; ntd.style.borderBottom = "1px solid lightgrey"; ntd.appendChild(document.createTextNode("extra values")); } c = this.accumulators().length; for (i=0; i<c ; i++) { var currentAccumulator; var bdytr; var bdytd; var ii, cc; currentAccumulator = this.accumulators()[i] bdytr = tbl.insertRow(true); bdytd = bdytr.insertCell(0); bdytd.style.borderRight = "1px solid lightgrey"; bdytd.style.color = "lightgrey"; bdytd.appendChild(document.createTextNode("" + i)); bdytd = bdytr.insertCell(1); bdytd.style.borderRight = "1px solid lightgrey"; bdytd.style.color = "gray"; bdytd.appendChild(document.createTextNode("" + currentAccumulator.stack().length())); cc = Math.max(currentAccumulator.stack().length(), this.firstPoolReseedLevel()); for (ii=0; ii<cc; ii++) { var cellText; bdytd = bdytr.insertCell(ii + 2); if (ii < currentAccumulator.stack().length()) { cellText = Clipperz.ByteArray.byteToHex(currentAccumulator.stack().byteAtIndex(ii)); } else { cellText = "_"; } if (ii == (this.firstPoolReseedLevel() - 1)) { bdytd.style.borderRight = "1px solid lightgrey"; } bdytd.appendChild(document.createTextNode(cellText)); } } if (appendToDoc) { var ne = document.createElement("div"); ne.id = "entropyGeneratorStatus"; with (ne.style) { fontFamily = "Courier New, monospace"; fontSize = "12px"; lineHeight = "16px"; borderTop = "1px solid black"; padding = "10px"; } if (document.getElementById(ne.id)) { MochiKit.DOM.swapDOM(ne.id, ne); } else { document.body.appendChild(ne); } ne.appendChild(tbl); } return tbl; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.Crypto.PRNG.Random = function(args) { args = args || {}; // MochiKit.Base.bindMethods(this); return this; } Clipperz.Crypto.PRNG.Random.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.Crypto.PRNG.Random"; }, //------------------------------------------------------------------------- 'getRandomBytes': function(aSize) { //Clipperz.Profile.start("Clipperz.Crypto.PRNG.Random.getRandomBytes"); var result; var i,c; result = new Clipperz.ByteArray() c = aSize || 1; for (i=0; i<c; i++) { result.appendByte((Math.random()*255) & 0xff); } //Clipperz.Profile.stop("Clipperz.Crypto.PRNG.Random.getRandomBytes"); return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# _clipperz_crypt_prng_defaultPRNG = null; Clipperz.Crypto.PRNG.defaultRandomGenerator = function() { if (_clipperz_crypt_prng_defaultPRNG == null) { _clipperz_crypt_prng_defaultPRNG = new Clipperz.Crypto.PRNG.Fortuna(); //............................................................. // // TimeRandomnessSource // //............................................................. { var newRandomnessSource; newRandomnessSource = new Clipperz.Crypto.PRNG.TimeRandomnessSource({intervalTime:111}); _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource); } //............................................................. // // MouseRandomnessSource // //............................................................. { var newRandomnessSource; newRandomnessSource = new Clipperz.Crypto.PRNG.MouseRandomnessSource(); _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource); } //............................................................. // // KeyboardRandomnessSource // //............................................................. { var newRandomnessSource; newRandomnessSource = new Clipperz.Crypto.PRNG.KeyboardRandomnessSource(); _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource); } } return _clipperz_crypt_prng_defaultPRNG; }; //############################################################################# Clipperz.Crypto.PRNG.exception = { NotEnoughEntropy: new MochiKit.Base.NamedError("Clipperz.Crypto.PRNG.exception.NotEnoughEntropy") }; MochiKit.DOM.addLoadEvent(Clipperz.Crypto.PRNG.defaultRandomGenerator); diff --git a/frontend/gamma/js/Clipperz/Crypto/RSA.js b/frontend/gamma/js/Clipperz/Crypto/RSA.js index 6844dba..5a480f1 100644 --- a/frontend/gamma/js/Clipperz/Crypto/RSA.js +++ b/frontend/gamma/js/Clipperz/Crypto/RSA.js @@ -1,148 +1,146 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.RSA depends on Clipperz.Crypto.BigInt!"; } if (typeof(Clipperz.Crypto.RSA) == 'undefined') { Clipperz.Crypto.RSA = {}; } Clipperz.Crypto.RSA.VERSION = "0.1"; Clipperz.Crypto.RSA.NAME = "Clipperz.RSA"; //############################################################################# MochiKit.Base.update(Clipperz.Crypto.RSA, { //------------------------------------------------------------------------- 'publicKeyWithValues': function (e, d, n) { var result; result = {}; if (e.isBigInt) { result.e = e; } else { result.e = new Clipperz.Crypto.BigInt(e, 16); } if (d.isBigInt) { result.d = d; } else { result.d = new Clipperz.Crypto.BigInt(d, 16); } if (n.isBigInt) { result.n = n; } else { result.n = new Clipperz.Crypto.BigInt(n, 16); } return result; }, 'privateKeyWithValues': function(e, d, n) { return Clipperz.Crypto.RSA.publicKeyWithValues(e, d, n); }, //----------------------------------------------------------------------------- 'encryptUsingPublicKey': function (aKey, aMessage) { var messageValue; var result; messageValue = new Clipperz.Crypto.BigInt(aMessage, 16); result = messageValue.powerModule(aKey.e, aKey.n); return result.asString(16); }, //............................................................................. 'decryptUsingPublicKey': function (aKey, aMessage) { return Clipperz.Crypto.RSA.encryptUsingPublicKey(aKey, aMessage); }, //----------------------------------------------------------------------------- 'encryptUsingPrivateKey': function (aKey, aMessage) { var messageValue; var result; messageValue = new Clipperz.Crypto.BigInt(aMessage, 16); result = messageValue.powerModule(aKey.d, aKey.n); return result.asString(16); }, //............................................................................. 'decryptUsingPrivateKey': function (aKey, aMessage) { return Clipperz.Crypto.RSA.encryptUsingPrivateKey(aKey, aMessage); }, //----------------------------------------------------------------------------- 'generatePublicKey': function(aNumberOfBits) { var result; var e; var d; var n; e = new Clipperz.Crypto.BigInt("10001", 16); { var p, q; var phi; do { p = Clipperz.Crypto.BigInt.randomPrime(aNumberOfBits); } while (p.module(e).equals(1)); do { q = Clipperz.Crypto.BigInt.randomPrime(aNumberOfBits); } while ((q.equals(p)) || (q.module(e).equals(1))); n = p.multiply(q); phi = (p.subtract(1).multiply(q.subtract(1))); d = e.powerModule(-1, phi); } result = Clipperz.Crypto.RSA.publicKeyWithValues(e, d, n); return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" //------------------------------------------------------------------------- }); //############################################################################# diff --git a/frontend/gamma/js/Clipperz/Crypto/SHA.js b/frontend/gamma/js/Clipperz/Crypto/SHA.js index b07fa85..f8bfe6e 100644 --- a/frontend/gamma/js/Clipperz/Crypto/SHA.js +++ b/frontend/gamma/js/Clipperz/Crypto/SHA.js @@ -1,298 +1,296 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; } if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } if (typeof(Clipperz.Crypto.SHA) == 'undefined') { Clipperz.Crypto.SHA = {}; } Clipperz.Crypto.SHA.VERSION = "0.3"; Clipperz.Crypto.SHA.NAME = "Clipperz.Crypto.SHA"; MochiKit.Base.update(Clipperz.Crypto.SHA, { '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, 'toString': function () { return this.__repr__(); }, //----------------------------------------------------------------------------- 'rotateRight': function(aValue, aNumberOfBits) { //Clipperz.Profile.start("Clipperz.Crypto.SHA.rotateRight"); var result; result = (aValue >>> aNumberOfBits) | (aValue << (32 - aNumberOfBits)); //Clipperz.Profile.stop("Clipperz.Crypto.SHA.rotateRight"); return result; }, 'shiftRight': function(aValue, aNumberOfBits) { //Clipperz.Profile.start("Clipperz.Crypto.SHA.shiftRight"); var result; result = aValue >>> aNumberOfBits; //Clipperz.Profile.stop("Clipperz.Crypto.SHA.shiftRight"); return result; }, //----------------------------------------------------------------------------- 'safeAdd': function() { //Clipperz.Profile.start("Clipperz.Crypto.SHA.safeAdd"); var result; var i, c; result = arguments[0]; c = arguments.length; for (i=1; i<c; i++) { var lowerBytesSum; lowerBytesSum = (result & 0xffff) + (arguments[i] & 0xffff); result = (((result >> 16) + (arguments[i] >> 16) + (lowerBytesSum >> 16)) << 16) | (lowerBytesSum & 0xffff); } //Clipperz.Profile.stop("Clipperz.Crypto.SHA.safeAdd"); return result; }, //----------------------------------------------------------------------------- 'sha256_array': function(aValue) { //Clipperz.Profile.start("Clipperz.Crypto.SHA.sha256_array"); var result; var message; var h0, h1, h2, h3, h4, h5, h6, h7; var k; var messageLength; var messageLengthInBits; var _i, _c; var charBits; var rotateRight; var shiftRight; var safeAdd; var bytesPerBlock; var currentMessageIndex; bytesPerBlock = 512/8; rotateRight = Clipperz.Crypto.SHA.rotateRight; shiftRight = Clipperz.Crypto.SHA.shiftRight; safeAdd = Clipperz.Crypto.SHA.safeAdd; charBits = 8; h0 = 0x6a09e667; h1 = 0xbb67ae85; h2 = 0x3c6ef372; h3 = 0xa54ff53a; h4 = 0x510e527f; h5 = 0x9b05688c; h6 = 0x1f83d9ab; h7 = 0x5be0cd19; k = [ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]; message = aValue; messageLength = message.length; //Pre-processing: message.push(0x80); // append a single "1" bit to message _c = (512 - (((messageLength + 1) * charBits) % 512) - 64) / charBits; if (_c < 0) { _c = _c + (512 / charBits); } for (_i=0; _i<_c; _i++) { message.push(0x00); // append "0" bits until message length ≡ 448 ≡ -64 (mod 512) } messageLengthInBits = messageLength * charBits; message.push(0x00); // the 4 most high byte are alway 0 as message length is represented with a 32bit value; message.push(0x00); message.push(0x00); message.push(0x00); message.push((messageLengthInBits >> 24) & 0xff); message.push((messageLengthInBits >> 16) & 0xff); message.push((messageLengthInBits >> 8) & 0xff); message.push( messageLengthInBits & 0xff); currentMessageIndex = 0; while(currentMessageIndex < message.length) { var w; var a, b, c, d, e, f, g, h; w = Array(64); _c = 16; for (_i=0; _i<_c; _i++) { var _j; _j = currentMessageIndex + _i*4; w[_i] = (message[_j] << 24) | (message[_j + 1] << 16) | (message[_j + 2] << 8) | (message[_j + 3] << 0); } _c = 64; for (_i=16; _i<_c; _i++) { var s0, s1; s0 = (rotateRight(w[_i-15], 7)) ^ (rotateRight(w[_i-15], 18)) ^ (shiftRight(w[_i-15], 3)); s1 = (rotateRight(w[_i-2], 17)) ^ (rotateRight(w[_i-2], 19)) ^ (shiftRight(w[_i-2], 10)); w[_i] = safeAdd(w[_i-16], s0, w[_i-7], s1); } a=h0; b=h1; c=h2; d=h3; e=h4; f=h5; g=h6; h=h7; _c = 64; for (_i=0; _i<_c; _i++) { var s0, s1, ch, maj, t1, t2; s0 = (rotateRight(a, 2)) ^ (rotateRight(a, 13)) ^ (rotateRight(a, 22)); maj = (a & b) ^ (a & c) ^ (b & c); t2 = safeAdd(s0, maj); s1 = (rotateRight(e, 6)) ^ (rotateRight(e, 11)) ^ (rotateRight(e, 25)); ch = (e & f) ^ ((~e) & g); t1 = safeAdd(h, s1, ch, k[_i], w[_i]); h = g; g = f; f = e; e = safeAdd(d, t1); d = c; c = b; b = a; a = safeAdd(t1, t2); } h0 = safeAdd(h0, a); h1 = safeAdd(h1, b); h2 = safeAdd(h2, c); h3 = safeAdd(h3, d); h4 = safeAdd(h4, e); h5 = safeAdd(h5, f); h6 = safeAdd(h6, g); h7 = safeAdd(h7, h); currentMessageIndex += bytesPerBlock; } result = new Array(256/8); result[0] = (h0 >> 24) & 0xff; result[1] = (h0 >> 16) & 0xff; result[2] = (h0 >> 8) & 0xff; result[3] = h0 & 0xff; result[4] = (h1 >> 24) & 0xff; result[5] = (h1 >> 16) & 0xff; result[6] = (h1 >> 8) & 0xff; result[7] = h1 & 0xff; result[8] = (h2 >> 24) & 0xff; result[9] = (h2 >> 16) & 0xff; result[10] = (h2 >> 8) & 0xff; result[11] = h2 & 0xff; result[12] = (h3 >> 24) & 0xff; result[13] = (h3 >> 16) & 0xff; result[14] = (h3 >> 8) & 0xff; result[15] = h3 & 0xff; result[16] = (h4 >> 24) & 0xff; result[17] = (h4 >> 16) & 0xff; result[18] = (h4 >> 8) & 0xff; result[19] = h4 & 0xff; result[20] = (h5 >> 24) & 0xff; result[21] = (h5 >> 16) & 0xff; result[22] = (h5 >> 8) & 0xff; result[23] = h5 & 0xff; result[24] = (h6 >> 24) & 0xff; result[25] = (h6 >> 16) & 0xff; result[26] = (h6 >> 8) & 0xff; result[27] = h6 & 0xff; result[28] = (h7 >> 24) & 0xff; result[29] = (h7 >> 16) & 0xff; result[30] = (h7 >> 8) & 0xff; result[31] = h7 & 0xff; //Clipperz.Profile.stop("Clipperz.Crypto.SHA.sha256_array"); return result; }, //----------------------------------------------------------------------------- 'sha256': function(aValue) { //Clipperz.Profile.start("Clipperz.Crypto.SHA.sha256"); var result; var resultArray; var valueArray; valueArray = aValue.arrayValues(); resultArray = Clipperz.Crypto.SHA.sha256_array(valueArray); result = new Clipperz.ByteArray(resultArray); //Clipperz.Profile.stop("Clipperz.Crypto.SHA.sha256"); return result; }, //----------------------------------------------------------------------------- 'sha_d256': function(aValue) { //Clipperz.Profile.start("Clipperz.Crypto.SHA.sha_d256"); var result; var resultArray; var valueArray; valueArray = aValue.arrayValues(); resultArray = Clipperz.Crypto.SHA.sha256_array(valueArray); resultArray = Clipperz.Crypto.SHA.sha256_array(resultArray); result = new Clipperz.ByteArray(resultArray); //Clipperz.Profile.stop("Clipperz.Crypto.SHA.sha256"); return result; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Crypto/SRP.js b/frontend/gamma/js/Clipperz/Crypto/SRP.js index 3b25275..597e72d 100644 --- a/frontend/gamma/js/Clipperz/Crypto/SRP.js +++ b/frontend/gamma/js/Clipperz/Crypto/SRP.js @@ -1,328 +1,316 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; } try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.BigInt!"; } try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.PRNG!"; } if (typeof(Clipperz.Crypto.SRP) == 'undefined') { Clipperz.Crypto.SRP = {}; } Clipperz.Crypto.SRP.VERSION = "0.1"; Clipperz.Crypto.SRP.NAME = "Clipperz.Crypto.SRP"; //############################################################################# MochiKit.Base.update(Clipperz.Crypto.SRP, { '_n': null, '_g': null, //------------------------------------------------------------------------- 'n': function() { if (Clipperz.Crypto.SRP._n == null) { Clipperz.Crypto.SRP._n = new Clipperz.Crypto.BigInt("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16); } return Clipperz.Crypto.SRP._n; }, //------------------------------------------------------------------------- 'g': function() { if (Clipperz.Crypto.SRP._g == null) { Clipperz.Crypto.SRP._g = new Clipperz.Crypto.BigInt(2); // eventually 5 (as suggested on the Diffi-Helmann documentation) } return Clipperz.Crypto.SRP._g; }, //----------------------------------------------------------------------------- 'exception': { 'InvalidValue': new MochiKit.Base.NamedError("Clipperz.Crypto.SRP.exception.InvalidValue") }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# // // S R P C o n n e c t i o n version 1.0 // //============================================================================= Clipperz.Crypto.SRP.Connection = function (args) { args = args || {}; this._C = args.C; this._P = args.P; this.hash = args.hash; this._a = null; this._A = null; this._s = null; this._B = null; this._x = null; this._u = null; this._K = null; this._M1 = null; this._M2 = null; this._sessionKey = null; return this; } Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { 'toString': function () { return "Clipperz.Crypto.SRP.Connection (username: " + this.username() + "). Status: " + this.statusDescription(); }, //------------------------------------------------------------------------- 'C': function () { return this._C; }, //------------------------------------------------------------------------- 'P': function () { return this._P; }, //------------------------------------------------------------------------- 'a': function () { if (this._a == null) { this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16); // this._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); -//MochiKit.Logging.logDebug("SRP a: " + this._a); } return this._a; }, //------------------------------------------------------------------------- 'A': function () { if (this._A == null) { // Warning: this value should be strictly greater than zero: how should we perform this check? this._A = Clipperz.Crypto.SRP.g().powerModule(this.a(), Clipperz.Crypto.SRP.n()); if (this._A.equals(0)) { -MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'A' to 0."); + Clipperz.logError("Clipperz.Crypto.SRP.Connection: trying to set 'A' to 0."); throw Clipperz.Crypto.SRP.exception.InvalidValue; } -//MochiKit.Logging.logDebug("SRP A: " + this._A); } return this._A; }, //------------------------------------------------------------------------- 's': function () { return this._s; -//MochiKit.Logging.logDebug("SRP s: " + this._S); }, 'set_s': function(aValue) { this._s = aValue; }, //------------------------------------------------------------------------- 'B': function () { return this._B; }, 'set_B': function(aValue) { // Warning: this value should be strictly greater than zero: how should we perform this check? if (! aValue.equals(0)) { this._B = aValue; -//MochiKit.Logging.logDebug("SRP B: " + this._B); } else { -MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to 0."); + Clipperz.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to 0."); throw Clipperz.Crypto.SRP.exception.InvalidValue; } }, //------------------------------------------------------------------------- 'x': function () { if (this._x == null) { this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s().asString(16, 64) + this.P()), 16); -//MochiKit.Logging.logDebug("SRP x: " + this._x); } return this._x; }, //------------------------------------------------------------------------- 'u': function () { if (this._u == null) { this._u = new Clipperz.Crypto.BigInt(this.stringHash(this.B().asString()), 16); -//MochiKit.Logging.logDebug("SRP u: " + this._u); } return this._u; }, //------------------------------------------------------------------------- 'S': function () { if (this._S == null) { var bigint; var srp; bigint = Clipperz.Crypto.BigInt; srp = Clipperz.Crypto.SRP; this._S = bigint.powerModule( bigint.subtract(this.B(), bigint.powerModule(srp.g(), this.x(), srp.n())), bigint.add(this.a(), bigint.multiply(this.u(), this.x())), srp.n() ) -//MochiKit.Logging.logDebug("SRP S: " + this._S); } return this._S; }, //------------------------------------------------------------------------- 'K': function () { if (this._K == null) { this._K = this.stringHash(this.S().asString()); -//MochiKit.Logging.logDebug("SRP K: " + this._K); } return this._K; }, //------------------------------------------------------------------------- 'M1': function () { if (this._M1 == null) { this._M1 = this.stringHash(this.A().asString(10) + this.B().asString(10) + this.K()); -//MochiKit.Logging.logDebug("SRP M1: " + this._M1); } return this._M1; }, //------------------------------------------------------------------------- 'M2': function () { if (this._M2 == null) { this._M2 = this.stringHash(this.A().asString(10) + this.M1() + this.K()); -//MochiKit.Logging.logDebug("SRP M2: " + this._M2); } return this._M2; }, //========================================================================= 'serverSideCredentialsWithSalt': function(aSalt) { var result; var s, x, v; s = aSalt; x = this.stringHash(s + this.P()); v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); result = {}; result['C'] = this.C(); result['s'] = s; result['v'] = v.asString(16); return result; }, 'serverSideCredentials': function() { var result; var s; s = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2); result = this.serverSideCredentialsWithSalt(s); return result; }, //========================================================================= /* 'computeServerSide_S': function(b) { var result; var v; var bigint; var srp; bigint = Clipperz.Crypto.BigInt; srp = Clipperz.Crypto.SRP; v = new Clipperz.Crypto.BigInt(srpConnection.serverSideCredentialsWithSalt(this.s().asString(16, 64)).v, 16); // _S = (this.A().multiply(this.v().modPow(this.u(), this.n()))).modPow(this.b(), this.n()); result = bigint.powerModule( bigint.multiply( this.A(), bigint.powerModule(v, this.u(), srp.n()) ), new Clipperz.Crypto.BigInt(b, 10), srp.n() ); return result; }, */ //========================================================================= 'stringHash': function(aValue) { var result; result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); return result; }, //========================================================================= __syntaxFix__: "syntax fix" }); //############################################################################# diff --git a/frontend/gamma/js/Clipperz/DOM.js b/frontend/gamma/js/Clipperz/DOM.js index 8f24653..1d52a4b 100644 --- a/frontend/gamma/js/Clipperz/DOM.js +++ b/frontend/gamma/js/Clipperz/DOM.js @@ -1,136 +1,134 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.DOM) == 'undefined') { Clipperz.DOM = {}; } Clipperz.DOM.VERSION = "0.1"; Clipperz.DOM.NAME = "Clipperz.DOM"; MochiKit.Base.update(Clipperz.DOM, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'selectOptionMatchingValue': function (aSelectElement, aValue, shouldUseCaseInsensitiveTest) { var selectedOptionIndex; var i, c; selectedOptionIndex = -1; c = aSelectElement.options.length; for (i=0; (i<c) && (selectedOptionIndex == -1); i++) { if (shouldUseCaseInsensitiveTest == true) { if (aSelectElement.options[i].value.toLowerCase() == aValue.toLowerCase()) { selectedOptionIndex = i; } } else { if (aSelectElement.options[i].value == aValue) { selectedOptionIndex = i; } } } if (selectedOptionIndex != -1) { aSelectElement.selectedIndex = selectedOptionIndex; } }, //------------------------------------------------------------------------- 'setFormContents': function(aNode, someValues) { var node; var values; var i, c; values = {}; c = someValues[0].length; for (i=0; i<c; i++) { values[someValues[0][i]] = someValues[1][i]; } // var m = MochiKit.Base; // var self = MochiKit.DOM; if (typeof(aNode) == "undefined" || aNode === null) { node = MochiKit.DOM._document.body; } else { node = MochiKit.DOM.getElement(aNode); } MochiKit.Base.nodeWalk(node, function(aNode) { var result; var name; result = null; name = aNode.name; if (MochiKit.Base.isNotEmpty(name) && (typeof(values[name]) != 'undefined')) { var tagName; tagName = aNode.tagName.toUpperCase(); if (tagName === "INPUT" && (aNode.type == "radio" || aNode.type == "checkbox")) { aNode.checked = values[name]; } else if (tagName === "SELECT") { if (aNode.type == "select-one") { Clipperz.DOM.selectOptionMatchingValue(aNode, values[name]); } else { // aNode.type == "select-multiple" -MochiKit.Logging.logWarning("### unhandled Select.type = 'select-multiple' condition"); + Clipperz.logWarning("### unhandled Select.type = 'select-multiple' condition"); } } else if (tagName === "FORM" || tagName === "P" || tagName === "SPAN" || tagName === "DIV") { result = aNode.childNodes; } else { aNode.value = values[name] } } else { result = aNode.childNodes; } return result; }); }, //------------------------------------------------------------------------- 'get': MochiKit.DOM.getElement, //------------------------------------------------------------------------- 'Helper': Clipperz.YUI.DomHelper, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Date.js b/frontend/gamma/js/Clipperz/Date.js index 020d77b..163790e 100644 --- a/frontend/gamma/js/Clipperz/Date.js +++ b/frontend/gamma/js/Clipperz/Date.js @@ -1,302 +1,297 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; } Clipperz.Date.VERSION = "0.1"; Clipperz.Date.NAME = "Clipperz.Date"; MochiKit.Base.update(Clipperz.Date, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'daysInMonth': [31,28,31,30,31,30,31,31,30,31,30,31], //------------------------------------------------------------------------- 'englishOrdinalDaySuffixForDate': function(aDate) { var result; switch (aDate.getDate()) { case 1: case 21: case 31: result = "st"; break; case 2: case 22: result = "nd"; break; case 3: case 23: result = "rd"; break; default: result = "th"; break; } return result; }, //------------------------------------------------------------------------- 'isLeapYear': function(aDate) { var year; var result; year = aDate.getFullYear(); result = ((year & 0x03) == 0 && (year % 100 || (year % 400 == 0 && year))); return result; }, //------------------------------------------------------------------------- 'getDaysInMonth': function(aDate) { var result; if (aDate.getMonth() == 1) { Clipperz.Date.isLeapYear(aDate) result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; } else { result = Clipperz.Date.daysInMonth[aDate.getMonth()]; } return result; }, //------------------------------------------------------------------------- 'getTimezone': function(aDate) { var result; result = aDate.toString(); result = result.replace(/([A-Z]{3}) [0-9]{4}/, '$1'); result = result.replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3"); return result; }, 'getGMTOffset': function(aDate) { return (aDate.getTimezoneOffset() > 0 ? "-" : "+") + MochiKit.Format.numberFormatter('00')(Math.floor(this.getTimezoneOffset() / 60)) + MochiKit.Format.numberFormatter('00')(this.getTimezoneOffset() % 60); }, //------------------------------------------------------------------------- 'dayOfYear': function(aDate) { var result; var i,c; result = 0; c = aDate.getMonth(); for (i=0; i<c; i++) { if (i == 1) { result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; } else { result += Clipperz.Date.daysInMonth[i]; } } return num + this.getDate() - 1; }, //------------------------------------------------------------------------- 'getPHPLikeFormatCode': function(aCharacter) { var result; switch (aCharacter) { case "d": result = " + MochiKit.Format.numberFormatter('00')(aDate.getDate())"; break; case "D": result = " + aLocale['shortDays'][aDate.getDay()]"; break; case "j": result = " + aDate.getDate()"; break; case "l": result = " + aLocale['days'][aDate.getDay()]"; break; case "S": result = " + Clipperz.Date.englishOrdinalDaySuffixForDate(aDate)"; break; case "w": result = " + aDate.getDay()"; break; case "z": result = " + aDate.getDayOfYear()"; break; case "W": result = " + aDate.getWeekOfYear()"; break; case "F": result = " + aLocale['months'][aDate.getMonth()]"; break; case "m": result = " + MochiKit.Format.numberFormatter('00')(aDate.getMonth() + 1)"; break; case "M": result = " + aLocale['shortMonths'][aDate.getMonth()]"; break; case "n": result = " + (aDate.getMonth() + 1)"; break; case "t": result = " + Clipperz.Date.getDaysInMonth(aDate)"; break; case "L": result = " + (Clipperz.Date.isLeapYear(aDate) ? 1 : 0)"; break; case "Y": result = " + aDate.getFullYear()"; break; case "y": result = " + ('' + aDate.getFullYear()).substring(2, 4)"; break; case "a": result = " + (aDate.getHours() < 12 ? aLocale['amDesignation'] : aLocale['pmDesignation'])"; break; case "A": result = " + (aDate.getHours() < 12 ? aLocale['amDesignation'].toUpperCase() : aLocale['pmDesignation'].toUpperCase())"; break; case "g": result = " + ((aDate.getHours() %12) ? aDate.getHours() % 12 : 12)"; break; case "G": result = " + aDate.getHours()"; break; case "h": result = " + MochiKit.Format.numberFormatter('00')((aDate.getHours() %12) ? aDate.getHours() % 12 : 12)"; break; case "H": result = " + MochiKit.Format.numberFormatter('00')(aDate.getHours())"; break; case "i": result = " + MochiKit.Format.numberFormatter('00')(aDate.getMinutes())"; break; case "s": result = " + MochiKit.Format.numberFormatter('00')(aDate.getSeconds())"; break; case "O": result = " + aDate.getGMTOffset()"; break; case "T": result = " + Clipperz.Date.getTimezone(aDate)"; break; case "Z": result = " + ( + aDate.getTimezoneOffset() * -60)"; break; default: result = " + '" + aCharacter + "'"; break; }; return result; }, //========================================================================= 'formatDateWithPHPLikeTemplateAndLocale': function(aDate, aFormat, aLocale) { var result; var formatterCode; var formatter; var i,c; -//MochiKit.Logging.logDebug(">>> Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale"); formatterCode = "Clipperz.Date.__scratchFormatter = function(aDate, aLocale){return ''"; c = aFormat.length; i = 0; while (i<c) { var character; character = aFormat.charAt(i); if (character == "\\") { i++; character = aFormat.charAt(i); formatterCode += " + '" + character + "'" } else { formatterCode += Clipperz.Date.getPHPLikeFormatCode(character); } i++; } formatterCode += ";}"; -//MochiKit.Logging.logDebug("--- Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale - formatterCode: " + formatterCode); eval(formatterCode); result = Clipperz.Date.__scratchFormatter.call(this, aDate, aLocale); delete Clipperz.Date.__scratchFormatter; -//MochiKit.Logging.logDebug("<<< Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale"); return result; }, //------------------------------------------------------------------------- 'parseDateWithPHPLikeTemplateAndLocale': function(aString, aFormat, aLocale) { return new Date(); }, //========================================================================= 'formatDateWithUTCFormatAndLocale': function(aDate, aLocale) { // return Clipperz.Date.formatWithJavaLikeTemplateAndLocale(aDate, "EEE, dd MMMM yyyy HH:mm:ss zzz", aLocale); return aDate.toString(); }, 'parseDateWithUTCFormatAndLocale': function(aValue, aLocale) { return new Date(Date.parse(aValue)); }, //========================================================================= 'exception': { // 'AbstractMethod': new MochiKit.Base.NamedError("Clipperz.Base.exception.AbstractMethod"), // 'UnknownType': new MochiKit.Base.NamedError("Clipperz.Base.exception.UnknownType") }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/KeePassExportProcessor.js b/frontend/gamma/js/Clipperz/KeePassExportProcessor.js index a3c10c8..e35d729 100644 --- a/frontend/gamma/js/Clipperz/KeePassExportProcessor.js +++ b/frontend/gamma/js/Clipperz/KeePassExportProcessor.js @@ -1,193 +1,191 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } Clipperz.KeePassExportProcessor = function(args) { args = args || {}; return this; } //============================================================================= Clipperz.KeePassExportProcessor.prototype = MochiKit.Base.update(null, { //------------------------------------------------------------------------- 'deferredParse_core': function(aContext) { var deferredResult; if (aContext.line == "") { deferredResult = MochiKit.Async.succeed(aContext.result); } else { var record; record = this.parseRecord(aContext); if (record != null) { aContext.result.push(record); } aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, ""); deferredResult = new Clipperz.Async.Deferred("KeePassExportProcessor.deferredParse_core"); deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); deferredResult.addCallback(MochiKit.Async.wait, 0.2); deferredResult.addMethod(this, 'deferredParse_core'); deferredResult.callback(aContext); } return deferredResult; }, //......................................................................... 'deferredParse': function(aValue) { var deferredResult; var lines; var context; lines = aValue.replace(/\r?\n/g, "\n"); context = { line: lines, size: lines.length, result: [] } deferredResult = new Clipperz.Async.Deferred("KeePassExportProcessor.deferredResult"); deferredResult.addMethod(this, 'deferredParse_core'); deferredResult.callback(context); return deferredResult; }, //------------------------------------------------------------------------- 'parseRecord': function(aContext) { var result; var recordLabelRegexp; var fieldLabelRegexp; var fieldValueRegexp; var fullLineRegexp; /* [Record name] Group Tree: UserName: URL: Password: Notes: test UUID: 525f62430079bae48b79ed2961924b05 Icon: 0 Creation Time: 2007-06-26 17:56:03 Last Access: 2007-10-25 16:23:51 Last Modification: 2007-10-25 16:23:51 Expires: 2999-12-28 23:59:59 [Record name] ==> Title Group: General ==> Group Group Tree: ==> Group Tree UserName: ==> UserName URL: ==> URL Password: ==> Password Notes: test ==> Notes UUID: 525f62430079bae48b79ed2961924b05 ==> UUID Icon: 0 ==> Icon Creation Time: 2007-06-26 17:56:03 ==> Creation Time Last Access: 2007-10-25 16:23:51 ==> Last Access Last Modification: 2007-10-25 16:23:51 ==> Last Modification Expires: 2999-12-28 23:59:59 ==> Expires Attachment Description: ==> Attachment Description Attachment: ==> Attachment */ // recordLabelRegexp = new RegExp("(^\\[(.*)\\]\\n|^Title:\s*(.*)\\n)"); recordLabelRegexp = new RegExp("^\\[(.*)\\]\\n|^Title:\s*(.*)\\n"); fieldLabelRegexp = new RegExp("^\s?(Group|Group Tree|Username|UserName|User Name|Url|URL|Password|Notes|Comment|UUID|Icon|Creation Time|Last Access|Last Modification|Expires|Attachment Description|Attachment|Valid until): "); fieldValueRegexp = new RegExp("(.*)(\\n|$)"); fullLineRegexp = new RegExp("^(.*\\n)"); if (recordLabelRegexp.test(aContext.line) == true) { var line; line = aContext.line; result = {}; result['Title'] = line.match(recordLabelRegexp)[1]; line = line.replace(/^.*\n/, ""); while (fieldLabelRegexp.test(line) == true) { var fieldName; var fieldValue; fieldName = RegExp.$1; line = RegExp.rightContext; fieldValue = line.match(fieldValueRegexp)[1]; line = RegExp.rightContext; if (fieldName == 'Notes') { var isMultiline; isMultiline = false; if ((line != "") && (fieldLabelRegexp.test(line) == false) && (recordLabelRegexp.test(line) == false)) { fieldValue += '\n'; } while ((line != "") && (fieldLabelRegexp.test(line) == false) && (recordLabelRegexp.test(line) == false)) { var newLineValue; newLineValue = line.match(fullLineRegexp)[1]; if (newLineValue != "\n") { isMultiline = true; } fieldValue += newLineValue; line = RegExp.rightContext; } if (isMultiline) { fieldValue = fieldValue.replace(/\n$/g, ""); } else { fieldValue = fieldValue.replace(/\n\n$/g, ""); } line = line.replace(/^\n/, ''); } result[fieldName] = fieldValue; } } else { result = null; } aContext.line = line; return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/KeyValueObjectStore.js b/frontend/gamma/js/Clipperz/KeyValueObjectStore.js index 36cda88..8bc125b 100644 --- a/frontend/gamma/js/Clipperz/KeyValueObjectStore.js +++ b/frontend/gamma/js/Clipperz/KeyValueObjectStore.js @@ -1,173 +1,166 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } //############################################################################# Clipperz.KeyValueObjectStore = function(args) { args = args || {}; // this._name = args['name'] || "unnamed KeyValueObjectStore"; this._values = args['values'] || {}; // this._referenceObjectStore = null; -//console.log("new KeyValueObjectStore", args, this._values); return this; } Clipperz.KeyValueObjectStore.prototype = MochiKit.Base.update(null, { 'values': function() { return this._values; }, 'initWithValues': function (someValues) { this._values = Clipperz.Base.deepClone(someValues) || {}; return this; }, 'setValues': function (someValues) { -//console.log("KeyValueObjectStore.setValues", someValues); this._values = someValues; return this; }, // 'initWithObjectStore': function (anObjectStore) { // this._referenceObjectStore = anObjectStore; // }, 'removeAllData': function () { this._values = {}; }, //------------------------------------------------------------------------- 'getValue': function(aKeyPath) { var result; var keys; var i,c; result = this.values(); keys = (aKeyPath + '').split('.'); c = keys.length; i = 0; while ((i<c) && (result != null)) { if (typeof result[keys[i]] != 'undefined') { result = result[keys[i]]; } else { result = null; } i++; } return result; }, //------------------------------------------------------------------------- 'setValue': function(aKeyPath, aValue) { var targetObject; var keys; var i,c; -//console.log(">>> KeyValueObjectStore.setValue", this, this.values(), aKeyPath, aValue); targetObject = this.values(); keys = (aKeyPath + '').split('.'); c = keys.length - 1; for (i=0; i<c; i++) { -//console.log("--- KeyValueObjectStore.setValue", i, targetObject, keys[i]); if (typeof targetObject[keys[i]] == 'undefined') { targetObject[keys[i]] = {} } targetObject = targetObject[keys[i]]; } targetObject[keys[c]] = aValue; -//console.log("<<< KeyValueObjectStore.setValue"); return aValue; }, //------------------------------------------------------------------------- 'removeValue': function (aKeyPath) { // this.setValue(aKeyPath, null); var targetObject; var keys; var i,c; targetObject = this.values(); keys = ('' + aKeyPath).split('.'); c = keys.length - 1; for (i=0; i<c; i++) { if (typeof targetObject[keys[i]] == 'undefined') { targetObject[keys[i]] = {} } targetObject = targetObject[keys[i]]; } delete targetObject[keys[c]]; }, //------------------------------------------------------------------------- 'deferredGetOrSet': function(aKeyPath, aGetterFunction) { var deferredResult; if (this.getValue(aKeyPath) != null) { deferredResult = MochiKit.Async.succeed(this.getValue(aKeyPath)); } else { deferredResult = new Clipperz.Async.Deferred("KeyValueObjectStore.deferredGetOrSet [" + aKeyPath + "]", {trace:false}); deferredResult.addCallback(aGetterFunction); deferredResult.addMethod(this, 'setValue', aKeyPath); deferredResult.callback(); } return deferredResult; }, //------------------------------------------------------------------------- 'isEmpty': function () { return (MochiKit.Base.keys(this.values()).length == 0) }, //------------------------------------------------------------------------- /* 'dumpData': function () { return Clipperz.Base.serializeJSON(this.values()); }, */ //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Logging.js b/frontend/gamma/js/Clipperz/Logging.js index 77a0896..b6b806a 100644 --- a/frontend/gamma/js/Clipperz/Logging.js +++ b/frontend/gamma/js/Clipperz/Logging.js @@ -1,39 +1,32 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz'); -if (typeof console == 'undefined') { - Clipperz.log = MochiKit.Logging.logDebug; -// Safari/WebKit 4 -} else if (navigator.userAgent.match(/WebKit/)) { -// Clipperz.log = console.log; - Clipperz.log = MochiKit.Logging.logDebug; -} else if (navigator.userAgent.match(/Gecko/)) { - Clipperz.log = function () { -// firebug 1.3 bug see http://code.google.com/p/fbug/issues/detail?id=1347 - console.log.apply(window._firebug, arguments); - }; -}
\ No newline at end of file +Clipperz.log = function () { + console.log.apply(console, arguments); +} + +Clipperz.logError = Clipperz.log; +Clipperz.logWarning = Clipperz.log; +Clipperz.logDebug = Clipperz.log;
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/BookmarkletProcessor.js b/frontend/gamma/js/Clipperz/PM/BookmarkletProcessor.js index 897beed..4818b76 100644 --- a/frontend/gamma/js/Clipperz/PM/BookmarkletProcessor.js +++ b/frontend/gamma/js/Clipperz/PM/BookmarkletProcessor.js @@ -1,193 +1,191 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ /* if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } Clipperz.PM.BookmarkletProcessor = function(aConfiguration) { this._configuration = aConfiguration; this._editableFields = null; this._favicon = null; return this; } Clipperz.PM.BookmarkletProcessor.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.PM.BookmarkletProcessor"; }, //------------------------------------------------------------------------- 'configuration': function() { return this._configuration; }, //------------------------------------------------------------------------- 'pageTitle': function() { return this.configuration().page.title; }, //------------------------------------------------------------------------- 'fields': function() { return this.configuration().form.inputs; }, //------------------------------------------------------------------------- 'editableFields': function() { if (this._editableFields == null) { this._editableFields = MochiKit.Base.filter(function(aField) { var result; var type; type = aField['type'].toLowerCase(); result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); return result; }, this.fields()) } return this._editableFields; }, //------------------------------------------------------------------------- 'hostname': function() { if (this._hostname == null) { var actionUrl; actionUrl = this.configuration()['form']['attributes']['action']; this._hostname = actionUrl.replace(/ ^ h t t p s ? : \ / \ / ( [ ^ \ / ] * ) \ / . * /, '$1'); } return this._hostname; }, 'favicon': function() { if (this._favicon == null) { this._favicon = "http://" + this.hostname() + "/favicon.ico"; } return this._favicon; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# / * Clipperz.PM.BookmarkletProcessor.createRecordFromBookmarkletConfiguration = function(anUser, aConfiguration) { var processor; var record; var recordVersion; var directLogin; var bindings; var i,c; processor = new Clipperz.PM.BookmarkletProcessor(aConfiguration); record = new Clipperz.PM.DataModel.Record({ 'label': processor.pageTitle(), 'notes': "", 'user': anUser }); recordVersion = new Clipperz.PM.DataModel.Record.Version(record, {}) record.setCurrentVersion(recordVersion); bindings = {}; c = processor.editableFields().length; for (i=0; i<c; i++) { var formField; var recordField; formField = processor.editableFields()[i]; recordField = new Clipperz.PM.DataModel.RecordField({ 'label': formField['name'], 'value': formField['value'], 'type': Clipperz.PM.Strings.inputTypeToRecordFieldType[formField['type']], 'hidden': false, 'recordVersion': recordVersion }); recordVersion.addField(recordField); bindings[formField['name']] = recordField.key(); } directLogin = new Clipperz.PM.DataModel.DirectLogin({ 'record': record, 'label': processor.pageTitle(), 'favicon': processor.favicon(), 'formData': processor.configuration()['form'], 'bindingData': bindings, 'bookmarkletVersion': '0.2' }); record.addDirectLogin(directLogin); anUser.addRecord(record); return record; }; * / //----------------------------------------------------------------------------- Clipperz.PM.BookmarkletProcessor.sanitizeBookmarkletConfiguration = function(aConfiguration) { var result; // throw "XSS Bookmarklet attempt"; result = aConfiguration; return result; }; //----------------------------------------------------------------------------- Clipperz.PM.BookmarkletProcessor.checkBookmarkletConfiguration = function(aConfiguration) { var result; try { result = Clipperz.Base.evalJSON(aConfiguration); result = Clipperz.PM.BookmarkletProcessor.sanitizeBookmarkletConfiguration(result); if (result['version'] != '0.2.3') { throw "WrongBookmarkletVersion"; } } catch (exception) { throw exception; } return result; }; //----------------------------------------------------------------------------- */
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/Connection.js b/frontend/gamma/js/Clipperz/PM/Connection.js index a05a310..6a8f15e 100644 --- a/frontend/gamma/js/Clipperz/PM/Connection.js +++ b/frontend/gamma/js/Clipperz/PM/Connection.js @@ -1,640 +1,637 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } //----------------------------------------------------------------------------- // // Abstract C O N N E C T I O N class // //----------------------------------------------------------------------------- Clipperz.PM.Connection = function (args) { args = args || {}; this._proxy = args.proxy || Clipperz.PM.Proxy.defaultProxy; this._getCredentialsFunction = args.getCredentialsFunction; this._clipperz_pm_crypto_version = null; this._connectionId = null; this._sharedSecret = null; this._serverLockValue = null; return this; } Clipperz.PM.Connection.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Connection [" + this.version() + "]"; }, //========================================================================= 'version': function() { throw Clipperz.Base.exception.AbstractMethod; }, 'clipperz_pm_crypto_version': function() { if (this._clipperz_pm_crypto_version == null) { var connectionVersions; var versions; var version; var i, c; version = null; connectionVersions = Clipperz.PM.Connection.communicationProtocol.versions; versions = MochiKit.Base.keys(connectionVersions); c = versions.length; for (i=0; i<c; i++) { if (! (versions[i] == 'current')) { if (this instanceof connectionVersions[versions[i]]) { version = versions[i]; }; } } this._clipperz_pm_crypto_version = version; } return this._clipperz_pm_crypto_version; }, //------------------------------------------------------------------------- 'defaultErrorHandler': function(anErrorString, anException) { -MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString + " (" + anException + ")"); +// Clipperz.logError("### Connection.defaultErrorHandler: " + anErrorString, anException); + Clipperz.logError("### Connection.defaultErrorHandler: " + anErrorString + " (" + anException + ")"); }, //------------------------------------------------------------------------- 'getCredentialsFunction': function () { return this._getCredentialsFunction; }, 'normalizedCredentials': function(someValues) { throw Clipperz.Base.exception.AbstractMethod; }, //========================================================================= 'proxy': function () { return this._proxy; }, //========================================================================= 'register': function () { throw Clipperz.Base.exception.AbstractMethod; }, 'login': function() { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'message': function(someArguments, aCallback) { throw Clipperz.Base.exception.AbstractMethod; }, //------------------------------------------------------------------------- 'serverSideUserCredentials': function() { throw Clipperz.Base.exception.AbstractMethod; }, //========================================================================= 'sharedSecret': function () { return this._sharedSecret; }, 'setSharedSecret': function (aValue) { this._sharedSecret = aValue; }, //------------------------------------------------------------------------- 'connectionId': function() { return this._connectionId; }, 'setConnectionId': function(aValue) { this._connectionId = aValue; }, //------------------------------------------------------------------------- 'serverLockValue': function () { return this._serverLockValue; }, 'setServerLockValue': function (aValue) { this._serverLockValue = aValue; }, //========================================================================= /* // TODO: ????? 'oneTimePassword': function() { return this._oneTimePassword; }, 'setOneTimePassword': function(aValue) { this._oneTimePassword = aValue; }, */ //========================================================================= 'reset': function() { this.setSharedSecret(null); this.setConnectionId(null); }, //========================================================================= __syntaxFix__: "syntax fix" } ); if (typeof(Clipperz.PM.Connection.SRP) == 'undefined') { Clipperz.PM.Connection.SRP = {}; } //----------------------------------------------------------------------------- // // S R P [ 1 . 0 ] C O N N E C T I O N class // //----------------------------------------------------------------------------- Clipperz.PM.Connection.SRP['1.0'] = function (args) { Clipperz.PM.Connection.call(this, args); return this; } Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.PM.Connection(), { 'version': function() { return '1.0'; }, //========================================================================= 'register': function (someUserData) { var deferredResult; var cryptoVersion; var srpConnection; cryptoVersion = this.clipperz_pm_crypto_version(); deferredResult = new Clipperz.Async.Deferred("Connection.registerWithVersion", {trace:false}); deferredResult.collectResults({ 'credentials': [ this.getCredentialsFunction(), MochiKit.Base.method(this, 'normalizedCredentials'), MochiKit.Base.bind(function(someCredentials) { var srpConnection; var result; srpConnection = new Clipperz.Crypto.SRP.Connection({ C:someCredentials['username'], P:someCredentials['password'], hash:this.hash() }); result = srpConnection.serverSideCredentials(); result['version'] = Clipperz.PM.Connection.communicationProtocol.currentVersion; return result; }, this) ], 'user': MochiKit.Base.partial(MochiKit.Async.succeed, someUserData), 'version': MochiKit.Base.partial(MochiKit.Async.succeed, Clipperz.PM.Connection.communicationProtocol.currentVersion), 'message': MochiKit.Base.partial(MochiKit.Async.succeed, 'completeRegistration') }); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this.proxy(), 'registration'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'updateCredentials': function (aUsername, aPassphrase, someUserData) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Connection.updateCredentials", {trace:false}); deferredResult.collectResults({ 'credentials': [ MochiKit.Base.method(this, 'normalizedCredentials', {username:aUsername, password:aPassphrase}), MochiKit.Base.bind(function(someCredentials) { var srpConnection; var result; srpConnection = new Clipperz.Crypto.SRP.Connection({ C:someCredentials['username'], P:someCredentials['password'], hash:this.hash() }); result = srpConnection.serverSideCredentials(); result['version'] = Clipperz.PM.Connection.communicationProtocol.currentVersion; return result; }, this) ], 'user': MochiKit.Base.partial(MochiKit.Async.succeed, someUserData) }); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this, 'message', 'upgradeUserCredentials'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.callback(); return deferredResult; }, //========================================================================= 'redeemOneTimePassword': function (someParameters) { -//console.log("Connections.redeemOneTimePassword", someParameters['username'], someParameters['password']); /* //========================================================================= // LOGIN WITH PASSPHRASE, extracted from the TRUNK version (LoginPanel.js) deferredResult.addCallback(function(anUsername, aOneTimePassword) { var args; args = { 'message': 'oneTimePassword', 'version': Clipperz.PM.Crypto.communicationProtocol.currentVersion, 'parameters': { 'oneTimePasswordKey': Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(anUsername, aOneTimePassword), 'oneTimePasswordKeyChecksum': Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(anUsername, aOneTimePassword) } } return args; }, anUsername, oneTimePassword); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_loadingOTP'); deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'handshake')); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_extractingPassphrase'); deferredResult.addCallback(function(aResult) { return Clipperz.PM.Crypto.deferredDecrypt(oneTimePassword, aResult['data'], aResult['version']); }); deferredResult.addCallback(function(aResult) { return (new Clipperz.ByteArray().appendBase64String(aResult['passphrase'])).asString(); }); deferredResult.addMethod(this, 'doLoginWithUsernameAndPassphrase', anUsername), */ var args; var normalizedOTP; normalizedOTP = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(someParameters['password']); args = { 'message': 'oneTimePassword', 'version': Clipperz.PM.Connection.communicationProtocol.currentVersion, 'parameters': { 'oneTimePasswordKey': Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(someParameters['username'], normalizedOTP), 'oneTimePasswordKeyChecksum': Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(someParameters['username'], normalizedOTP) } } return Clipperz.Async.callbacks("Connction.redeemOTP", [ MochiKit.Base.method(this.proxy(), 'handshake', args), function(aResult) { return Clipperz.PM.Crypto.deferredDecrypt({ value: aResult['data'], key: normalizedOTP, version:aResult['version'] }); }, function(aResult) { return (new Clipperz.ByteArray().appendBase64String(aResult['passphrase'])).asString(); } ], {trace:false}) }, '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'); // deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'updatedProgressState', 'connection_sendingCredentials'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addCallback(MochiKit.Base.bind(function(someCredentials) { srpConnection = new Clipperz.Crypto.SRP.Connection({ C:someCredentials['username'], P:someCredentials['password'], hash:this.hash() }); }, this)); deferredResult.addCallback(function() { var result; result = { message: 'connect', version: cryptoVersion, parameters: { C: srpConnection.C(), A: srpConnection.A().asString(16) // reconnecting: this.connectionId() } }; // TODO: ????? // if (isReconnecting == true) { // args.parameters['reconnecting'] = aConnection.connectionId(); // } return result; }); deferredResult.addMethod(this.proxy(), 'handshake'); // deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'updatedProgressState', 'connection_credentialVerification'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addCallback(function(someParameters) { var result; srpConnection.set_s(new Clipperz.Crypto.BigInt(someParameters['s'], 16)); srpConnection.set_B(new Clipperz.Crypto.BigInt(someParameters['B'], 16)); // TODO: ????? // if (typeof(someParameters['oneTimePassword']) != 'undefined') { // this.setOneTimePassword(someParameters['oneTimePassword']); // } result = { message: 'credentialCheck', version: cryptoVersion, parameters: { M1: srpConnection.M1() } }; return result; }); deferredResult.addMethod(this.proxy(), 'handshake'); deferredResult.addCallback(function(someParameters) { var result; if (someParameters['M2'] == srpConnection.M2()) { result = MochiKit.Async.succeed(someParameters); } else { result = MochiKit.Async.fail(Clipperz.PM.Connection.exception.WrongChecksum); } return result; }); deferredResult.addCallback(MochiKit.Base.bind(function(someParameters) { this.setConnectionId(someParameters['connectionId']); this.setSharedSecret(srpConnection.K()); // TODO: ????? // 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'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addCallback(MochiKit.Async.succeed, {result:"done"}); deferredResult.callback(); return deferredResult; }, //========================================================================= 'logout': function() { return Clipperz.Async.callbacks("Connection.logout", [ MochiKit.Base.method(this, 'setSharedSecret'), MochiKit.Base.method(this.proxy(), 'logout', {}) ], {trace:false}); }, //========================================================================= 'ping': function () { // TODO: ping the server in order to have a valid session }, //========================================================================= '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: parameters } return this.sendMessage(args); }, //------------------------------------------------------------------------- 'sendMessage': function(someArguments) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Connection.sendMessage", {trace:false}); deferredResult.addMethod(this.proxy(), 'message', someArguments); deferredResult.addCallback(MochiKit.Base.bind(function(res) { if (typeof(res['lock']) != 'undefined') { this.setServerLockValue(res['lock']); } return res; }, this)); deferredResult.addErrback(MochiKit.Base.method(this, 'messageExceptionHandler'), someArguments); deferredResult.callback(); return deferredResult }, //------------------------------------------------------------------------- 'messageExceptionHandler': function(anOriginalMessageArguments, anError) { var result; -console.log(">>> Connection.messageExceptionHandler", anError, anError.message); +Clipperz.log(">>> Connection.messageExceptionHandler: " + anError.message, anError); if (anError instanceof MochiKit.Async.CancelledError) { result = anError; } else { if ((anError.message == 'Trying to communicate without an active connection') || (anError.message == 'No tollManager available for current session') ) { result = this.reestablishConnection(anOriginalMessageArguments); } else if (anError.message == 'Session with stale data') { MochiKit.Signal.signal(this, 'EXCEPTION'); } else { result = anError; } } -console.log("<<< Connection.messageExceptionHandler", anError) - +Clipperz.log("<<< Connection.messageExceptionHandler") + return result;; }, //========================================================================= 'reestablishConnection': function(anOriginalMessageArguments) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Connection.reestablishConnection"); deferredResult.addMethod(this, 'reset'); deferredResult.addMethod(this, 'login', true); deferredResult.addCallback(MochiKit.Base.bind(function(aMessage) { aMessage['srpSharedSecret'] = this.sharedSecret(); return aMessage; }, this), anOriginalMessageArguments); deferredResult.addMethod(this, 'sendMessage'); deferredResult.addErrback(MochiKit.Signal.signal, this, 'EXCEPTION', null); deferredResult.callback(); return deferredResult; }, //========================================================================= 'serverSideUserCredentials': function(aUsername, aPassword) { var result; var newSrpConnection; var normalizedAttributes; normalizedAttributes = this.normalizedCredentials({username:aUsername, password:aPassword}); newSrpConnection = new Clipperz.Crypto.SRP.Connection({ C:normalizedAttributes['username'], P:normalizedAttributes['password'], hash:this.hash() }); result = newSrpConnection.serverSideCredentials(); result['version'] = this.clipperz_pm_crypto_version(); return result; }, //========================================================================= 'normalizedCredentials': function(someValues) { var result; result = {} result['username'] = this.hash()(new Clipperz.ByteArray(someValues['username'])).toHexString().substring(2); result['password'] = this.hash()(new Clipperz.ByteArray(someValues['password'] + someValues['username'])).toHexString().substring(2); return result; }, //----------------------------------------------------------------------------- 'hash': function() { return Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].hash; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //----------------------------------------------------------------------------- // // S R P [ 1 . 1 ] C O N N E C T I O N class // //----------------------------------------------------------------------------- Clipperz.PM.Connection.SRP['1.1'] = function (args) { Clipperz.PM.Connection.SRP['1.0'].call(this, args); return this; } Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz.PM.Connection.SRP['1.0'](), { 'version': function() { return '1.1'; }, //----------------------------------------------------------------------------- 'normalizedCredentials': function(someValues) { var result; result = {} result['username'] = this.hash()(new Clipperz.ByteArray(someValues['username'] + someValues['password'])).toHexString().substring(2); result['password'] = this.hash()(new Clipperz.ByteArray(someValues['password'] + someValues['username'])).toHexString().substring(2); return result; }, //----------------------------------------------------------------------------- 'hash': function() { return Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].hash; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); 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") }; Clipperz.PM.Connection.communicationProtocol = { 'currentVersion': '0.2', 'versions': { '0.1': Clipperz.PM.Connection.SRP['1.0'], //Clipperz.Crypto.SRP.versions['1.0'].Connection, '0.2': Clipperz.PM.Connection.SRP['1.1'] //Clipperz.Crypto.SRP.versions['1.1'].Connection }, 'fallbackVersions': { // 'current': '0.1', '0.2': '0.1', '0.1': null } }; MochiKit.Base.update(Clipperz.PM.Connection.communicationProtocol.versions, { 'current': Clipperz.PM.Connection.communicationProtocol.versions[Clipperz.PM.Connection.communicationProtocol.currentVersion] }); MochiKit.Base.update(Clipperz.PM.Connection.communicationProtocol.fallbackVersions, { 'current': Clipperz.PM.Connection.communicationProtocol.fallbackVersions[Clipperz.PM.Connection.communicationProtocol.currentVersion] }); diff --git a/frontend/gamma/js/Clipperz/PM/Crypto.js b/frontend/gamma/js/Clipperz/PM/Crypto.js index 31fe349..cd10e33 100644 --- a/frontend/gamma/js/Clipperz/PM/Crypto.js +++ b/frontend/gamma/js/Clipperz/PM/Crypto.js @@ -1,510 +1,508 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Crypto) == 'undefined') { Clipperz.PM.Crypto = {}; } Clipperz.PM.Crypto.VERSION = "0.2"; Clipperz.PM.Crypto.NAME = "Clipperz.PM.Crypto"; Clipperz.PM.Crypto.encryptingFunctions = {}; MochiKit.Base.update(Clipperz.PM.Crypto, { '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- /* 'communicationProtocol': { 'currentVersion': '0.2', 'versions': { '0.1': Clipperz.PM.Connection.SRP['1.0'], //Clipperz.Crypto.SRP.versions['1.0'].Connection, '0.2': Clipperz.PM.Connection.SRP['1.1'] //Clipperz.Crypto.SRP.versions['1.1'].Connection }, 'fallbackVersions': { 'current': '0.1', '0.2': '0.1', '0.1': null } }, */ //------------------------------------------------------------------------- 'encryptingFunctions': { 'currentVersion': '0.3', 'versions': { //##################################################################### '0.1': { 'encrypt': function(aKey, aValue) { return Clipperz.Crypto.Base.encryptUsingSecretKey(aKey, Clipperz.Base.serializeJSON(aValue)); }, 'deferredEncrypt': function(aKey, aValue) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Crypto[0.1].deferredEncrypt"); deferredResult.addCallback(Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].encrypt, aKey, aValue); deferredResult.callback(); return deferredResult; }, 'decrypt': function(aKey, aValue) { var result; if (aValue != null) { result = Clipperz.Base.evalJSON(Clipperz.Crypto.Base.decryptUsingSecretKey(aKey, aValue)); } else { result = null; } return result; }, 'deferredDecrypt': function(aKey, aValue) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Crypto.[0.1].deferredDecrypt"); deferredResult.addCallback(Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].decrypt, aKey, aValue); deferredResult.callback(); return deferredResult; }, 'hash': function(aValue) { var result; var strngResult; stringResult = Clipperz.Crypto.Base.computeHashValue(aValue.asString()); // !!!!!!! result = new Clipperz.ByteArray("0x" + stringResult); return result; }, 'deriveKey': function(aStringValue) { return Clipperz.Crypto.Base.computeHashValue(aStringValue); } }, //##################################################################### '0.2': { 'encrypt': function(aKey, aValue, aNonce) { var result; var key, value; var dataToEncrypt; var encryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray(Clipperz.Base.serializeJSON(aValue)); dataToEncrypt = Clipperz.Crypto.SHA.sha_d256(value).appendBlock(value); encryptedData = Clipperz.Crypto.AES.encrypt(key, dataToEncrypt, aNonce); result = encryptedData.toBase64String(); return result; }, 'deferredEncrypt': function(aKey, aValue, aNonce) { var deferredResult; var key, value; var dataToEncrypt; // var encryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray(Clipperz.Base.serializeJSON(aValue)); dataToEncrypt = Clipperz.Crypto.SHA.sha_d256(value).appendBlock(value); deferredResult = new Clipperz.Async.Deferred("Crypto[0.2].deferredEncrypt") deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, dataToEncrypt, aNonce); deferredResult.addCallback(function(aResult) { return aResult.toBase64String(); }) deferredResult.callback(); return deferredResult; }, 'decrypt': function(aKey, aValue) { var result; if (aValue != null) { var key, value; var decryptedData; var decryptedValue; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); decryptedData = Clipperz.Crypto.AES.decrypt(key, value); decryptedValue = decryptedData.split((256/8)); try { result = Clipperz.Base.evalJSON(decryptedValue.asString()); } catch (exception) { - MochiKit.Logging.logError("Error while decrypting data [1]"); + Clipperz.logError("Error while decrypting data [1]"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; } } else { result = null; } return result; }, 'deferredDecrypt': function(aKey, aValue) { var result; if (aValue != null) { var deferredResult; var key, value; // var decryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); deferredResult = new Clipperz.Async.Deferred("Crypto.[0.2].deferredDecrypt"); deferredResult.addCallback(Clipperz.Crypto.AES.deferredDecrypt, key, value); deferredResult.addCallback(function(aResult) { var result; var decryptedData; decryptedData = aResult.split((256/8)); try { result = Clipperz.Base.evalJSON(decryptedData.asString()); } catch (exception) { - MochiKit.Logging.logError("Error while decrypting data [2]"); + Clipperz.logError("Error while decrypting data [2]"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; } return result; }) deferredResult.callback(); result = deferredResult; } else { result = MochiKit.Async.succeed(null); } return result; }, 'hash': Clipperz.Crypto.SHA.sha_d256, 'deriveKey': function(aStringValue) { var byteData; var result; byteData = new Clipperz.ByteArray(aStringValue); result = Clipperz.Crypto.SHA.sha_d256(byteData); return result; } }, //##################################################################### '0.3': { 'encrypt': function(aKey, aValue, aNonce) { var result; var key, value; var data; var dataToEncrypt; var encryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = Clipperz.Base.serializeJSON(aValue); data = new Clipperz.ByteArray(value); encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce); result = encryptedData.toBase64String(); return result; }, 'deferredEncrypt': function(aKey, aValue, aNonce) { var deferredResult; var key, value; var data; var dataToEncrypt; var encryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = Clipperz.Base.serializeJSON(aValue); data = new Clipperz.ByteArray(value); deferredResult = new Clipperz.Async.Deferred("Crypto[0.3].deferredEncrypt") deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, data, aNonce); deferredResult.addCallback(function(aResult) { return aResult.toBase64String(); }) deferredResult.callback(); return deferredResult; }, 'decrypt': function(aKey, aValue) { var result; if (aValue != null) { var key, value; var decryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); decryptedData = Clipperz.Crypto.AES.decrypt(key, value); value = decryptedData.asString(); try { result = Clipperz.Base.evalJSON(value); } catch (exception) { - MochiKit.Logging.logError("Error while decrypting data [3]"); + Clipperz.logError("Error while decrypting data [3]"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; } } else { result = null; } return result; }, 'deferredDecrypt': function(aKey, aValue) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Crypto[0.3].deferredDecrypt", {trace: false}); // now = new Date; if (aValue != null) { var key, value; // var decryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); deferredResult.addCallback(Clipperz.Crypto.AES.deferredDecrypt, key, value); deferredResult.addCallback(MochiKit.Async.wait, 0.1); deferredResult.addCallback(function(aResult) { return aResult.asString(); }); deferredResult.addCallback(MochiKit.Async.wait, 0.1); deferredResult.addCallback(Clipperz.Base.evalJSON); deferredResult.addErrback(function(anError) { - MochiKit.Logging.logError("Error while decrypting data [4]"); + Clipperz.logError("Error while decrypting data [4]"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; }) } else { deferredResult.addCallback(function() { return null; }); } deferredResult.callback(); return deferredResult; }, 'hash': Clipperz.Crypto.SHA.sha_d256, 'deriveKey': function(aStringValue) { var byteData; var result; byteData = new Clipperz.ByteArray(aStringValue); result = Clipperz.Crypto.SHA.sha_d256(byteData); return result; } }, //##################################################################### /* '0.4': { 'encrypt': function(aKey, aValue, aNonce) { var result; var key, value; var data; var dataToEncrypt; var encryptedData; -//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); +//Clipperz.logDebug(">>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1"); +//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1"); value = Clipperz.Base.serializeJSON(aValue); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2"); +//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2"); / * -//MochiKit.Logging.logDebug("--> encrypt.fullSize: " + value.length); +//Clipperz.logDebug("--> encrypt.fullSize: " + value.length); value = value.replace(/":{"label":"/g, '":{l:"'); value = value.replace(/":{"key":"/g, '":{k:"'); value = value.replace(/":{"notes":"/g, '":{n:"'); value = value.replace(/":{"record":"/g, '":{r:"'); value = value.replace(/", "label":"/g, '",l:"'); value = value.replace(/", "favicon":"/g, '",f:"'); -//MochiKit.Logging.logDebug("<-- encrypt.compressed: " + value.length); +//Clipperz.logDebug("<-- encrypt.compressed: " + value.length); * / data = new Clipperz.ByteArray(value); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3"); +//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3"); encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4"); +//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4"); result = encryptedData.toBase64String(); -//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); +//Clipperz.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); return result; }, 'decrypt': function(aKey, aValue) { var result; if (aValue != null) { var key, value; var decryptedData; key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); decryptedData = Clipperz.Crypto.AES.decrypt(key, value); value = decryptedData.asString(); / * value = value.replace(/":{l:"/g, '":{"label":"'); value = value.replace(/":{k:"/g, '":{"key":"'); value = value.replace(/":{n:"/g, '":{"notes":"'); value = value.replace(/":{r:"/g, '":{"record":"'); value = value.replace(/",l:"/g, '", "label":"'); value = value.replace(/",f:"/g, '", "favicon":"'); * / try { result = Clipperz.Base.evalJSON(value); } catch (exception) { - MochiKit.Logging.logError("Error while decrypting data"); + Clipperz.logError("Error while decrypting data"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; } } else { result = null; } return result; }, 'hash': Clipperz.Crypto.SHA.sha_d256 }, */ //##################################################################### __syntaxFix__: "syntax fix" } }, //------------------------------------------------------------------------- 'encrypt': function(aKey, aValue, aVersion) { return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].encrypt(aKey, aValue); }, 'deferredEncrypt': function(someParameters) { return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters['version']].deferredEncrypt(someParameters['key'], someParameters['value']); }, //......................................................................... 'decrypt': function(aKey, aValue, aVersion) { return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].decrypt(aKey, aValue); }, 'deferredDecrypt': function(someParameters) { return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters['version']].deferredDecrypt(someParameters['key'], someParameters['value']); }, //------------------------------------------------------------------------- 'hash': function(aValue) { return Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion]['hash'](aValue); }, //------------------------------------------------------------------------- 'randomKey': function() { return Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2); }, //------------------------------------------------------------------------- 'deriveKey': function(aValue) { return Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion].deriveKey(aValue); }, //------------------------------------------------------------------------- 'passwordEntropy': function(aValue) { var result; var bitPerChar; bitPerChar = 4; if (/[a-z]/.test(aValue)) { bitPerChar ++; } if (/[A-Z]/.test(aValue)) { bitPerChar ++; } if (/[^a-zA-Z0-9]/.test(aValue)) { bitPerChar ++; } result = aValue.length * bitPerChar; return result; }, //------------------------------------------------------------------------- 'nullValue': '####', //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //***************************************************************************** //MochiKit.Base.update(Clipperz.PM.Connection.communicationProtocol.versions, { // 'current': Clipperz.PM.Connection.communicationProtocol.versions[Clipperz.PM.Connection.communicationProtocol.currentVersion] //}); MochiKit.Base.update(Clipperz.PM.Crypto.encryptingFunctions.versions, { 'current': Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion] }); //***************************************************************************** diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js index 8f8696d..507ee31 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js @@ -1,1073 +1,1063 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.DataModel'); Clipperz.PM.DataModel.DirectLogin = function(args) { args = args || {}; Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); this._record = args.record || Clipperz.Base.exception.raise('MandatoryParameter'); this._retrieveIndexDataFunction = args.retrieveIndexDataFunction || this.record().retrieveDirectLoginIndexDataFunction() || Clipperz.Base.exception.raise('MandatoryParameter'); this._setIndexDataFunction = args.setIndexDataFunction || this.record().setDirectLoginIndexDataFunction() || Clipperz.Base.exception.raise('MandatoryParameter'); this._removeIndexDataFunction = args.removeIndexDataFunction || this.record().removeDirectLoginIndexDataFunction() || Clipperz.Base.exception.raise('MandatoryParameter'); this._inputs = null; this._bindings = null; this._formValues = null; // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); this._transientState = null; this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); this.record().addDirectLogin(this); return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { 'toString': function() { return "DirectLogin (" + this.reference() + ")"; }, //========================================================================= 'reference': function () { return this._reference; }, //------------------------------------------------------------------------- 'record': function () { return this._record; }, //========================================================================= 'isBrandNew': function () { return this._isBrandNew; }, //========================================================================= 'removeIndexDataFunction': function () { return this._removeIndexDataFunction; }, 'remove': function () { return Clipperz.Async.callbacks("DirectLogin.remove", [ MochiKit.Base.partial(this.removeIndexDataFunction(), this.reference()), MochiKit.Base.method(this.record(), 'removeDirectLogin', this) ], {trace:false}); }, //========================================================================= /* 'inputsDeferredLock': function () { return this._inputsDeferredLock; }, 'bindingsDeferredLock': function () { return this._bindingsDeferredLock; }, 'formValuesDeferredLock': function () { return this._formValuesDeferredLock; }, */ //========================================================================= 'label': function () { return this.getIndexDataForKey('label'); }, 'setLabelKeepingBackwardCompatibilityWithBeta': function (aValue) { return Clipperz.Async.callbacks("DirectLogin.setLabelKeepingBackwardCompatibilityWithBeta", [ MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue), MochiKit.Base.method(this, 'setValue', 'label', aValue) ], {trace:false}); }, 'setLabel': function (aValue) { return this.setLabelKeepingBackwardCompatibilityWithBeta(aValue); // return this.setIndexDataForKey('label', aValue); }, //========================================================================= 'favicon': function () { return this.getIndexDataForKey('favicon'); }, 'setFavicon': function (aValue) { return this.setIndexDataForKey('favicon', aValue); }, 'faviconUrlWithBookmarkletConfiguration': function (aBookmarkletConfiguration) { var result; if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['page']['favicon'])) { result = aBookmarkletConfiguration['page']['favicon']; } else if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['form']['attributes']['action'])) { var actionUrl; var hostname; actionUrl = aBookmarkletConfiguration['form']['attributes']['action']; hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); result = "http://" + hostname + "/favicon.ico"; } else { result = null; } return result; }, //------------------------------------------------------------------------- /* 'faviconData': function () { var regexp = new RegExp('^data\:\/\/.*', 'i'); return Clipperz.Async.callbacks("DirectLogin.favicon", [ MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), MochiKit.Base.method(regexp, 'test'), Clipperz.Async.deferredIf("is data URL", [ MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon') ], [ MochiKit.Base.method(this, 'transientState'), MochiKit.Base.itemgetter('faviconData'), Clipperz.Async.deferredIf('has a chaced value for the favicon data', [ MochiKit.Base.operator.identity ], [ MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), MochiKit.Base.method(this, 'loadFaviconDataFromURL') ]) ]) ], {trace:false}); }, //------------------------------------------------------------------------- 'loadFaviconDataFromURL': function (anURL) { var deferredResult; var image; deferredResult = new Clipperz.Async.Deferred("DirectLogin.loadFaviconDataFromURL", {trace:false}); deferredResult.addCallback(function (anEvent) { var image = anEvent.src(); var canvas = document.createElement("canvas"); var result; canvas.width = image.width; canvas.height = image.height; var ctx = canvas.getContext("2d"); ctx.drawImage(image, 0, 0); result = canvas.toDataURL(/*"image/png"* /); return result; }); deferredResult.addErrback(MochiKit.Async.succeed, Clipperz.PM.Strings.getValue('defaultFaviconUrl')); deferredResult.addBoth(MochiKit.Base.bind(function (aDataUrl) { this.transientState()['faviconData'] = aDataUrl; return aDataUrl; }, this)); image = new Image(); MochiKit.Signal.connect(image, 'onload', MochiKit.Base.method(deferredResult, 'callback')); MochiKit.Signal.connect(image, 'onerror', MochiKit.Base.method(deferredResult, 'errback')); MochiKit.Signal.connect(image, 'onabort', MochiKit.Base.method(deferredResult, 'errback')); image.src = anURL; return deferredResult; }, */ //========================================================================= 'type': function () { return this.getValue('formData.attributes.type') }, //========================================================================= 'serializedData': function () { return Clipperz.Async.collectResults("DirectLogin.serializedData", { 'bookmarkletVersion': MochiKit.Base.method(this, 'getValue', 'bookmarkletVersion'), 'formData': MochiKit.Base.method(this, 'getValue', 'formData'), 'formValues': MochiKit.Base.method(this, 'getValue', 'formValues'), 'bindingData': [ MochiKit.Base.method(this, 'bindings'), function (someBindings) { var result; var bindingKey; result = {} for (bindingKey in someBindings) { result[bindingKey] = someBindings[bindingKey].serializedData(); } return result; } ] }, {trace:false})() }, //========================================================================= /* 'fixFormDataFromBookmarkletVersion_0_1': function(aValue) { //{"type":"radio", "name":"action", "value":"new-user", "checked":false }, { "type":"radio", "name":"action", "value":"sign-in", "checked":true } // || // \ / // \/ //{"name":"dominio", "type":"radio", "options":[{"value":"@alice.it", "checked":true}, {"value":"@tin.it", "checked":false}, {"value":"@virgilio.it", "checked":false}, {"value":"@tim.it", "checked":false}]} var result; var inputs; var updatedInputs; var radios; result = aValue; inputs = aValue['inputs']; updatedInputs = MochiKit.Base.filter(function(anInput) { var result; var type; type = anInput['type'] || 'text'; result = type.toLowerCase() != 'radio'; return result; }, inputs); radios = MochiKit.Base.filter(function(anInput) { var result; var type; type = anInput['type'] || 'text'; result = type.toLowerCase() == 'radio'; return result; }, inputs); if (radios.length > 0) { var updatedRadios; updatedRadios = {}; MochiKit.Iter.forEach(radios, MochiKit.Base.bind(function(aRadio) { var radioConfiguration; radioConfiguration = updatedRadios[aRadio['name']]; if (radioConfiguration == null) { radioConfiguration = {type:'radio', name:aRadio['name'], options:[]}; updatedRadios[aRadio['name']] = radioConfiguration; } // TODO: remove the value: field and replace it with element.dom.value = <some value> radioConfiguration.options.push({value:aRadio['value'], checked:aRadio['checked']}); // TODO: shoud remove the 'formValues' call, as it is now deferred // if ((aRadio['checked'] == true) && (this.formValues()[aRadio['name']] == null)) { // this.formValues()[aRadio['name']] = aRadio['value']; // } }, this)) updatedInputs = MochiKit.Base.concat(updatedInputs, MochiKit.Base.values(updatedRadios)); } delete result.inputs; result.inputs = updatedInputs; return result; }, '_fixConfiguration': function (aConfiguration) { var fixedConfiguration; // var inputs; // var bindings; // var i,c; fixedConfiguration = Clipperz.Base.deepClone(aConfiguration); -//console.log("PROCESS CONFIGURATION", aConfiguration); +//Clipperz.log("PROCESS CONFIGURATION", aConfiguration); switch (aConfiguration['bookmarkletVersion']) { case '0.1': fixedConfiguration['formData'] = this.fixFormDataFromBookmarkletVersion_0_1(aConfiguration['formData']); break; case '0.2': fixedConfiguration['formData'] = aConfiguration['formData']; break; } / * aConfiguration['_inputs'] = []; c = formData['inputs'].length; for (i=0; i<c; i++) { aConfiguration['_inputs'].push(new Clipperz.PM.DataModel.DirectLoginInput(formData['inputs'][i])); } * / / * aConfiguration['_bindings'] = {}; if (aConfiguration['legacyBindingData'] == null) { if (aConfiguration['bindingData'] != null) { var bindingKey; for (bindingKey in aConfiguration['bindingData']) { var newBinding; newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldKey:aConfiguration['bindingData'][bindingKey]}); aConfiguration['_bindings'][newBinding.key()] = newBinding; } } else { var editableFields; editableFields = MochiKit.Base.filter(function(aField) { var result; var type; type = aField['type'].toLowerCase(); result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); return result; }, aConfiguration['_inputs']); MochiKit.Iter.forEach(editableFields, MochiKit.Base.bind(function(anEditableField) { var newBinding; newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(anEditableField['name']); aConfiguration['_bindings'][newBinding.key()] = newBinding; }, this)); } } else { var bindingKey; for (bindingKey in aConfiguration['legacyBindingData']) { var newBinding; newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(bindingKey, {fieldName:aConfiguration['legacyBindingData'][bindingKey]}); aConfiguration['_bindings'][newBinding.key()] = newBinding; } } * / return fixedConfiguration; }, //------------------------------------------------------------------------- 'getObjectDataStore': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("DirectLogin.getObjectDataStore", {trace:false}); deferredResult.acquireLock(this.objectDataStoreDeferredLock()); deferredResult.addCallback(MochiKit.Base.bind(function () { var innerDeferredResult; if (this._objectDataStore == null) { this._objectDataStore = new Clipperz.KeyValueObjectStore(); innerDeferredResult = new Clipperz.Async.Deferred("DirectLogin.getObjectDataStore <inner deferred>", {trace:false}); // innerDeferredResult.addMethod(this.record(), 'getValue', 'directLogins' + '.' + this.reference()); innerDeferredResult.addMethod(this, 'getValue', ''), innerDeferredResult.addMethod(this, 'setOriginalState'); innerDeferredResult.addMethod(this, '_fixConfiguration'); innerDeferredResult.addMethod(this._objectDataStore, 'initWithValues'); // innerDeferredResult.addMethod(this._objectDataStore, 'setValues'); innerDeferredResult.callback(); } else { innerDeferredResult = MochiKit.Async.succeed(this._objectDataStore); } return innerDeferredResult; }, this)); deferredResult.releaseLock(this.objectDataStoreDeferredLock()); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'hasInitiatedObjectDataStore': function () { return (this._objectDataStore != null); }, //------------------------------------------------------------------------- 'resetObjectDataStore': function () { this._objectDataStore.removeAllData(); this._objectDataStore = null; }, */ //========================================================================= 'bookmarkletConfiguration': function () { return Clipperz.Async.callbacks("DirectLogin.bookmarkletConfiguration", [ Clipperz.Async.collectResults("DirectLogin.bookmarkletConfiguration <inner results>", { 'label': MochiKit.Base.method(this, 'label'), 'configuration': MochiKit.Base.method(this, 'getValue', '') }, {trace:false}), function (someValues) { var result; if (someValues['configuration'] != null) { var configuration; configuration = { 'page': { 'title': someValues['label'] // 'favicon' // 'url' }, 'form': someValues['configuration']['formData'], 'version': someValues['configuration']['bookmarkletVersion'] } result = Clipperz.Base.formatJSON(configuration); } else { result = ''; } return result; } ], {trace:false}); }, //------------------------------------------------------------------------- 'setBookmarkletConfiguration': function (aValue) { var bookmarkletConfiguration; bookmarkletConfiguration = Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(aValue); -//console.log("BOOKMARKLET CONFIGURATION", bookmarkletConfiguration); + return Clipperz.Async.callbacks("DirectLogin.setBookmarkletConfiguration", [ MochiKit.Base.method(this, 'setValue', 'formData', bookmarkletConfiguration['form']), -//function (aValue) { console.log("SET VALUE - formData", aValue); return aValue; }, MochiKit.Base.method(this, 'setValue', 'bookmarkletVersion', bookmarkletConfiguration['version']), MochiKit.Base.method(this, 'favicon'), Clipperz.Async.deferredIf("the favicon is not set", [ ], [ MochiKit.Base.method(this, 'faviconUrlWithBookmarkletConfiguration', bookmarkletConfiguration), MochiKit.Base.method(this, 'setFavicon') ]), MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration'), MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), MochiKit.Base.noop ], {trace:false}); }, //========================================================================= 'formAttributes': function () { return this.getValue('formData.attributes'); }, //========================================================================= 'inputs': function () { return Clipperz.Async.callbacks("DirectLogin.inputs", [ Clipperz.Async.deferredIf("this._inputs is defined", [ ], [ MochiKit.Base.method(this, 'updateInputsAfterChangingBookmarkletConfiguration') ]) ], {trace:false}, this._inputs); }, 'setInputWithFormDataConfiguration': function (aFormDataConfiguration) { this._inputs = {}; if (aFormDataConfiguration != null) { MochiKit.Iter.forEach(aFormDataConfiguration['inputs'], MochiKit.Base.bind(function (anInputData) { var newInput; newInput = new Clipperz.PM.DataModel.DirectLoginInput(anInputData); this._inputs[newInput.name()] = newInput; }, this)); } return this._inputs; }, 'updateInputsAfterChangingBookmarkletConfiguration': function () { return Clipperz.Async.callbacks("DirectLogin.updateInputsAfterChangingBookmarkletConfiguration", [ -// MochiKit.Base.method(this, 'getValue', ''), -//function (aValue) { console.log("VALUE", aValue); return aValue }, MochiKit.Base.method(this, 'getValue', 'formData'), -//function (aValue) { console.log("FORM DATA", aValue); return aValue }, MochiKit.Base.method(this, 'setInputWithFormDataConfiguration') ], {trace:false}); }, //========================================================================= 'inputValues': function () { return Clipperz.Async.callbacks("DirectLogin.inputValues", [ MochiKit.Base.method(this, 'inputs'), MochiKit.Base.values, -//function (aValue) { console.log("INPUTS", aValue); return aValue; }, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.partial(MochiKit.Base.method(this, 'inputValue'))), Clipperz.Async.collectAll, Clipperz.Base.mergeItems ], {trace:false}); }, 'inputValue': function (anInput) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("DirectLogin.inputValue", {trace:false}); if (anInput.needsFormValue()) { deferredResult.addMethod(this, 'formValues'); deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); deferredResult.addMethodcaller('value'); } else if (anInput.needsBinding()) { deferredResult.addMethod(this, 'bindings'); deferredResult.addCallback(MochiKit.Base.itemgetter(anInput.name())); deferredResult.addMethodcaller('field'); deferredResult.addMethodcaller('value'); } else { deferredResult.addCallback(MochiKit.Async.succeed, anInput.value()); } deferredResult.addCallback(function (anActualValue) { return [anInput.name(), anActualValue]; }); deferredResult.callback(); return deferredResult; }, //========================================================================= 'bindings': function () { return Clipperz.Async.callbacks("DirectLogin.bindings", [ Clipperz.Async.deferredIf("this._bindings is defined", [ ], [ MochiKit.Base.method(this, 'updateBindingsAfterChangingBookmarkletConfiguration'), MochiKit.Base.bind(function () { return this._bindings;}, this) ]) ], {trace:false}, this._bindings); }, 'bindFormFieldWithLabelToRecordFieldWithLabel': function (aFormFieldLabel, aRecordFieldLabel) { return Clipperz.Async.callbacks("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel", [ Clipperz.Async.collectResults("DirectLogin.bindFormFieldWithLabelToCardFieldWithLabel - collect results", { 'binding': [ MochiKit.Base.method(this, 'bindings'), MochiKit.Base.itemgetter(aFormFieldLabel) ], 'field': [ MochiKit.Base.method(this.record(), 'fieldWithLabel', aRecordFieldLabel) ] }), function (someValues) { someValues['binding'].setField(someValues['field']) } ], {trace:false}); }, //------------------------------------------------------------------------- /* 'bindingValues': function () { return Clipperz.Async.callbacks("DirectLogin.bindingValues", [ Clipperz.Async.collectResults("DirectLogin.bindingValues [collectResults]", { 'fieldValues': [ MochiKit.Base.method(this, 'record'), MochiKit.Base.methodcaller('getFieldsValues') ], 'bindings': MochiKit.Base.method(this, 'bindings') }, {trace:false}), function (someData) { var result; var bindingKey; result = {}; for (bindingKey in someData['bindings']) { result[bindingKey] = someData['fieldValues'][someData['bindings'][bindingKey].fieldKey()]['value']; } return result; } ], {trace:false}); }, */ //------------------------------------------------------------------------- 'updateBindingsAfterChangingBookmarkletConfiguration': function () { return Clipperz.Async.callbacks("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration", [ Clipperz.Async.collectResults("DirectLogin.updateBindingsAfterChangingBookmarkletConfiguration<collect results>", { 'currentValues': MochiKit.Base.method(this, 'getValue', ''), 'originalValues': MochiKit.Base.method(this, 'originalConfiguration'), 'inputs': MochiKit.Base.method(this, 'inputs') }, {trace:false}), MochiKit.Base.bind(function (someValues) { var availableBindingValues; var inputRequiringBindingValues; var newBindingValues; if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['bindingData'])) { availableBindingValues = {}; } else { availableBindingValues = Clipperz.Base.deepClone(someValues['originalValues']['bindingData']) } if (someValues['currentValues'] != null) { MochiKit.Base.update(availableBindingValues, someValues['currentValues']['bindingData']); } this._bindings = {}; newBindingValues = {} MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsBinding'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { var newBinding; newBindingValues[anInput.name()] = availableBindingValues[anInput.name()]; newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { 'key': anInput.name(), 'field': availableBindingValues[anInput.name()] }); this._bindings[anInput.name()] = newBinding; }, this)) -//console.log("THIS._BINDINGS", this._bindings); return newBindingValues; /* this._bindings = {}; -//console.log("CONFIGURATION", aConfiguration); if (someValues['currentValues'] != null) { if (someValues['currentValues']['bindingData'] != null) { var bindingKey; -//console.log("BINDING DATA", someValues['currentValues']['bindingData']); for (bindingKey in someValues['currentValues']['bindingData']) { var newBinding; newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { 'key': bindingKey, 'field': someValues['currentValues']['bindingData'][bindingKey] }); this._bindings[newBinding.key()] = newBinding; } } else if (someValues['currentValues']['legacyBindingData'] == null) { var bindingKey; for (bindingKey in someValues['currentValues']['legacyBindingData']) { var newBinding; newBinding = new Clipperz.PM.DataModel.DirectLoginBinding(this, { 'key': bindingKey, 'field': someValues['currentValues']['legacyBindingData'][bindingKey] }); this._bindings[newBinding.key()] = newBinding; } } else { WTF = TODO; } } return this._bindings; */ }, this), MochiKit.Base.method(this, 'setValue', 'bindingData') ], {trace:false}); }, //========================================================================= 'formValues': function () { return Clipperz.Async.callbacks("DirectLogin.formValues", [ Clipperz.Async.deferredIf("this._formValues is defined", [ ], [ MochiKit.Base.method(this, 'updateFormValuesAfterChangingBookmarkletConfiguration'), MochiKit.Base.bind(function () { return this._formValues;}, this) ]) ], {trace:false}, this._formValues); }, //------------------------------------------------------------------------- 'updateFormValuesAfterChangingBookmarkletConfiguration': function () { return Clipperz.Async.callbacks("DirectLogin.updateFormValuesAfterChangingBookmarkletConfiguration", [ Clipperz.Async.collectResults("DirectLogin.updateFormValuesAfterChangingBookmarkletConfiguration <collect results>", { 'currentValues': MochiKit.Base.method(this, 'getValue', ''), 'originalValues': MochiKit.Base.method(this, 'originalConfiguration'), 'inputs': MochiKit.Base.method(this, 'inputs') }, {trace:false}), MochiKit.Base.bind(function (someValues) { var availableFormValues; var inputRequiringFormValues; var newFormValues; if (MochiKit.Base.isUndefinedOrNull(someValues['originalValues']) || MochiKit.Base.isUndefinedOrNull(someValues['originalValues']['formValues'])) { availableFormValues = {}; } else { availableFormValues = Clipperz.Base.deepClone(someValues['originalValues']['formValues']) } MochiKit.Base.update(availableFormValues, someValues['currentValues']['formValues']); this._formValues = {}; newFormValues = {}; MochiKit.Iter.forEach(MochiKit.Base.filter(MochiKit.Base.methodcaller('needsFormValue'), MochiKit.Base.values(someValues['inputs'])), MochiKit.Base.bind(function (anInput) { var newFormValue; var fieldOptions; fieldOptions = { 'type': anInput.type(), 'options': anInput.options() }; newFormValues[anInput.name()] = availableFormValues[anInput.name()] newFormValue = new Clipperz.PM.DataModel.DirectLoginFormValue(this, { 'key': anInput.name(), 'fieldOptions': fieldOptions, 'value': availableFormValues[anInput.name()] }); this._formValues[anInput.name()] = newFormValue; }, this)) return newFormValues; }, this), MochiKit.Base.method(this, 'setValue', 'formValues') ], {trace:false}); }, //========================================================================= 'retrieveIndexDataFunction': function () { return this._retrieveIndexDataFunction; }, 'getIndexDataForKey': function (aKey) { return Clipperz.Async.callbacks("DirectLogin.getIndexDataForKey", [ MochiKit.Base.partial(this.retrieveIndexDataFunction(), this.reference()), Clipperz.Async.deferredIf("DirectLogin.getIndexDataForKey - index data not null", [ MochiKit.Base.itemgetter(aKey) ],[ MochiKit.Async.succeed ]) ], {trace:false}); }, //------------------------------------------------------------------------- 'setIndexDataForKey': function (aKey, aValue) { return Clipperz.Async.callbacks("DirectLogin.setValueForKey", [ MochiKit.Base.method(this, 'getIndexDataForKey', aKey), MochiKit.Base.bind(function (anActualValue) { var transientStateKey; transientStateKey = 'original_' + aKey; if (MochiKit.Base.isUndefinedOrNull(this.transientState()[transientStateKey])) { if (anActualValue != aValue) { this.transientState()[transientStateKey] = anActualValue; } } else if (this.transientState()[transientStateKey] == aValue) { this.transientState()[transientStateKey] = null; } }, this), MochiKit.Base.partial(this._setIndexDataFunction, this.reference(), aKey, aValue) ], {trace:false}) }, //------------------------------------------------------------------------- /* 'setValueForKey': function (aKey, aValue) { return Clipperz.Async.callbacks("DirectLogin.setValueForKey", [ MochiKit.Base.method(this, 'getIndexDataForKey', aKey), MochiKit.Base.bind(function (anActualValue) { var transientStateKey; transientStateKey = 'original_' + aKey; if (MochiKit.Base.isUndefinedOrNull(this.transientState()[transientStateKey])) { if (anActualValue != aValue) { this.transientState()[transientStateKey] = anActualValue; } } else if (this.transientState()[transientStateKey] == aValue) { this.transientState()[transientStateKey] = null; } }, this), MochiKit.Base.method(this, 'setIndexDataForKey', aKey, aValue) ], {trace:false}) }, */ //========================================================================= /* 'storedConfiguration': function () { return this.record().getValue('directLogins' + '.' + this.reference()); }, // 'setStoredConfiguration': function (aValue) { // return this.record().setValue('directLogins' + '.' + this.reference(), aValue); // }, */ //========================================================================= 'hasPendingChanges': function () { var result; var deferredResult; result = false; result = result || this.isBrandNew(); result = result || (! MochiKit.Base.isUndefinedOrNull(this.transientState()['original_label'])); result = result || (! MochiKit.Base.isUndefinedOrNull(this.transientState()['original_favicon'])); if ((result == false) && (this.originalConfiguration() != null)) { deferredResult = Clipperz.Async.callbacks("DirectLogin.hasPendingChanges", [ MochiKit.Base.method(this, 'serializedData'), MochiKit.Base.bind(function (aCurrentConfiguration) { var originalConfiguration; var currentConfiguration; var result; originalConfiguration = this.originalConfiguration(); currentConfiguration = aCurrentConfiguration; result = false; result = result || (MochiKit.Base.compare(originalConfiguration['bookmarkletVersion'], currentConfiguration['bookmarkletVersion']) != 0); result = result || (MochiKit.Base.compare(originalConfiguration['formData'], currentConfiguration['formData']) != 0); result = result || (MochiKit.Base.compare(originalConfiguration['formValues'], currentConfiguration['formValues']) != 0); result = result || (MochiKit.Base.compare(originalConfiguration['bindingData'], currentConfiguration['bindingData']) != 0); return result; }, this) ], {trace:false}); } else { deferredResult = MochiKit.Async.succeed(result); } return deferredResult; }, //------------------------------------------------------------------------- 'revertChanges': function () { var deferredResult; if (this.transientState()['original_label'] != null) { this.setLabel(this.transientState()['original_label']); } if (this.transientState()['original_favicon'] != null) { this.setFavicon(this.transientState()['original_favicon']); } if (this.originalConfiguration() != null) { deferredResult = this.setValue('', this.originalConfiguration()); } else { deferredResult = MochiKit.Async.succeed(); } this._inputs = null; this._bindings = null; this._formValues = null; this.resetTransientState(false); /* if (this.hasInitiatedObjectDataStore()) { deferredResult = Clipperz.Async.callbacks("DirectLogin.revertChanges", [ // MochiKit.Base.method(this.record(), 'setValue', 'directLogins' + '.' + this.reference(), this.originalState()), MochiKit.Base.method(this, 'setValue', '', this.originalState()), MochiKit.Base.method(this, 'resetObjectDataStore') ], {trace:false}) } else { deferredResult = MochiKit.Async.succeed(); } */ return deferredResult; }, //========================================================================= 'transientState': function () { if (this._transientState == null) { this._transientState = {} } return this._transientState; }, 'resetTransientState': function (isCommitting) { this._transientState = null; }, 'commitTransientState': function (isCommitting) { this._transientState = null; this._isBrandNew = false; }, //------------------------------------------------------------------------- 'originalConfiguration': function () { return this.transientState()['original_configuration']; }, 'setOriginalConfiguration': function (aConfiguration) { this.transientState()['original_configuration'] = Clipperz.Base.deepClone(aConfiguration); }, //========================================================================= 'actualKey': function (aValueKey) { var actualKey; actualKey = 'directLogins' + '.' + this.reference(); if (aValueKey != '') { actualKey = actualKey + '.' + aValueKey; } return actualKey; }, //------------------------------------------------------------------------- 'getValue': function (aValueKey) { return this.record().getValue(this.actualKey(aValueKey)); }, 'setValue': function (aValueKey, aValue) { // return this.record().setValue(this.actualKey(aValueKey), aValue); return Clipperz.Async.callbacks("DirectLogin.setValue", [ MochiKit.Base.method(this, 'getValue', ''), MochiKit.Base.bind(function (aValue) { if (this.originalConfiguration() == null) { this.setOriginalConfiguration(aValue); } }, this), // MochiKit.Base.method(this, 'originalConfiguration'), // Clipperz.Async.deferredIf("originalConfiguration has been set", [ // ], [ // MochiKit.Base.method(this, 'getValue', ''), // MochiKit.Base.method(this, 'setOriginalConfiguration') // ]), MochiKit.Base.method(this.record(), 'setValue', this.actualKey(aValueKey), aValue) ], {trace:false}); }, 'removeValue': function (aValueKey) { // return this.record().removeValue(this.actualKey(aValueKey)); return Clipperz.Async.callbacks("DirectLogin.setValue", [ MochiKit.Base.method(this, 'originalConfiguration'), Clipperz.Async.deferredIf("originalConfiguration has been set", [ ], [ MochiKit.Base.method(this, 'getValue', ''), MochiKit.Base.method(this, 'setOriginalConfiguration') ]), MochiKit.Base.method(this.record(), 'removeValue', this.actualKey(aValueKey)) ], {trace:false}); }, //========================================================================= 'deleteAllCleanTextData': function () { this._inputs = null; this._bindings = null; this._formValues = null; this.resetTransientState(); }, //------------------------------------------------------------------------- 'hasAnyCleanTextData': function () { var result; result = false; result = result || (this._inputs != null); result = result || (this._bindings != null); result = result || (this._formValues != null); result = result || (MochiKit.Base.keys(this.transientState()).length != 0); return MochiKit.Async.succeed(result); }, //========================================================================= __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.PM.DataModel.DirectLogin.exception = { 'WrongBookmarkletConfiguration': new MochiKit.Base.NamedError("Clipperz.PM.DataModel.DirectLogin.exception.WrongBookmarkletConfiguration") }; Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration = function(aConfiguration) { var configuration; try { configuration = Clipperz.Base.evalJSON(aConfiguration); // configuration = Clipperz.PM.BookmarkletProcessor.sanitizeBookmarkletConfiguration(configuration); if (MochiKit.Base.isUndefinedOrNull(configuration['page']['title']) || MochiKit.Base.isUndefinedOrNull(configuration['form']['attributes']['action']) // || MochiKit.Base.isUndefinedOrNull(configuration['form']['attributes']['method']) || MochiKit.Base.isUndefinedOrNull(configuration['form']['inputs']) || MochiKit.Base.isUndefinedOrNull(configuration['version']) ) { throw Clipperz.PM.DataModel.DirectLogin.exception.WrongBookmarkletConfiguration; } // if (MochiKit.Base.isUndefinedOrNull(configuration['favicon'])) { // throw Clipperz.PM.DataModel.DirectLogin.exception.WrongBookmarkletConfiguration; // } } catch (exception) { throw exception; } return configuration; }; diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js index 4377853..a8ebb97 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginBinding.js @@ -1,122 +1,120 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } //############################################################################# Clipperz.PM.DataModel.DirectLoginBinding = function(aDirectLogin, args) { args = args || {}; this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); this._key = args.key || Clipperz.Base.exception.raise('MandatoryParameter'); this._fieldKey = args.field || /* this.directLogin().fieldWithName(args.fieldName).reference() || */ null; return this; } Clipperz.PM.DataModel.DirectLoginBinding.prototype = MochiKit.Base.update(null, { 'toString': function() { return "DirectLoginBinding (" + this.key() + ", " + this.fieldKey() + ")"; }, //------------------------------------------------------------------------- 'directLogin': function () { return this._directLogin; }, //------------------------------------------------------------------------- 'key': function() { return this._key; }, //------------------------------------------------------------------------- 'fieldKey': function() { return this._fieldKey; }, 'setFieldKey': function(aValue) { this._fieldKey = aValue; return this.directLogin().setValue('bindingData' + '.' + this.key(), aValue); }, // 'fieldName': function() { // return this._fieldName; // }, //------------------------------------------------------------------------- 'field': function() { var deferredResult; if (this.fieldKey() != null) { deferredResult = Clipperz.Async.callbacks("DirectLoginBinding.field [1]", [ MochiKit.Base.method(this.directLogin().record(), 'fields'), MochiKit.Base.itemgetter(this.fieldKey()) ], {trace:false}); // } else if (this.fieldName() != null) { // WTF = TODO; // result = this.directLogin().record().fieldWithName(this.fieldName()); // // this.setFieldKey(result.key()); } else { deferredResult = MochiKit.Async.succeed(null); } return deferredResult; }, 'setField': function (aField) { this.setFieldKey(aField.reference()); }, //------------------------------------------------------------------------- /* 'fieldValue': function () { return Clipperz.Async.callbacks("DirectLoginBinding.fieldValue", [ MochiKit.Base.method('field'), MochiKit.Base.methodcaller('value') ], {trace:false}); }, */ //------------------------------------------------------------------------- 'serializedData': function() { return this.fieldKey(); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js index a461197..2429f88 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginFormValue.js @@ -1,104 +1,101 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } //############################################################################# Clipperz.PM.DataModel.DirectLoginFormValue = function(aDirectLogin, args) { args = args || {}; this._directLogin = aDirectLogin|| Clipperz.Base.exception.raise('MandatoryParameter'); this._key = args.key || Clipperz.Base.exception.raise('MandatoryParameter'); this._fieldOptions = args.fieldOptions || Clipperz.Base.exception.raise('MandatoryParameter'); this._value = args.value || null; return this; } Clipperz.PM.DataModel.DirectLoginFormValue.prototype = MochiKit.Base.update(null, { 'toString': function() { return "DirectLoginFormValue (" + this.key() + ", " + this.value() + ")"; }, //------------------------------------------------------------------------- 'directLogin': function () { return this._directLogin; }, //------------------------------------------------------------------------- 'key': function() { return this._key; }, //------------------------------------------------------------------------- 'fieldOptions': function() { return this._fieldOptions; }, //------------------------------------------------------------------------- 'type': function () { return this.fieldOptions()['type']; }, //------------------------------------------------------------------------- 'value': function() { var result; result = this._value; // if ((result == null) && (this.type() == 'checkbox')) { // result = false; // }; return result; }, 'setValue': function (aValue) { -//console.log("DirectLoginFormValue.setValue", aValue); this._value = aValue; return this.directLogin().setValue('formValues' + '.' + this.key(), aValue); }, //------------------------------------------------------------------------- /* 'serializedData': function() { return this.value(); }, */ //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js index 8188389..d9995fc 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js @@ -1,200 +1,192 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } //############################################################################# Clipperz.PM.DataModel.DirectLoginInput = function(args) { this._args = args; return this; } Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, { 'args': function() { return this._args; }, //------------------------------------------------------------------------- 'name': function() { return this.args()['name']; }, //------------------------------------------------------------------------- 'type': function() { var result; result = this.args()['type']; if (result != null) { result = result.toLowerCase(); } return result; }, //------------------------------------------------------------------------- 'options': function() { return this.args()['options']; }, //------------------------------------------------------------------------- 'value': function() { return this.args()['value']; }, //------------------------------------------------------------------------- /* 'formConfiguration': function(someFormValues, someBindings, someFields) { var result; -//console.log("### DirectLoginInput.formConfiguration", someFields); + if (this.shouldSetValue()) { switch (this.type()) { case 'select': var currentValue; var options; // currentValue = this.directLogin()._configuration['formValues'][this.name()]; currentValue = someFormValues[this.name()]; options = this.args()['options']; result = MochiKit.DOM.SELECT({name:this.name()}, MochiKit.Base.map(function(anOption) { var options; options = {value:anOption['value']}; if (currentValue == anOption['value']) { options.selected = true; } return MochiKit.DOM.OPTION(options, anOption['label']) }, options) ) break; case 'checkbox': var options; options = {type:'checkbox', name: this.name()}; // if (this.directLogin()._configuration['formValues'][this.name()] == true) { if (someFormValues[this.name()] == true) { options['checked'] = true; }; result = MochiKit.DOM.INPUT(options, null); break; case 'radio': var currentName; var currentValue; var options; currentName = this.name(); // currentValue = this.directLogin()._configuration['formValues'][this.name()]; currentValue = someFormValues[this.name()]; options = this.args()['options']; result = MochiKit.DOM.DIV(null, MochiKit.Base.map(function(anOption) { var options; var isChecked; var inputNode; var divNode; options = {type:'radio', name:currentName, value:anOption['value']} isChecked = (currentValue == anOption['value']); if (isChecked) { options.checked = true; } if (Clipperz_IEisBroken == true) { var checkedValue; checkedValue = (isChecked ? " CHECKED" : ""); inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">"); } else { inputNode = MochiKit.DOM.INPUT(options, anOption['value']); } divNode = MochiKit.DOM.DIV(null, inputNode); return divNode; }, options) ); break; } } else { var binding; // binding = this.directLogin().bindings()[this.name()]; binding = someBindings[this.name()]; -//console.log("### binding", binding); -//if (binding != null) { -/// console.log(" binding.field()", binding.field()); -/// console.log(" binding.field().value()", binding.field().value()); -// console.log(" someFields[binding.fieldKey()].value()", someFields[binding.fieldKey()].value()); -//} result = MochiKit.DOM.INPUT({ type:((this.type() != 'password') ? this.type() : 'text'), name:this.name(), // value:((binding != null)? binding.field().value() : this.value()) value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value()) // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value()) }, null); } return result; }, */ //------------------------------------------------------------------------- 'needsFormValue': function() { var type; var result; type = this.type(); result = ((type == 'checkbox') || (type == 'radio') || (type == 'select')); return result; }, 'needsBinding': function() { var type; var result; type = this.type(); result = ((type == 'text') || (type == 'password')); return result; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js b/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js index cdeec8b..1aa7a52 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/EncryptedRemoteObject.js @@ -1,548 +1,542 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!"; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) { args = args || {}; this._name = args.name || null; this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); this._isBrandNew = ((args.reference == null) && (args.remoteData == null)); if ((this._isBrandNew == false) && (args['retrieveKeyFunction'] == null)) { Clipperz.Base.exception.raise('MandatoryParameter'); } else { this._retrieveKeyFunction = args['retrieveKeyFunction']; } this._retrieveRemoteDataFunction = args.retrieveRemoteDataFunction || null; this._remoteData = args.remoteData || null; // this._remoteData = args.remoteData ? Clipperz.Base.deepClone(args.remoteData) : null; if ((!this._isBrandNew) && ((this._retrieveRemoteDataFunction == null) && (this._remoteData == null))) { Clipperz.Base.exception.raise('MandatoryParameter'); } this._encryptedDataKeypath = args.encryptedDataKeypath || 'data'; //Clipperz.Base.exception.raise('MandatoryParameter'); this._encryptedVersionKeypath = args.encryptedVersionKeypath || 'version'; //Clipperz.Base.exception.raise('MandatoryParameter'); this._transientState = null; this._deferredLocks = {}; if (this._isBrandNew == true) { this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [1]'}*/); } else { this._objectDataStore = null; } return this; } // // Basic data workflow // ======================= // // getRemoteData // unpackRemoteData // getDecryptData [encryptedDataKeypath, encryptedVersionKeypath] // unpackData // // // ?? packData // ?? encryptDataWithKey // ?? packRemoteData [encryptedDataKeypath (?), encryptedVersionKeypath (?)] // Clipperz.PM.DataModel.EncryptedRemoteObject.prototype = MochiKit.Base.update(null, { 'toString': function () { return "Clipperz.PM.DataModel.EncryptedRemoteObject" + (this.name() != null ? " - " + this.name() : ""); }, //------------------------------------------------------------------------- 'name': function () { return this._name; }, //------------------------------------------------------------------------- 'reference': function () { return this._reference; }, 'setReference': function (aValue) { this._reference = aValue; return this._reference; }, //------------------------------------------------------------------------- 'transientState': function () { if (this._transientState == null) { this._transientState = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.transientState [2]'}*/); } return this._transientState; }, 'resetTransientState': function (isCommitting) { if (this._transientState != null) { this._transientState.removeAllData(); } this._transientState = null; }, //------------------------------------------------------------------------- 'isBrandNew': function () { return this._isBrandNew; }, //------------------------------------------------------------------------- 'getKey': function () { var deferredResult; var deferredLock; deferredLock = this.getDeferredLockForKey('key'); deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.getKey", {trace:false}); deferredResult.acquireLock(deferredLock); deferredResult.addMethod( this.decryptedDataStore(), 'deferredGetOrSet', 'decryptionKey', MochiKit.Base.partial(this.retrieveKeyFunction(), this.reference()) ); deferredResult.releaseLock(deferredLock); deferredResult.callback(); return deferredResult; }, // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 'retrieveKeyFunction': function () { return this._retrieveKeyFunction; }, 'setRetrieveKeyFunction': function (aFunction) { this._retrieveKeyFunction = aFunction; }, //------------------------------------------------------------------------- 'hasLoadedRemoteData': function () { return (this._remoteData != null); }, 'getRemoteData': function () { var deferredResult; var deferredLock; deferredLock = this.getDeferredLockForKey('remoteData'); deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObjects.getRemoteData", {trace:false}); deferredResult.acquireLock(deferredLock); deferredResult.addCallback(MochiKit.Base.bind(function () { var innerDeferredResult; if (this._remoteData != null) { innerDeferredResult = MochiKit.Async.succeed(this._remoteData); } else { innerDeferredResult = Clipperz.Async.callbacks("EncryptedRemoteObjects.getRemoteData <inner deferred>", [ MochiKit.Base.partial(this.retrieveRemoteDataFunction(), this.reference()), MochiKit.Base.method(this, 'unpackRemoteData'), MochiKit.Base.bind(function (someData) { this._remoteData = someData; return this._remoteData; }, this) ], {trace:false}); } return innerDeferredResult; }, this)) deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.releaseLock(deferredLock); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'unpackRemoteData': function (someData) { return MochiKit.Async.succeed(someData); }, //......................................................................... 'packRemoteData': function (someData) { var result; result = { 'reference': this.reference(), 'data': someData, 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion }; return MochiKit.Async.succeed(result); }, //------------------------------------------------------------------------- 'retrieveRemoteDataFunction': function () { return this._retrieveRemoteDataFunction; }, 'setRetrieveRemoteDataFunction': function (aFunction) { this._retrieveRemoteDataFunction = aFunction; }, //------------------------------------------------------------------------- 'decryptedDataStore': function () { if (this._decryptedDataStore == null) { this._decryptedDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.decryptedDataStore [3]'}*/); }; return this._decryptedDataStore; }, //......................................................................... 'getDecryptedData': function () { var deferredResult; var deferredLock; deferredLock = this.getDeferredLockForKey('decryptedData'); deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.getDecryptedData", {trace:false}); deferredResult.acquireLock(deferredLock); deferredResult.addMethod(this, 'decryptedDataStore'); deferredResult.addCallback(MochiKit.Base.methodcaller('deferredGetOrSet', 'decryptedData', MochiKit.Base.bind(function () { var innerDeferredResult; innerDeferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.getDecryptedData <inner deferred>", {trace:false}); innerDeferredResult.addMethod(this, 'getRemoteData'); innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); innerDeferredResult.collectResults({ 'key': MochiKit.Base.method(this, 'getKey'), 'value': MochiKit.Base.itemgetter(this._encryptedDataKeypath), 'version': MochiKit.Base.itemgetter(this._encryptedVersionKeypath) }); innerDeferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt); innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); innerDeferredResult.addMethod(this, 'unpackData'); innerDeferredResult.callback(); return innerDeferredResult; }, this))); deferredResult.releaseLock(deferredLock); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'setValue': function(aKey, aValue) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.setValue", {trace:false}); deferredResult.addMethod(this, '_getObjectDataStore'); deferredResult.addCallback(MochiKit.Base.methodcaller('setValue', aKey, aValue)); deferredResult.callback(); return deferredResult; }, //......................................................................... 'getValue': function (aKey) { return Clipperz.Async.callbacks("EncryptedRemoteObject.getValue", [ MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('getValue', aKey) ], {trace:false}); }, //......................................................................... 'removeValue': function (aKey) { return Clipperz.Async.callbacks("EncryptedRemoteObject.removeValue", [ MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('removeValue', aKey) ], {trace:false}); }, //......................................................................... 'values': function () { return Clipperz.Async.callbacks("EncryptedRemoteObject.values", [ MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('values') ], {trace:false}); }, 'setValues': function (someValues) { return Clipperz.Async.callbacks("EncryptedRemoteObject.values", [ MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('setValues', someValues) ], {trace:false}); }, //......................................................................... '_getObjectDataStore': function () { var deferredResult; var deferredLock; deferredLock = this.getDeferredLockForKey('objectDataStore'); deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject._getObjectDataStore", {trace:false}); deferredResult.acquireLock(deferredLock); deferredResult.addCallback(MochiKit.Base.bind(function () { var innerDeferredResult; if (this._objectDataStore == null) { this._objectDataStore = new Clipperz.KeyValueObjectStore(/*{'name':'EncryptedRemoteObject.objectDataStore [4]'}*/); innerDeferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject._getObjectDataStore <inner deferred>", {trace:false}); innerDeferredResult.addMethod(this, 'getDecryptedData'); innerDeferredResult.addMethod(this._objectDataStore, 'initWithValues'); innerDeferredResult.callback(); } else { innerDeferredResult = MochiKit.Async.succeed(this._objectDataStore); } return innerDeferredResult; }, this)); deferredResult.releaseLock(deferredLock); deferredResult.callback(); return deferredResult; }, 'hasInitiatedObjectDataStore': function () { return (this._objectDataStore != null); }, //------------------------------------------------------------------------- 'getDeferredLockForKey': function (aKey) { var result; result = this._deferredLocks[aKey]; if (typeof(result) == 'undefined') { result = new MochiKit.Async.DeferredLock(); this._deferredLocks[aKey] = result; } return result; }, //------------------------------------------------------------------------- 'unpackData': function (someData) { // ++ return someData; }, 'packData': function (someData) { // ++ return someData; }, //------------------------------------------------------------------------- 'hasPendingChanges': function () { var deferredResult; var tempObj = this; if (this.isBrandNew()) { // deferredResult = MochiKit.Async.succeed(true); deferredResult = this.hasPendingChangesWhenBrandNew(); } else if (this.hasInitiatedObjectDataStore()) { deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.hasPendingChanges", {trace:false}); deferredResult.collectResults({ 'decryptedData': [ MochiKit.Base.method(this, 'getDecryptedData'), Clipperz.Base.serializeJSON ], 'objectData': [ MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('values'), Clipperz.Base.serializeJSON ] }); deferredResult.addCallback(function (someValues) { -//if (someValues['decryptedData'] != someValues['objectData']) { -// console.log("ORIGINAL DATA", '[[[' + someValues['decryptedData'] + ']]]'); -// console.log("CURRENT DATA", '>>>' + someValues['objectData'] + '<<<'); -//} return (someValues['decryptedData'] != someValues['objectData']); }); deferredResult.callback(); } else { deferredResult = MochiKit.Async.succeed(false); } return deferredResult; }, 'hasPendingChangesWhenBrandNew': function () { return MochiKit.Async.succeed(true); }, //------------------------------------------------------------------------- 'commitTransientState': function () { var deferredResult; // if (this.transientState().getValue('__prepareRemoteData') == true) { if (this.transientState().getValue('packedRemoteData') != null) { deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - prepareRemoteData", [ MochiKit.Base.bind(function (someData) { this._remoteData = this.transientState().getValue('packedRemoteData'); }, this), MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('values'), Clipperz.Base.deepClone, MochiKit.Base.method(this.decryptedDataStore(), 'setValue', 'decryptedData'), MochiKit.Base.method(this, 'resetTransientState', true) ], {trace:false}); } else { deferredResult = Clipperz.Async.callbacks("EncryptedRemoteObject.commitTransientState - NO prepareRemoteData", [ MochiKit.Base.method(this, 'resetTransientState', true) ], {trace:false}); } this._isBrandNew = false; return deferredResult; }, //------------------------------------------------------------------------- 'revertChanges': function () { if (this.hasInitiatedObjectDataStore()) { this._objectDataStore.removeAllData(); this._objectDataStore = null; } this.resetTransientState(false); return MochiKit.Async.succeed(); }, //------------------------------------------------------------------------- 'deleteAllCleanTextData': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("EncryptedRemoteObject.deleteAllCleanTextData", {trace:false}); deferredResult.addMethod(this, 'resetTransientState', false); deferredResult.acquireLock(this.getDeferredLockForKey('decryptedData')); deferredResult.addCallback(MochiKit.Base.bind(function () { if (this._decryptedDataStore != null) { this._decryptedDataStore.removeAllData(); } }, this)); deferredResult.releaseLock(this.getDeferredLockForKey('decryptedData')); deferredResult.acquireLock(this.getDeferredLockForKey('objectDataStore')); deferredResult.addCallback(MochiKit.Base.bind(function () { if (this._objectDataStore != null) { this._objectDataStore.removeAllData(); this._objectDataStore = null; } }, this)); deferredResult.releaseLock(this.getDeferredLockForKey('objectDataStore')); deferredResult.callback(); return deferredResult; }, //......................................................................... 'hasAnyCleanTextData': function () { var result; result = false; result = result || (! this.decryptedDataStore().isEmpty()); result = result || (! this.transientState().isEmpty()); if (this.hasInitiatedObjectDataStore()) { result = result || (! this._objectDataStore.isEmpty()); } return MochiKit.Async.succeed(result); }, //------------------------------------------------------------------------- 'prepareRemoteDataWithKey': function (aKey) { return Clipperz.Async.callbacks("EncryptedRemoteObject.prepareRemoteDataWithKey", [ // MochiKit.Base.method(this.transientState(), 'setValue', '__prepareRemoteData', true), MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('values'), MochiKit.Base.method(this, 'packData'), function (someData) { return Clipperz.PM.Crypto.deferredEncrypt({ 'key': aKey, 'value': someData, 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion }) }, MochiKit.Base.method(this, 'packRemoteData'), MochiKit.Base.method(this.transientState(), 'setValue', 'packedRemoteData'), function (someData) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'advanceProgress'); return someData; } ], {trace:false}); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js b/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js index 834e21b..fbca1ff 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/OneTimePassword.js @@ -1,354 +1,350 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } //############################################################################# Clipperz.PM.DataModel.OneTimePassword = function(args) { args = args || {}; // this._user = args['user']; this._reference = args['reference'] || Clipperz.PM.Crypto.randomKey(); this._password = args['password']; this._passwordValue = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(args['password']); this._creationDate = args['created'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['created']) : new Date(); this._usageDate = args['used'] ? Clipperz.PM.Date.parseDateWithUTCFormat(args['used']) : null; this._status = args['status'] || 'ACTIVE'; // 'REQUESTED', 'USED', 'DISABLED' this._connectionInfo= null; this._key = null; this._keyChecksum = null; return this; } Clipperz.PM.DataModel.OneTimePassword.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.PM.DataModel.OneTimePassword"; }, /* //------------------------------------------------------------------------- 'user': function() { return this._user; }, //------------------------------------------------------------------------- 'password': function() { return this._password; }, //------------------------------------------------------------------------- 'passwordValue': function() { return this._passwordValue; }, //------------------------------------------------------------------------- 'creationDate': function() { return this._creationDate; }, //------------------------------------------------------------------------- 'reference': function() { return this._reference; }, //------------------------------------------------------------------------- 'key': function() { if (this._key == null) { this._key = Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(this.user().username(), this.passwordValue()); } return this._key; }, //------------------------------------------------------------------------- 'keyChecksum': function() { if (this._keyChecksum == null) { this._keyChecksum = Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(this.user().username(), this.passwordValue()); } return this._keyChecksum; }, */ //------------------------------------------------------------------------- 'status': function() { return this._status; }, 'setStatus': function(aValue) { this._status = aValue; }, //------------------------------------------------------------------------- /* 'serializedData': function() { var result; result = { 'password': this.password(), 'created': this.creationDate() ? Clipperz.PM.Date.formatDateWithUTCFormat(this.creationDate()) : null, 'used': this.usageDate() ? Clipperz.PM.Date.formatDateWithUTCFormat(this.usageDate()) : null, 'status': this.status() }; return result; }, //------------------------------------------------------------------------- 'packedPassphrase': function() { var result; var packedPassphrase; var encodedPassphrase; var prefixPadding; var suffixPadding; var getRandomBytes; getRandomBytes = MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'getRandomBytes'); encodedPassphrase = new Clipperz.ByteArray(this.user().passphrase()).toBase64String(); -//MochiKit.Logging.logDebug("--- encodedPassphrase.length: " + encodedPassphrase.length); +//Clipperz.logDebug("--- encodedPassphrase.length: " + encodedPassphrase.length); prefixPadding = getRandomBytes(getRandomBytes(1).byteAtIndex(0)).toBase64String(); -//MochiKit.Logging.logDebug("--- prefixPadding.length: " + prefixPadding.length); +//Clipperz.logDebug("--- prefixPadding.length: " + prefixPadding.length); suffixPadding = getRandomBytes((500 - prefixPadding.length - encodedPassphrase.length) * 6 / 8).toBase64String(); -//MochiKit.Logging.logDebug("--- suffixPadding.length: " + suffixPadding.length); -//MochiKit.Logging.logDebug("--- total.length: " + (prefixPadding.length + encodedPassphrase.length + suffixPadding.length)); +//Clipperz.logDebug("--- suffixPadding.length: " + suffixPadding.length); +//Clipperz.logDebug("--- total.length: " + (prefixPadding.length + encodedPassphrase.length + suffixPadding.length)); packedPassphrase = { 'prefix': prefixPadding, 'passphrase': encodedPassphrase, 'suffix': suffixPadding }; // result = Clipperz.Base.serializeJSON(packedPassphrase); result = packedPassphrase; -//MochiKit.Logging.logDebug("===== OTP packedPassprase: [" + result.length + "]" + result); -//MochiKit.Logging.logDebug("<<< OneTimePassword.packedPassphrase"); +//Clipperz.logDebug("===== OTP packedPassprase: [" + result.length + "]" + result); +//Clipperz.logDebug("<<< OneTimePassword.packedPassphrase"); return result; }, //------------------------------------------------------------------------- 'encryptedPackedPassphrase': function() { return Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion(this.passwordValue(), this.packedPassphrase()) }, //------------------------------------------------------------------------- 'encryptedData': function() { var deferredResult; var result; -//MochiKit.Logging.logDebug(">>> OneTimePassword.encryptedData"); -//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - id: " + this.reference()); +//Clipperz.logDebug(">>> OneTimePassword.encryptedData"); +//Clipperz.logDebug("--- OneTimePassword.encryptedData - id: " + this.reference()); result = { 'reference': this.reference(), 'key': this.key(), 'keyChecksum': this.keyChecksum(), 'data': "", 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion } -//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 2: " + Clipperz.Base.serializeJSON(result)); +//Clipperz.logDebug("--- OneTimePassword.encryptedData - 2: " + Clipperz.Base.serializeJSON(result)); deferredResult = new MochiKit.Async.Deferred(); -//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 3"); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 1: " + res); return res;}); +//Clipperz.logDebug("--- OneTimePassword.encryptedData - 3"); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 1: " + res); return res;}); //# deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncryptWithCurrentVersion, this.passwordValue(), this.packedPassphrase()); deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedPackedPassphrase')); -//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 4"); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 2: [" + res.length + "]" + res); return res;}); +//Clipperz.logDebug("--- OneTimePassword.encryptedData - 4"); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 2: [" + res.length + "]" + res); return res;}); deferredResult.addCallback(function(aResult, res) { aResult['data'] = res; return aResult; }, result); -//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 5"); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.encryptedData - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); +//Clipperz.logDebug("--- OneTimePassword.encryptedData - 5"); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.encryptedData - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); deferredResult.callback(); -//MochiKit.Logging.logDebug("--- OneTimePassword.encryptedData - 6"); +//Clipperz.logDebug("--- OneTimePassword.encryptedData - 6"); return deferredResult; }, //------------------------------------------------------------------------- 'saveChanges': function() { var deferredResult; var result; -//MochiKit.Logging.logDebug(">>> OneTimePassword.saveChanges"); +//Clipperz.logDebug(">>> OneTimePassword.saveChanges"); result = {}; deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_encryptUserData'); deferredResult.addCallback(MochiKit.Base.method(this.user(), 'encryptedData')); deferredResult.addCallback(function(aResult, res) { aResult['user'] = res; return aResult; }, result); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_encryptOTPData'); deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData')); deferredResult.addCallback(function(aResult, res) { aResult['oneTimePassword'] = res; return aResult; }, result); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_sendingData'); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 1: " + Clipperz.Base.serializeJSON(res)); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 1: " + Clipperz.Base.serializeJSON(res)); return res;}); deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'addNewOneTimePassword'); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveOTP_updatingInterface'); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'OTPUpdated'); deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'oneTimePassword_saveChanges_done', null); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); +//deferredResult.addBoth(function(res) {Clipperz.logDebug("OneTimePassword.saveChanges - 2: " + res); return res;}); deferredResult.callback(); -//MochiKit.Logging.logDebug("<<< OneTimePassword.saveChanges"); +//Clipperz.logDebug("<<< OneTimePassword.saveChanges"); return deferredResult; }, //------------------------------------------------------------------------- 'usageDate': function() { return this._usageDate; }, 'setUsageDate': function(aValue) { this._usageDate = aValue; }, //------------------------------------------------------------------------- 'connectionInfo': function() { return this._connectionInfo; }, 'setConnectionInfo': function(aValue) { this._connectionInfo = aValue; }, //------------------------------------------------------------------------- 'isExpired': function() { return (this.usageDate() != null); }, //------------------------------------------------------------------------- 'updateStatusWithValues': function(someValues) { var result; result = false; if (someValues['status'] != this.status()) { result = true; } this.setStatus(someValues['status']); this.setUsageDate(Clipperz.PM.Date.parseDateWithUTCFormat(someValues['requestDate'])); this.setConnectionInfo(someValues['connection']); return result; }, */ //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword = function(anUsername, aPassword) { return Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aPassword)).toHexString().substring(2); } Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword = function(anUsername, aPassword) { return Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(anUsername + aPassword)).toHexString().substring(2); } //============================================================================= Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue = function(aPassword) { var result; // "yaxx k7ww - f8y6 tqz5 - 58b6 th44 - 9cwv q0fg" -//console.log("Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue", aPassword); if (aPassword.replace(/[\s\-]/g, '').length == 32) { try { var passwordByteArray; passwordByteArray = new Clipperz.ByteArray(); passwordByteArray.appendBase32String(aPassword); result = true; } catch(exception) { result = false; } } else { result = false; } return result; } //============================================================================= Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword = function(aPassword) { var result; if (aPassword.replace(/[\s\-]/g, '').length == 32) { try { var passwordByteArray; passwordByteArray = new Clipperz.ByteArray(); passwordByteArray.appendBase32String(aPassword); result = passwordByteArray.toBase64String(); } catch(exception) { result = aPassword; } } else { result = aPassword; } -//console.log("Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword", aPassword, result); return result; } //############################################################################# diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js index f51bbc2..986db40 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.Field.js @@ -1,164 +1,162 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.DataModel.Record.Version) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.Record.Version.Field depends on Clipperz.PM.DataModel.Record.Version!"; } Clipperz.PM.DataModel.Record.Version.Field = function(args) { Clipperz.PM.DataModel.Record.Version.Field.superclass.constructor.apply(this, arguments); this._recordVersion = args.recordVersion || Clipperz.Base.exception.raise('MandatoryParameter'); this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version.Field, Object, { 'toString': function() { return "Record.Version.Field (" + this.reference() + ")"; }, //------------------------------------------------------------------------- 'recordVersion': function () { return this._recordVersion; }, //------------------------------------------------------------------------- 'reference': function () { return this._reference; }, //------------------------------------------------------------------------- 'getItem': function (aKey) { return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.getItem", [ MochiKit.Base.method(this, 'recordVersion'), MochiKit.Base.methodcaller('getValue', 'fields' + '.' + this.reference() + '.' + aKey) ], {trace:false}); }, 'setItem': function (aKey, aValue) { return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.getItem", [ MochiKit.Base.method(this, 'recordVersion'), MochiKit.Base.methodcaller('setValue', 'fields' + '.' + this.reference() + '.' + aKey, aValue) ], {trace:false}); }, //------------------------------------------------------------------------- 'label': function () { return this.getItem('label'); }, 'setLabel': function (aValue) { return this.setItem('label', aValue); }, //------------------------------------------------------------------------- 'value': function () { return this.getItem('value'); }, 'setValue': function (aValue) { return this.setItem('value', aValue); }, //------------------------------------------------------------------------- 'actionType': function () { return Clipperz.Async.callbacks("Clipperz.PM.DataModel.Record.Version.Field.actionType", [ Clipperz.Async.collectResults("Clipperz.PM.DataModel.Record.Version.Field.actionType [collect results]", { 'isHidden': MochiKit.Base.method(this, 'isHidden'), 'value': MochiKit.Base.method(this, 'value') }, {trace:false}), function (someValues) { var result; // 'NONE', 'URL', 'EMAIL', 'PASSWORD' result = 'NONE'; if (someValues['isHidden']) { result = 'PASSWORD'; } else if (Clipperz.Base.isUrl(someValues['value'])) { result = 'URL' } else if (Clipperz.Base.isEmail(someValues['value'])) { result = 'EMAIL' }; return result; } ], {trace:false}); }, //------------------------------------------------------------------------- 'isHidden': function () { return this.getItem('hidden'); }, 'setIsHidden': function (aValue) { return this.setItem('hidden', aValue); }, //------------------------------------------------------------------------- 'isEmpty': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.Field.isEmpty", {trace:false}); deferredResult.collectResults({ 'label': [ MochiKit.Base.method(this, 'label'), MochiKit.Base.partial(MochiKit.Base.operator.eq, '') ], 'value': [ MochiKit.Base.method(this, 'value'), MochiKit.Base.partial(MochiKit.Base.operator.eq, '') ], 'isHidden': [ MochiKit.Base.method(this, 'isHidden'), MochiKit.Base.partial(MochiKit.Base.operator.eq, false) ] }); deferredResult.addCallback(MochiKit.Base.values); deferredResult.addCallback(function(someValues) { return MochiKit.Iter.every(someValues, MochiKit.Base.operator.identity); }); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js index dd35fc9..87b319c 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.Version.js @@ -1,333 +1,328 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.DataModel.Record) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.Record.Version depends on Clipperz.PM.DataModel.Record!"; } Clipperz.PM.DataModel.Record.Version = function(args) { -//console.log(">>> Record.new"); Clipperz.PM.DataModel.Record.Version.superclass.constructor.apply(this, arguments); this._getVersionFunction = args.getVersion || Clipperz.Base.exception.raise('MandatoryParameter'); this._fields = null; return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.Record.Version, Clipperz.PM.DataModel.EncryptedRemoteObject, { 'toString': function() { return "Record.Version (" + this.reference() + ")"; }, //------------------------------------------------------------------------- 'reference': function () { return this._reference; }, //------------------------------------------------------------------------- /* 'hasPendingChanges': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.hasPendingChanges", {trace:false}); deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.Version.superclass.hasPendingChanges, this)); deferredResult.callback(); return deferredResult; }, */ //------------------------------------------------------------------------- 'hasPendingChangesWhenBrandNew': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.hasPendingChangesWhenBrandNew", {trace:false}); deferredResult.addMethod(this, 'fields'); deferredResult.addCallback(MochiKit.Base.values); deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.methodcaller('isEmpty')) deferredResult.addCallback(Clipperz.Async.collectAll); deferredResult.addCallback(function(someValues) { return MochiKit.Iter.every(someValues, MochiKit.Base.operator.identity); }); deferredResult.addCallback(MochiKit.Base.operator.lognot) deferredResult.callback(); return deferredResult; }, //========================================================================= 'commitTransientState': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.Version.commitTransientState", {trace:false}); deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.Version.superclass.commitTransientState, this)); deferredResult.callback(); return deferredResult; }, //========================================================================= 'unpackData': function (someData) { // ++ var result; -//console.log("Record.Version - UNPACK DATA", this, someData); result = someData; if ((someData['fields'] != null) && (someData['fields'] instanceof Array)) { var fields; var i,c; fields = someData['fields']; delete someData['fields']; someData['fields'] = {}; c = fields.length; for (i=0; i<c; i++) { someData['fields'][i] = fields[i]; } } return result; }, //========================================================================= 'fields': function () { var deferredResult; var deferredLock; deferredLock = this.getDeferredLockForKey('fields'); deferredResult = new Clipperz.Async.Deferred("Record.Version.fields", {trace:false}); deferredResult.acquireLock(deferredLock); deferredResult.addCallback(MochiKit.Base.bind(function () { var innerDeferredResult; if (this._fields == null) { innerDeferredResult = new Clipperz.Async.Deferred("Record.Version.fields <inner deferred>", {trace:false}); innerDeferredResult.addMethod(this, 'getValue', 'fields'); innerDeferredResult.addCallback(MochiKit.Base.bind(function (someObjectData) { var reference; this._fields = {}; for (reference in someObjectData) { var recordVersionField; recordVersionField = new Clipperz.PM.DataModel.Record.Version.Field({ 'recordVersion': this, 'reference': reference }); this._fields[reference] = recordVersionField; } return this._fields; }, this)); innerDeferredResult.callback(); } else { innerDeferredResult = MochiKit.Async.succeed(this._fields); } return innerDeferredResult; }, this)); deferredResult.releaseLock(deferredLock); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'getFieldsValues': function () { return this.getValue('fields'); }, //------------------------------------------------------------------------- 'addField': function (someParameters) { var newField; newField = new Clipperz.PM.DataModel.Record.Version.Field({recordVersion:this}); return Clipperz.Async.callbacks("Record.Version.addField", [ MochiKit.Base.method(this, 'fields'), MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('values'), Clipperz.Base.serializeJSON, MochiKit.Base.bind(function () { this._fields[newField.reference()] = newField; }, this), MochiKit.Base.method(newField, 'setLabel', someParameters['label']), MochiKit.Base.method(newField, 'setValue', someParameters['value']), MochiKit.Base.method(newField, 'setIsHidden', someParameters['isHidden']), MochiKit.Base.method(this, '_getObjectDataStore'), MochiKit.Base.methodcaller('values'), Clipperz.Base.serializeJSON, MochiKit.Base.partial(MochiKit.Async.succeed, newField) ], {trace:false}); }, //------------------------------------------------------------------------- 'removeField': function (aField) { return Clipperz.Async.callbacks("Record.Version.removeField", [ MochiKit.Base.method(this, 'fields'), MochiKit.Base.bind(function () { delete this._fields[aField.reference()]; }, this), MochiKit.Base.method(this, 'removeValue', 'fields' + '.' + aField.reference()) ], {trace:false}); }, //------------------------------------------------------------------------- /* 'sortFieldReference': function (someSortedFieldReferences) { }, */ //========================================================================= /* 'directLogins': function () { return MochiKit.Base.values(this._directLogins); }, 'addDirectLogin': function (aDirectLogin) { this._directLogins[aDirectLogin.reference()] = aDirectLogin; }, */ //========================================================================= /* 'updateValues': function (anotherVersion) { return Clipperz.Async.callbacks("Record.Version.updateValue", [ MochiKit.Base.partial(MochiKit.Async.succeed, this) ], {trace:false}); }, */ //========================================================================= 'setRemoteData': function (aValue) { this._remoteData = aValue; return aValue; }, //========================================================================= 'getVersionFunction': function () { return this._getVersionFunction; }, 'previousVersion': function () { return Clipperz.Async.callbacks("Record.Versions.previousVersion", [ MochiKit.Base.method(this, 'previousVersionReference'), this.getVersionFunction() ], {trace:false}); }, 'previousVersionReference': function () { return this.getValue('previousVersionReference'); }, 'previousVersionKey': function () { // TODO: this value i encrypted on its own. So it can not be saved in the main objectStore!!! return this.getValue('previousVersionKey'); }, //------------------------------------------------------------------------- 'setPreviousVersionReferenceAndKey': function (aVersionObjectAndKey) { // this._previousVersion = anotherVersion; return Clipperz.Async.callbacks("Record.Version.setPreviousVersion", [ MochiKit.Base.method(this, 'setValue', 'previousVersionReference', aVersionObjectAndKey['reference']), MochiKit.Base.method(this, 'setValue', 'previousVersionKey', aVersionObjectAndKey['key']) ], {trace:false}); }, //========================================================================= 'revertChanges': function () { this.setReference(this.transientState()['originalReference']); Clipperz.PM.DataModel.Record.Version.superclass.revertChanges.apply(this, arguments); }, //------------------------------------------------------------------------- 'prepareRemoteDataWithKey': function (aKey) { var deferredResult; var result; result = {}; -//console.log("prepareRemoteDataWithKey", aKey); deferredResult = new Clipperz.Async.Deferred("Record.Version.prepareRemoteDataWithKey", {trace:false}); if (this.isBrandNew() == false) { this.transientState()['originalReference'] = this.reference(); deferredResult.collectResults({ 'key': MochiKit.Base.partial(MochiKit.Async.succeed, aKey), 'value': MochiKit.Base.method(this, 'getKey'), 'version': MochiKit.Base.partial(MochiKit.Async.succeed, Clipperz.PM.Crypto.encryptingFunctions.currentVersion) }); deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncrypt); deferredResult.addCallback(Clipperz.Async.setItem, result, 'previousVersionKey'); } else { deferredResult.addCallback(Clipperz.Async.setItem, result, 'previousVersionKey', Clipperz.PM.Crypto.nullValue); } deferredResult.addCallback(MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.prepareRemoteDataWithKey, this, aKey)); deferredResult.addCallback(MochiKit.Base.update, result); deferredResult.addMethod(this, 'setRemoteData'); deferredResult.callback(); return deferredResult; }, //========================================================================= /* 'deleteAllCleanTextData': function () { return Clipperz.PM.DataModel.Record.Version.superclass.deleteAllCleanTextData.apply(this, arguments); }, 'hasAnyCleanTextData': function () { return Clipperz.PM.DataModel.Record.Version.superclass.hasAnyCleanTextData.apply(this, arguments); }, */ //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js index b816f80..3fc1813 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js @@ -1,878 +1,854 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } Clipperz.PM.DataModel.Record = function(args) { -//console.log(">>> new Clipperz.PM.DataModel.Record", args); Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); this._retrieveIndexDataFunction = args.retrieveIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction || null; this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction || null; this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; this._directLogins = {}; this._versions = {}; this._currentRecordVersion = null; if (this.isBrandNew()) { var newVersion; this.setNotes(''); newVersion = new Clipperz.PM.DataModel.Record.Version({ 'retrieveKeyFunction': MochiKit.Base.method(this, 'getVersionKey'), 'getVersion': MochiKit.Base.method(this, 'getVersion') }); this._versions[newVersion.reference()] = newVersion; this._currentVersionReference = newVersion.reference(); // this.setLabel(''); } -//console.log("<<< new Clipperz.PM.DataModel.Record", args); - return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { 'toString': function() { return "Record (" + this.reference() + ")"; }, //------------------------------------------------------------------------- 'reference': function () { return this._reference; }, //========================================================================= 'getIndexData': function () { return this._retrieveIndexDataFunction(this.reference()); }, //......................................................................... 'getIndexDataForKey': function (aKey) { return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ MochiKit.Base.method(this, 'getIndexData'), MochiKit.Base.itemgetter(aKey) ], {trace:false}); }, //------------------------------------------------------------------------- 'setIndexDataForKey': function (aKey, aValue) { // return this._updateIndexDataFunction(this.reference(), aKey, aValue); var deferredResult; deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); deferredResult.addMethod(this, 'getIndexDataForKey', aKey); deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { var result; var originalValue; originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); if (originalValue == null) { originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); } if (aCurrentValue != aValue) { if (originalValue != aValue) { this.transientState().setValue('hasPendingChanges.indexData.' + aKey, true); } else { this.transientState().setValue('hasPendingChanges.indexData.' + aKey, false); } result = this._updateIndexDataFunction(this.reference(), aKey, aValue); } else { result = MochiKit.Async.succeed(aValue); } return result; }, this)); deferredResult.callback(); return deferredResult; }, //========================================================================= /* 'key': function () { return this.getIndexDataForKey('key'); }, */ //========================================================================= 'label': function () { return this.getIndexDataForKey('label'); }, //......................................................................... 'setLabel': function (aValue) { return this.setIndexDataForKey('label', aValue); }, //========================================================================= 'headerNotes': function () { return this.getIndexDataForKey('notes'); }, //------------------------------------------------------------------------- 'notes': function () { return Clipperz.Async.callbacks("Record.notes", [ MochiKit.Base.method(this, 'headerNotes'), MochiKit.Base.bind(function (someHeaderNotes) { var result; if ((someHeaderNotes == null) || (typeof(someHeaderNotes) == 'undefined')) { result = this.getValue('notes'); } else { result = MochiKit.Async.succeed(someHeaderNotes); } return result; }, this) ], {trace:false}); }, //......................................................................... 'setNotes': function (aValue) { return this.setValue('notes', aValue); }, //========================================================================= 'updateDate': function () { return MochiKit.Async.succeed(this._updateDate); }, //========================================================================= 'favicon': function () { var result; var directLogins; directLogins = MochiKit.Base.values(this.directLogins()); if (directLogins.length > 0) { result = directLogins[0].favicon(); // } else if (/* is there an URL to use for searching a favicon */){ } else { result = null; // MochiKit.Async.succeed(Clipperz.PM.Strings['defaultFaviconUrl']); } return result; }, //------------------------------------------------------------------------- 'searchableContent': function () { var deferredResult; -//console.log(">>> searchableContent"); deferredResult = new Clipperz.Async.Deferred("Record.searchableContent", {trace:false}); deferredResult.collectResults({ 'recordLabel': MochiKit.Base.method(this, 'label'), 'directLoginLabels': [ MochiKit.Base.method(this, 'directLoginReferences'), MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.itemgetter('label')) ] }) deferredResult.addCallback(function (someValues) { return someValues['recordLabel'] + ' ' + someValues['directLoginLabels'].join(' '); }); deferredResult.callback(); -//console.log("<<< searchableContent"); return deferredResult; }, //------------------------------------------------------------------------- 'isMatching': function (aRegExp) { return Clipperz.Async.callbacks("deferredFilterFunction", [ MochiKit.Base.method(this, 'searchableContent'), MochiKit.Base.method(aRegExp, 'test'), function (doesItMatch) { var result; if (doesItMatch) { result = MochiKit.Async.succeed('match'); } else { result = MochiKit.Async.fail('miss'); } return result; } ], {trace:false}); }, //========================================================================= 'directLogins': function () { return this._directLogins; }, 'addDirectLogin': function (aDirectLogin) { this._directLogins[aDirectLogin.reference()] = aDirectLogin; }, 'directLoginWithReference': function (aDirectLoginReference) { return this._directLogins[aDirectLoginReference]; }, 'createNewDirectLoginFunction': function () { return this._createNewDirectLoginFunction; }, 'saveOriginalDirectLoginStatusToTransientState': function () { if (this.transientState().getValue('directLogins') == null) { // this.transientState().setValue('directLogins', this._directLogins) -//console.log("SET TRANSIENT STATE", Clipperz.Base.serializeJSON(MochiKit.Base.keys(this.transientState().getValue('directLogins')))) MochiKit.Iter.forEach(MochiKit.Base.keys(this._directLogins), MochiKit.Base.bind(function(aKey) { this.transientState().setValue('directLogins' + '.' + aKey, this._directLogins[aKey]) }, this)) } }, 'createNewDirectLogin': function () { this.saveOriginalDirectLoginStatusToTransientState(); return this.createNewDirectLoginFunction()(this); }, 'removeDirectLogin': function(aDirectLogin) { this.saveOriginalDirectLoginStatusToTransientState(); return Clipperz.Async.callbacks("Record.removeDirectLogin", [ MochiKit.Base.method(this, 'removeValue', 'directLogins' + '.' + aDirectLogin.reference()), MochiKit.Base.bind(function () { delete this._directLogins[aDirectLogin.reference()] }, this) ], {trace:false}); }, 'directLoginReferences': function () { var result; result = Clipperz.Async.callbacks("Record.directLoginReferences", [ MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.values, function (someDirectLogins) { var result; var i,c; result = []; c = someDirectLogins.length; for (i=0; i<c; i++) { result.push(Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", { '_rowObject': MochiKit.Async.succeed, '_reference': MochiKit.Base.methodcaller('reference'), 'label': MochiKit.Base.methodcaller('label'), 'favicon': MochiKit.Base.methodcaller('favicon') }, {trace:false})(someDirectLogins[i])); }; return result; }, Clipperz.Async.collectAll ], {trace:false}); return result; }, //========================================================================= 'unpackRemoteData': function (someData) { var result; -//console.log("new Clipperz.PM.DataModel.Record.Version [2]"); /* this._currentRecordVersion = new Clipperz.PM.DataModel.Record.Version({ 'reference': someData['currentVersion']['reference'], 'retrieveKeyFunction': MochiKit.Base.method(this, 'getCurrentRecordVersionKey'), 'remoteData': someData['currentVersion'], }); */ var versionKey; for (versionKey in someData['versions']) { -//console.log("### versionKey", versionKey); this._versions[versionKey] = new Clipperz.PM.DataModel.Record.Version({ 'reference': versionKey, 'retrieveKeyFunction': MochiKit.Base.method(this, 'getVersionKey'), 'remoteData': someData['versions'][versionKey], 'getVersion': MochiKit.Base.method(this, 'getVersion') }) } // this._currentVersionReference = someData['currentVersion']['reference']; this._currentVersionReference = someData['currentVersion']; -//console.log("=== currentVersionReference", this._currentVersionReference, someData); result = Clipperz.PM.DataModel.Record.superclass.unpackRemoteData.apply(this, arguments); return result; }, //------------------------------------------------------------------------- 'unpackData': function (someData) { var result; result = Clipperz.PM.DataModel.Record.superclass.unpackData.apply(this, arguments); if (MochiKit.Base.isUndefinedOrNull(result['notes'])) { result['notes'] = '' } return result; }, //------------------------------------------------------------------------- 'prepareRemoteDataWithKey': function (aKey) { var deferredResult; var newVersionKey; var result; newVersionKey = Clipperz.PM.Crypto.randomKey(); result = {}; deferredResult = new Clipperz.Async.Deferred("Record.prepareRemoteDataWithKey", {trace:false}); deferredResult.addCallbackList([ Clipperz.Async.collectResults("Record.prepareRemoteDataWithKey - collect results", { 'isBrandNew': MochiKit.Base.method(this, 'isBrandNew'), 'versionHasPendingChanges': [ // MochiKit.Base.method(this, 'getCurrentRecordVersion'), // MochiKit.Base.methodcaller('hasPendingChanges') MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') ] }), Clipperz.Async.or, Clipperz.Async.deferredIf("Current Version has pending changes", [ MochiKit.Base.method(this, 'createNewRecordVersion'), MochiKit.Base.methodcaller('prepareRemoteDataWithKey', newVersionKey), MochiKit.Base.partial(Clipperz.Async.setItem, result, 'currentRecordVersion'), MochiKit.Base.method(this, 'setCurrentRecordVersionKey', newVersionKey) ], []), MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.prepareRemoteDataWithKey, this, aKey), MochiKit.Base.partial(Clipperz.Async.setItem, result, 'record'), MochiKit.Base.partial(MochiKit.Async.succeed, result) ]); deferredResult.callback(); return deferredResult; }, //========================================================================= 'fields': function () { return this.invokeCurrentRecordVersionMethod('fields'); }, 'addField': function (someParameters) { return this.invokeCurrentRecordVersionMethod('addField', someParameters); }, 'removeField': function (someParameters) { return this.invokeCurrentRecordVersionMethod('removeField', someParameters); }, // 'sortFieldReference': function (someSortedFieldReferences) { // return this.invokeCurrentRecordVersionMethod('sortFieldReference', someSortedFieldReferences); // }, 'getFieldsValues': function () { return this.invokeCurrentRecordVersionMethod('getFieldsValues'); }, 'fieldWithLabel': function (aLabel) { return Clipperz.Async.callbacks("Record.fieldWithLabel", [ MochiKit.Base.method(this, 'fields'), MochiKit.Base.values, MochiKit.Base.partial(Clipperz.Async.deferredFilter, function (aField) { return Clipperz.Async.callbacks("Record.fieldWithLabel - check field label", [ MochiKit.Base.methodcaller('label'), MochiKit.Base.partial(MochiKit.Base.operator.eq, aLabel) ], {trace:false}, aField); }), function (someFilteredResults) { var result; switch (someFilteredResults.length) { case 0: result = null; break; case 1: result = someFilteredResults[0]; break; default: WTF = TODO; break; } return result; } ], {trace:false}); }, //========================================================================= 'getVersion': function (aVersionReference) { return Clipperz.Async.callbacks("Record.getVersion", [ MochiKit.Base.method(this, 'getVersions'), MochiKit.Base.itemgetter(aVersionReference) ], {trace:false}); }, //------------------------------------------------------------------------- 'getVersionKey': function (aVersionReference) { var deferredResult; var transientStateKey; transientStateKey = 'versionKeys' + '.' + aVersionReference; if (this.transientState().getValue(transientStateKey) != null) { deferredResult = MochiKit.Async.succeed(this.transientState().getValue(transientStateKey)); } else { deferredResult = Clipperz.Async.callbacks("Record.getVersionKey", [ MochiKit.Base.method(this, 'getVersions'), MochiKit.Base.partial(MochiKit.Base.operator.eq, aVersionReference, this.currentVersionReference()), Clipperz.Async.deferredIf("getVersionKey for current version", [ MochiKit.Base.method(this, 'getCurrentRecordVersionKey'), MochiKit.Base.method(this.transientState(), 'setValue', transientStateKey) ],[ MochiKit.Async.fail ]) ], {trace:false}); } return deferredResult; }, //------------------------------------------------------------------------- 'versions': function () { return this._versions; }, 'getVersions': function () { return Clipperz.Async.callbacks("Record.versions", [ MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), MochiKit.Base.bind(function () { return this._versions; }, this) ], {trace:false}); }, //------------------------------------------------------------------------- 'getCurrentRecordVersion': function () { return Clipperz.Async.callbacks("Record.getCurrentRecordVersion", [ // MochiKit.Base.method(this, 'getValue', 'fakeKey, just to trigger unpackRemoteData'), // MochiKit.Base.bind(function () { return this._currentRecordVersion; }, this) MochiKit.Base.method(this, 'versions'), MochiKit.Base.itemgetter(this.currentVersionReference()), Clipperz.Async.deferredIf("The current version is available", [ MochiKit.Async.succeed ], [ MochiKit.Base.method(this, 'getVersions'), MochiKit.Base.bind(function (someVersions) { return someVersions[this.currentVersionReference()]}, this) ]) ], {trace:false}); }, 'setCurrentRecordVersion': function (aRecordVersion) { this._currentVersionReference = aRecordVersion.reference(); }, //......................................................................... 'currentVersionReference': function () { -//console.log("currentVersionReference"); return this._currentVersionReference; }, //------------------------------------------------------------------------- 'createNewRecordVersion': function () { var deferredResult; if (this.isBrandNew()) { deferredResult = this.getCurrentRecordVersion(); } else { var newVersion; newVersion = new Clipperz.PM.DataModel.Record.Version({ // 'reference': versionKey, 'retrieveKeyFunction': MochiKit.Base.method(this, 'getVersionKey'), // 'remoteData': {}, 'getVersion': MochiKit.Base.method(this, 'getVersion') }) this._versions[newVersion.reference()] = newVersion; deferredResult = Clipperz.Async.callbacks("Record.createNewRecordVersion", [ // MochiKit.Base.method(this, 'getCurrentRecordVersion'), // MochiKit.Base.methodcaller('values'), MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'values'), MochiKit.Base.method(newVersion, 'setValues'), Clipperz.Async.collectResults("Record.createNewRecordVersion [collect results]", { 'reference': MochiKit.Base.method(this, 'currentVersionReference'), 'key': MochiKit.Base.method(this, 'getCurrentRecordVersionKey') }, {trace:false}), MochiKit.Base.method(newVersion, 'setPreviousVersionReferenceAndKey'), // MochiKit.Base.method(this, 'getCurrentRecordVersion'), // MochiKit.Base.method(this, 'revertChanges'), MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'revertChanges'), MochiKit.Base.method(this, 'setCurrentRecordVersion', newVersion), MochiKit.Base.partial(MochiKit.Async.succeed, newVersion) ], {trace:false}); } return deferredResult; }, //------------------------------------------------------------------------- 'getCurrentRecordVersionKey': function () { -//console.log("getCurrentRecordVersionKey"); return Clipperz.Async.callbacks("Record.getCurrentRecordVersionKey", [ MochiKit.Base.method(this, 'getValue', 'currentVersionKey'), Clipperz.Async.deferredIf("currentVersionKey is NOT null", [ MochiKit.Async.succeed ], [ MochiKit.Base.method(this, 'getKey') ]) ], {trace:false}); }, 'setCurrentRecordVersionKey': function (aValue) { // TODO: triple check this method! return Clipperz.Async.callbacks("Record.setCurrentRecordVersionKey", [ MochiKit.Base.method(this, 'setValue', 'currentVersionKey', aValue) ], {trace:false}); }, //------------------------------------------------------------------------- 'invokeCurrentRecordVersionMethod': function (aMethodName, someValues) { -//console.log(">>> invokeCurrentRecordVersionMethod", aMethodName); return Clipperz.Async.callbacks("Record.invokeCurrentRecordVersionMethod", [ MochiKit.Base.method(this, 'getCurrentRecordVersion'), -//function (aValue) { console.log("=== getCurrentRecordVersion", aValue); return aValue}, MochiKit.Base.methodcaller(aMethodName, someValues) ], {trace:false}); }, 'lazilyinvokeCurrentRecordVersionMethod': function (aMethodName, someValues, defaultResult) { return Clipperz.Async.callbacks("Record.lazilyinvokeCurrentRecordVersionMethod", [ MochiKit.Base.method(this, 'currentVersionReference'), -//function (aValue) { console.log("LAZY -> versions", aValue); return aValue; }, Clipperz.Async.deferredIf("versions has been loaded", [ -//function (aValue) { console.log("LAZY -> then"); return aValue; }, MochiKit.Base.method(this, 'getCurrentRecordVersion'), MochiKit.Base.methodcaller(aMethodName, someValues), -//function (aValue) { console.log("LAZY <- then"); return aValue; } ], [ -//function (aValue) { console.log("LAZY -> else"); return aValue; }, MochiKit.Base.partial(MochiKit.Async.succeed, defaultResult), -//function (aValue) { console.log("LAZY <- else"); return aValue; } ]) ], {trace:false}); }, //========================================================================= 'hasPendingChanges': function () { var deferredResult; if (this.hasInitiatedObjectDataStore()) { deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false}); deferredResult.collectResults({ 'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this), 'currentVersion': [ // MochiKit.Base.method(this, 'getCurrentRecordVersion'), // MochiKit.Base.methodcaller('hasPendingChanges') MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'hasPendingChanges') ], 'directLogins': [ MochiKit.Base.method(this, 'directLogins'), -//function (aValue) { console.log("Record.directLogins", aValue); return aValue; }, MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), Clipperz.Async.collectAll, Clipperz.Async.or // function(someValues) { // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); // } ] }); -//deferredResult.addCallback(function (aValue) { console.log("Record.hasPendingResults", aValue); return aValue; }); deferredResult.addCallback(MochiKit.Base.values); deferredResult.addCallback(MochiKit.Base.bind(function(someValues) { var result; result = MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); if ((result == false) && (this.isBrandNew() == false)) { result = MochiKit.Iter.some(MochiKit.Base.values(this.transientState().getValue('hasPendingChanges.indexData')), MochiKit.Base.operator.identity); } return result; }, this)); deferredResult.callback(); } else { deferredResult = Clipperz.Async.callbacks("Recrod.hasPendingChanges [hasInitiatedObjectDataStore == false]", [ MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasPendingChanges')), Clipperz.Async.collectAll, Clipperz.Async.or // function(someValues) { // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); // } ], {trace:false}) } return deferredResult; }, //------------------------------------------------------------------------- 'hasPendingChangesWhenBrandNew': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChangesWhenBrandNew", {trace:false}); deferredResult.collectResults({ 'label': [ MochiKit.Base.method(this, 'label'), MochiKit.Base.partial(MochiKit.Base.operator.ne, '') ], 'notes': [ MochiKit.Base.method(this, 'notes'), MochiKit.Base.partial(MochiKit.Base.operator.ne, '') ] }); // deferredResult.addCallback(MochiKit.Base.values); // deferredResult.addCallback(function(someValues) { // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); // }); deferredResult.addCallback(Clipperz.Async.or); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'isBrandNewWithNoPendingChanges': function () { var deferredResult; if (this.isBrandNew() == false) { deferredResult = MochiKit.Async.succeed(false); } else { deferredResult = Clipperz.Async.callbacks("Record.isBrandNewWithNoPendingChanges", [ MochiKit.Base.method(this, 'hasPendingChanges'), MochiKit.Base.operator.lognot ], {trace:false}); } return deferredResult; }, //========================================================================= 'revertChanges': function () { var deferredResult; if (this.isBrandNew() == false) { deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.revertChanges", {trace:false}); deferredResult.addMethod(this, 'hasPendingChanges'); deferredResult.addIf([ // MochiKit.Base.method(this, 'getCurrentRecordVersion'), // MochiKit.Base.methodcaller('revertChanges'), MochiKit.Base.method(this,'invokeCurrentRecordVersionMethod', 'revertChanges'), MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')), MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.revertChanges, this) ], [ MochiKit.Async.succeed ]); deferredResult.callback(); } else { // this.deleteAllCleanTextData(); deferredResult = MochiKit.Async.succeed(); } return deferredResult; }, //------------------------------------------------------------------------- 'resetTransientState': function (isCommitting) { // if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { // this._directLogins = this.transientState().getValue('directLogins'); // } return Clipperz.Async.callbacks("Record.resetTransientState", [ //- MochiKit.Base.method(this, 'getCurrentRecordVersion'), //- MochiKit.Base.methodcaller('resetTransientState'), // MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'resetTransientState'), MochiKit.Base.method(this, 'lazilyinvokeCurrentRecordVersionMethod', 'resetTransientState'), MochiKit.Base.method(this, 'directLogins'), -//function (aValue) { console.log("resetTransientState - directLogins", aValue); return aValue; }, MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('resetTransientState')), MochiKit.Base.bind(function () { if ((isCommitting == false) && (this.transientState().getValue('directLogins') != null)) { this._directLogins = this.transientState().getValue('directLogins'); } }, this), MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.resetTransientState, this, isCommitting) ], {trace:false}) }, //------------------------------------------------------------------------- 'commitTransientState': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.commitTransientState", {trace:false}); deferredResult.addMethod(this, 'hasPendingChanges'); deferredResult.addIf([ MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.commitTransientState, this), // MochiKit.Base.method(this, 'getCurrentRecordVersion'), // MochiKit.Base.methodcaller('commitTransientState'), MochiKit.Base.method(this, 'invokeCurrentRecordVersionMethod', 'commitTransientState'), MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('commitTransientState')) ], [ MochiKit.Async.succeed ]); deferredResult.callback(); return deferredResult; }, //========================================================================= 'retrieveDirectLoginIndexDataFunction': function () { -//console.log("Record.retrieveDirectLoginIndexDataFunction", this._retrieveDirectLoginIndexDataFunction); return this._retrieveDirectLoginIndexDataFunction; }, 'setDirectLoginIndexDataFunction': function () { return this._setDirectLoginIndexDataFunction; }, 'removeDirectLoginIndexDataFunction': function () { return this._removeDirectLoginIndexDataFunction; }, //========================================================================= 'deleteAllCleanTextData': function () { // return Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData.apply(this, arguments); return Clipperz.Async.callbacks("Record.deleteAllCleanTextData", [ MochiKit.Base.method(this, 'versions'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.deleteAllCleanTextData, this) ], {trace:false}); }, 'hasAnyCleanTextData': function () { // return Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData.apply(this, arguments); return Clipperz.Async.callbacks("Record.hasAnyCleanTextData", [ Clipperz.Async.collectResults("Record.hasAnyCleanTextData [collect results]", { 'versions': [ MochiKit.Base.method(this, 'versions'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), Clipperz.Async.collectAll ], 'directLogins': [ MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), Clipperz.Async.collectAll ], 'super': [ MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasAnyCleanTextData, this) ] }, {trace:false}), Clipperz.Async.or ]) }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js index d6202ff..cda5a41 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Legacy.js @@ -1,184 +1,182 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.User.Header.Legacy depends on Clipperz.PM.DataModel.User!"; } if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } Clipperz.PM.DataModel.User.Header.Legacy = function(args) { // args = args || {}; Clipperz.PM.DataModel.User.Header.Legacy.superclass.constructor.apply(this, arguments); this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction || Clipperz.Base.exception.raise('MandatoryParameter'); this._records = null; // this._directLogins = null; return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Legacy, Clipperz.PM.DataModel.EncryptedRemoteObject, { 'toString': function() { return "Clipperz.PM.DataModel.User.Header.Legacy"; }, //------------------------------------------------------------------------- 'retrieveRecordDetailFunction': function () { return this._retrieveRecordDetailFunction; }, //------------------------------------------------------------------------- 'getRecordKey': function (aRecordReference) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.getRecordKey", {trace:false}); deferredResult.addMethod(this, 'getRecordIndexData'); deferredResult.addCallback(MochiKit.Base.itemgetter('key')) deferredResult.callback(); return deferredResult; }, //========================================================================= 'getRecordIndexData': function (aRecordReference) { return this.getValue('records.' + aRecordReference); }, 'updateRecordIndexData': function (aRecordReference, aKey, aValue) { return this.setValue('records.' + aRecordReference + "." + aKey, aValue); }, //------------------------------------------------------------------------- 'getDirectLoginIndexData': function (aDirectLoginReference) { return this.getValue('directLogins.' + aDirectLoginReference); }, 'setDirectLoginIndexData': function (aDirectLoginReference, aKey, aValue) { return this.setValue('directLogins.' + aDirectLoginReference + '.' + aKey, aValue); }, 'removeDirectLoginIndexData': function (aDirectLoginReference) { return this.removeValue('directLogins.' + aDirectLoginReference); }, //========================================================================= 'records': function () { var deferredResult; var deferredLock; deferredLock = this.getDeferredLockForKey('records'); deferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.records", {trace:false}); deferredResult.acquireLock(deferredLock); deferredResult.addCallback(MochiKit.Base.bind(function () { var innerDeferredResult; if (this._records == null) { innerDeferredResult = new Clipperz.Async.Deferred("User.Header.Legacy.records <inner deferred>", {trace:false}); innerDeferredResult.collectResults({ 'header': [ // MochiKit.Base.method(this, 'getObjectDataStore'), // MochiKit.Base.methodcaller('values') MochiKit.Base.method(this, 'values') ], 'recordsStats': [ MochiKit.Base.method(this, 'getRemoteData'), MochiKit.Base.itemgetter('recordsStats') ] }); innerDeferredResult.addCallback(MochiKit.Base.bind(function (someObjectData) { var reference; this._records = {}; // this._directLogins = {}; for (reference in someObjectData['header']['records']) { var record; record = new Clipperz.PM.DataModel.Record({ 'reference': reference, 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), 'retrieveRemoteDataFunction': this.retrieveRecordDetailFunction(), // 'encryptedDataKeypath': 'data', // 'encryptedVersionKeypath': 'version', 'retrieveIndexDataFunction': MochiKit.Base.method(this, 'getRecordIndexData'), 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), 'updateDate': someObjectData['recordsStats'][reference]['updateDate'], 'retrieveDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'getDirectLoginIndexData'), 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), 'removeDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData') }); this._records[reference] = record; } for (reference in someObjectData['header']['directLogins']) { var directLogin; var record; record = this._records[someObjectData['header']['directLogins'][reference]['record']]; if (record != null) { directLogin = new Clipperz.PM.DataModel.DirectLogin({ 'reference': reference, 'record': record //, // 'retrieveIndexDataFunction': MochiKit.Base.method(this, 'getDirectLoginIndexData'), // 'setIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), // 'removeIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData') }); } else { Clipperz.log("WARNING: DIRECT LOGIN without a matching RECORD!!"); } } return this._records; }, this)); innerDeferredResult.callback(); } else { innerDeferredResult = MochiKit.Async.succeed(this._records); } return innerDeferredResult; }, this)); deferredResult.releaseLock(deferredLock); deferredResult.callback(); return deferredResult; }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js index 3528db6..e82da47 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js @@ -1,125 +1,117 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.User.Header.OneTimePasswords depends on Clipperz.PM.DataModel.User!"; } if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } //----------------------------------------------------------------------------- Clipperz.PM.DataModel.User.Header.OneTimePasswords = function(args) { Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.constructor.apply(this, arguments); this._oneTimePasswords = null; return this; } //----------------------------------------------------------------------------- Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.OneTimePasswords, Clipperz.PM.DataModel.EncryptedRemoteObject, { 'toString': function() { return "Clipperz.PM.DataModel.User.Header.OneTimePasswords"; }, //------------------------------------------------------------------------- /* 'packData': function (someData) { // ++ var result; -console.log(">>> OneTimePasswords.packData", someData); result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.packData.apply(this, arguments); -console.log("<<< OneTimePasswords.packData"); return result; }, */ //------------------------------------------------------------------------- /* 'packRemoteData': function (someData) { var result; -console.log(">>> OneTimePasswords.packRemoteData", someData); result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.packRemoteData.apply(this, arguments); -console.log("<<< OneTimePasswords.packRemoteData"); return result; }, */ //------------------------------------------------------------------------- /* 'prepareRemoteDataWithKey': function (aKey) { var result; -console.log(">>> OneTimePasswords.prepareRemoteDataWithKey"); result = Clipperz.PM.DataModel.User.Header.OneTimePasswords.superclass.prepareRemoteDataWithKey.apply(this, arguments); -console.log("<<< OneTimePasswords.prepareRemoteDataWithKey"); return result; }, */ //========================================================================= 'oneTimePasswords': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.Header.OneTimePasswords.oneTimePasswords", {trace:false}); if (this._oneTimePasswords == null) { deferredResult.addMethod(this, 'values') deferredResult.addCallback(MochiKit.Base.bind(function (someData) { var otpKey; this._oneTimePasswords = {}; for (otpKey in someData) { var otp; var otpParameters; otpParameters = Clipperz.Base.deepClone(someData[otpKey]); otpParameters['reference'] = otpKey; otp = new Clipperz.PM.DataModel.OneTimePassword(otpParameters); this._oneTimePasswords[otpKey] = otp; } return this._oneTimePasswords; }, this)); deferredResult.callback(); } else { deferredResult = MochiKit.Async.succeed(this._oneTimePasswords); } return deferredResult; }, //========================================================================= __syntaxFix__: "syntax fix" }); //----------------------------------------------------------------------------- diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js index b164889..f1f95e8 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.Preferences.js @@ -1,50 +1,48 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.User.Header.Preferences depends on Clipperz.PM.DataModel.User!"; } if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } Clipperz.PM.DataModel.User.Header.Preferences = function(args) { Clipperz.PM.DataModel.User.Header.Preferences.superclass.constructor.apply(this, arguments); return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.Preferences, Clipperz.PM.DataModel.EncryptedRemoteObject, { 'toString': function() { return "Clipperz.PM.DataModel.User.Header.Preferences"; }, //------------------------------------------------------------------------- //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js index f77ea80..5681f70 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.Header.RecordIndex.js @@ -1,702 +1,685 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.DataModel.User) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.DataModel.User.Header.RecordIndex depends on Clipperz.PM.DataModel.User!"; } if (typeof(Clipperz.PM.DataModel.User.Header) == 'undefined') { Clipperz.PM.DataModel.User.Header = {}; } Clipperz.PM.DataModel.User.Header.RecordIndex = function(args) { Clipperz.PM.DataModel.User.Header.RecordIndex.superclass.constructor.apply(this, arguments); -//console.log("NEW Clipperz.PM.DataModel.User.Header.RecordIndex", args); this._recordsData = new Clipperz.PM.DataModel.EncryptedRemoteObject({ 'name': 'recordsData', 'retrieveKeyFunction': args.retrieveKeyFunction, 'remoteData': { 'data': args.recordsData['data'], 'version': args.encryptedDataVersion, 'recordsStats': args.recordsStats }//, // 'encryptedDataKeypath': 'data', // 'encryptedVersionKeypath': 'version' }); this._directLoginsData = new Clipperz.PM.DataModel.EncryptedRemoteObject({ 'name': 'directLoginsData', 'retrieveKeyFunction': args.retrieveKeyFunction, 'remoteData': { 'data': args.directLoginsData['data'], 'version': args.encryptedDataVersion }//, // 'encryptedDataKeypath': 'data', // 'encryptedVersionKeypath': 'version' }); this._lock = new MochiKit.Async.DeferredLock(); this._transientState = null; this._retrieveRecordDetailFunction = args.retrieveRecordDetailFunction || Clipperz.Base.exception.raise('MandatoryParameter'); this._recordsIndex = args.recordsData['index'] || Clipperz.Base.exception.raise('MandatoryParameter'); this._directLoginsIndex = args.directLoginsData['index'] || Clipperz.Base.exception.raise('MandatoryParameter'); this._records = null; return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.User.Header.RecordIndex, Object, { 'toString': function() { return "Clipperz.PM.DataModel.User.Header.RecordIndex"; }, //------------------------------------------------------------------------- 'retrieveRecordDetailFunction': function () { return this._retrieveRecordDetailFunction; }, //------------------------------------------------------------------------- 'recordsIndex': function () { return this._recordsIndex; }, 'recordsData': function () { return this._recordsData; }, //------------------------------------------------------------------------- 'directLoginsIndex': function () { return this._directLoginsIndex; }, 'directLoginsData': function () { return this._directLoginsData; }, //------------------------------------------------------------------------- 'lock': function () { return this._lock; }, //------------------------------------------------------------------------- 'transientState': function () { if (this._transientState == null) { this._transientState = new Clipperz.KeyValueObjectStore(/*{'name':'User.Header.RecordIndex.transientState [1]'}*/); } return this._transientState; }, 'resetTransientState': function (isCommitting) { -//console.log("######## UserHeaderRecordIndex - resetTransientState", Clipperz.Base.deepClone(this._transientState)); if (this._transientState != null) { this._transientState.removeAllData(); } this._transientState = null; }, //------------------------------------------------------------------------- 'getRecordKey': function (aRecordReference) { return Clipperz.Async.callbacks("User.Header.RecordIndex.getRecordKey", [ MochiKit.Base.method(this, 'getRecordIndexData', aRecordReference), MochiKit.Base.itemgetter('key') ], {trace:false}); }, 'setRecordKey': function (aRecordReference, aValue) { return this.updateRecordIndexData(aRecordReference, 'key', aValue); }, //------------------------------------------------------------------------- 'getRecordIndexData': function (aRecordReference) { return this.recordsData().getValue(this.recordsIndex()[aRecordReference]); }, //......................................................................... 'updateRecordIndexData': function (aRecordReference, aKey, aValue) { return this.recordsData().setValue(this.recordsIndex()[aRecordReference]+'.'+aKey, aValue); }, //------------------------------------------------------------------------- 'getDirectLoginIndexData': function (aDirectLoginReference) { return this.directLoginsData().getValue(this.directLoginsIndex()[aDirectLoginReference]); }, 'setDirectLoginIndexData': function (aDirectLoginReference, aKey, aValue) { -//console.log("UserHeaderRecordIndex.setDirectLoginIndexData", aDirectLoginReference, this.directLoginsIndex()[aDirectLoginReference], aKey); //if (MochiKit.Base.isUndefinedOrNull(this.directLoginsIndex()[aDirectLoginReference])) { // throw "PIPPO"; //} return this.directLoginsData().setValue(this.directLoginsIndex()[aDirectLoginReference] + '.' + aKey, aValue); }, 'addDirectLoginIndexData': function (aDirectLoginReference) { -//console.log("UserHeaderRecordIndex.addDirectLoginIndexData", aDirectLoginReference, this.directLoginsIndex()[aDirectLoginReference]); return this.directLoginsData().setValue(this.directLoginsIndex()[aDirectLoginReference], {}); }, 'removeDirectLoginIndexData': function (aDirectLoginReference) { return this.directLoginsData().removeValue(this.directLoginsIndex()[aDirectLoginReference]) }, //------------------------------------------------------------------------- 'records': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.records", {trace:false}); deferredResult.acquireLock(this.lock()); deferredResult.addCallback(MochiKit.Base.bind(function () { var innerDeferredResult; if (this._records == null) { innerDeferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.records <inner deferred>", {trace:false}); innerDeferredResult.collectResults({ 'records': [ // MochiKit.Base.method(this.recordsData(), 'getObjectDataStore'), // MochiKit.Base.methodcaller('values') MochiKit.Base.method(this.recordsData(), 'values') ], 'recordsStats': [ MochiKit.Base.method(this.recordsData(), 'getRemoteData'), MochiKit.Base.itemgetter('recordsStats') ], 'directLogins': [ // MochiKit.Base.method(this.directLoginsData(), 'getObjectDataStore'), // MochiKit.Base.methodcaller('values') MochiKit.Base.method(this.directLoginsData(), 'values') ] }) innerDeferredResult.addCallback(MochiKit.Base.bind(function (someData) { var indexReference; var recordsInvertedIndex; var directLoginsInvertedIndex; recordsInvertedIndex = Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex(this.recordsIndex()); directLoginsInvertedIndex = Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex(this.directLoginsIndex()); this._records = {}; for (indexReference in someData['records']) { var record; var reference; var updateDate; reference = recordsInvertedIndex[indexReference]; if (typeof(someData['recordsStats'][reference]) != 'undefined') { updateDate = someData['recordsStats'][reference]['updateDate']; record = new Clipperz.PM.DataModel.Record({ 'reference': reference, 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), 'retrieveRemoteDataFunction': this.retrieveRecordDetailFunction(), 'retrieveIndexDataFunction': MochiKit.Base.method(this, 'getRecordIndexData'), 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), 'updateDate': updateDate, 'retrieveDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'getDirectLoginIndexData'), 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), 'removeDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData'), 'createNewDirectLoginFunction': MochiKit.Base.method(this, 'createNewDirectLogin') }); this._records[reference] = record; } else { Clipperz.log("SKIPPING record " + reference + " as there are no stas associated - " + Clipperz.Base.serializeJSON(someData['records'][reference])); // # skip the record, as it seems it is not present in the DB // updateDate = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); } } for (indexReference in someData['directLogins']) { // var directLogin; var reference; var record; reference = directLoginsInvertedIndex[indexReference]; record = this._records[recordsInvertedIndex[someData['directLogins'][indexReference]['record']]]; if (record != null) { // directLogin = new Clipperz.PM.DataModel.DirectLogin({ new Clipperz.PM.DataModel.DirectLogin({ 'reference': reference, 'record': record }); } else { -Clipperz.log("WARNING: DIRECT LOGIN without a matching RECORD!!"); -//console.log("direct login data", someData['directLogins']); -//console.log("current direct login data", someData['directLogins'][indexReference]) -//console.log("reference", reference); -//console.log("record index", this.recordsIndex()); -//console.log("record inverted index", recordsInvertedIndex); + Clipperz.logWarning("WARNING: DIRECT LOGIN without a matching RECORD!!"); } } return this._records; }, this)); innerDeferredResult.callback(); } else { innerDeferredResult = MochiKit.Async.succeed(this._records); } return innerDeferredResult; }, this)); deferredResult.releaseLock(this.lock()); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'updateRecordIndexForNewRecord': function (aNewRecord) { var newRecordIndex; var recordReference; recordReference = aNewRecord.reference(); newRecordIndex = (MochiKit.Base.listMax(MochiKit.Base.map(MochiKit.Base.partial(MochiKit.Base.operator.mul, 1), MochiKit.Base.values(this.recordsIndex()))) + 1) + ''; this.recordsIndex()[recordReference] = newRecordIndex; this.transientState().setValue('newlyCreatedRecordsIndex' + '.' + recordReference, newRecordIndex); this.transientState().setValue('newlyCreatedRecordsReferences' + '.' + recordReference, aNewRecord); }, //......................................................................... 'createNewRecord': function () { var deferredResult; var newRecord; -//console.log("#### new Clipperz.PM.DataModel.Record [4]"); newRecord = new Clipperz.PM.DataModel.Record({ 'retrieveKeyFunction': MochiKit.Base.method(this, 'getRecordKey'), 'retrieveRemoteDataFunction': this.retrieveRecordDetailFunction(), 'retrieveIndexDataFunction': MochiKit.Base.method(this, 'getRecordIndexData'), 'updateIndexDataFunction': MochiKit.Base.method(this, 'updateRecordIndexData'), 'updateDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), 'retrieveDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'getDirectLoginIndexData'), 'setDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'setDirectLoginIndexData'), 'removeDirectLoginIndexDataFunction': MochiKit.Base.method(this, 'removeDirectLoginIndexData'), 'createNewDirectLoginFunction': MochiKit.Base.method(this, 'createNewDirectLogin') }); this.transientState().setValue('newRecordsReferences' + '.' + newRecord.reference(), newRecord); this.updateRecordIndexForNewRecord(newRecord); deferredResult = Clipperz.Async.callbacks("User.Header.RecordIndex.createNewRecord", [ MochiKit.Base.method(this, 'records'), MochiKit.Base.partial(Clipperz.Async.setItemOnObject, newRecord.reference(), newRecord), MochiKit.Base.method(this, 'setRecordKey', newRecord.reference(), Clipperz.PM.Crypto.randomKey()), MochiKit.Base.method(newRecord, 'setLabel', ''), MochiKit.Base.partial(MochiKit.Async.succeed, newRecord) ], {trace:false}); return deferredResult; }, //------------------------------------------------------------------------- 'deleteRecord': function (aRecord) { var deferredResult; var recordReference; recordReference = aRecord.reference(); deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.deleteRecord", {trace:false}); deferredResult.addMethod(aRecord, 'directLogins'); deferredResult.addCallback(MochiKit.Base.values); deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'removeDirectLogin')); deferredResult.addMethod(this.recordsData(), 'removeValue', this.recordsIndex()[recordReference]); deferredResult.addCallback(MochiKit.Base.bind(function () { this.transientState().setValue('deleteRecordsIndex' + '.' + recordReference, this.recordsIndex()[recordReference]); delete this.recordsIndex()[recordReference]; }, this)); deferredResult.addMethod(this, 'records'); deferredResult.addCallback(MochiKit.Base.itemgetter(recordReference)); deferredResult.addMethod(this.transientState(), 'setValue', 'deleteRecordsReferences' + '.' + recordReference); deferredResult.addMethod(this, 'records'); deferredResult.addCallback(MochiKit.Base.bind(function (someRecords) { delete someRecords[recordReference]; }, this)); deferredResult.callback(); return deferredResult; }, //========================================================================= 'removeDirectLogin': function (aDirectLogin) { this.directLoginsData().removeValue(this.directLoginsIndex()[aDirectLogin.reference()]); }, //------------------------------------------------------------------------- 'createNewDirectLogin': function (aRecord) { var newDirectLogin; var newDirectLoginIndexValue; newDirectLogin = new Clipperz.PM.DataModel.DirectLogin({record:aRecord}); newDirectLoginIndexValue = MochiKit.Base.listMax(MochiKit.Base.map(function (aValue) { return aValue * 1; }, MochiKit.Base.values(this.directLoginsIndex()))) + 1; this.transientState().setValue('newDirectLoginReferences' + '.' + newDirectLogin.reference(), newDirectLogin); -//console.log("UserHeaderRecordIndex.createNewDirectLogin [1]", newDirectLogin.reference(), newDirectLoginIndexValue); this.directLoginsIndex()[newDirectLogin.reference()] = newDirectLoginIndexValue; -//console.log("UserHeaderRecordIndex.createNewDirectLogin [2]", newDirectLogin.reference(), this.directLoginsIndex()[newDirectLogin.reference()]); this.directLoginsData().setValue(this.directLoginsIndex()[newDirectLogin.reference()], {'record': this.recordsIndex()[aRecord.reference()]}); return newDirectLogin; }, //========================================================================= 'deleteAllCleanTextData': function () { return Clipperz.Async.callbacks("User.Header.RecordIndex.deleteAllCleanTextData", [ // MochiKit.Base.method(this, 'records'), // MochiKit.Base.values, // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('deleteAllCleanTextData')), MochiKit.Base.method(this, 'recordsData'), MochiKit.Base.methodcaller('deleteAllCleanTextData'), MochiKit.Base.method(this, 'directLoginsData'), MochiKit.Base.methodcaller('deleteAllCleanTextData') ], {trace:false}); }, //------------------------------------------------------------------------- 'hasAnyCleanTextData': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred({trace:false}); deferredResult.collectResults({ 'recordsData': [ MochiKit.Base.method(this, 'recordsData'), MochiKit.Base.methodcaller('hasAnyCleanTextData') ], 'directLoginsData': [ MochiKit.Base.method(this, 'directLoginsData'), MochiKit.Base.methodcaller('hasAnyCleanTextData') ], // 'records': [ // MochiKit.Base.method(this, 'records'), // MochiKit.Base.values, // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('hasAnyCleanTextData')), // Clipperz.Async.collectAll // ] }); -//deferredResult.addCallback(function (aValue) { console.log("USER.Header.RecordIndex.hasAnyCleanTextData", aValue); return aValue}); // deferredResult.addCallback(MochiKit.Base.values); // deferredResult.addCallback(MochiKit.Base.flattenArguments); // deferredResult.addCallback(function(someValues) { // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); // }); deferredResult.addCallback(Clipperz.Async.or); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'hasPendingChanges': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.hasPendingChanges", {trace:false}); deferredResult.collectResults({ 'recordsData': [ MochiKit.Base.method(this, 'recordsData'), MochiKit.Base.methodcaller('hasPendingChanges') ], 'directLoginsData': [ MochiKit.Base.method(this, 'directLoginsData'), MochiKit.Base.methodcaller('hasPendingChanges') ] }); -//deferredResult.addCallback(function (aValue) { console.log("UserHeaderIndex.hasPendingResults", aValue); return aValue; }); deferredResult.addCallback(Clipperz.Async.or); // deferredResult.addCallback(MochiKit.Base.values); // deferredResult.addCallback(MochiKit.Base.flattenArguments); // deferredResult.addCallback(function(someValues) { // return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity); // }); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'commitTransientState': function () { var deferredResult; deferredResut = Clipperz.Async.callbacks("User.Header.RecordIndex.commitTransientState", [ MochiKit.Base.method(this, 'recordsData'), MochiKit.Base.methodcaller('commitTransientState'), MochiKit.Base.method(this, 'directLoginsData'), MochiKit.Base.methodcaller('commitTransientState'), MochiKit.Base.method(this, 'resetTransientState', true) ], {trace:false}); return deferredResult; }, //------------------------------------------------------------------------- 'revertChanges': function () { return Clipperz.Async.callbacks("User.Header.RecordIndex.revertChanges", [ MochiKit.Base.method(this, 'recordsData'), MochiKit.Base.methodcaller('revertChanges'), // MochiKit.Base.method(this, 'directLoginsData'), // MochiKit.Base.methodcaller('revertChanges'), MochiKit.Base.method(this, 'records'), MochiKit.Base.bind(function (someRecords) { var recordReference; for (recordReference in this.transientState().getValue('deleteRecordsReferences')) { this.recordsIndex()[recordReference] = this.transientState().getValue('deleteRecordsIndex' + '.' + recordReference); someRecords[recordReference] = this.transientState().getValue('deleteRecordsReferences' + '.' + recordReference); } for (recordReference in this.transientState().getValue('newRecordsReferences')) { delete this.recordsIndex()[recordReference]; delete someRecords[recordReference]; } }, this), // MochiKit.Base.method(this, 'directLogins'), MochiKit.Base.bind(function () { var directLoginReference; // this.transientState().setValue('newDirectLoginReferences' + '.' + newDirectLogin.reference(), newDirectLogin); // // this.directLoginsIndex()[newDirectLogin.reference()] = newDirectLoginIndexValue; // this.directLoginsData().setValue(this.directLoginsIndex()[newDirectLogin.reference()], {'record': this.recordsIndex()[aRecord.reference()]}); // for (directLoginReference in this.transientState().getValue('deleteDirectLoginReferences')) { // someDirectLogins[directLoginReference] = this.transientState().getValue('deleteDirectLoginReferences' + '.' + recordReference); // } for (directLoginReference in this.transientState().getValue('newDirectLoginReferences')) { // this.directLoginsData().removeValue(this.directLoginsIndex()[directLoginReference]); delete this.directLoginsIndex()[directLoginReference]; } }, this), MochiKit.Base.method(this, 'directLoginsData'), MochiKit.Base.methodcaller('revertChanges'), MochiKit.Base.method(this, 'resetTransientState', false) ], {trace:false}); }, //------------------------------------------------------------------------- 'prepareRemoteDataWithKey': function (aKey) { // "records": { // "index": { // "eeda70e0392261967bda71c3764da78989c45bbd2bb7be6b941b90f81d9b81b5": "0", // "13a5e52976337ab210903cd04872588e1b21fb72bc183e91aa25c494b8138551": "1", // ... // "465a067a0bd2b470fa834de5397e38494de0c7707938262fae3427932e219744": "18", // "4fd1dc2ca860b7fb47cef10a84edb3270da05510b0a30a6b0b083898712d4b9e": "19" // }, // "data": "n+AzGEEQXaSRSY4d ... BDypotrXgPo94uHfoXvGFzwCn8w=" // }, // "directLogins": { // "index": { // "61e87fdc4f1d9112e3b30c1f6812d095dcdb24f014c83319091eb6c9899ec348":"0", // "989593d4c48929f0c8f1581aa96969c622807e99619ed4732026e967530a68ad":"1", // ... // "cb9ae0bba1957075ccdbfd3b3481704d62087687a2ac7c411a4f07d444bde0f7":"17", // "7e1d069b7fa57c03bd7bf48807520feb953157834503aaff8c9d493f37dea69d":"18" // }, // "data":"5YG9KKU/OZ5guUgFlms6k1 ... ZG/5Fn0uN+LoAsNfHm+EE62x" // }, var deferredResult; var result; -//console.log("recordsIndex", this.recordsIndex()); result = {}; deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.prepareRemoteDataWithKey", {trace:false}); deferredResult.collectResults({ 'index': MochiKit.Base.partial(MochiKit.Async.succeed, this.recordsIndex()), 'data': [ MochiKit.Base.method(this.recordsData(), 'prepareRemoteDataWithKey', aKey), MochiKit.Base.itemgetter('data') ] }); deferredResult.addCallback(Clipperz.Async.setItem, result, 'records'); deferredResult.collectResults({ 'index': MochiKit.Base.partial(MochiKit.Async.succeed, this.directLoginsIndex()), 'data': [ MochiKit.Base.method(this.directLoginsData(), 'prepareRemoteDataWithKey', aKey), MochiKit.Base.itemgetter('data') ] }); deferredResult.addCallback(Clipperz.Async.setItem, result, 'directLogins'); deferredResult.addCallback(MochiKit.Async.succeed, result); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'updateRecordKeyAndPrepareRemoteData': function (aRecord) { var newRecordKey; var deferredResult; newRecordKey = Clipperz.PM.Crypto.randomKey(); deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.updateRecordKeyAndPrepareRemoteData", {trace:false}); deferredResult.addCallback(MochiKit.Base.method(aRecord, 'prepareRemoteDataWithKey', newRecordKey)); deferredResult.addCallbackPass(MochiKit.Base.method(this, 'setRecordKey', aRecord.reference(), newRecordKey)); deferredResult.callback(); return deferredResult; }, //......................................................................... 'removeNewRecordWithNoChanges': function (aRecord) { var deferredResult; var recordReference; recordReference = aRecord.reference(); deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.removeNewRecordWithNoChanges", {trace:false}); deferredResult.addMethod(this.recordsData(), 'removeValue', this.recordsIndex()[recordReference]); deferredResult.addCallback(MochiKit.Base.bind(function () { delete this.recordsIndex()[recordReference]; }, this)); deferredResult.addMethod(this, 'records'); deferredResult.addCallback(MochiKit.Base.bind(function (someRecords) { delete someRecords[recordReference]; }, this)); deferredResult.callback(); return deferredResult; }, //......................................................................... 'prepareRemoteDataForChangedRecords': function () { var deferredResult; var result; result = {}; deferredResult = new Clipperz.Async.Deferred("User.Header.RecordIndex.prepareRemoteDataForChangedRecords", {trace:false}); deferredResult.addMethod(this, 'records'); deferredResult.addCallback(MochiKit.Base.values); deferredResult.addCallback(Clipperz.Async.deferredFilter, MochiKit.Base.methodcaller('isBrandNewWithNoPendingChanges')); deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'removeNewRecordWithNoChanges')); deferredResult.addMethod(this, 'records'); deferredResult.addCallback(MochiKit.Base.values); deferredResult.addCallback(Clipperz.Async.deferredFilter, MochiKit.Base.methodcaller('hasPendingChanges')); deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordKeyAndPrepareRemoteData')); deferredResult.addCallback(Clipperz.Async.collectAll); deferredResult.addCallback(Clipperz.Async.deferredIf("updated records != null", [ MochiKit.Base.operator.identity ], [ MochiKit.Base.partial(MochiKit.Async.succeed, []) ])); deferredResult.addCallback(Clipperz.Async.setItem, result, 'updated'); deferredResult.addMethod(this.transientState(), 'getValue', 'deleteRecordsReferences'); deferredResult.addCallback(MochiKit.Base.keys); deferredResult.addCallback(Clipperz.Async.deferredIf("deleted records != null", [ MochiKit.Base.operator.identity ], [ MochiKit.Base.partial(MochiKit.Async.succeed, []) ])); deferredResult.addCallback(Clipperz.Async.setItem, result, 'deleted'); deferredResult.addCallback(MochiKit.Async.succeed, result); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.PM.DataModel.User.Header.RecordIndex.invertIndex = function (anIndex) { var result; var key; result = {}; for (key in anIndex) { result[anIndex[key]] = key; } return result; };
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index 646ce21..fd18faf 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js @@ -1,814 +1,810 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } //############################################################################# Clipperz.PM.DataModel.User = function (args) { args = args || {}; Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); this._username = args.username || null; this._getPassphraseFunction = args.getPassphraseFunction || null; this._data = null; this._connection = null; this._connectionVersion = 'current'; this._serverData = null; // this._serverLockValue = null; this._transientState = null; this._deferredLocks = { 'passphrase': new MochiKit.Async.DeferredLock(), 'serverData': new MochiKit.Async.DeferredLock(), // 'recordsIndex': new MochiKit.Async.DeferredLock(), // 'directLoginsIndex': new MochiKit.Async.DeferredLock() // 'preferences': new MochiKit.Async.DeferredLock() // 'oneTimePasswords': new MochiKit.Async.DeferredLock() '__syntaxFix__': 'syntax fix' }; return this; } Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { 'toString': function () { return "Clipperz.PM.DataModel.User - " + this.username(); }, //------------------------------------------------------------------------- 'username': function () { return this._username; }, 'setUsername': function (aValue) { this._username = aValue; }, //------------------------------------------------------------------------- 'displayName': function() { return "" + this.username() + ""; }, //------------------------------------------------------------------------- 'data': function () { if (this._data == null) { this._data = new Clipperz.KeyValueObjectStore(/*{'name':'User.data [1]'}*/); }; return this._data; }, //------------------------------------------------------------------------- /* 'serverLockValue': function () { return this._serverLockValue; }, 'setServerLockValue': function (aValue) { this._serverLockValue = aValue; }, */ //------------------------------------------------------------------------- 'transientState': function () { if (this._transientState == null) { this._transientState = {} } return this._transientState; }, 'resetTransientState': function (isCommitting) { this._transientState = null; }, //------------------------------------------------------------------------- 'deferredLockForSection': function(aSectionName) { return this._deferredLocks[aSectionName]; }, //------------------------------------------------------------------------- 'getPassphrase': function() { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.getPassphrase", {trace:false}); deferredResult.acquireLock(this.deferredLockForSection('passphrase')); deferredResult.addMethod(this.data(), 'deferredGetOrSet', 'passphrase', this.getPassphraseFunction()); deferredResult.releaseLock(this.deferredLockForSection('passphrase')); deferredResult.callback(); return deferredResult; }, 'getPassphraseFunction': function () { return this._getPassphraseFunction; }, //------------------------------------------------------------------------- 'getCredentials': function () { return Clipperz.Async.collectResults("User; get username and passphrase", { 'username': MochiKit.Base.method(this, 'username'), 'password': MochiKit.Base.method(this, 'getPassphrase') }, {trace:false})(); }, //------------------------------------------------------------------------- 'changePassphrase': function (aNewValue) { return this.updateCredentials(this.username(), aNewValue); }, //......................................................................... 'updateCredentials': function (aUsername, aPassphrase) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.updateCredentials", {trace:false}); // deferredResult.addMethod(this, 'getPassphrase'); // deferredResult.setValue('currentPassphrase'); deferredResult.addMethod(this.connection(), 'ping'); deferredResult.addMethod(this, 'setUsername', aUsername) deferredResult.acquireLock(this.deferredLockForSection('passphrase')); deferredResult.addMethod(this.data(), 'deferredGetOrSet', 'passphrase', aPassphrase); deferredResult.releaseLock(this.deferredLockForSection('passphrase')); // deferredResult.getValue('currentPassphrase'); deferredResult.addMethod(this, 'prepareRemoteDataWithKey', aPassphrase); deferredResult.addMethod(this.connection(), 'updateCredentials', aUsername, aPassphrase); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'initialSetupWithNoData': function () { this._serverData = { 'version': '0.1', 'statistics': "", 'header': { 'data': null, 'version': Clipperz.PM.Crypto.encryptingFunctions.currentVersion, 'recordsIndex': new Clipperz.PM.DataModel.User.Header.RecordIndex({ 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), 'recordsData': {'data':null, 'index':{}}, 'recordsStats': null, 'directLoginsData': {'data':null, 'index':{}}, 'encryptedDataVersion': Clipperz.PM.Crypto.encryptingFunctions.currentVersion, 'retrieveRecordDetailFunction': MochiKit.Base.method(this, 'getRecordDetail') }), 'preferences': new Clipperz.PM.DataModel.User.Header.Preferences({ 'name': 'preferences', 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') }), 'oneTimePasswords': new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ 'name': 'preferences', 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') }) } }; // this._serverLockValue = Clipperz.PM.Crypto.randomKey(); }, //......................................................................... 'registerAsNewAccount': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.registerAsNewAccount", {trace:false}); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); deferredResult.addMethod(this, 'initialSetupWithNoData') deferredResult.addMethod(this, 'getPassphrase'); 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.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered'); // deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure')); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'login': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.login", {trace:false}); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); deferredResult.addMethod(this, 'getPassphrase'); deferredResult.addCallback(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue); deferredResult.addCallback(Clipperz.Async.deferredIf("Is the passphrase an OTP", [ MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':1}), MochiKit.Base.method(this, 'getCredentials'), MochiKit.Base.method(this.connection(), 'redeemOneTimePassword'), MochiKit.Base.method(this.data(), 'setValue', 'passphrase') ], [])); deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase')); deferredResult.addMethod(this.connection(), 'login', false); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn'); deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback')); deferredResult.callback(); return deferredResult; }, //......................................................................... 'handleConnectionFallback': function(aValue) { var result; if (aValue instanceof MochiKit.Async.CancelledError) { result = aValue; } else { this.setConnectionVersion(Clipperz.PM.Connection.communicationProtocol.fallbackVersions[this.connectionVersion()]); if (this.connectionVersion() != null) { result = new Clipperz.Async.Deferred("User.handleConnectionFallback - retry"); result.addMethod(this, 'login'); result.callback(); } else { result = Clipperz.Async.callbacks("User.handleConnectionFallback - failed", [ MochiKit.Base.method(this.data(), 'removeValue', 'passphrase'), MochiKit.Base.method(this, 'setConnectionVersion', 'current'), MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userLoginFailed'), MochiKit.Base.partial(MochiKit.Async.fail, Clipperz.PM.DataModel.User.exception.LoginFailed) ], {trace:false}); } } return result; }, //------------------------------------------------------------------------- 'lock': function () { return Clipperz.Async.callbacks("User.lock", [ MochiKit.Base.method(this, 'deleteAllCleanTextData') ], {trace:false}); }, //------------------------------------------------------------------------- 'logout': function () { return Clipperz.Async.callbacks("User.logout", [ MochiKit.Base.method(this, 'deleteAllCleanTextData'), MochiKit.Base.method(this.connection(), 'logout') ], {trace:false}); }, //------------------------------------------------------------------------- 'headerFormatVersion': function(anHeader) { var result; if (anHeader.charAt(0) == '{') { var headerData; headerData = Clipperz.Base.evalJSON(anHeader); result = headerData['version']; } else { result = 'LEGACY'; } return result; }, //------------------------------------------------------------------------- 'unpackServerData': function (someServerData) { var unpackedData; var headerVersion; var recordsIndex; var preferences; var oneTimePasswords; -//console.log(">>> ***************** user.unpackServerData", someServerData); // this.setServerLockValue(someServerData['lock']); headerVersion = this.headerFormatVersion(someServerData['header']); switch (headerVersion) { case 'LEGACY': var legacyHeader; legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), 'remoteData': { 'data': someServerData['header'], 'version': someServerData['version'], 'recordsStats': someServerData['recordsStats'] }, // 'encryptedDataKeypath': 'data', // 'encryptedVersionKeypath': 'version', 'retrieveRecordDetailFunction': MochiKit.Base.method(this, 'getRecordDetail') }); recordsIndex = legacyHeader; preferences = legacyHeader; oneTimePasswords = legacyHeader; break; case '0.1': var headerData; headerData = Clipperz.Base.evalJSON(someServerData['header']); recordsIndex = new Clipperz.PM.DataModel.User.Header.RecordIndex({ 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), 'recordsData': headerData['records'], 'recordsStats': someServerData['recordsStats'], 'directLoginsData': headerData['directLogins'], 'encryptedDataVersion': someServerData['version'], 'retrieveRecordDetailFunction': MochiKit.Base.method(this, 'getRecordDetail') }); // Still missing a test case that actually fais with the old version of the code, where the check for undefined was missing if (typeof(headerData['preferences']) != 'undefined') { preferences = new Clipperz.PM.DataModel.User.Header.Preferences({ 'name': 'preferences', 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), 'remoteData': { 'data': headerData['preferences']['data'], 'version': someServerData['version'] } }); } else { preferences = new Clipperz.PM.DataModel.User.Header.Preferences({ 'name': 'preferences', 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') }); } if (typeof(headerData['oneTimePasswords']) != 'undefined') { oneTimePasswords = new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ 'name': 'preferences', 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), 'remoteData': { 'data': headerData['oneTimePasswords']['data'], 'version': someServerData['version'] } }); } else { oneTimePasswords = new Clipperz.PM.DataModel.User.Header.OneTimePasswords({ 'name': 'preferences', 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase') }); } break; } unpackedData = { 'version': someServerData['version'], 'statistics': someServerData['statistics'], 'header': { 'data': someServerData['header'], 'version': headerVersion, 'recordsIndex': recordsIndex, 'preferences': preferences, 'oneTimePasswords': oneTimePasswords } }; this._serverData = unpackedData; -//console.log("<<< ***************** user.unpackServerData", this._serverData); return this._serverData; }, //------------------------------------------------------------------------- 'getServerData': function() { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.getServerData", {trace:false}); deferredResult.acquireLock(this.deferredLockForSection('serverData')); deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { var innerDeferredResult; innerDeferredResult = new Clipperz.Async.Deferred("User.getUserDetails.innerDeferred", {trace:false}); if (this._serverData == null) { innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'loadingUserDetails'); innerDeferredResult.addMethod(this.connection(), 'message', 'getUserDetails'); innerDeferredResult.addMethod(this, 'unpackServerData'); innerDeferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'loadedUserDetails'); } innerDeferredResult.addCallback(MochiKit.Base.bind(function () { return this._serverData; },this)); innerDeferredResult.callback(); return innerDeferredResult; }, this)); deferredResult.releaseLock(this.deferredLockForSection('serverData')); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'connectionVersion': function() { return this._connectionVersion; }, 'setConnectionVersion': function(aValue) { if (this._connectionVersion != aValue) { this.resetConnection(); } this._connectionVersion = aValue; }, //------------------------------------------------------------------------- 'connection': function() { if ((this._connection == null) && (this.connectionVersion() != null) ){ this._connection = new Clipperz.PM.Connection.communicationProtocol.versions[this.connectionVersion()]({ getCredentialsFunction: MochiKit.Base.method(this, 'getCredentials') }); } return this._connection; }, 'resetConnection': function(aValue) { if (this._connection != null) { this._connection.reset(); } this._connection = null; }, //========================================================================= 'getHeaderIndex': function (aKey) { return Clipperz.Async.callbacks("User.getHeaderIndex", [ MochiKit.Base.method(this, 'getServerData'), MochiKit.Base.itemgetter('header'), MochiKit.Base.itemgetter(aKey) ], {trace:false}) }, //========================================================================= 'getRecords': function () { return Clipperz.Async.callbacks("User.getRecords", [ MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'), MochiKit.Base.methodcaller('records'), MochiKit.Base.values ], {trace:false}); }, 'recordWithLabel': function (aLabel) { return Clipperz.Async.callbacks("User.recordWithLabel", [ MochiKit.Base.method(this, 'getRecords'), MochiKit.Base.partial(Clipperz.Async.deferredFilter, function (aRecord) { return Clipperz.Async.callbacks("User.recordWithLabel - check record label", [ MochiKit.Base.methodcaller('label'), MochiKit.Base.partial(MochiKit.Base.operator.eq, aLabel) ], {trace:false}, aRecord); }), function (someFilteredResults) { var result; switch (someFilteredResults.length) { case 0: result = null; break; case 1: result = someFilteredResults[0]; break; default: WTF = TODO; break; } return result; } ], {trace:false}); }, //------------------------------------------------------------------------- 'getRecord': function (aRecordReference) { return Clipperz.Async.callbacks("User.getRecord", [ MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'), MochiKit.Base.methodcaller('records'), MochiKit.Base.itemgetter(aRecordReference), Clipperz.Async.deferredIf("record != null", [ MochiKit.Base.operator.identity ], [ function () { throw "Record does not exists"} ]) ], {trace:false}); }, //------------------------------------------------------------------------- 'getRecordDetail': function (aRecordReference) { return this.connection().message('getRecordDetail', {reference: aRecordReference}); }, //------------------------------------------------------------------------- 'deleteRecord': function (aRecord) { return Clipperz.Async.callbacks("User.deleteRecord", [ MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'), MochiKit.Base.methodcaller('deleteRecord', aRecord) ], {trace:false}); }, //------------------------------------------------------------------------- 'createNewRecord': function () { return Clipperz.Async.callbacks("User.createNewRecord", [ MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'), MochiKit.Base.methodcaller('createNewRecord') ], {trace:false}); }, //========================================================================= 'getDirectLogins': function() { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.getDirectLogins", {trace:false}); deferredResult.addMethod(this, 'getRecords'); deferredResult.addCallback(MochiKit.Base.map, MochiKit.Base.compose(MochiKit.Base.values, MochiKit.Base.methodcaller('directLogins'))); deferredResult.addCallback(MochiKit.Base.flattenArray); deferredResult.callback(); return deferredResult; }, //========================================================================= 'getOneTimePasswords': function () { return Clipperz.Async.callbacks("User.getOneTimePasswords", [ MochiKit.Base.method(this, 'getHeaderIndex', 'oneTimePasswords'), MochiKit.Base.methodcaller('oneTimePasswords'), MochiKit.Base.values ], {trace:false}); }, //========================================================================= 'invokeMethodNamedOnHeader': function (aMethodName, aValue) { return Clipperz.Async.collectResults("User.invokeMethodNamedOnHeader [" + aMethodName + "]", { 'recordIndex': [ MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'), MochiKit.Base.methodcaller(aMethodName, aValue) ], 'preferences': [ MochiKit.Base.method(this, 'getHeaderIndex', 'preferences'), MochiKit.Base.methodcaller(aMethodName, aValue) ], 'oneTimePasswords': [ MochiKit.Base.method(this, 'getHeaderIndex', 'oneTimePasswords'), MochiKit.Base.methodcaller(aMethodName, aValue) ]//, // 'statistics': [ // MochiKit.Base.method(this, 'getStatistics'), // MochiKit.Base.methodcaller(aMethodName, aValue) // ] }, {trace:false})(); }, //------------------------------------------------------------------------- 'invokeMethodNamedOnRecords': function (aMethodName, aValue) { return Clipperz.Async.callbacks("User.invokeMethodNamedOnRecords[" + aMethodName + "]", [ MochiKit.Base.method(this, 'getRecords'), MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller(aMethodName, aValue)), Clipperz.Async.collectAll ], {trace:false}); }, //========================================================================= 'hasPendingChanges': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.hasPendingChanges", {trace:false}); deferredResult.collectResults({ 'header': [ MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'hasPendingChanges'), MochiKit.Base.values ], 'records': MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'hasPendingChanges') }); deferredResult.addCallback(Clipperz.Async.or); deferredResult.callback(); // recordsIndex = legacyHeader; // preferences = legacyHeader; // oneTimePasswords = legacyHeader; return deferredResult; }, //========================================================================= 'commitTransientState': function () { return Clipperz.Async.callbacks("User.commitTransientState", [ MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'commitTransientState'), MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'), MochiKit.Base.method(this, 'transientState'), // MochiKit.Base.itemgetter('lock'), // MochiKit.Base.method(this, 'setServerLockValue'), MochiKit.Base.method(this, 'resetTransientState', true) ], {trace:false}); }, //------------------------------------------------------------------------- 'revertChanges': function () { return Clipperz.Async.callbacks("User.revertChanges", [ MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'revertChanges'), MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'revertChanges'), MochiKit.Base.method(this, 'resetTransientState', false) ], {trace:false}); }, //========================================================================= 'deleteAllCleanTextData': function () { return Clipperz.Async.callbacks("User.deleteAllCleanTextData", [ MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'deleteAllCleanTextData'), MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'deleteAllCleanTextData'), MochiKit.Base.method(this.data(), 'removeAllData'), MochiKit.Base.method(this, 'resetTransientState', false) ], {trace:false}); }, //------------------------------------------------------------------------- 'hasAnyCleanTextData': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("User.hasAnyCleanTextData", {trace:false}); deferredResult.collectResults({ 'header': [ MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'hasAnyCleanTextData'), MochiKit.Base.values ], 'records': MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'hasAnyCleanTextData'), 'data': MochiKit.Base.bind(function () { return MochiKit.Async.succeed(! this.data().isEmpty()); }, this), 'transientState': MochiKit.Base.bind(function () { return MochiKit.Async.succeed(MochiKit.Base.keys(this.transientState()).length != 0); }, this) }); deferredResult.addCallback(Clipperz.Async.or); deferredResult.callback(); return deferredResult; }, //========================================================================= 'prepareRemoteDataWithKey': function (aKey /*, aCurrentKey*/) { var deferredResult; var result; result = {}; deferredResult = new Clipperz.Async.Deferred("User.prepareRemoteDataWithKey", {trace:false}); deferredResult.addMethod(this, 'invokeMethodNamedOnHeader', 'prepareRemoteDataWithKey', aKey /*, aCurrentKey*/); deferredResult.addCallback(MochiKit.Base.bind(function (aResult, someHeaderPackedData) { var header; header = {}; header['records'] = someHeaderPackedData['recordIndex']['records']; header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; // ??????????? header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; // ??????????? header['version'] = '0.1'; aResult['header'] = Clipperz.Base.serializeJSON(header); aResult['statistics'] = this._serverData['statistics']; // "someHeaderPackedData['statistics']['data']"; 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.callback(); return deferredResult; }, //========================================================================= 'saveChanges': function () { var deferredResult; var messageParameters; messageParameters = {}; deferredResult = new Clipperz.Async.Deferred("User.saveChangaes", {trace:false}); deferredResult.addMethod(this, 'getHeaderIndex', 'recordsIndex'); deferredResult.addCallback(MochiKit.Base.methodcaller('prepareRemoteDataForChangedRecords')); deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'records'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this, 'getPassphrase'); deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'user'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addCallback(MochiKit.Async.succeed, messageParameters); deferredResult.addMethod(this.connection(), 'message', 'saveChanges'); deferredResult.addCallback(MochiKit.Base.update, this.transientState()) deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this, 'commitTransientState'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userDataSuccessfullySaved'); deferredResult.addErrbackPass(MochiKit.Base.method(this, 'revertChanges')); deferredResult.addErrbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'failureWhileSavingUserData'); deferredResult.callback(); return deferredResult; }, //========================================================================= __syntaxFix__: "syntax fix" }); //----------------------------------------------------------------------------- Clipperz.PM.DataModel.User.registerNewAccount = function (anUsername, aPassphraseFunction) { var deferredResult; var user; user = new Clipperz.PM.DataModel.User({'username':anUsername, 'getPassphraseFunction':aPassphraseFunction}); deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.User.registerNewAccount", {trace:false}); deferredResult.addMethod(user, 'registerAsNewAccount'); deferredResult.addMethod(user, 'login'); deferredResult.addCallback(MochiKit.Async.succeed, user); deferredResult.callback(); return deferredResult; } //----------------------------------------------------------------------------- Clipperz.PM.DataModel.User.exception = { LoginFailed: new MochiKit.Base.NamedError("Clipperz.PM.DataModel.User.exception.LoginFailed"), CredentialUpgradeFailed: new MochiKit.Base.NamedError("Clipperz.PM.DataModel.User.exception.CredentialUpgradeFailed") }; //----------------------------------------------------------------------------- diff --git a/frontend/gamma/js/Clipperz/PM/Date.js b/frontend/gamma/js/Clipperz/PM/Date.js index 96a2700..a62857e 100644 --- a/frontend/gamma/js/Clipperz/PM/Date.js +++ b/frontend/gamma/js/Clipperz/PM/Date.js @@ -1,198 +1,196 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Date) == 'undefined') { Clipperz.PM.Date = {}; } Clipperz.PM.Date.VERSION = "0.1"; Clipperz.PM.Date.NAME = "Clipperz.PM.Date"; MochiKit.Base.update(Clipperz.PM.Date, { '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'locale': function() { return { 'amDesignation': Clipperz.PM.Strings.getValue('calendarStrings.amDesignation'), 'pmDesignation': Clipperz.PM.Strings.getValue('calendarStrings.pmDesignation'), 'days': Clipperz.PM.Strings.getValue('calendarStrings.days'), 'shortDays': Clipperz.PM.Strings.getValue('calendarStrings.shortDays'), 'shortMonths': Clipperz.PM.Strings.getValue('calendarStrings.shortMonths'), 'months': Clipperz.PM.Strings.getValue('calendarStrings.months') } }, //========================================================================= /* 'formatDateWithPHPLikeTemplate': function(aDate, aTemplate) { return Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(aDate, aTemplate, Clipperz.PM.Date.locale()); }, 'parseDateWithPHPLikeTemplate': function(aDate, aTemplate) { return Clipperz.Date.parseDateWithPHPTemplateAndLocale(aDate, aTemplate, Clipperz.PM.Date.locale()); }, //========================================================================= 'formatDateWithJavaLikeTemplate': function(aDate, aTemplate) { return Clipperz.Date.formatDateWithJavaLikeTemplateAndLocale(aDate, aTemplate, Clipperz.PM.Date.locale()); }, 'parseDateWithJavaLikeTemplate': function(aDate, aTemplate) { return Clipperz.Date.parseDateWithJavaLikeTemplateAndLocale(aDate, aTemplate, Clipperz.PM.Date.locale()); }, */ //========================================================================= 'formatWithTemplate': function (aTemplate, aDate) { return Clipperz.PM.Date.formatDateWithTemplate(aDate, aTemplate); }, 'formatDateWithTemplate': function(aDate, aTemplate) { var result; if (aDate == null) { result = "" } else { result = Clipperz.Date.formatDateWithPHPLikeTemplateAndLocale(aDate, aTemplate, Clipperz.PM.Date.locale()); }; return result; }, 'parseDateWithTemplate': function(aValue, aTemplate) { return Clipperz.Date.parseDateWithPHPTemplateAndLocale(aValue, aTemplate, Clipperz.PM.Date.locale()); }, //========================================================================= 'formatDateWithUTCFormat': function(aDate) { return Clipperz.Date.formatDateWithUTCFormatAndLocale(aDate, Clipperz.PM.Date.locale()); }, 'parseDateWithUTCFormat': function(aValue) { var result; if (aValue == null) { result = null; } else { result = Clipperz.Date.parseDateWithUTCFormatAndLocale(aValue, Clipperz.PM.Date.locale()); } return result; }, //========================================================================= 'getElapsedTimeDescription': function(aDate) { var result; result = "" if (aDate != null) { var now; var elapsedTime; var millisencondsInAMinute; var millisencondsInAnHour; var millisencondsInADay; var millisencondsInAWeek; var millisencondsInAMonth; now = new Date(); elapsedTime = now.getTime() - aDate.getTime(); millisencondsInAMinute = 60 * 1000; millisencondsInAnHour = millisencondsInAMinute * 60; millisencondsInADay = millisencondsInAnHour * 24; millisencondsInAWeek = millisencondsInADay * 7; millisencondsInAMonth = millisencondsInAWeek * 5; if ((elapsedTime / millisencondsInAMonth) > 1) { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.MORE_THAN_A_MONTH_AGO'); } else if ((elapsedTime / millisencondsInAWeek) > 1) { var elapsedWeeks; elapsedWeeks = Math.floor((elapsedTime / millisencondsInAWeek)); if (elapsedWeeks == 1) { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.MORE_THAN_A_WEEK_AGO'); } else { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.MORE_THAN_*_WEEKS_AGO').replace(/__elapsed__/, elapsedWeeks); } } else if ((elapsedTime / millisencondsInADay) > 1) { var elapsedDays; elapsedDays = Math.floor((elapsedTime / millisencondsInADay)); if (elapsedDays == 1) { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.YESTERDAY'); } else { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.*_DAYS_AGO').replace(/__elapsed__/, elapsedDays); } } else if ((elapsedTime / millisencondsInAnHour) > 1) { var elapsedHours; elapsedHours = Math.floor((elapsedTime / millisencondsInAnHour)); if (elapsedHours == 1) { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.ABOUT_AN_HOUR_AGO'); } else { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.*_HOURS_AGO').replace(/__elapsed__/, elapsedHours); } } else { var elapsed10Minutes; elapsed10Minutes = (Math.floor((elapsedTime / millisencondsInAMinute) / 10)) * 10; if (elapsed10Minutes == 0) { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.JUST_A_FEW_MINUTES_AGO'); } else { result = Clipperz.PM.Strings.getValue('elapsedTimeDescriptions.ABOUT_*_MINUTES_AGO').replace(/__elapsed__/, elapsed10Minutes+""); } } } return result; }, //------------------------------------------------------------------------- 'parse': function (aValue) { return Clipperz.PM.Date.parseDateWithUTCFormat(aValue); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/PIN.js b/frontend/gamma/js/Clipperz/PM/PIN.js index bc932b2..a32889a 100644 --- a/frontend/gamma/js/Clipperz/PM/PIN.js +++ b/frontend/gamma/js/Clipperz/PM/PIN.js @@ -1,134 +1,132 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ 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.js b/frontend/gamma/js/Clipperz/PM/Proxy.js index 190bffd..a5eaae6 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy.js @@ -1,169 +1,161 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } //============================================================================= Clipperz.PM.Proxy = function(args) { args = args || {}; this._shouldPayTolls = args.shouldPayTolls || false; this._tolls = { 'CONNECT': [], 'REGISTER': [], 'MESSAGE': [] }; if (args.isDefault === true) { Clipperz.PM.Proxy.defaultProxy = this; } return this; } Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.PM.Proxy"; }, //========================================================================= 'shouldPayTolls': function() { return this._shouldPayTolls; }, //------------------------------------------------------------------------- 'tolls': function() { return this._tolls; }, //------------------------------------------------------------------------- 'payToll': function(aRequestType, someParameters) { var deferredResult; -//console.log(">>> Proxy.payToll", aRequestType, someParameters); if (this.shouldPayTolls()) { deferredResult = new Clipperz.Async.Deferred("Proxy.payToll", {trace:false}); if (this.tolls()[aRequestType].length == 0) { deferredResult.addMethod(this, 'sendMessage', 'knock', {requestType:aRequestType}); deferredResult.addMethod(this, 'setTollCallback'); } deferredResult.addMethod(this.tolls()[aRequestType], 'pop'); deferredResult.addCallback(MochiKit.Base.methodcaller('deferredPay')); deferredResult.addCallback(function(aToll) { var result; result = { parameters: someParameters, toll: aToll } return result; }); deferredResult.callback(); } else { deferredResult = MochiKit.Async.succeed({parameters:someParameters}); } -//console.log("<<< Proxy.payToll"); return deferredResult; }, //------------------------------------------------------------------------- 'addToll': function(aToll) { -//console.log(">>> Proxy.addToll", aToll); this.tolls()[aToll.requestType()].push(aToll); -//console.log("<<< Proxy.addToll"); }, //========================================================================= 'setTollCallback': function(someParameters) { -//console.log(">>> Proxy.setTollCallback", someParameters); if (typeof(someParameters['toll']) != 'undefined') { -//console.log("added a new toll", someParameters['toll']); this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); } -//console.log("<<< Proxy.setTallCallback", someParameters['result']); + return someParameters['result']; }, //========================================================================= 'registration': function (someParameters) { return this.processMessage('registration', someParameters, 'REGISTER'); }, 'handshake': function (someParameters) { return this.processMessage('handshake', someParameters, 'CONNECT'); }, 'message': function (someParameters) { return this.processMessage('message', someParameters, 'MESSAGE'); }, 'logout': function (someParameters) { return this.processMessage('logout', someParameters, 'MESSAGE'); }, //========================================================================= 'processMessage': function (aFunctionName, someParameters, aRequestType) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false}); deferredResult.addMethod(this, 'payToll', aRequestType); deferredResult.addMethod(this, 'sendMessage', aFunctionName); deferredResult.addMethod(this, 'setTollCallback'); deferredResult.callback(someParameters); return deferredResult; }, //========================================================================= 'sendMessage': function () { throw Clipperz.Base.exception.AbstractMethod; }, //========================================================================= 'isReadOnly': function () { return false; }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js index 5b39b4a..7d10dd4 100755 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.JSON.js @@ -1,91 +1,89 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } //============================================================================= Clipperz.PM.Proxy.JSON = function(args) { Clipperz.PM.Proxy.JSON.superclass.constructor.call(this, args); this._url = args.url || Clipperz.Base.exception.raise('MandatoryParameter'); return this; } Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, { 'toString': function() { return "Clipperz.PM.Proxy.JSON"; }, //========================================================================= 'url': function () { return this._url; }, //========================================================================= 'sendMessage': function(aFunctionName, someParameters) { var deferredResult; var parameters; parameters = { method: aFunctionName, // version: someParameters['version'], // message: someParameters['message'], parameters: Clipperz.Base.serializeJSON(someParameters) }; deferredResult = new Clipperz.Async.Deferred("Proxy.JSON.sendMessage", {trace:false}); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestSent'); deferredResult.addCallback(MochiKit.Async.doXHR, this.url(), { method:'POST', sendContent:MochiKit.Base.queryString(parameters), headers:{"Content-Type":"application/x-www-form-urlencoded"} }); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'remoteRequestReceived'); // deferredResult.addCallback(MochiKit.Async.evalJSONRequest); deferredResult.addCallback(MochiKit.Base.itemgetter('responseText')); deferredResult.addCallback(Clipperz.Base.evalJSON); deferredResult.addCallback(function (someValues) { if (someValues['result'] == 'EXCEPTION') { throw someValues['message']; } return someValues; }) // return MochiKit.Base.evalJSON(req.responseText); deferredResult.callback(); return deferredResult; }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js index 01ba122..326022c 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js @@ -1,808 +1,788 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ try { if (typeof(Clipperz.PM.Proxy.Offline) == 'undefined') { throw ""; }} catch (e) { throw "Clipperz.PM.Proxy.Offline.DataStore depends on Clipperz.PM.Proxy.Offline!"; } //============================================================================= Clipperz.PM.Proxy.Offline.DataStore = function(args) { args = args || {}; this._data = args.data || (typeof(_clipperz_dump_data_) != 'undefined' ? _clipperz_dump_data_ : null); this._isReadOnly = (typeof(args.readOnly) == 'undefined' ? true : args.readOnly); this._shouldPayTolls = args.shouldPayTolls || false; this._tolls = {}; this._currentStaticConnection = null; return this; } Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { //------------------------------------------------------------------------- 'isReadOnly': function () { return this._isReadOnly; }, //------------------------------------------------------------------------- 'shouldPayTolls': function() { return this._shouldPayTolls; }, //------------------------------------------------------------------------- 'data': function () { return this._data; }, //------------------------------------------------------------------------- 'tolls': function () { return this._tolls; }, //========================================================================= 'resetData': function() { this._data = { 'users': { 'catchAllUser': { __masterkey_test_value__: 'masterkey', s: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00', v: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00' } } }; }, //------------------------------------------------------------------------- 'setupWithEncryptedData': function(someData) { this._data = Clipperz.Base.deepClone(someData); }, //------------------------------------------------------------------------- 'setupWithData': function(someData) { var deferredResult; var resultData; var i, c; //Clipperz.log(">>> Proxy.Test.setupWithData"); resultData = this._data; deferredResult = new Clipperz.Async.Deferred("Proxy.Test.seupWithData", {trace:false}); c = someData['users'].length; for (i=0; i<c; i++) { var newConnection; var recordConfiguration; deferredResult.addMethod(this, 'userSerializedEncryptedData', someData['users'][i]); deferredResult.addCallback(MochiKit.Base.bind(function(aUserSerializationContext) { -//console.log("SERIALIZED USER", aUserSerializationContext); resultData['users'][aUserSerializationContext['credentials']['C']] = { 's': aUserSerializationContext['credentials']['s'], 'v': aUserSerializationContext['credentials']['v'], 'version': aUserSerializationContext['data']['connectionVersion'], 'userDetails': aUserSerializationContext['encryptedData']['user']['header'], 'userDetailsVersion': aUserSerializationContext['encryptedData']['user']['version'], 'statistics': aUserSerializationContext['encryptedData']['user']['statistics'], 'lock': aUserSerializationContext['encryptedData']['user']['lock'], 'records': this.rearrangeRecordsData(aUserSerializationContext['encryptedData']['records']) } }, this)); } deferredResult.addCallback(MochiKit.Base.bind(function() { -//console.log("this._data", resultData); this._data = resultData; }, this)); deferredResult.callback(); //Clipperz.log("<<< Proxy.Test.setupWithData"); return deferredResult; }, //========================================================================= 'getTollForRequestType': function (aRequestType) { var result; var targetValue; var cost; targetValue = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2); switch (aRequestType) { case 'REGISTER': cost = 5; break; case 'CONNECT': cost = 5; break; case 'MESSAGE': cost = 2; break; } result = { requestType: aRequestType, targetValue: targetValue, cost: cost } if (this.shouldPayTolls()) { this.tolls()[targetValue] = result; } return result; }, //------------------------------------------------------------------------- 'checkToll': function (aFunctionName, someParameters) { if (this.shouldPayTolls()) { var localToll; var tollParameters; tollParameters = someParameters['toll']; localToll = this.tolls()[tollParameters['targetValue']]; if (localToll != null) { if (! Clipperz.PM.Toll.validate(tollParameters['targetValue'], tollParameters['toll'], localToll['cost'])) { throw "Toll value too low."; }; } else { throw "Missing toll"; } } }, //========================================================================= 'currentStaticConnection': function () { if (this._currentStaticConnection == null) { this._currentStaticConnection = {}; } return this._currentStaticConnection; }, //------------------------------------------------------------------------- 'getConnectionForRequest': function (aFunctionName, someParameters) { var result; if (this.shouldPayTolls()) { if ((typeof(someParameters['toll']) != 'undefined') && (typeof(someParameters['toll']['targetValue']) != 'undefined')) { result = this.tolls()[someParameters['toll']['targetValue']]['connection']; if (typeof(result) == 'undefined') { result = {}; } } else { result = {}; } } else { result = this.currentStaticConnection(); } return result; }, //------------------------------------------------------------------------- 'storeConnectionForRequestWithConnectionAndResponse': function (aFunctionName, someParameters, aConnection, aResponse) { if (this.shouldPayTolls()) { if ((typeof(aResponse['toll']) != 'undefined') && (typeof(aResponse['toll']['targetValue']) != 'undefined') && (typeof(this.tolls()[aResponse['toll']['targetValue']]) != 'undefined') ) { this.tolls()[aResponse['toll']['targetValue']]['connection'] = aConnection; } } }, //========================================================================= 'processMessage': function (aFunctionName, someParameters) { var result; var connection; connection = this.getConnectionForRequest(aFunctionName, someParameters); switch(aFunctionName) { case 'knock': result = this._knock(connection, someParameters); break; case 'registration': this.checkToll(aFunctionName, someParameters); result = this._registration(connection, someParameters.parameters); break; case 'handshake': this.checkToll(aFunctionName, someParameters); result = this._handshake(connection, someParameters.parameters); break; case 'message': this.checkToll(aFunctionName, someParameters); result = this._message(connection, someParameters.parameters); break; case 'logout': this._currentStaticConnection = null; result = this._logout(connection, someParameters.parameters); break; } this.storeConnectionForRequestWithConnectionAndResponse(aFunctionName, someParameters, connection, result); return MochiKit.Async.succeed(result); }, //========================================================================= '_knock': function(aConnection, someParameters) { var result; result = { toll: this.getTollForRequestType(someParameters['requestType']) } return result; }, //------------------------------------------------------------------------- '_registration': function(aConnection, someParameters) { if (this.isReadOnly() == false) { if (typeof(this.data()['users'][someParameters['credentials']['C']]) == 'undefined') { this.data()['users'][someParameters['credentials']['C']] = { 's': someParameters['credentials']['s'], 'v': someParameters['credentials']['v'], 'version': someParameters['credentials']['version'], 'lock': Clipperz.Crypto.Base.generateRandomSeed(), 'userDetails': someParameters['user']['header'], 'statistics': someParameters['user']['statistics'], 'userDetailsVersion': someParameters['user']['version'], 'records': {} } } else { throw "user already exists"; } } else { throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; } result = { result: { 'lock': this.data()['users'][someParameters['credentials']['C']]['lock'], 'result': 'done' }, toll: this.getTollForRequestType('CONNECT') } return result; }, //------------------------------------------------------------------------- '_handshake': function(aConnection, someParameters) { var result; var nextTollRequestType; result = {}; if (someParameters.message == "connect") { var userData; var randomBytes; var v; userData = this.data()['users'][someParameters.parameters.C]; if ((typeof(userData) != 'undefined') && (userData['version'] == someParameters.version)) { aConnection['userData'] = userData; aConnection['C'] = someParameters.parameters.C; } else { aConnection['userData'] = this.data()['users']['catchAllUser']; } randomBytes = Clipperz.Crypto.Base.generateRandomSeed(); aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16); v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); aConnection['B'] = v.add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())); aConnection['A'] = someParameters.parameters.A; result['s'] = aConnection['userData']['s']; result['B'] = aConnection['B'].asString(16); nextTollRequestType = 'CONNECT'; } else if (someParameters.message == "credentialCheck") { var v, u, S, A, K, M1; v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aConnection['B'].asString(10))).toHexString(), 16); A = new Clipperz.Crypto.BigInt(aConnection['A'], 16); S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()); K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(S.asString(10))).toHexString().slice(2); M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10) + K)).toHexString().slice(2); if (someParameters.parameters.M1 == M1) { var M2; M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + someParameters.parameters.M1 + K)).toHexString().slice(2); result['M2'] = M2; } else { throw new Error("Client checksum verification failed! Expected <" + M1 + ">, received <" + someParameters.parameters.M1 + ">.", "Error"); } nextTollRequestType = 'MESSAGE'; } else if (someParameters.message == "oneTimePassword") { var otpData; otpData = this.data()['onetimePasswords'][someParameters.parameters.oneTimePasswordKey]; try { if (typeof(otpData) != 'undefined') { if (otpData['status'] == 'ACTIVE') { if (otpData['key_checksum'] == someParameters.parameters.oneTimePasswordKeyChecksum) { result = { 'data': otpData['data'], 'version': otpData['version'] } otpData['status'] = 'REQUESTED'; } else { otpData['status'] = 'DISABLED'; throw "The requested One Time Password has been disabled, due to a wrong keyChecksum"; } } else { throw "The requested One Time Password was not active"; } } else { throw "The requested One Time Password has not been found" } } catch (exception) { result = { 'data': Clipperz.PM.Crypto.randomKey(), 'version': Clipperz.PM.Connection.communicationProtocol.currentVersion } } nextTollRequestType = 'CONNECT'; } else { - MochiKit.Logging.logError("Clipperz.PM.Proxy.Test.handshake - unhandled message: " + someParameters.message); + Clipperz.logError("Clipperz.PM.Proxy.Test.handshake - unhandled message: " + someParameters.message); } result = { result: result, toll: this.getTollForRequestType(nextTollRequestType) } return result; }, //------------------------------------------------------------------------- '_message': function(aConnection, someParameters) { var result; result = {}; //===================================================================== // // R E A D - O N L Y M e t h o d s // //===================================================================== if (someParameters.message == 'getUserDetails') { var recordsStats; var recordReference; recordsStats = {}; for (recordReference in aConnection['userData']['records']) { recordsStats[recordReference] = { 'updateDate': aConnection['userData']['records'][recordReference]['updateDate'] } } result['header'] = this.userDetails(aConnection); result['statistics'] = this.statistics(aConnection); result['maxNumberOfRecords'] = aConnection['userData']['maxNumberOfRecords']; result['version'] = aConnection['userData']['userDetailsVersion']; result['recordsStats'] = recordsStats; if (this.isReadOnly() == false) { var lock; if (typeof(aConnection['userData']['lock']) == 'undefined') { aConnection['userData']['lock'] = "<<LOCK>>"; } result['lock'] = aConnection['userData']['lock']; } //===================================================================== } else if (someParameters.message == 'getRecordDetail') { /* var recordData; var currentVersionData; recordData = this.userData()['records'][someParameters['parameters']['reference']]; result['reference'] = someParameters['parameters']['reference']; result['data'] = recordData['data']; result['version'] = recordData['version']; result['creationData'] = recordData['creationDate']; result['updateDate'] = recordData['updateDate']; result['accessDate'] = recordData['accessDate']; currentVersionData = recordData['versions'][recordData['currentVersion']]; result['currentVersion'] = {}; result['currentVersion']['reference'] = recordData['currentVersion']; result['currentVersion']['version'] = currentVersionData['version']; result['currentVersion']['header'] = currentVersionData['header']; result['currentVersion']['data'] = currentVersionData['data']; result['currentVersion']['creationData'] = currentVersionData['creationDate']; result['currentVersion']['updateDate'] = currentVersionData['updateDate']; result['currentVersion']['accessDate'] = currentVersionData['accessDate']; if (typeof(currentVersionData['previousVersion']) != 'undefined') { result['currentVersion']['previousVersionKey'] = currentVersionData['previousVersionKey']; result['currentVersion']['previousVersion'] = currentVersionData['previousVersion']; } */ MochiKit.Base.update(result, aConnection['userData']['records'][someParameters['parameters']['reference']]); result['reference'] = someParameters['parameters']['reference']; //===================================================================== // // R E A D - W R I T E M e t h o d s // //===================================================================== } else if (someParameters.message == 'upgradeUserCredentials') { if (this.isReadOnly() == false) { var parameters; var credentials; parameters = someParameters['parameters']; credentials = parameters['credentials']; if ((credentials['C'] == null) || (credentials['s'] == null) || (credentials['v'] == null) || (credentials['version'] != Clipperz.PM.Connection.communicationProtocol.currentVersion) ) { result = Clipperz.PM.DataModel.User.exception.CredentialUpgradeFailed; } else { var oldCValue; oldCValue = aConnection['C']; this.data()['users'][credentials['C']] = aConnection['userData']; aConnection['C'] = credentials['C']; aConnection['userData']['s'] = credentials['s']; aConnection['userData']['v'] = credentials['v']; aConnection['userData']['version'] = credentials['version']; aConnection['userData']['userDetails'] = parameters['user']['header']; aConnection['userData']['userDetailsVersion'] = parameters['user']['version']; aConnection['userData']['statistics'] = parameters['user']['statistics']; aConnection['userData']['lock'] = parameters['user']['lock']; delete this.data()['users'][oldCValue]; result = {result:"done", parameters:parameters}; } } else { throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; } //===================================================================== /* } else if (someParameters.message == 'updateData') { if (this.isReadOnly() == false) { var i, c; -//console.log("###==============================================================="); -//console.log("###>>>", Clipperz.Base.serializeJSON(someParameters)); -//console.log("###--- userData", Clipperz.Base.serializeJSON(this.userData())); if (this.userData()['lock'] != someParameters['parameters']['user']['lock']) { throw "the lock attribute is not processed correctly" } this.userData()['userDetails'] = someParameters['parameters']['user']['header']; this.userData()['statistics'] = someParameters['parameters']['user']['statistics']; this.userData()['userDetailsVersions'] = someParameters['parameters']['user']['version']; c = someParameters['parameters']['records'].length; for (i=0; i<c; i++) { var currentRecord; var currentRecordData; currentRecordData = someParameters['parameters']['records'][i]; currentRecord = this.userData()['records'][currentRecordData['record']['reference']]; if (currentRecord == null) { } currentRecord['data'] = currentRecordData['record']['data']; currentRecord['version'] = currentRecordData['record']['version']; currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference']; currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = { 'data': currentRecordData['currentRecordVersion']['data'], 'version': currentRecordData['currentRecordVersion']['version'], 'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'], 'previousVersionKey': currentRecordData['currentRecordVersion']['previousVersionKey'] } } this.userData()['lock'] = Clipperz.PM.Crypto.randomKey(); result['lock'] = this.userData()['lock']; result['result'] = 'done'; -//console.log("###<<< userData", Clipperz.Base.serializeJSON(this.userData())); } else { throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; } */ //===================================================================== } else if (someParameters.message == 'saveChanges') { if (this.isReadOnly() == false) { var i, c; -//console.log("###==============================================================="); -//console.log("###>>>", someParameters); -//console.log("###>>>", Clipperz.Base.serializeJSON(someParameters)); -//console.log("###--- userData", Clipperz.Base.serializeJSON(this.userData())); -//console.log("###==============================================================="); -//console.log("--- userData.lock ", this.userData()['lock']); -//console.log("--- parameters.lock", someParameters['parameters']['user']['lock']); if (aConnection['userData']['lock'] != someParameters['parameters']['user']['lock']) { throw "the lock attribute is not processed correctly" } aConnection['userData']['userDetails'] = someParameters['parameters']['user']['header']; aConnection['userData']['statistics'] = someParameters['parameters']['user']['statistics']; aConnection['userData']['userDetailsVersions'] = someParameters['parameters']['user']['version']; c = someParameters['parameters']['records']['updated'].length; for (i=0; i<c; i++) { var currentRecord; var currentRecordData; currentRecordData = someParameters['parameters']['records']['updated'][i]; currentRecord = aConnection['userData']['records'][currentRecordData['record']['reference']]; if ( (typeof(aConnection['userData']['records'][currentRecordData['record']['reference']]) == 'undefined') && (typeof(currentRecordData['currentRecordVersion']) == 'undefined') ) { -//console.log("######## SHIT HAPPENS"); throw "Record added without a recordVersion"; } if (currentRecord == null) { currentRecord = {}; currentRecord['versions'] = {}; currentRecord['creationDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); currentRecord['accessDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); aConnection['userData']['records'][currentRecordData['record']['reference']] = currentRecord; } currentRecord['data'] = currentRecordData['record']['data']; currentRecord['version'] = currentRecordData['record']['version']; currentRecord['updateDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date()); if (typeof(currentRecordData['currentRecordVersion']) != 'undefined') { currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference']; currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = { 'data': currentRecordData['currentRecordVersion']['data'], 'version': currentRecordData['currentRecordVersion']['version'], 'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'], 'previousVersionKey': currentRecordData['currentRecordVersion']['previousVersionKey'], 'creationDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), 'updateDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()), 'accessDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()) } } } c = someParameters['parameters']['records']['deleted'].length; for (i=0; i<c; i++) { var currentRecordReference; currentRecordReference = someParameters['parameters']['records']['deleted'][i]; -//console.log("DELETING records", currentRecordReference); delete aConnection['userData']['records'][currentRecordReference]; } aConnection['userData']['lock'] = Clipperz.PM.Crypto.randomKey(); result['lock'] = aConnection['userData']['lock']; result['result'] = 'done'; -//console.log("###<<< userData", Clipperz.Base.serializeJSON(this.userData())); } else { throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly; } //===================================================================== // // U N H A N D L E D M e t h o d // //===================================================================== } else { - MochiKit.Logging.logError("Clipperz.PM.Proxy.Test.message - unhandled message: " + someParameters.message); + Clipperz.logError("Clipperz.PM.Proxy.Test.message - unhandled message: " + someParameters.message); } result = { result: result, toll: this.getTollForRequestType('MESSAGE') } // return MochiKit.Async.succeed(result); return result; }, //------------------------------------------------------------------------- '_logout': function(someParameters) { // return MochiKit.Async.succeed({result: 'done'}); return {result: 'done'}; }, //========================================================================= //######################################################################### 'isTestData': function(aConnection) { return (typeof(aConnection['userData']['__masterkey_test_value__']) != 'undefined'); }, 'userDetails': function(aConnection) { var result; if (this.isTestData(aConnection)) { var serializedHeader; var version; -//MochiKit.Logging.logDebug("### test data"); +//Clipperz.logDebug("### test data"); version = aConnection['userData']['userDetailsVersion']; serializedHeader = Clipperz.Base.serializeJSON(aConnection['userData']['userDetails']); result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedHeader); } else { -//MochiKit.Logging.logDebug("### NOT test data"); +//Clipperz.logDebug("### NOT test data"); result = aConnection['userData']['userDetails']; } return result; }, 'statistics': function(aConnection) { var result; if (aConnection['userData']['statistics'] != null) { if (this.isTestData(aConnection)) { var serializedStatistics; var version; version = aConnection['userData']['userDetailsVersion']; serializedStatistics = Clipperz.Base.serializeJSON(aConnection['userData']['statistics']); result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedStatistics); } else { result = aConnection['userData']['statistics']; } } else { result = null; } return result; }, /* 'userSerializedEncryptedData': function(someData) { var deferredResult; var deferredContext; deferredContext = { 'data': someData }; deferredResult = new Clipperz.Async.Deferred('Proxy.Test.serializeUserEncryptedData', {trace:false}); deferredResult.addCallback(MochiKit.Base.bind(function(aDeferredContext) { aDeferredContext['user'] = this.createUserUsingConfigurationData(aDeferredContext['data']); return aDeferredContext; }, this)); deferredResult.addCallback(function(aDeferredContext) { // return aDeferredContext['user'].encryptedDataUsingVersion(aDeferredContext['data']['version']); return aDeferredContext['user'].serializedDataUsingVersion(MochiKit.Base.values(aDeferredContext['user'].records()), aDeferredContext['data']['version']); }); deferredResult.addCallback(function(aUserEncryptedData) { deferredContext['encryptedData'] = aUserEncryptedData; return deferredContext; }); deferredResult.addCallback(function(aDeferredContext) { var connection; connection = new Clipperz.PM.Connection.communicationProtocol.versions[aDeferredContext['data']['connectionVersion']]() aDeferredContext['credentials'] = connection.serverSideUserCredentials(aDeferredContext['user'].username(),aDeferredContext['user'].passphrase()); return aDeferredContext; }); // deferredResult.addCallback(function(aDeferredContext) { -//console.log("#-#-#-#-#", aDeferredContext); // return aDeferredContext['user'].serializedDataUsingVersion(MochiKit.Base.values(aDeferredContext['user'].records()), aDeferredContext['data']['version']); // }, deferredContext); // deferredResult.addCallback(function(aUserSerializedData) { -//console.log("USER SERIALIZED DATA", aUserSerializedData); // }); // // deferredResult.addCallback(MochiKit.Async.succeed, deferredContext); deferredResult.callback(deferredContext); return deferredResult; }, 'createUserUsingConfigurationData': function(someData) { var result; var user; var recordLabel; user = new Clipperz.PM.DataModel.User(); user.initForTests(); user.setUsername(someData['username']); user.setPassphrase(someData['passphrase']); for (recordLabel in someData['records']) { var recordData; var record; var i, c; recordData = someData['records'][recordLabel]; record = new Clipperz.PM.DataModel.Record({user:user, label:recordLabel}); record.setNotes(recordData['notes']); c = recordData['fields'].length; for (i=0; i<c; i++) { var recordField; recordField = new Clipperz.PM.DataModel.RecordField(); recordField.setLabel(recordData['fields'][i]['name']); recordField.setValue(recordData['fields'][i]['value']); recordField.setType(recordData['fields'][i]['type']); record.addField(recordField); } user.addRecord(record, true); } result = user; return result; }, */ //========================================================================= __syntaxFix__: "syntax fix" }); Clipperz.PM.Proxy.Offline.DataStore['exception'] = { 'ReadOnly': new MochiKit.Base.NamedError("Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly") };
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js index a86ac4f..5764bda 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.js @@ -1,64 +1,62 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } //============================================================================= Clipperz.PM.Proxy.Offline = 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.Offline, Clipperz.PM.Proxy, { 'toString': function () { return "Clipperz.PM.Proxy.Offline"; }, //------------------------------------------------------------------------- 'dataStore': function () { return this._dataStore; }, //------------------------------------------------------------------------- 'sendMessage': function(aFunctionName, someParameters) { return this.dataStore().processMessage(aFunctionName, someParameters); }, //------------------------------------------------------------------------- __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 index 803c590..f628975 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.OfflineCache.js @@ -1,65 +1,63 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ 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/Proxy/Proxy.Test.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js index d554c6a..d459726 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js @@ -1,164 +1,156 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Proxy) == 'undefined') { Clipperz.PM.Proxy = {}; } //============================================================================= Clipperz.PM.Proxy.Test = function(args) { Clipperz.PM.Proxy.Test.superclass.constructor.call(this, args); args = args || {}; this._expectedRequests = (args.shouldCheckExpectedRequests === true) ? [] : null; this._isExpectingRequests = true; this._unexpectedRequests = []; this.dataStore().resetData(); return this; } Clipperz.Base.extend(Clipperz.PM.Proxy.Test, Clipperz.PM.Proxy.Offline, { 'toString': function() { return "Clipperz.PM.Proxy.Test"; }, //========================================================================= 'expectedRequests': function () { return this._expectedRequests; }, //------------------------------------------------------------------------- 'shouldCheckExpectedRequests': function () { return (this._expectedRequests != null); }, 'setShouldCheckExpectedRequests': function(aValue) { if (aValue) { this._expectedRequests = aValue; } else { this._expectedRequests = null; } }, //------------------------------------------------------------------------- 'shouldNotReceiveAnyFurtherRequest': function () { this._isExpectingRequests = false; }, 'mayReceiveMoreRequests': function () { this._isExpectingRequests = true; this.resetUnexpectedRequests(); }, 'isExpectingRequests': function () { return this._isExpectingRequests; }, //------------------------------------------------------------------------- 'unexpectedRequests': function () { return this._unexpectedRequests; }, 'resetUnexpectedRequests': function () { this._unexpectedRequests = []; }, //------------------------------------------------------------------------- 'testExpectedRequestParameters': function (aPath, anActualRequest, anExpectedRequest) { var aKey; -//console.log(">>> Proxy.testExpectedRequestParameters [" + aPath + "]", anActualRequest, anExpectedRequest); for (aKey in anExpectedRequest) { if (typeof(anActualRequest[aKey]) == 'undefined') { throw "the expected paramter [" + aKey + "] is missing from the actual request"; } if (typeof(anExpectedRequest[aKey]) == 'object') { this.testExpectedRequestParameters(aPath + "." + aKey, anActualRequest[aKey], anExpectedRequest[aKey]) } else { if (! anExpectedRequest[aKey](anActualRequest[aKey])) { throw "wrong value for paramter [" + aKey + "]; got '" + anActualRequest[aKey] + "'"; } } } -//console.log("<<< Proxy.testExpectedRequestParameters"); }, //------------------------------------------------------------------------- 'checkRequest': function(aFunctionName, someParameters) { if (this.shouldCheckExpectedRequests()) { var expectedRequest; -//console.log(">>> Proxy.Test.checkRequest - " + aFunctionName, someParameters); expectedRequest = this.expectedRequests().pop(); -//console.log("--- Proxy.Test.checkRequest - expectedRequest", expectedRequest); if (expectedRequest == null) { throw "Proxy.Test.sentMessage: no expected result specified. Got request '" + aFunctionName + "': " + someParameters; } try { if (aFunctionName != expectedRequest.functionName) { throw "wrong function name. Got '" + aFunctionName + "', expected '" + expectedRequest.request.functionName + "'"; } this.testExpectedRequestParameters("parameters", someParameters, expectedRequest.parameters); } catch(exception) { -//console.log("EXCEPTION: Proxy.Test.sentMessage[" + expectedRequest.name + "]", exception) throw "Proxy.Test.sentMessage[" + expectedRequest.name + "]: " + exception; } } -//console.log("<<< Proxy.Test.checkRequest"); }, //========================================================================= 'sendMessage': function(aFunctionName, someParameters) { var result; if (this.isExpectingRequests() == false) { // throw Clipperz.PM.Connection.exception.UnexpectedRequest; Clipperz.log("UNEXPECTED REQUEST " + aFunctionName /* + ": " + Clipperz.Base.serializeJSON(someParameters) */); this.unexpectedRequests().push({'functionName':aFunctionName, 'someParameters': someParameters}); }; this.checkRequest(aFunctionName, someParameters); result = Clipperz.PM.Proxy.Test.superclass.sendMessage.call(this, aFunctionName, someParameters); return result; }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/Strings.js b/frontend/gamma/js/Clipperz/PM/Strings.js index a051365..7e855ff 100644 --- a/frontend/gamma/js/Clipperz/PM/Strings.js +++ b/frontend/gamma/js/Clipperz/PM/Strings.js @@ -1,292 +1,285 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Strings) == 'undefined') { Clipperz.PM.Strings = {}; } if (typeof(Clipperz.PM.Strings.Languages) == 'undefined') { Clipperz.PM.Strings.Languages = {}; } //----------------------------------------------------------------------------- /* Clipperz.PM.Strings.standardStrings = { 'loginPanelSwitchLanguageSelectOptions': [ / * {tag:'option', html:"Arabic (Oman) (العربية)", value:'ar-OM', disabled:true}, {tag:'option', html:"Arabic (Syria) (العربية)", value:'ar-SY', disabled:true}, {tag:'option', html:"Bahasa Indonesia", value:'id-ID', disabled:true}, {tag:'option', html:"Bulgarian (Български)", value:'bg-BG', disabled:true}, {tag:'option', html:"Català", value:'ca-ES', disabled:true}, {tag:'option', html:"Chinese (Simplified) (简体中文)", value:'zh-CN', disabled:true}, {tag:'option', html:"Chinese (Traditional) (正體中文)", value:'zh-TW', disabled:true}, {tag:'option', html:"Czech (Česky)", value:'cs-CZ', disabled:true}, {tag:'option', html:"Dansk", value:'da-DK', disabled:true}, {tag:'option', html:"Deutsch", value:'de-DE'/ *, disabled:true* /}, {tag:'option', html:"English (American)", value:'en-US'/ *, disabled:true* /}, {tag:'option', html:"English (British)", value:'en-GB'/ *, disabled:true* /}, {tag:'option', html:"English (Canadian)", value:'en-CA'/ *, disabled:true* /}, {tag:'option', html:"Español", value:'es-ES', disabled:true}, {tag:'option', html:"Eesti", value:'et-EE', disabled:true}, {tag:'option', html:"Français", value:'fr-FR', disabled:true}, {tag:'option', html:"Galego", value:'gl-ES', disabled:true}, {tag:'option', html:"Greek (Ελληνικά)", value:'el-GR', disabled:true}, {tag:'option', html:"Íslenska", value:'is-IS', disabled:true}, {tag:'option', html:"Italiano", value:'it-IT'/ *, disabled:true* /}, {tag:'option', html:"Japanese (日本語)", value:'ja-JP', disabled:true}, {tag:'option', html:"Korean (한국어)", value:'ko-KR', disabled:true}, {tag:'option', html:"Latviešu", value:'lv-LV', disabled:true}, {tag:'option', html:"Lietuvių", value:'lt-LT', disabled:true}, {tag:'option', html:"Macedonian (Македонски)", value:'mk-MK', disabled:true}, {tag:'option', html:"Magyar", value:'hu-HU', disabled:true}, {tag:'option', html:"Nederlands", value:'nl-NL', disabled:true}, {tag:'option', html:"Norsk bokmål", value:'nb-NO', disabled:true}, {tag:'option', html:"Norsk nynorsk", value:'nn-NO', disabled:true}, {tag:'option', html:"Persian (Western) (فارسى)", value:'fa-IR', disabled:true}, {tag:'option', html:"Polski", value:'pl-PL', disabled:true}, {tag:'option', html:"Português", value:'pt-PT'/ *, disabled:true* /}, {tag:'option', html:"Português Brasileiro", value:'pt-BR'/ *, disabled:true* /}, {tag:'option', html:"Românä", value:'ro-RO', disabled:true}, {tag:'option', html:"Russian (Русский)", value:'ru-RU', disabled:true}, {tag:'option', html:"Slovak (Slovenčina)", value:'sk-SK', disabled:true}, {tag:'option', html:"Slovenian (Slovenščina)", value:'sl-SI', disabled:true}, {tag:'option', html:"Suomi", value:'fi-FI', disabled:true}, {tag:'option', html:"Svenska", value:'sv-SE', disabled:true}, {tag:'option', html:"Thai (ไทย)", value:'th-TH', disabled:true}, {tag:'option', html:"Türkçe", value:'tr-TR', disabled:true}, {tag:'option', html:"Ukrainian (Українська)", value:'uk-UA', disabled:true} * / {tag:'option', html:"Arabic (العربية)", value:"ar", disabled:true, cls:'disabledOption'}, // {tag:'option', html:"Chinese (中文)", value:"zh", disabled:true}, {tag:'option', html:"Chinese (Simplified) (简体中文)", value:'zh-CN'}, {tag:'option', html:"Dutch (Nederlands)", value:"nl-NL", disabled:true, cls:'disabledOption'}, {tag:'option', html:"English", value:"en-US"}, {tag:'option', html:"French (Français)", value:"fr-FR"}, {tag:'option', html:"German (Deutsch)", value:"de-DE", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Greek (Ελληνικά)", value:"el-GR", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Hebrew (עברית)", value:"he-IL", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Italian (Italiano)", value:"it-IT"}, {tag:'option', html:"Japanese (日本語)", value:"ja-JP"}, {tag:'option', html:"Korean (한국어)", value:"ko-KR", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Norwegian (Norsk)", value:"no", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Persian (فارسی)", value:"fa-IR", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Polish (Polski)", value:"pl-PL", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Portuguese (Português)", value:"pt-BR"}, {tag:'option', html:"Russian (Русский)", value:"ru-RU", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Spanish (Español)", value:"es-ES"}, {tag:'option', html:"Swedish (Svenska)", value:"sv-SE", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Turkish (Türkçe)", value:"tr-TR", disabled:true, cls:'disabledOption'}, {tag:'option', html:"Vietnamese (Tiếng Việt)", value:"vi-VN", disabled:true, cls:'disabledOption'} ] } */ Clipperz.PM.Strings.GeneralSettings = { 'defaults': { // 'loginFormAarghThatsBadUrl': "http://www.clipperz.com/support/faq/account_faq", // 'loginFormVerifyTheCodeUrl': "http://www.clipperz.com/learn_more/reviewing_the_code", // 'donateHeaderLinkUrl': "http://www.clipperz.com/donations", // 'creditsHeaderLinkUrl': "http://www.clipperz.com/credits", // 'feedbackHeaderLinkUrl': "http://www.clipperz.com/contact", // 'helpHeaderLinkUrl': "http://www.clipperz.com/support/user_guide", // 'forumHeaderLinkUrl': "http://www.clipperz.com/forum", // 'httpAuthBookmarkletConfiguration': {tag:'textarea', id:'httpAuthDefaultConfiguration', html:"" + // "{ \"page\":{\"title\":\"HTTP authentication\"}," + "\n" + // " \"form\":{\"attributes\": {" + "\n" + // " \"action\":\"\"," + "\n" + // " \"type\":\"http_auth\"" + "\n" + // " }, \"inputs\": [" + "\n" + // " {\"type\":\"text\",\"name\":\"url\",\"value\":\"\"}," + "\n" + // " {\"type\":\"text\",\"name\":\"username\",\"value\":\"\"}," + "\n" + // " {\"type\":\"password\",\"name\":\"password\",\"value\":\"\"}" + "\n" + // " ]}, \"version\":\"0.2.3\"}" // }, 'directLoginJumpPageUrl': "", 'defaultFaviconUrl': "data:application/octet-stream;charset=utf-8;base64,AAABAAEAFxcAAAEAGAD8BgAAFgAAACgAAAAXAAAALgAAAAEAGAAAAAAAAAAAABIXAAASFwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////9zAC////////////////////////////////////////////////////////////////////////////////////////////9pAG////////////////////////////////////////////////////////////////////////////////////////////9rAC////////////////////////////////////////////////////////////////////////////////////////////9yAHP////////////////////////IyMizs7O6urrq6ur////////////Ozs6zs7Ozs7Pq6ur///////////////////////8AAAD////////////////////V1dWXl5eXl5eXl5elpaX4+Pj////Ozs6Xl5eXl5eXl5eenp7///////////////////////8AAAD////////////////////Ozs6Xl5eXl5eXl5eXl5fBwcHq6uqenp6Xl5eXl5eXl5eXl5f///////////////////////8AAAD////////////////////j4+OXl5eXl5eXl5eXl5eXl5elpaWXl5eXl5eXl5eXl5ezs7P///////////////////////8AAAD////////////////////////IyMiXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eenp7x8fH////////////////////////////////////////////////////4+PilpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5fOzs7////////////////////////////////////////////////////////q6uq6urqXl5eXl5eXl5eXl5eXl5eXl5eenp7V1dX4+Pj///////////////////////8AAAD////////////4+PjOzs6lpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5e6urrj4+P///////////////8AAAD////////////BwcGXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fx8fH///////////8AAAD///////////+zs7OXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fj4+P///////////8AAAD////////////IyMiXl5eXl5eXl5eXl5e6urqXl5eXl5eXl5eXl5esrKylpaWXl5eXl5eXl5eenp7x8fH///////////8AAAD////////////////Ozs7Ozs7V1dX4+Pj///+Xl5eXl5eXl5eXl5fOzs7////q6urOzs7Ozs7q6ur///////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD////////////////////////////////////IyMiXl5eXl5eenp7x8fH///////////////////////////////////8AAAD////////////////////////////////////////j4+Pj4+Px8fH///////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAo=", 'defaultFaviconUrl_IE': "https://www.clipperz.com/images/icons/misc/favicon.ico", // 'icons_baseUrl': "https://www.clipperz.com/images/icons", // 'passwordGeneratorLowercaseCharset': "abcdefghijklmnopqrstuvwxyz", // 'passwordGeneratorUppercaseCharset': "ABCDEFGHIJKLMNOPQRSTUVWXYZ", // 'passwordGeneratorNumberCharset': "0123456789", // 'passwordGeneratorSymbolCharset': "!@#$%^&*+?[]{}/|\\<>,.;:~=-_", // 'passwordGenerator': { // 'lowercaseCharset': "abcdefghijklmnopqrstuvwxyz", // 'uppercaseCharset': "ABCDEFGHIJKLMNOPQRSTUVWXYZ", // 'numberCharset': "0123456789", // 'symbolCharset': "!@#$%^&*+?[]{}/|\\<>,.;:~=-_", // }, '_': "" } } Clipperz.PM.Strings.defaultLanguages = { 'default': "en-us", // 'de': "de-de", // 'el': "el-gr", // 'he': "he-il", // 'ru': "ru-ru", 'fr': "fr-fr", 'es': "es-es", 'zh': "zh-cn", 'ja': "ja-jp", 'pt': "pt-br", 'it': "it-it", 'en': "en-us" } Clipperz.PM.Strings.inputTypeToRecordFieldType = { 'text': 'TXT', 'password': 'PWD', 'checkbox': 'CHECK', 'radio': 'RADIO', 'select': 'SELECT' }; //----------------------------------------------------------------------------- Clipperz.PM.Strings.translateBookmarklet = function (aBookmarkletString) { var result; result = aBookmarkletString; result = result.replace(/@BOOKMARKLET_NO_EXCEPTION_MESSAGE@/, Clipperz.PM.Strings.getValue('bookmarkletCopy.noExceptionMessage')); result = result.replace(/@BOOKMARKLET_EXCEPTION_MESSAGE@/, Clipperz.PM.Strings.getValue('bookmarkletCopy.exceptionMessage')); result = result.replace(/@BOOKMARKLET_COPY@/, Clipperz.PM.Strings.getValue('bookmarkletCopy.copy')); result = result.replace(/@BOOKMARKLET_SUCCESSFUL_MESSAGE@/, Clipperz.PM.Strings.getValue('bookmarkletCopy.successfulMessage')); result = result.replace(/@BOOKMARKLET_FAIL_MESSAGE@/, Clipperz.PM.Strings.getValue('bookmarkletCopy.failMessage')); return result; } //----------------------------------------------------------------------------- Clipperz.PM.Strings.Languages.setSelectedLanguage = function(aLanguage) { var language; var selectedLanguage; language = (aLanguage || Clipperz.PM.Strings.preferredLanguage || 'default').toLowerCase(); if (typeof(Clipperz.PM.Strings.defaultLanguages[language]) != 'undefined') { language = Clipperz.PM.Strings.defaultLanguages[language]; } if (typeof(Clipperz.PM.Strings.Languages[language]) != 'undefined') { selectedLanguage = language; } else if (typeof(Clipperz.PM.Strings.defaultLanguages[language.substr(0,2)]) != 'undefined') { selectedLanguage = Clipperz.PM.Strings.defaultLanguages[language.substr(0,2)]; } else { selectedLanguage = Clipperz.PM.Strings.defaultLanguages['default']; } if (selectedLanguage != Clipperz.PM.Strings.selectedLanguage) { var translations; Clipperz.PM.Strings.selectedLanguage = selectedLanguage; translations = {}; // MochiKit.Base.update(translations, Clipperz.PM.Strings.standardStrings) MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages['defaults']); MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings['defaults']); MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages[Clipperz.PM.Strings.defaultLanguages['default']]); MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings[Clipperz.PM.Strings.defaultLanguages['default']]); MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.Languages[selectedLanguage]); MochiKit.Base.updatetree(translations, Clipperz.PM.Strings.GeneralSettings[selectedLanguage]); Clipperz.PM.Strings.stringsObjectStore = new Clipperz.KeyValueObjectStore(/*{'name':'String.stringsObjectStore [1]'}*/); Clipperz.PM.Strings.stringsObjectStore.initWithValues(translations); if (typeof(bookmarklet) != 'undefined') { Clipperz.PM.Strings.stringsObjectStore.setValue('bookmarklet', Clipperz.PM.Strings.translateBookmarklet(bookmarklet)); } MochiKit.Signal.signal(Clipperz.PM.Strings.Languages, 'switchLanguage', selectedLanguage); } } //----------------------------------------------------------------------------- Clipperz.PM.Strings.getValue = function (aKeyPath, someKeyValues) { var result; result = Clipperz.PM.Strings.stringsObjectStore.getValue(aKeyPath); -//try { if (typeof(result) == 'string') { if (typeof (someKeyValues) != 'undefined') { var key; for (key in someKeyValues) { result = result.replace( new RegExp(key), someKeyValues[key]); - // result.replace(, ''); } } result = result.replace(new RegExp('\n'), '<br>'); } -//} catch (exception) { -// console.log("####", result, aKeyPath, someKeyValues, exception); -//} return result; } Clipperz.PM.Strings.errorDescriptionForException = function (anException) { var result; result = Clipperz.PM.Strings.getValue('exceptionsMessages' + '.' + anException.name); if (result == null) { result = anException.message; } return result; }, //----------------------------------------------------------------------------- Clipperz.PM.Strings.Languages.initSetup = function() { var language; var languageParser; language = navigator.language || navigator.userLanguage; // en, en-US, .... "de", "nb-no" languageParser = new RegExp("language=([a-z]{2}(?:\-[a-z]{2})?)(\&|$)", "i"); if (languageParser.test(window.location.search)) { language = RegExp.$1; } Clipperz.PM.Strings.preferredLanguage = language.toLowerCase(); Clipperz.PM.Strings.Languages.setSelectedLanguage(Clipperz.PM.Strings.preferredLanguage); } //----------------------------------------------------------------------------- diff --git a/frontend/gamma/js/Clipperz/PM/Strings/MessagePanelConfigurations.js b/frontend/gamma/js/Clipperz/PM/Strings/MessagePanelConfigurations.js index 7f6c52f..7565d2d 100644 --- a/frontend/gamma/js/Clipperz/PM/Strings/MessagePanelConfigurations.js +++ b/frontend/gamma/js/Clipperz/PM/Strings/MessagePanelConfigurations.js @@ -1,386 +1,384 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Strings) == 'undefined') { Clipperz.PM.Strings = {}; } Clipperz.PM.Strings.messagePanelConfigurations = { //------------------------------------------------------------------------- // // Registration - connection // 'registration_verify': function() { return { 'title': null, 'text': Clipperz.PM.Strings['connectionRegistrationSendingRequestMessageText'] } }, 'registration_sendingCredentials': function() { return { 'title': null, 'text': Clipperz.PM.Strings['connectionRegistrationSendingCredentialsMessageText'] } }, //------------------------------------------------------------------------- // // One Time Password login message panel // 'OTP_login_start': function() { return { 'title': Clipperz.PM.Strings['OTPloginMessagePanelInitialTitle'], 'text': Clipperz.PM.Strings['OTPloginMessagePanelInitialText'], 'steps': '+3', 'buttons': {} } }, 'OTP_login_loadingOTP': function() { return { 'title': Clipperz.PM.Strings['OTPloginMessagePanelLoadingTitle'], 'text': Clipperz.PM.Strings['OTPloginMessagePanelLoadingText'] } }, 'OTP_login_extractingPassphrase': function() { return { 'title': Clipperz.PM.Strings['OTPloginMessagePanelProcessingTitle'], 'text': Clipperz.PM.Strings['OTPloginMessagePanelProcessingText'] } }, //------------------------------------------------------------------------- // // Login message panel // 'login_start': function() { return { 'title': Clipperz.PM.Strings['loginMessagePanelInitialTitle'], 'text': Clipperz.PM.Strings['loginMessagePanelInitialText'], 'steps': '+7', 'buttons': { 'ok': Clipperz.PM.Strings['loginMessagePanelInitialButtonLabel'] } } }, 'login_connected': function() { return { 'title': Clipperz.PM.Strings['loginMessagePanelConnectedTitle'], 'text': Clipperz.PM.Strings['loginMessagePanelConnectedText'], 'buttons': {} } }, 'login_failed': function() { return { 'title': Clipperz.PM.Strings['loginMessagePanelFailureTitle'], 'text': Clipperz.PM.Strings['loginMessagePanelFailureText'], 'button': Clipperz.PM.Strings['loginMessagePanelFailureButtonLabel'] } }, //------------------------------------------------------------------------- // // Login message panel - connection // 'connection_sendingCredentials': function() { return { 'title': Clipperz.PM.Strings['connectionLoginSendingCredentialsMessageTitle'], 'text': Clipperz.PM.Strings['connectionLoginSendingCredentialsMessageText'] } }, 'connection_credentialVerification': function() { return { 'title': Clipperz.PM.Strings['connectionLoginCredentialsVerificationMessageTitle'], 'text': Clipperz.PM.Strings['connectionLoginCredentialsVerificationMessageText'] } }, 'connection_loggedIn': function() { return { 'title': Clipperz.PM.Strings['connectionLoginDoneMessageTitle'], 'text': Clipperz.PM.Strings['connectionLoginDoneMessageText'] } }, //------------------------------------------------------------------------- // // Login message panel - user // 'connection_upgrading': function() { return { 'title': Clipperz.PM.Strings['userLoginPanelUpgradingUserCredentialsMessageTitle'], 'text': Clipperz.PM.Strings['userLoginPanelUpgradingUserCredentialsMessageText'], 'steps': '+1' } }, 'connection_done': function() { return { 'title': Clipperz.PM.Strings['userLoginPanelConnectedMessageTitle'], 'text': Clipperz.PM.Strings['userLoginPanelConnectedMessageText'] } }, 'connection_tryOlderSchema': function() { return { 'title': Clipperz.PM.Strings['userLoginPanelTryingAnOlderConnectionSchemaMessageTitle'], 'text': Clipperz.PM.Strings['userLoginPanelTryingAnOlderConnectionSchemaMessageText'], 'steps': '+4' } }, 'connection_loadingUserData': function() { return { 'title': Clipperz.PM.Strings['userLoginPanelLoadingUserDataMessageTitle'], 'text': Clipperz.PM.Strings['userLoginPanelLoadingUserDataMessageText'] } }, 'connection_decryptingUserData': function() { return { 'title': Clipperz.PM.Strings['userLoginPanelDecryptingUserDataMessageTitle'], 'text': Clipperz.PM.Strings['userLoginPanelDecryptingUserDataMessageText'], 'steps': '+1' } }, 'connection_decryptingUserStatistics': function() { return { 'title': Clipperz.PM.Strings['userLoginPanelDecryptingUserStatisticsMessageTitle'], 'text': Clipperz.PM.Strings['userLoginPanelDecryptingUserStatisticsMessageText'] } }, 'collectingEntropy': function() { return { 'text': Clipperz.PM.Strings['panelCollectingEntryopyMessageText'], 'steps': '+1' } }, //------------------------------------------------------------------------- // // Cards block - delete card panel // 'deleteRecord_collectData': function() { return { 'title': Clipperz.PM.Strings['deleteRecordPanelCollectRecordDataMessageTitle'], 'text': Clipperz.PM.Strings['deleteRecordPanelCollectRecordDataMessageText'] } }, 'deleteRecord_encryptData': function() { return { 'title': Clipperz.PM.Strings['deleteRecordPanelEncryptUserDataMessageTitle'], 'text': Clipperz.PM.Strings['deleteRecordPanelEncryptUserDataMessageText'] } }, 'deleteRecord_sendingData': function() { return { 'title': Clipperz.PM.Strings['deleteRecordPanelSendingDataToTheServerMessageTitle'], 'text': Clipperz.PM.Strings['deleteRecordPanelSendingDataToTheServerMessageText'] } }, 'deleteRecord_updatingInterface': function() { return { 'title': Clipperz.PM.Strings['deleteRecordPanelUpdatingTheInterfaceMessageTitle'], 'text': Clipperz.PM.Strings['deleteRecordPanelUpdatingTheInterfaceMessageText'] } }, //------------------------------------------------------------------------- // // Cards block - save card panel // 'saveCard_collectRecordInfo': function() { return { 'title': Clipperz.PM.Strings['recordSaveChangesPanelCollectRecordInfoMessageTitle'], 'text': Clipperz.PM.Strings['recordSaveChangesPanelCollectRecordInfoMessageText'] } }, 'saveCard_encryptUserData': function() { return { 'title': Clipperz.PM.Strings['recordSaveChangesPanelEncryptUserDataMessageTitle'], 'text': Clipperz.PM.Strings['recordSaveChangesPanelEncryptUserDataMessageText'] } }, 'saveCard_encryptRecordData': function() { return { 'title': Clipperz.PM.Strings['recordSaveChangesPanelEncryptRecordDataMessageTitle'], 'text': Clipperz.PM.Strings['recordSaveChangesPanelEncryptRecordDataMessageText'] } }, 'saveCard_encryptRecordVersions': function() { return { 'title': Clipperz.PM.Strings['recordSaveChangesPanelEncryptRecordVersionDataMessageTitle'], 'text': Clipperz.PM.Strings['recordSaveChangesPanelEncryptRecordVersionDataMessageText'] } }, 'saveCard_sendingData': function() { return { 'title': Clipperz.PM.Strings['recordSaveChangesPanelSendingDataToTheServerMessageTitle'], 'text': Clipperz.PM.Strings['recordSaveChangesPanelSendingDataToTheServerMessageText'] } }, 'saveCard_updatingInterface': function() { return { 'title': Clipperz.PM.Strings['recordSaveChangesPanelUpdatingTheInterfaceMessageTitle'], 'text': Clipperz.PM.Strings['recordSaveChangesPanelUpdatingTheInterfaceMessageText'] } }, //------------------------------------------------------------------------- // // Account panel - user preferences // 'account_savingPreferences_1': function() { return { 'title': Clipperz.PM.Strings['accountPreferencesSavingPanelTitle_Step1'], 'text': Clipperz.PM.Strings['accountPreferencesSavingPanelText_Step1'], 'steps': '+3' } }, 'account_savingPreferences_2': function() { return { 'title': Clipperz.PM.Strings['accountPreferencesSavingPanelTitle_Step2'], 'text': Clipperz.PM.Strings['accountPreferencesSavingPanelText_Step2'] } }, //------------------------------------------------------------------------- // // Account panel - change credentials // 'changeCredentials_encryptingData': function() { return { 'title': Clipperz.PM.Strings['changeCredentialsPanelEncryptingDataMessageTitle'], 'text': Clipperz.PM.Strings['changeCredentialsPanelEncryptingDataMessageText'] } }, 'changeCredentials_creatingNewCredentials': function() { return { 'title': Clipperz.PM.Strings['changeCredentialsPanelCreatingNewCredentialsMessageTitle'], 'text': Clipperz.PM.Strings['changeCredentialsPanelCreatingNewCredentialsMessageText'] } }, 'changeCredentials_sendingCredentials': function() { return { 'title': Clipperz.PM.Strings['changeCredentialsPanelSendingNewCredentialsToTheServerMessageTitle'], 'text': Clipperz.PM.Strings['changeCredentialsPanelSendingNewCredentialsToTheServerMessageText'] } }, 'changeCredentials_done': function() { return { 'title': Clipperz.PM.Strings['changeCredentialsPanelDoneMessageTitle'], 'text': Clipperz.PM.Strings['changeCredentialsPanelDoneMessageText'] } }, //------------------------------------------------------------------------- // // Account panel - change credentials // 'saveOTP_encryptUserData': function() { return { 'title': Clipperz.PM.Strings['saveOTP_encryptUserDataTitle'], 'text': Clipperz.PM.Strings['saveOTP_encryptUserDataText'], 'steps': '+4' } }, 'saveOTP_encryptOTPData': function() { return { 'title': Clipperz.PM.Strings['saveOTP_encryptOTPDataTitle'], 'text': Clipperz.PM.Strings['saveOTP_encryptOTPDataText'] } }, 'saveOTP_sendingData': function() { return { 'title': Clipperz.PM.Strings['saveOTP_sendingDataTitle'], 'text': Clipperz.PM.Strings['saveOTP_sendingDataText'] } }, 'saveOTP_updatingInterface': function() { return { 'title': Clipperz.PM.Strings['saveOTP_updatingInterfaceTitle'], 'text': Clipperz.PM.Strings['saveOTP_updatingInterfaceText'] } }, //------------------------------------------------------------------------- // // Data panel - processingImportData // 'parseImportData': function() { return { 'title': Clipperz.PM.Strings['importData_parsingDataTitle'], 'text': Clipperz.PM.Strings['importData_parsingDataText'] } }, 'previewImportData': function() { return { 'title': Clipperz.PM.Strings['importData_previewingDataTitle'], 'text': Clipperz.PM.Strings['importData_previewingDataText'] } }, 'processingImportData': function() { return { 'title': Clipperz.PM.Strings['importData_processingDataTitle'], 'text': Clipperz.PM.Strings['importData_processingDataText'] } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" } diff --git a/frontend/gamma/js/Clipperz/PM/Strings/Strings_defaults.js b/frontend/gamma/js/Clipperz/PM/Strings/Strings_defaults.js index 101ed3f..aefd94a 100644 --- a/frontend/gamma/js/Clipperz/PM/Strings/Strings_defaults.js +++ b/frontend/gamma/js/Clipperz/PM/Strings/Strings_defaults.js @@ -1,387 +1,385 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Strings) == 'undefined') { Clipperz.PM.Strings = {}; } if (typeof(Clipperz.PM.Strings.Languages) == 'undefined') { Clipperz.PM.Strings.Languages = {}; } //============================================================================= // // D E F A U L T S ( defaults ) // //============================================================================= Clipperz.PM.Strings.Languages['defaults'] = { 'elapsedTimeDescriptions': { 'MORE_THAN_A_MONTH_AGO': "more than a month ago", 'MORE_THAN_A_WEEK_AGO': "more than a week ago", 'MORE_THAN_*_WEEKS_AGO': "more than __elapsed__ weeks ago", 'YESTERDAY': "yesterday", '*_DAYS_AGO': "__elapsed__ days ago", 'ABOUT_AN_HOUR_AGO': "about an hour ago", '*_HOURS_AGO': "__elapsed__ hours ago", 'JUST_A_FEW_MINUTES_AGO': "just a few minutes ago", 'ABOUT_*_MINUTES_AGO': "about __elapsed__ minutes ago" }, /* 'unknown_ip': "unknown", 'countries': { '--': "unknown", 'AD': "Andorra", 'AE': "United Arab Emirates", 'AF': "Afghanistan", 'AG': "Antigua and Barbuda", 'AI': "Anguilla", 'AL': "Albania", 'AM': "Armenia", 'AN': "Netherlands Antilles", 'AO': "Angola", 'AP': "Non-Spec Asia Pas Location", 'AR': "Argentina", 'AS': "American Samoa", 'AT': "Austria", 'AU': "Australia", 'AW': "Aruba", 'AX': "Aland Islands", 'AZ': "Azerbaijan", 'BA': "Bosnia and Herzegowina", 'BB': "Barbados", 'BD': "Bangladesh", 'BE': "Belgium", 'BF': "Burkina Faso", 'BG': "Bulgaria", 'BH': "Bahrain", 'BI': "Burundi", 'BJ': "Benin", 'BM': "Bermuda", 'BN': "Brunei Darussalam", 'BO': "Bolivia", 'BR': "Brazil", 'BS': "Bahamas", 'BT': "Bhutan", 'BW': "Botswana", 'BY': "Belarus", 'BZ': "Belize", 'CA': "Canada", 'CD': "Congo the Democratic Republic of the", 'CF': "Central African Republic", 'CH': "Switzerland", 'CI': "Cote D'ivoire", 'CK': "Cook Islands", 'CL': "Chile", 'CM': "Cameroon", 'CN': "China", 'CO': "Colombia", 'CR': "Costa Rica", 'CS': "Serbia and Montenegro", 'CU': "Cuba", 'CY': "Cyprus", 'CZ': "Czech Republic", 'DE': "Germany", 'DJ': "Djibouti", 'DK': "Denmark", 'DO': "Dominican Republic", 'DZ': "Algeria", 'EC': "Ecuador", 'EE': "Estonia", 'EG': "Egypt", 'ER': "Eritrea", 'ES': "Spain", 'ET': "Ethiopia", 'EU': "European Union", 'FI': "Finland", 'FJ': "Fiji", 'FM': "Micronesia Federated States of", 'FO': "Faroe Islands", 'FR': "France", 'GA': "Gabon", 'GB': "United Kingdom", 'GD': "Grenada", 'GE': "Georgia", 'GF': "French Guiana", 'GG': "Guernsey", 'GH': "Ghana", 'GI': "Gibraltar", 'GL': "Greenland", 'GM': "Gambia", 'GP': "Guadeloupe", 'GR': "Greece", 'GT': "Guatemala", 'GU': "Guam", 'GW': "Guinea-Bissau", 'GY': "Guyana", 'HK': "Hong Kong", 'HN': "Honduras", 'HR': "Croatia (Local Name: Hrvatska)", 'HT': "Haiti", 'HU': "Hungary", 'ID': "Indonesia", 'IE': "Ireland", 'IL': "Israel", 'IM': "Isle of Man", 'IN': "India", 'IO': "British Indian Ocean Territory", 'IQ': "Iraq", 'IR': "Iran (Islamic Republic of)", 'IS': "Iceland", 'IT': "Italy", 'JE': "Jersey", 'JM': "Jamaica", 'JO': "Jordan", 'JP': "Japan", 'KE': "Kenya", 'KG': "Kyrgyzstan", 'KH': "Cambodia", 'KI': "Kiribati", 'KN': "Saint Kitts and Nevis", 'KR': "Korea Republic of", 'KW': "Kuwait", 'KY': "Cayman Islands", 'KZ': "Kazakhstan", 'LA': "Lao People's Democratic Republic", 'LB': "Lebanon", 'LC': "Saint Lucia", 'LI': "Liechtenstein", 'LK': "Sri Lanka", 'LR': "Liberia", 'LS': "Lesotho", 'LT': "Lithuania", 'LU': "Luxembourg", 'LV': "Latvia", 'LY': "Libyan Arab Jamahiriya", 'MA': "Morocco", 'MC': "Monaco", 'MD': "Moldova Republic of", 'MG': "Madagascar", 'MH': "Marshall Islands", 'MK': "Macedonia the Former Yugoslav Republic of", 'ML': "Mali", 'MM': "Myanmar", 'MN': "Mongolia", 'MO': "Macau", 'MP': "Northern Mariana Islands", 'MR': "Mauritania", 'MS': "Montserrat", 'MT': "Malta", 'MU': "Mauritius", 'MV': "Maldives", 'MW': "Malawi", 'MX': "Mexico", 'MY': "Malaysia", 'MZ': "Mozambique", 'NA': "Namibia", 'NC': "New Caledonia", 'NF': "Norfolk Island", 'NG': "Nigeria", 'NI': "Nicaragua", 'NL': "Netherlands", 'NO': "Norway", 'NP': "Nepal", 'NR': "Nauru", 'NU': "Niue", 'NZ': "New Zealand", 'OM': "Oman", 'PA': "Panama", 'PE': "Peru", 'PF': "French Polynesia", 'PG': "Papua New Guinea", 'PH': "Philippines", 'PK': "Pakistan", 'PL': "Poland", 'PR': "Puerto Rico", 'PS': "Palestinian Territory Occupied", 'PT': "Portugal", 'PW': "Palau", 'PY': "Paraguay", 'QA': "Qatar", 'RO': "Romania", 'RS': "Serbia", 'RU': "Russian Federation", 'RW': "Rwanda", 'SA': "Saudi Arabia", 'SB': "Solomon Islands", 'SC': "Seychelles", 'SD': "Sudan", 'SE': "Sweden", 'SG': "Singapore", 'SI': "Slovenia", 'SK': "Slovakia (Slovak Republic)", 'SL': "Sierra Leone", 'SM': "San Marino", 'SN': "Senegal", 'SR': "Suriname", 'SV': "El Salvador", 'SY': "Syrian Arab Republic", 'SZ': "Swaziland", 'TC': "Turks and Caicos Islands", 'TG': "Togo", 'TH': "Thailand", 'TJ': "Tajikistan", 'TM': "Turkmenistan", 'TN': "Tunisia", 'TO': "Tonga", 'TR': "Turkey", 'TT': "Trinidad and Tobago", 'TV': "Tuvalu", 'TW': "Taiwan Province of China", 'TZ': "Tanzania United Republic of", 'UA': "Ukraine", 'UG': "Uganda", 'US': "United States", 'UY': "Uruguay", 'UZ': "Uzbekistan", 'VA': "Holy See (Vatican City State)", 'VE': "Venezuela", 'VG': "Virgin Islands (British)", 'VI': "Virgin Islands (U.S.)", 'VN': "Viet Nam", 'VU': "Vanuatu", 'WF': "Wallis and Futuna Islands", 'WS': "Samoa", 'YE': "Yemen", 'ZA': "South Africa", 'ZM': "Zambia", 'ZW': "Zimbabwe", 'ZZ': "Reserved" }, 'browsers': { 'UNKNOWN': "Unknown", 'MSIE': "Internet Explorer", 'FIREFOX': "Firefox", 'OPERA': "Opera", 'SAFARI': "Safari", 'OMNIWEB': "OmniWeb", 'CAMINO': "Camino", 'CHROME': "Chrome" }, 'operatingSystems': { 'UNKNOWN': "Unknown", 'WINDOWS': "Windows", 'MAC': "Mac", 'LINUX': "Linux", 'IPHONE': "iPhone", 'MOBILE': "Mobile", 'OPENBSD': "OpenBSD", 'FREEBSD': "FreeBSD", 'NETBSD': "NetBSD" }, */ // Calendar texts 'calendarStrings': { 'months': { '0': "January", '1': "February", '2': "March", '3': "April", '4': "May", '5': "June", '6': "July", '7': "August", '8': "September", '9': "October", '10': "November", '11': "December" }, 'shortMonths': { '0': "Jan", '1': "Feb", '2': "Mar", '3': "Apr", '4': "May", '5': "Jun", '6': "Jul", '7': "Aug", '8': "Sep", '9': "Oct", '10': "Nov", '11': "Dec" }, 'days': { '0': "Sunday", '1': "Monday", '2': "Tuesday", '3': "Wednesday", '4': "Thursday", '5': "Friday", '6': "Saturday" }, 'shortDays': { '0': "Sun", '1': "Mon", '2': "Tue", '3': "Wed", '4': "Thu", '5': "Fri", '6': "Sat" }, 'veryShortDays': { '0': "Su", '1': "Mo", '2': "Tu", '3': "We", '4': "Th", '5': "Fr", '6': "Sa" }, 'amDesignation': "am", 'pmDesignation': "pm" }, // Date format 'fullDate_format': "l, F d, Y H:i:s", //################################################################################ 'pageHeader': { 'donation': "donate", 'forum': "forum", 'credits': "credits", 'feedback': "feedback", 'help': "help" }, 'bookmarkletCopy': { 'noExceptionMessage': "The direct login configuration has been collected.", 'exceptionMessage': "Sorry! There was an error while processing the page.", 'copy': "copy", 'successfulMessage': "DONE!", 'failMessage': "Failed! :(" }, //################################################################################ __syntaxFix__: "syntax fix" } diff --git a/frontend/gamma/js/Clipperz/PM/Strings/Strings_en-US.js b/frontend/gamma/js/Clipperz/PM/Strings/Strings_en-US.js index b540633..85d55c0 100644 --- a/frontend/gamma/js/Clipperz/PM/Strings/Strings_en-US.js +++ b/frontend/gamma/js/Clipperz/PM/Strings/Strings_en-US.js @@ -1,534 +1,532 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ //============================================================================= // // E N G L I S H A M E R I C A N ( en_US ) // //============================================================================= Clipperz.PM.Strings.Languages['en-us'] = { /* // Login page - description 'clipperzServiceDescription': "\ <!-- FIX CSS DONE --> \ <h2>Keep it to yourself!</h2>\ <ul>\ <li>\ <h3>Clipperz is:</h3>\ <ul>\ <li><p>a secure and simple password manager</p></li>\ <li><p>an effective single sign-on solution</p></li>\ <li><p>a digital vault for your personal data</p></li>\ </ul>\ </li>\ <li>\ <h3>With Clipperz you can:</h3>\ <ul>\ <li><p>store and manage your passwords and online credentials</p></li>\ <li><p>login to your web services without entering any username or password</p></li>\ <li><p>protect all your sensitive data: codes for burglar alarms, PINs, credit card numbers, …</p></li>\ <li><p>share secrets with family members and associates (coming soon)</p></li>\ </ul>\ </li>\ <li>\ <h3>Clipperz benefits:</h3>\ <ul>\ <li><p>free and completely anonymous</p></li>\ <li><p>access it any time from any computer</p></li>\ <li><p>no software to download and nothing to install</p></li>\ <li><p>avoid keeping secrets on your PC or on paper</p></li>\ </ul>\ </li>\ <li>\ <h3>Clipperz security:</h3>\ <ul>\ <li><p>your secrets are locally encrypted by your browser before being uploaded to Clipperz</p></li>\ <li><p>the encryption key is a passphrase known only to you</p></li>\ <li><p>Clipperz hosts your sensitive data in encrypted form and could never actually access the data in its plain form</p></li>\ <li><p>Clipperz is built upon standard encryption schemes, nothing fancies or homemade</p></li>\ <li><p>you can review the source code anytime you like, but you need to know nothing about cryptography to be an happy user!</p></li>\ </ul>\ </li>\ <li>\ <a href=\"http://www.clipperz.com\" target=\"_blank\">Learn more</a>\ </li>\ </ul>", 'loginFormTitle': "login with your Clipperz account", 'loginFormUsernameLabel': "username", 'loginFormPassphraseLabel': "passphrase", 'loginFormDontHaveAnAccountLabel': "don\'t have an account?", 'loginFormCreateOneLabel': "create one", 'loginFormForgotYourCredentialsLabel': "forgot your credentials?", 'loginFormAarghThatsBadLabel': "aargh! that\'s bad!", 'loginFormAfraidOfMaliciousScriptsLabel': "afraid of malicious scripts?", 'loginFormVerifyTheCodeLabel': "verify the code", 'loginFormButtonLabel': "Login", 'loginFormOneTimePasswordCheckboxLabel': "use a one-time passphrase", 'loginFormOneTimePasswordCheckboxDescription': "", // Login page - language selection 'loginPanelSwithLanguageDescription': "<h5>Switch to your preferred language</h5>", // Login page - browser compatibility 'browserCompatibilityDescription': "<p>Have a better and safer Clipperz experience with Firefox. However Clipperz works just fine also with Opera, Safari and MS Internet Explorer!</p>", // Login with OTP - message panel 'OTPloginMessagePanelInitialTitle': "Logging in using a one-time passphrase", 'OTPloginMessagePanelInitialText': "Sending OTP credentials …", 'OTPloginMessagePanelLoadingTitle': "Logging in using a one-time passphrase", 'OTPloginMessagePanelLoadingText': "Fetching encrypted authentication data from the server …", 'OTPloginMessagePanelProcessingTitle': "Logging in using a one-time passphrase", 'OTPloginMessagePanelProcessingText': "Local decryption of authentication data", // Regular login - message panel 'loginMessagePanelInitialTitle': "Logging in …", 'loginMessagePanelInitialText': "---", 'loginMessagePanelInitialButtonLabel': "Cancel", 'loginMessagePanelConnectedTitle': "Connected", 'loginMessagePanelConnectedText': "Done", 'loginMessagePanelFailureTitle': "Error", 'loginMessagePanelFailureText': "Login failed", 'loginMessagePanelFailureButtonLabel': "Close", // Regular login - message panel - connection 'connectionLoginSendingCredentialsMessageTitle': "Verifying credentials", 'connectionLoginSendingCredentialsMessageText': "Sending credentials", 'connectionLoginCredentialsVerificationMessageTitle': "Verifying credentials", 'connectionLoginCredentialsVerificationMessageText': "Performing SRP authentication", 'connectionLoginDoneMessageTitle': "Verifying credentials", 'connectionLoginDoneMessageText': "Connected", // Regular login - message panel - user 'userLoginPanelUpgradingUserCredentialsMessageTitle': "Verifying credentials", 'userLoginPanelUpgradingUserCredentialsMessageText': "Upgrading your credentials to a new authentication schema", 'userLoginPanelConnectedMessageTitle': "User authenticated", 'userLoginPanelConnectedMessageText': "Successfully logged in", 'userLoginPanelTryingAnOlderConnectionSchemaMessageTitle': "Verifying credentials", 'userLoginPanelTryingAnOlderConnectionSchemaMessageText': "Trying an older authentication schema", 'userLoginPanelLoadingUserDataMessageTitle': "User authenticated", 'userLoginPanelLoadingUserDataMessageText': "Downloading encrypted card headers from Clipperz", 'userLoginPanelDecryptingUserDataMessageTitle': "User authenticated", 'userLoginPanelDecryptingUserDataMessageText': "Local decryption of card headers", 'userLoginPanelDecryptingUserStatisticsMessageTitle': "User authenticated", 'userLoginPanelDecryptingUserStatisticsMessageText': "Local decryption of usage statistics", // Registration page - splash alert 'splashAlertTitle': "Welcome to Clipperz!", 'splashAlertText': "\ <!-- FIX CSS DONE! --> \ <p>Some security advice</p>\ <ul>\ <li><p>Storing your data at Clipperz is as secure as the passphrase you choose to protect them. Nobody can access them unless they know your passphrase.</p></li>\ <li><p>If you are going to use Clipperz for safeguarding sensitive and critical information please make sure to use a strong passphrase. The longer the better!</p></li>\ <li><p>Clipperz will not be able to recover a lost passphrase!</p></li>\ </ul>\ <p>For any further information, please refer to <a href=\"http://www.clipperz.com\" target=\"_blank\">Clipperz</a> website.</p>", 'splashAlertCloseButtonLabel': "Ok", // Registration page - form 'registrationFormTitle': "create your account", 'registrationFormUsernameLabel': "username", 'registrationFormPassphraseLabel': "passphrase", 'registrationFormRetypePassphraseLabel': "re-enter passphrase", 'registrationFormSafetyCheckLabel': "I understand that Clipperz will not be able to recover a lost passphrase.", 'registrationFormTermsOfServiceCheckLabel': "I have read and agreed to the <a href='http://www.clipperz.com/terms_of_service' target='_blank'>Terms of Service</a>.", 'registrationFormDoYouAlreadyHaveAnAccountLabel': "do you already have an account?", 'registrationFormSimplyLoginLabel': "simply login", 'registrationFormButtonLabel': "Register", // Registration page - warning messages 'registrationFormWarningMessageNotMatchingPassphrases': "Your passphrases don't match, please re-type them.", 'registrationFormWarningMessageSafetyCheckNotSelected': "Please read and check all the boxes below.", 'registrationFormWarningMessageTermsOfServiceCheckNotSelected': "You need to agree to the Terms of Service.", // Registration page - message panel 'registrationMessagePanelInitialTitle': "Creating account …", 'registrationMessagePanelInitialText': "---", 'registrationMessagePanelInitialButtonLabel': "Cancel", 'registrationMessagePanelRegistrationDoneTitle': "Registration", 'registrationMessagePanelRegistrationDoneText': "Done", 'registrationMessagePanelFailureTitle': "Registration failed", 'registrationMessagePanelFailureButtonLabel': "Close", // Registration page - message panel - connection 'connectionRegistrationSendingRequestMessageText': "Verifying credentials", 'connectionRegistrationSendingCredentialsMessageText': "Sending credentials", // Registration page - splash panel 'registrationSplashPanelTitle': "Security advice", 'registrationSplashPanelDescription': "<p>These are your Clipperz credentials, take good care of them. Clipperz will never display your username and passphrase a second time!</p>", 'registrationSplashPanelUsernameLabel': "username", 'registrationSplashPanelPassphraseLabel': "passphrase", 'registrationSplashPanelShowPassphraseButtonLabel': "show passphrase", // Header links 'donateHeaderLinkLabel': "donate", 'creditsHeaderLinkLabel': "credits", 'feedbackHeaderLinkLabel': "feedback", 'helpHeaderLinkLabel': "help", 'forumHeaderLinkLabel': "forum", // Menu labels 'recordMenuLabel': "cards", 'accountMenuLabel': "account", 'dataMenuLabel': "data", 'contactsMenuLabel': "contacts", 'toolsMenuLabel': "tools", 'logoutMenuLabel': "logout", 'lockMenuLabel': "lock", // Lock dialog 'lockTitle': "The account is locked", 'lockDescription': "<p>To unlock your account, please enter your passphrase.</p>", 'unlockButtonLabel': "Unlock", // Account panel - change passphrase 'changePasswordTabLabel': "Change your passphrase", 'changePasswordTabTitle': "Change your passphrase", 'changePasswordFormUsernameLabel': "username", 'changePasswordFormOldPassphraseLabel': "old passphrase", 'changePasswordFormNewPassphraseLabel': "new passphrase", 'changePasswordFormRetypePassphraseLabel': "re-enter new passphrase", 'changePasswordFormSafetyCheckboxLabel': "I understand that Clipperz will not be able to recover a lost passphrase.", 'changePasswordFormSubmitLabel': "Change passphrase", // Account panel - change passphrase - warning messages 'changePasswordFormWrongUsernameWarning': "Wrong username", 'changePasswordFormWrongPassphraseWarning': "Wrong passphrase", 'changePasswordFormWrongRetypePassphraseWarning': "Your passphrases don't match, please re-type them.", 'changePasswordFormSafetyCheckWarning': "Please read and check the box below.", // Account panel - change passphrase - progress dialog 'changePasswordFormProgressDialogTitle': "Changing user credentials", 'changePasswordFormProgressDialogEmptyText': "---", 'changePasswordFormProgressDialogConnectedMessageTitle': "Connected", 'changePasswordFormProgressDialogConnectedMessageText': "Done", 'changePasswordFormProgressDialogErrorMessageTitle': "Error", 'changePasswordFormProgressDialogErrorMessageText': "Credentials change failed!", 'changeCredentialsPanelEncryptingDataMessageTitle': "Changing your passphrase", 'changeCredentialsPanelEncryptingDataMessageText': "Local encryption of card headers", 'changeCredentialsPanelCreatingNewCredentialsMessageTitle': "Changing your passphrase", 'changeCredentialsPanelCreatingNewCredentialsMessageText': "Updating your credentials", 'changeCredentialsPanelSendingNewCredentialsToTheServerMessageTitle': "Changing your passphrase", 'changeCredentialsPanelSendingNewCredentialsToTheServerMessageText': "Uploading your encrypted credentials to Clipperz", 'changeCredentialsPanelDoneMessageTitle': "Changing your passphrase", 'changeCredentialsPanelDoneMessageText': "Done", // Account panel - OTP 'manageOTPTabLabel': "Manage your one-time passphrases", 'manageOTPTabTitle': "Manage your one-time passphrases", 'manageOTPTabDescription': "\ <p>A one-time passphrase works like your regular passphrase, but can be used only once.</p>\ <p>If the same passphrase is used again at a later stage in a login attempt it will be rejected and the login process will fail.</p>\ <p>Immediately after a successful login, your one-time passphrase will be deleted preventing any fraudulent access.</p>\ <p>One-time passphrases are an excellent choice if one is concerned about keyloggers or spyware infections that may be collecting data from compromised machines.</p>\ <p><b>It's strongly advisable to use one-time passphrases when accessing Clipperz from public terminals, such as Internet cafes and libraries.</b></p>", // Account panel - OTP - OTP table 'oneTimePasswordReadOnlyMessage': "\ <h6>Sorry!</h6>\ <p>You cannot manage your one-time passphrases when using the offline version of Clipperz.</p>", 'oneTimePasswordLoadingMessage': "\ <h6>Loading data</h6>\ <p>Please wait …</p>", 'oneTimePasswordNoPasswordAvailable': "\ <h6>No one-time passphrase available</h6>\ <p>Click the “New” button above to add one-time passphrases to your account.</p>", 'createNewOTPButtonLabel': "New", 'deleteOTPButtonLabel': "Delete", 'printOTPButtonLabel': "Print", 'disabledOneTimePassword_warning': "disabled", 'oneTimePasswordSelectionLink_selectLabel': "Select:", 'oneTimePasswordSelectionLink_all': "all", 'oneTimePasswordSelectionLink_none': "none", 'oneTimePasswordSelectionLink_used': "used", 'oneTimePasswordSelectionLink_unused': "unused", //Account panel - OTP - saving new OTP dialog 'saveOTP_encryptUserDataTitle': "Saving one-time passphrase", 'saveOTP_encryptUserDataText': "Processing new OTP credentials …", 'saveOTP_encryptOTPDataTitle': "Saving one-time passphrase", 'saveOTP_encryptOTPDataText': "Local encryption of authentication data …", 'saveOTP_sendingDataTitle': "Saving one-time passphrase", 'saveOTP_sendingDataText': "Sending authentication data to the server …", 'saveOTP_updatingInterfaceTitle': "Saving one-time passphrase", 'saveOTP_updatingInterfaceText': "Updating interface", // Account panel - preferences 'accountPreferencesLabel': "Preferences", 'accountPreferencesTabTitle': "Preferences", 'accountPreferencesLanguageTitle': "Language", 'accountPreferencesLanguageDescription': "<p>Choose your preferred language from the list below.</p>", 'showDonationReminderPanelTitle': "Donation reminders", 'showDonationReminderPanelDescription': "<p>Show donation reminders</p>", 'saveUserPreferencesFormSubmitLabel': "Save", 'cancelUserPreferencesFormSubmitLabel': "Cancel", // Account panel - preferences - saving dialog 'accountPreferencesSavingPanelTitle_Step1': "Saving preferences", 'accountPreferencesSavingPanelText_Step1': "Local encryption of your preferences", 'accountPreferencesSavingPanelTitle_Step2': "Saving preferences", 'accountPreferencesSavingPanelText_Step2': "Sending encrypted preferences to Clipperz", // Account panel - login history 'accountLoginHistoryLabel': "Login history", 'loginHistoryTabTitle': "Login history", 'loginHistoryReadOnlyMessage': "\ <h6>Sorry!</h6>\ <p>The login history is not available while using the offline version of Clipperz.</p>", 'loginHistoryLoadingMessage': "\ <h6>Loading data</h6>\ <p>Please wait …</p>", 'loginHistoryLoadedMessage': "\ <h6>Your latest 10 logins</h6>\ <p></p>", 'loginHistoryIPLabel': "IP", 'loginHistoryTimeLabel': "date", 'loginHistoryCurrentSessionText': "current session", 'loginHistoryReloadButtonLabel': "Reload login history", // Account panel - delete account 'deleteAccountTabLabel': "Delete your account", 'deleteAccountTabTitle': "Delete your account", 'deleteAccountFormUsernameLabel': "username", 'deleteAccountFormPassphraseLabel': "passphrase", 'deleteAccountFormSafetyCheckboxLabel': "I understand that all my data will be deleted and that this action is irreversible.", 'deleteAccountFormSubmitLabel': "Delete my account", //Account panel - delete account - warnings 'deleteAccountFormWrongUsernameWarning': "Wrong username", 'deleteAccountFormWrongPassphraseWarning': "Wrong passphrase", 'deleteAccountFormSafetyCheckWarning': "Please read and check the box below.", //Account panel - delete account - confirmation 'accountPanelDeletingAccountPanelConfirmationTitle': "ATTENTION", 'accountPanelDeleteAccountPanelConfirmationText': "Are your sure you want to delete your account?", 'accountPanelDeleteAccountPanelConfirmButtonLabel': "Yes", 'accountPanelDeleteAccountPanelDenyButtonLabel': "No", //Account panel - delete account - confirmation 'accountPanelDeletingAccountPanelProgressTitle': "Deleting the account data", 'accountPanelDeletingAccountPanelProgressText': "The operation could take long, please be patient.", //Data panel - offline copy 'offlineCopyTabLabel': "Offline copy", 'offlineCopyTabTitle': "Offline copy", 'offlineCopyTabDescription': "\ <!-- FIX CSS DONE! --> \ <p>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.</p>\ <p>The read-only version is as secure as the read-and-write one and will not expose your data to higher risks since they both share the same code and security architecture.</p>\ <ol>\ <li><p>Click the link below to start the download.</p></li>\ <li><p>The browser will ask you what to do with the “Clipperz_YYYYMMDD.html” file. Save it on your hard disk.</p></li>\ <li><p>Double click on the downloaded file to launch the offline version in your browser.</p></li>\ <li><p>Enter the usual username and passphrase.</p></li>\ </ol>", 'offlineCopyDownloadLinkLabel': "Download", // Data panel - offline copy - not updated 'offlineCopyDownloadWarning': "\ <!-- FIX CSS DONE! --> \ <h4><a href=\"#\" id=\"offlineCopyDownloadWarningLink\">Update your “offline copy”!</a></h4>\ <p>You have recently created or modified one or more cards, it would be wise to download a new copy of the offline version.</p>", 'offlineCopyDownloadOk': "", // Data panel - sharing 'sharingTabLabel': "Sharing", 'sharingTabTitle': "Sharing", 'sharingTabDescription': "\ <p>Quite often a confidential piece of information needs to be shared with one or more persons.</p>\ <p>This could be as simple as giving your colleague the access code of your voice mailbox when you are out of the office, or as complicated as enabling the entitled heirs to access your safe deposit box at the local bank when you pass on.</p>\ <p>Clipperz can make sharing your secrets a secure and straightforward process.</p>\ <p></p>\ <p><b>Coming soon …</b></p>", // Data panel - import 'importTabLabel': "Import", 'importTabTitle': "Import", 'importTabDescription': "<p>You can bulk import data to your Clipperz account from several file formats.</p>", // Data panel - export 'printingTabLabel': "Export", 'printingTabTitle': "Export", 'printingTabDescription': "\ <h5>Printing</h5>\ <p>Click on the link below to open a new window displaying all your cards in a printable format.</p>\ <p>If you are going to print for backup purposes, please consider the safer option provided by the “offline copy”.</p>", 'printingLinkLabel': "Printable version", 'exportTabDescription': "\ <h5>Exporting to JSON</h5>\ <p>JSON enables a “lossless” export of your cards. All the information will be preserved, including direct login configurations.</p>\ <p>This custom format it’s quite convenient if you need to move some of all of your cards to a different Clipperz account. Or if you want to restore a card that has been accidentally deleted.</p>\ <p>Click on the link below to start the export process.</p>", 'exportLinkLabel': "Export to JSON", 'exportDataInProgressDescription': "<h4>Exporting, please wait while your data are being processed …</h4>", 'exportDataDescription': "\ <h4>Instructions</h4>\ <p>Copy the text below to your favorite editor and save it. (e.g. “clipperz_export_20071217.json”)</p>", // Contacts panel 'contactsTabLabel': "Contacts", 'contactsTabTitle': "Contacts", //Tools panel - password generator 'passwordGeneratorTabLabel': "Password generator", 'bookmarkletTabLabel': "Bookmarklet", 'compactTabLabel': "Compact edition", 'httpAuthTabLabel': "HTTP authentication", 'passwordGeneratorTabTitle': "Password generator", 'bookmarkletTabTitle': "Bookmarklet", 'compactTabTitle': "Compact edition", 'httpAuthTabTitle': "HTTP authentication", // Tools panel - password generator - description 'paswordGeneratorTabDescription': "<p></p>", 'passwordGeneratorTabButtonLabel': "Generate password", // Tools panel - bookmarklet 'bookmarkletTabLabel': "Bookmarklet", 'bookmarkletTabTitle': "Bookmarklet", 'bookmarkletTabDescription': "\ <!-- FIX CSS DONE! --> \ <p>A bookmarklet is a simple “one-click” tool that can perform very useful tasks. It can be saved and used like a normal web page bookmark.</p>\ <p>The Clipperz bookmarklet will help you to quickly create new cards and new “direct logins” within existing cards.</p>\ <p><b>Please note that the bookmarklet does not include any information related to your account (e.g. your username or passphrase), the bookmarklet is a general tool containing the same code for every Clipperz user.</b></p>\ <h3>How to install the bookmarklet</h3>\ <h>Firefox, Camino, Opera, Safari</h5>\ <ol>\ <li><p>Make sure that the “Bookmarks Bar” is displayed by selecting “View > Toolbars > Bookmarks”, or similar menu items, from the browser menu.</p></li>\ <li><p>Drag and drop the “Add to Clipperz” link below to the bookmark bar.</p></li>\ </ol>\ \ <h5>Internet Explorer</h5>\ <ol>\ <li><p>Make sure that the “Links” toolbar is displayed by selecting “View > Toolbars > Links” from the browser menu.</p></li>\ <li><p>Right-click on the “Add to Clipperz” link below.</p></li>\ <li><p>Select “Add to favorites” from the contextual menu.</p></li>\ <li><p>Click “Yes” for any security message that pops up.</p></li>\ <li><p>Open the “Links” folder and click “OK”</p></li>\ </ol>", 'bookmarkletTabBookmarkletTitle': "Add to Clipperz", // Tools panel - bookmarklet - instructions 'bookmarkletTabInstructions': "\ <!-- FIX CSS DONE! --> \ <h3>How to create a new card inclusive of a “direct login” link to an online service</h3>\ <ol>\ <li><p>Open the web page where the login form is hosted. (this is the page where you usually enter your sign-in credentials)</p></li>\ <li><p>Launch the bookmarklet by clicking on it: a pop-up window will appear over the web page.</p></li>\ <li><p>Copy to the clipboard the content of the large text area within the pop-up. (ctrl-C)</p></li>\ <li><p>Enter your Clipperz account and click on the <b>Add new card</b> button.</p></li>\ <li><p>Select the “Direct login” template and paste the content of the clipboard to the large text area in the form. (ctrl-V)</p></li>\ <li><p>Press the <b>Create</b> button, complete and review the details, then click <b>Save</b>.</p></li>\ </ol>\ \ <h3>How to add a “direct login” link to an existing card</h3>\ <ol>\ <li><p>Same as above.</p></li>\ <li><p>Same as above.</p></li>\ <li><p>Same as above.</p></li>\ <li><p>Enter your Clipperz account and select the card containing the credentials for the web service you just visited and click the <b>Edit</b> button.</p></li>\ <li><p>Paste the content of the clipboard to the large text area in the “Direct logins” section. (ctrl-V)</p></li>\ <li><p>Press the <b>Add direct login</b> button, review the details and then click <b>Save</b>.</p></li>\ </ol>\ \ <p></p>\ <p>Further information about the bookmarklet are <a href=\"http://www.clipperz.com/support/user_guide/bookmarklet\" target=\"_blank\">available here</a>.</p>", // Tools panel - Compact - instructions 'compactTabDescription': "\ <!-- FIX CSS DONE! --> \ <p>Clipperz Compact is a special version of Clipperz designed to be opened in the Firefox sidebar.</p>\ <p>Its purpose is to keep your collection of “direct logins” always at hand. Read more <a href=\"http://www.clipperz.com/support/user_guide/clipperz_compact\", target=\"blank\">here</a></p>\ \ <h3>How to launch Clipperz Compact in the sidebar</h3>\ <ol>\ <li><p>Get Firefox! Sidebars are only available in Firefox and you need to switch to Firefox in order to enjoy the convenience of Clipperz Compact.</p></li>\ <li>\ <p>Add the following URL to Firefox bookmarks, or even better, drag it to the bookmark bar.</p>\ <div id=\"compactLinkBox\"><a href=\"https://www.clipperz.com/beta/index.html?compact\" target=\"_search\">Clipperz Compact</a></div>\ </li>\ <li><p>Change the properties of the bookmark so that “load this bookmark in the sidebar” is checked.</p></li>\ </ol>\ \ <h5>Added bonus: Clipperz Compact works also in Opera’s panel.</h5>", // Tools panel - HTTP authentication - instructions 'httpAuthTabDescription': "\ <!-- FIX CSS DONE! --> \ <p>HTTP authentication is a method designed to allow a web browser to provide credentials – in the form of a username and password – including them in a website address (HTTP or HTTPS URL).</p>\ <p>Nowadays it is rarely used, but it can still be found on small, private websites. You can tell that a website is protected by HTTP authentication when the browser displays a pop-up window to enter username and password.</p>\ <p>Unfortunately the Clipperz bookmarklet does not work on websites that use HTTP authentication. However you can still create a “direct login”.</p>\ \ <h3>How to create a “direct login” for a website that uses HTTP authentication</h3>\ <ol>\ <li><p>Store website URL, username and password in a new card.</p></li>\ <li><p>Copy the configuration below and paste it to the large text area in the “Direct logins” section of the new card.</p></li>\ <li><p>Press the <b>Add direct login</b> button, bind URL, username and password fields and then click <b>Save</b>.</p></li>\ </ol>\ \ <h5><a href=\"http://support.microsoft.com/kb/834489\" target=\"_blank\">Warning: Internet Explorer does not support HTTP authentication.</a></h5>", // Direct logins block 'mainPanelDirectLoginBlockLabel': "Direct logins", 'directLinkReferenceShowButtonLabel': "show", // Direct logins - blank slate 'mainPanelDirectLoginBlockDescription': "\ diff --git a/frontend/gamma/js/Clipperz/PM/Toll.js b/frontend/gamma/js/Clipperz/PM/Toll.js index bb31c43..e9c3092 100644 --- a/frontend/gamma/js/Clipperz/PM/Toll.js +++ b/frontend/gamma/js/Clipperz/PM/Toll.js @@ -1,191 +1,189 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } //============================================================================= Clipperz.PM.Toll = function(args) { args = args || {}; this._requestType = args.requestType; this._targetValue = args.targetValue; this._cost = args.cost; this._toll = null; return this; } Clipperz.PM.Toll.prototype = MochiKit.Base.update(null, { 'toString': function() { return "Clipperz.PM.Toll (" + this.requestType() + ": " + this.cost() + " - " + ((this.toll() == null)? 'UNPAID' : 'PAID') + ")"; }, //------------------------------------------------------------------------- 'requestType': function() { return this._requestType; }, //------------------------------------------------------------------------- 'targetValue': function() { return this._targetValue; }, //------------------------------------------------------------------------- 'cost': function() { return this._cost; }, //------------------------------------------------------------------------- 'toll': function() { return this._toll; }, //------------------------------------------------------------------------- /* '__pay': function() { var result; var targetData; var targetMatchSize; var prefixMatchingBits; var payment; var i; if (this.toll() == null) { i = 0; targetData = new Clipperz.ByteArray("0x" + this.targetValue()); targetMatchSize = this.cost(); payment = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32); do { var paymentData; //payment = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32); payment.increment(); paymentData = Clipperz.Crypto.SHA.sha256(payment); // prefixMatchingBits = this.prefixMatchingBits(targetData, paymentData); prefixMatchingBits = Clipperz.ByteArray.prefixMatchingBits(targetData, paymentData); i++; } while (prefixMatchingBits < targetMatchSize); this._toll = payment.toHexString().substring(2) } return this; }, */ //------------------------------------------------------------------------- 'innerDeferredPay': function (aTargetValue, aCost, aPayment) { var deferredResult; var result; var payment; var i; result = null; payment = aPayment; i = 0; while ((result == null) && (i < Clipperz.PM.Toll.numberOfCloseLoopIterations)) { if (Clipperz.ByteArray.prefixMatchingBits(aTargetValue, Clipperz.Crypto.SHA.sha256(payment)) > aCost) { result = payment; } else { payment.increment(); } i ++; } if (result == null) { deferredResult = MochiKit.Async.callLater(Clipperz.PM.Toll.pauseBetweenEachCloseLoop, MochiKit.Base.method(this, 'innerDeferredPay', aTargetValue, aCost, aPayment)); } else { deferredResult = MochiKit.Async.succeed(result); } return deferredResult; }, 'deferredPay': function () { var deferredResult; var toll; toll = this; deferredResult = new Clipperz.Async.Deferred("Toll.deferredPay"); //deferredResult.addLog("--->>> deferredPay - " + this.cost()); deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'getRandomBytes', 32); deferredResult.addMethod(toll, 'innerDeferredPay', new Clipperz.ByteArray("0x" + this.targetValue()), this.cost()); deferredResult.addCallback(MochiKit.Base.bind(function(aPayment) { var result; result = { targetValue: this.targetValue(), toll: aPayment.toHexString().substr(2) }; return result; }, this)); //deferredResult.addLog("<<<--- deferredPay - " + this.cost()); deferredResult.callback(); return deferredResult; }, //========================================================================= __syntaxFix__: "syntax fix" }); Clipperz.PM.Toll.validate = function(aTargetValue, aToll, aCost) { var result; var tollValue; var targetValue; var hashedTollValue; var payedToll; tollValue = new Clipperz.ByteArray("0x" + aToll); targetValue = new Clipperz.ByteArray("0x" + aTargetValue); hashedTollValue = Clipperz.Crypto.SHA.sha256(tollValue); payedToll = Clipperz.ByteArray.prefixMatchingBits(targetValue, hashedTollValue); if (payedToll < aCost) { result = false; } else { result = true; } return result; }; Clipperz.PM.Toll.numberOfCloseLoopIterations = 50; Clipperz.PM.Toll.pauseBetweenEachCloseLoop = 0.5;
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/download.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/download.js index 25e82ca..f667526 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/download.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/download.js @@ -1,117 +1,115 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // download.js // Download // // Created by Giulio Cesare Solaroli on 3/15/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_CoverActions_downloadWidth = 46.0; var kClipperz_PM_UI_Canvas_CoverActions_downloadHeight = 46.0; function Clipperz_PM_UI_Canvas_CoverActions_download(canvas, aColor, aFillColor, aThickness) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var stroke; var path; var pointX; var pointY; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_CoverActions_downloadWidth + canvas.height / kClipperz_PM_UI_Canvas_CoverActions_downloadHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_CoverActions_downloadWidth, canvas.height / kClipperz_PM_UI_Canvas_CoverActions_downloadHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_CoverActions_downloadWidth, kClipperz_PM_UI_Canvas_CoverActions_downloadHeight); // arrow stroke = aThickness; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 16.5; pointY = 22.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 19.5; pointY = 8.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 30.038; pointY = 10.605; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.354; pointY = 24.354; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 33.28; pointY = 25.293; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 19.81; pointY = 36.828; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 10.07; pointY = 21.617; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 16.5; pointY = 22.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aFillColor; context.fill(); context.strokeStyle = aColor; context.lineWidth = stroke; context.lineCap = "square"; context.stroke(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/look.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/look.js index ba425ec..dae5a2d 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/look.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/CoverActions/look.js @@ -1,205 +1,203 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // look.js // Look // // Created by Giulio Cesare Solaroli on 3/15/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_CoverActions_lookWidth = 46.0; var kClipperz_PM_UI_Canvas_CoverActions_lookHeight = 46.0; function Clipperz_PM_UI_Canvas_CoverActions_look(canvas, aColor, aFillColor, aThickness) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var stroke; var path; var pointX; var pointY; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_CoverActions_lookWidth + canvas.height / kClipperz_PM_UI_Canvas_CoverActions_lookHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_CoverActions_lookWidth, canvas.height / kClipperz_PM_UI_Canvas_CoverActions_lookHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_CoverActions_lookWidth, kClipperz_PM_UI_Canvas_CoverActions_lookHeight); // Layer 6 stroke = aThickness; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.save(); context.translate(17.5, 23.0); context.rotate(-0.503); context.translate(-17.5, -23.0); context.beginPath(); pointX = 28.5; pointY = 31.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 28.5; pointY = 14.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 6.5; pointY = 14.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 6.5; pointY = 31.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 28.5; pointY = 31.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aFillColor; context.fill(); context.strokeStyle = aColor; context.lineWidth = stroke; context.lineCap = "square"; context.stroke(); context.restore(); // Layer 3 stroke = aThickness; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.save(); context.translate(22.5, 20.0); context.rotate(-0.071); context.translate(-22.5, -20.0); context.beginPath(); pointX = 33.5; pointY = 28.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 33.5; pointY = 11.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 11.5; pointY = 11.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 11.5; pointY = 28.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 33.5; pointY = 28.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aFillColor; context.fill(); context.strokeStyle = aColor; context.lineWidth = stroke; context.lineCap = "square"; context.stroke(); context.restore(); // Layer 4 stroke = aThickness; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.save(); context.translate(27.5, 18.0); context.rotate(0.232); context.translate(-27.5, -18.0); context.beginPath(); pointX = 38.5; pointY = 26.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 38.5; pointY = 9.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 16.5; pointY = 9.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 16.5; pointY = 26.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 38.5; pointY = 26.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aFillColor; context.fill(); context.strokeStyle = aColor; context.lineWidth = stroke; context.lineCap = "square"; context.stroke(); context.restore(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/directLogin.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/directLogin.js index 5c1f860..497fd05 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/directLogin.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/directLogin.js @@ -1,206 +1,204 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // directLogin.js // directLogin // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Features_directLoginWidth = 76.0; var kClipperz_PM_UI_Canvas_Features_directLoginHeight = 76.0; function Clipperz_PM_UI_Canvas_Features_directLogin(canvas, aColor, aBannerColor, aBannerBackgroundColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var stroke; var path; var pointX; var pointY; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Features_directLoginWidth + canvas.height / kClipperz_PM_UI_Canvas_Features_directLoginHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Features_directLoginWidth, canvas.height / kClipperz_PM_UI_Canvas_Features_directLoginHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Features_directLoginWidth, kClipperz_PM_UI_Canvas_Features_directLoginHeight); // Layer 2 stroke = 6.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 30.0; pointY = 41.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 45.579; pointY = 25.451; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.lineWidth = stroke; context.lineCap = "square"; context.stroke(); alignStroke = 0.0; context.beginPath(); pointX = 34.207; pointY = 45.697; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 24.101; pointY = 37.52; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 24.122; pointY = 47.828; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 34.207; pointY = 45.697; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); stroke = 6.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 24.631; pointY = 28.971; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 46.497; pointY = 26.451; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.stroke(); alignStroke = 0.0; context.beginPath(); pointX = 25.014; pointY = 35.265; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 22.166; pointY = 22.58; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 15.784; pointY = 30.675; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 25.014; pointY = 35.265; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); stroke = 6.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 42.282; pointY = 47.03; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 47.771; pointY = 25.714; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.stroke(); alignStroke = 0.0; context.beginPath(); pointX = 48.294; pointY = 48.929; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 35.432; pointY = 47.039; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 40.7; pointY = 55.899; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 48.294; pointY = 48.929; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/protect.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/protect.js index b829ed6..f015535 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/protect.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/protect.js @@ -1,234 +1,232 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // protect.js // protect // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Features_protectWidth = 76.0; var kClipperz_PM_UI_Canvas_Features_protectHeight = 76.0; function Clipperz_PM_UI_Canvas_Features_protect(canvas, aColor, aBannerColor, aBannerBackgroundColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; var stroke; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Features_protectWidth + canvas.height / kClipperz_PM_UI_Canvas_Features_protectHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Features_protectWidth, canvas.height / kClipperz_PM_UI_Canvas_Features_protectHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Features_protectWidth, kClipperz_PM_UI_Canvas_Features_protectHeight); // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 38.5; pointY = 36.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 37.068; pointY = 38.816; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 37.41; controlPoint1Y = 36.234; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 37.175; controlPoint2Y = 37.907; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 37.031; pointY = 40.802; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 36.991; controlPoint1Y = 39.474; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 36.98; controlPoint2Y = 40.141; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 37.258; pointY = 42.23; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 37.068; controlPoint1Y = 41.283; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 37.139; controlPoint2Y = 41.762; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 38.348; pointY = 43.979; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 37.402; controlPoint1Y = 42.799; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 37.682; controlPoint2Y = 43.798; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 38.5; pointY = 36.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 40.249; controlPoint1Y = 44.497; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 40.723; controlPoint2Y = 36.303; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 38.5; pointY = 36.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 50.0; pointY = 52.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 26.0; pointY = 52.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 26.0; pointY = 33.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 50.0; pointY = 33.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 50.0; pointY = 52.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 47.0; pointY = 32.463; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 38.0; pointY = 52.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 47.0; controlPoint1Y = 52.925; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 38.0; controlPoint2Y = 52.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 29.0; pointY = 32.463; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 38.0; controlPoint1Y = 52.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 29.0; controlPoint2Y = 52.925; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 47.0; pointY = 32.463; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 29.0; controlPoint1Y = 12.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 47.0; controlPoint2Y = 12.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.strokeStyle = aColor; stroke = 4.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; stroke *= 2.0; context.lineWidth = stroke; context.lineCap = "square"; context.save(); context.clip(); context.stroke(); context.restore(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/share.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/share.js index 8d73cc7..47972fc 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/share.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/share.js @@ -1,534 +1,532 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // share.js // share // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Features_shareWidth = 76.0; var kClipperz_PM_UI_Canvas_Features_shareHeight = 76.0; function Clipperz_PM_UI_Canvas_Features_share(canvas, aColor, aBannerColor, aBannerBackgroundColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; var stroke; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Features_shareWidth + canvas.height / kClipperz_PM_UI_Canvas_Features_shareHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Features_shareWidth, canvas.height / kClipperz_PM_UI_Canvas_Features_shareHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Features_shareWidth, kClipperz_PM_UI_Canvas_Features_shareHeight); // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 43.179; pointY = 18.621; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 37.163; pointY = 12.605; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 43.179; controlPoint1Y = 15.32; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 40.463; controlPoint2Y = 12.605; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 31.147; pointY = 18.621; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 33.863; controlPoint1Y = 12.605; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 31.147; controlPoint2Y = 15.32; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 37.163; pointY = 24.637; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 31.147; controlPoint1Y = 21.921; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 33.863; controlPoint2Y = 24.637; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 43.179; pointY = 18.621; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 40.463; controlPoint1Y = 24.637; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 43.179; controlPoint2Y = 21.921; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 56.548; pointY = 53.379; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 51.2; pointY = 48.032; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 56.548; controlPoint1Y = 50.446; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 54.134; controlPoint2Y = 48.032; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 45.853; pointY = 53.379; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 48.267; controlPoint1Y = 48.032; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 45.853; controlPoint2Y = 50.446; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 51.2; pointY = 58.727; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 45.853; controlPoint1Y = 56.313; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 48.267; controlPoint2Y = 58.727; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 56.548; pointY = 53.379; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 54.134; controlPoint1Y = 58.727; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 56.548; controlPoint2Y = 56.313; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 31.147; pointY = 38.674; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 25.8; pointY = 33.326; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 31.147; controlPoint1Y = 35.74; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 28.733; controlPoint2Y = 33.326; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 20.452; pointY = 38.674; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 22.866; controlPoint1Y = 33.326; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 20.452; controlPoint2Y = 35.74; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.8; pointY = 44.021; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.452; controlPoint1Y = 41.607; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 22.866; controlPoint2Y = 44.021; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 31.147; pointY = 38.674; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 28.733; controlPoint1Y = 44.021; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 31.147; controlPoint2Y = 41.607; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 39.168; pointY = 48.032; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 33.821; pointY = 42.684; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 39.168; controlPoint1Y = 45.098; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 36.754; controlPoint2Y = 42.684; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 28.473; pointY = 48.032; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 30.887; controlPoint1Y = 42.684; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 28.473; controlPoint2Y = 45.098; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 33.821; pointY = 53.379; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 28.473; controlPoint1Y = 50.965; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 30.887; controlPoint2Y = 53.379; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 39.168; pointY = 48.032; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 36.754; controlPoint1Y = 53.379; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 39.168; controlPoint2Y = 50.965; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 56.548; pointY = 29.984; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 53.206; pointY = 26.642; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 56.548; controlPoint1Y = 28.151; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 55.039; controlPoint2Y = 26.642; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 49.863; pointY = 29.984; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 51.372; controlPoint1Y = 26.642; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 49.863; controlPoint2Y = 28.151; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 53.206; pointY = 33.326; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 49.863; controlPoint1Y = 31.817; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 51.372; controlPoint2Y = 33.326; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 56.548; pointY = 29.984; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 55.039; controlPoint1Y = 33.326; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 56.548; controlPoint2Y = 31.817; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 49.863; pointY = 39.342; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 46.521; pointY = 36.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 49.863; controlPoint1Y = 37.509; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 48.355; controlPoint2Y = 36.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 43.179; pointY = 39.342; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 44.688; controlPoint1Y = 36.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 43.179; controlPoint2Y = 37.509; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 46.521; pointY = 42.684; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 43.179; controlPoint1Y = 41.176; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 44.688; controlPoint2Y = 42.684; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 49.863; pointY = 39.342; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 48.355; controlPoint1Y = 42.684; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 49.863; controlPoint2Y = 41.176; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); stroke = 1.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 37.163; pointY = 19.289; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 53.206; pointY = 29.984; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.lineWidth = stroke; context.lineCap = "square"; context.stroke(); stroke = 1.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 50.532; pointY = 54.048; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 37.163; pointY = 48.7; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.stroke(); stroke = 1.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 27.805; pointY = 33.995; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 33.153; pointY = 24.637; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.stroke(); stroke = 1.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); else stroke = Math.round(stroke); stroke /= resolution; alignStroke = (0.5 * stroke * resolution) % 1.0; context.beginPath(); pointX = 38.5; pointY = 24.637; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 45.184; pointY = 36.668; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.strokeStyle = aColor; context.stroke(); stroke = 1.0; stroke *= resolution; if (stroke < 1.0) stroke = Math.ceil(stroke); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/store.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/store.js index 572d9be..a4f30b2 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/store.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Features/store.js @@ -1,307 +1,305 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // store.js // store // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Features_storeWidth = 76.0; var kClipperz_PM_UI_Canvas_Features_storeHeight = 76.0; function Clipperz_PM_UI_Canvas_Features_store(canvas, aColor, aBannerColor, aBannerBackgroundColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Features_storeWidth + canvas.height / kClipperz_PM_UI_Canvas_Features_storeHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Features_storeWidth, canvas.height / kClipperz_PM_UI_Canvas_Features_storeHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Features_storeWidth, kClipperz_PM_UI_Canvas_Features_storeHeight); // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 27.0; pointY = 29.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 27.0; pointY = 24.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 24.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 29.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.0; pointY = 29.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 54.0; pointY = 29.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 54.0; pointY = 24.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 24.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 29.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 54.0; pointY = 29.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 43.0; pointY = 37.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 43.0; pointY = 32.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 32.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 37.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 43.0; pointY = 37.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 27.0; pointY = 37.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 27.0; pointY = 32.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 32.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 37.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.0; pointY = 37.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 27.0; pointY = 44.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 27.0; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 44.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.0; pointY = 44.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 46.0; pointY = 44.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 46.0; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 44.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 46.0; pointY = 44.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 40.0; pointY = 51.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 40.0; pointY = 46.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 46.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.0; pointY = 51.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 40.0; pointY = 51.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 27.0; pointY = 51.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 27.0; pointY = 46.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 46.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.0; pointY = 51.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.0; pointY = 51.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/GraphicFunctions.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/GraphicFunctions.js index b9443bd..dccefab 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/GraphicFunctions.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/GraphicFunctions.js @@ -1,65 +1,63 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Canvas'); MochiKit.Base.update(Clipperz.PM.UI.Canvas , { 'marks': { '!': Clipperz_PM_UI_Canvas_Marks_exclamationMark, '?': Clipperz_PM_UI_Canvas_Marks_questionMark, 'i': Clipperz_PM_UI_Canvas_Marks_info }, 'features': { 'store': Clipperz_PM_UI_Canvas_Features_store, 'protect': Clipperz_PM_UI_Canvas_Features_protect, 'directLogin': Clipperz_PM_UI_Canvas_Features_directLogin, 'share': Clipperz_PM_UI_Canvas_Features_share }, 'tips': { 'open': Clipperz_PM_UI_Canvas_Tips_open, 'close': Clipperz_PM_UI_Canvas_Tips_close }, 'star': { 'normal': Clipperz_PM_UI_Canvas_Star_normal }, 'coverActions': { 'look': Clipperz_PM_UI_Canvas_CoverActions_look, 'download': Clipperz_PM_UI_Canvas_CoverActions_download }, 'registerButton': { 'normal': Clipperz_PM_UI_Canvas_RegisterButton_normal }, 'logo': { 'normal': Clipperz_PM_UI_Canvas_Logo_normal }, __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Logo/normal.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Logo/normal.js index cc60bba..24c0bc3 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Logo/normal.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Logo/normal.js @@ -1,54 +1,52 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // normal.js // New Image // // Created by Giulio Cesare Solaroli on 2/13/12 // Copyright 2012 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Logo_normalWidth = 150.0; var kClipperz_PM_UI_Canvas_Logo_normalHeight = 39.0; function Clipperz_PM_UI_Canvas_Logo_normal(canvas, logo, fontSize, text_color) { var context = canvas.getContext("2d"); canvas.width = kClipperz_PM_UI_Canvas_Logo_normalWidth; canvas.height = kClipperz_PM_UI_Canvas_Logo_normalHeight; context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Logo_normalWidth, canvas.height / kClipperz_PM_UI_Canvas_Logo_normalHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Logo_normalWidth, kClipperz_PM_UI_Canvas_Logo_normalHeight); context.font = fontSize + " HelveticaNeue-Bold"; context.fillStyle = text_color; context.fillText(logo, 3, 30); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/exclamationMark.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/exclamationMark.js index 02f2f80..5982f0d 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/exclamationMark.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/exclamationMark.js @@ -1,277 +1,275 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // exclamationMark.js // ! // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Marks_exclamationMarkWidth = 50.0; var kClipperz_PM_UI_Canvas_Marks_exclamationMarkHeight = 50.0; function Clipperz_PM_UI_Canvas_Marks_exclamationMark(canvas, aColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Marks_exclamationMarkWidth + canvas.height / kClipperz_PM_UI_Canvas_Marks_exclamationMarkHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Marks_exclamationMarkWidth, canvas.height / kClipperz_PM_UI_Canvas_Marks_exclamationMarkHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Marks_exclamationMarkWidth, kClipperz_PM_UI_Canvas_Marks_exclamationMarkHeight); // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 26.499; pointY = 10.848; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 20.887; pointY = 11.584; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.395; controlPoint1Y = 10.802; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 22.175; controlPoint2Y = 11.078; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 20.013; pointY = 13.194; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.335; controlPoint1Y = 11.814; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.921; controlPoint2Y = 12.826; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 23.049; pointY = 28.788; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.243; controlPoint1Y = 15.448; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 22.589; controlPoint2Y = 26.35; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.027; pointY = 29.156; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 23.279; controlPoint1Y = 29.018; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 24.705; controlPoint2Y = 29.202; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.971; pointY = 11.354; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.809; controlPoint1Y = 25.384; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.971; controlPoint2Y = 12.826; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 26.499; pointY = 10.848; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.557; controlPoint1Y = 11.032; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 26.913; controlPoint2Y = 10.848; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 26.499; pointY = 10.848; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 24.337; pointY = 31.962; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 21.899; pointY = 32.882; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 23.463; controlPoint1Y = 31.962; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 22.589; controlPoint2Y = 32.284; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 20.703; pointY = 35.458; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.163; controlPoint1Y = 33.572; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 20.703; controlPoint2Y = 34.538; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.669; pointY = 38.08; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.703; controlPoint1Y = 36.47; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 20.979; controlPoint2Y = 37.344; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.015; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 22.405; controlPoint1Y = 38.77; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 23.325; controlPoint2Y = 39.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 26.821; pointY = 38.034; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.073; controlPoint1Y = 39.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 26.131; controlPoint2Y = 38.724; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.833; pointY = 35.55; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.465; controlPoint1Y = 37.344; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.833; controlPoint2Y = 36.194; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 26.683; pointY = 32.744; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.833; controlPoint1Y = 34.676; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.557; controlPoint2Y = 33.572; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.337; pointY = 31.962; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 26.085; controlPoint1Y = 32.238; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 25.211; controlPoint2Y = 31.962; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.337; pointY = 31.962; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 30.639; pointY = 38.402; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); context.fillStyle = aColor; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/info.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/info.js index fad5c10..2501992 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/info.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/info.js @@ -1,388 +1,386 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // info.js // i // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Marks_infoWidth = 50.0; var kClipperz_PM_UI_Canvas_Marks_infoHeight = 50.0; function Clipperz_PM_UI_Canvas_Marks_info(canvas, aColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; var color; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Marks_infoWidth + canvas.height / kClipperz_PM_UI_Canvas_Marks_infoHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Marks_infoWidth, canvas.height / kClipperz_PM_UI_Canvas_Marks_infoHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Marks_infoWidth, kClipperz_PM_UI_Canvas_Marks_infoHeight); // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 30.253; pointY = 37.436; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 28.505; pointY = 37.022; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.677; pointY = 35.09; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.953; controlPoint1Y = 36.792; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.677; controlPoint2Y = 36.47; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.631; pointY = 27.546; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.631; controlPoint1Y = 32.974; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.631; controlPoint2Y = 29.892; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.677; pointY = 19.726; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.631; controlPoint1Y = 24.97; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.677; controlPoint2Y = 21.612; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.535; pointY = 21.336; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.331; controlPoint1Y = 20.692; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 20.593; controlPoint2Y = 21.336; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.443; pointY = 22.762; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 19.397; controlPoint1Y = 21.52; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.305; controlPoint2Y = 22.532; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.283; pointY = 23.82; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.639; controlPoint1Y = 23.222; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 20.961; controlPoint2Y = 23.452; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.605; pointY = 24.97; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.513; controlPoint1Y = 24.05; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.605; controlPoint2Y = 24.602; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.651; pointY = 29.156; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.651; controlPoint1Y = 25.752; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.651; controlPoint2Y = 27.592; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.605; pointY = 35.228; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.651; controlPoint1Y = 31.364; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.651; controlPoint2Y = 34.216; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 20.823; pointY = 37.022; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.559; controlPoint1Y = 36.332; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.467; controlPoint2Y = 36.838; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.121; pointY = 37.436; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.363; controlPoint1Y = 37.206; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.857; controlPoint2Y = 37.298; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.121; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 18.937; controlPoint1Y = 37.62; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 18.983; controlPoint2Y = 38.77; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.503; pointY = 38.862; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.271; controlPoint1Y = 39.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.927; controlPoint2Y = 38.862; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 30.023; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.401; controlPoint1Y = 38.862; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 29.149; controlPoint2Y = 39.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 30.253; pointY = 37.436; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 30.299; controlPoint1Y = 38.77; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 30.391; controlPoint2Y = 37.62; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 30.253; pointY = 37.436; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 27.493; pointY = 13.976; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 27.125; pointY = 12.228; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.493; controlPoint1Y = 13.608; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.401; controlPoint2Y = 12.688; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.963; pointY = 11.63; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 26.849; controlPoint1Y = 11.998; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 26.113; controlPoint2Y = 11.63; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.513; pointY = 12.688; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 23.767; controlPoint1Y = 11.63; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 22.203; controlPoint2Y = 12.09; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.283; pointY = 14.942; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.145; controlPoint1Y = 13.148; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.145; controlPoint2Y = 14.436; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 22.801; pointY = 17.012; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.513; controlPoint1Y = 15.908; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.973; controlPoint2Y = 16.69; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 26.205; pointY = 16.69; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 23.399; controlPoint1Y = 17.288; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 25.791; controlPoint2Y = 17.058; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.493; pointY = 13.976; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 26.941; controlPoint1Y = 16.046; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.493; controlPoint2Y = 14.896; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.493; pointY = 13.976; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 30.851; pointY = 38.862; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); color = "#FFFFFF"; context.fillStyle = color; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/questionMark.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/questionMark.js index 5842828..9a8ac7d 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/questionMark.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Marks/questionMark.js @@ -1,435 +1,433 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // questionMark.js // ? // // Created by Giulio Cesare Solaroli on 3/7/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Marks_questionMarkWidth = 50.0; var kClipperz_PM_UI_Canvas_Marks_questionMarkHeight = 50.0; function Clipperz_PM_UI_Canvas_Marks_questionMark(canvas, aColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; var color; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Marks_questionMarkWidth + canvas.height / kClipperz_PM_UI_Canvas_Marks_questionMarkHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Marks_questionMarkWidth, canvas.height / kClipperz_PM_UI_Canvas_Marks_questionMarkHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Marks_questionMarkWidth, kClipperz_PM_UI_Canvas_Marks_questionMarkHeight); // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 24.118; pointY = 24.464; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 24.854; pointY = 23.406; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 24.118; controlPoint1Y = 24.05; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 24.44; controlPoint2Y = 23.636; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 29.454; pointY = 20.6; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 26.418; controlPoint1Y = 22.532; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 28.534; controlPoint2Y = 21.566; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 30.282; pointY = 17.794; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 29.868; controlPoint1Y = 20.232; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 30.282; controlPoint2Y = 19.082; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.2; pointY = 12.688; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 30.282; controlPoint1Y = 16.322; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 29.454; controlPoint2Y = 14.344; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 21.312; pointY = 10.664; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.636; controlPoint1Y = 11.492; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 23.382; controlPoint2Y = 10.664; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.886; pointY = 11.124; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 20.898; controlPoint1Y = 10.664; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 20.162; controlPoint2Y = 10.894; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 18.0; pointY = 14.666; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 19.104; controlPoint1Y = 11.676; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 18.0; controlPoint2Y = 14.068; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 18.598; pointY = 15.586; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 18.0; controlPoint1Y = 14.896; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 18.138; controlPoint2Y = 15.494; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.794; pointY = 15.908; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 19.012; controlPoint1Y = 15.678; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.426; controlPoint2Y = 15.77; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.36; pointY = 20.002; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 22.508; controlPoint1Y = 16.644; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 25.36; controlPoint2Y = 17.886; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.21; pointY = 21.704; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.36; controlPoint1Y = 20.738; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 25.084; controlPoint2Y = 21.198; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.058; pointY = 24.326; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 23.106; controlPoint1Y = 22.348; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.886; controlPoint2Y = 23.774; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 18.506; pointY = 25.936; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 18.736; controlPoint1Y = 24.556; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 18.506; controlPoint2Y = 25.338; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 20.898; pointY = 29.064; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 18.506; controlPoint1Y = 26.948; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.334; controlPoint2Y = 28.42; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 22.048; pointY = 29.156; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.22; controlPoint1Y = 29.156; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.726; controlPoint2Y = 29.202; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.268; pointY = 27.592; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 22.508; controlPoint1Y = 29.064; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 24.9; controlPoint2Y = 27.96; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.406; pointY = 26.856; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 25.406; controlPoint1Y = 27.454; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 25.544; controlPoint2Y = 26.994; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.118; pointY = 24.464; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 24.578; controlPoint1Y = 25.936; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 24.118; controlPoint2Y = 24.786; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 24.118; pointY = 24.464; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 23.06; pointY = 31.962; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 20.53; pointY = 32.928; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 22.186; controlPoint1Y = 31.962; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.22; controlPoint2Y = 32.33; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 19.426; pointY = 35.458; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 19.794; controlPoint1Y = 33.618; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.426; controlPoint2Y = 34.538; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 20.392; pointY = 38.08; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 19.426; controlPoint1Y = 36.47; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 19.702; controlPoint2Y = 37.344; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 22.738; pointY = 39.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 21.128; controlPoint1Y = 38.77; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 22.048; controlPoint2Y = 39.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.544; pointY = 38.034; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 23.796; controlPoint1Y = 39.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 24.854; controlPoint2Y = 38.724; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 26.556; pointY = 35.55; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 26.188; controlPoint1Y = 37.344; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 26.556; controlPoint2Y = 36.194; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 25.452; pointY = 32.744; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 26.556; controlPoint1Y = 34.676; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 26.326; controlPoint2Y = 33.618; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 23.06; pointY = 31.962; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 24.854; controlPoint1Y = 32.284; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 23.934; controlPoint2Y = 31.962; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 23.06; pointY = 31.962; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 32.214; pointY = 38.402; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); color = "#FFFFFF"; context.fillStyle = color; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/RegisterButton/normal.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/RegisterButton/normal.js index 2462d0e..65e5ca6 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/RegisterButton/normal.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/RegisterButton/normal.js @@ -1,400 +1,398 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // normal.js // normal // // Created by Giulio Cesare Solaroli on 3/24/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_RegisterButton_normalWidth = 282.0; var kClipperz_PM_UI_Canvas_RegisterButton_normalHeight = 93.0; function Clipperz_PM_UI_Canvas_RegisterButton_normal(canvas, aBackgroundColor, aDarkBackgroundColor, aLightColor, aDarkColor, aStarColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; var gradient; var color; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_RegisterButton_normalWidth + canvas.height / kClipperz_PM_UI_Canvas_RegisterButton_normalHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_RegisterButton_normalWidth, canvas.height / kClipperz_PM_UI_Canvas_RegisterButton_normalHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_RegisterButton_normalWidth, kClipperz_PM_UI_Canvas_RegisterButton_normalHeight); // background alignStroke = 0.0; context.beginPath(); pointX = 241.0; pointY = 80.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 274.0; pointY = 47.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 259.103; controlPoint1Y = 80.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 274.0; controlPoint2Y = 65.103; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 274.0; pointY = 45.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 241.0; pointY = 12.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 274.0; controlPoint1Y = 26.897; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 259.103; controlPoint2Y = 12.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 60.0; pointY = 12.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 27.0; pointY = 45.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 41.897; controlPoint1Y = 12.0; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 27.0; controlPoint2Y = 26.897; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 27.0; pointY = 47.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 60.0; pointY = 80.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 27.0; controlPoint1Y = 65.103; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 41.897; controlPoint2Y = 80.0; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 241.0; pointY = 80.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); gradient = context.createLinearGradient(150.5, 12.0, 150.5, 80.0); gradient.addColorStop(0.0, aBackgroundColor); gradient.addColorStop(1.0, aDarkBackgroundColor); context.fillStyle = gradient; context.fill(); // round alignStroke = 0.0; context.beginPath(); pointX = 44.103; pointY = 4.014; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 65.629; pointY = 10.515; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 51.706; controlPoint1Y = 4.217; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 59.185; controlPoint2Y = 6.475; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 78.65; pointY = 70.918; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 43.0; pointY = 90.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 70.676; controlPoint1Y = 82.788; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 57.23; controlPoint2Y = 89.817; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 0.056; pointY = 44.801; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 18.834; controlPoint1Y = 90.07; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = -1.18; controlPoint2Y = 68.879; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 44.103; pointY = 4.014; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 1.242; controlPoint1Y = 21.708; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 21.202; controlPoint2Y = 3.72; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 44.103; pointY = 4.014; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); gradient = context.createLinearGradient(39.326, 90, 39.326, 4.011); gradient.addColorStop(0.0, aDarkColor); gradient.addColorStop(1.0, aLightColor); context.fillStyle = gradient; context.fill(); // * alignStroke = 0.0; context.beginPath(); pointX = 23.983; pointY = 35.944; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 37.25; pointY = 40.261; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 37.25; pointY = 24.963; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 48.231; pointY = 24.963; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 48.231; pointY = 40.261; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 61.498; pointY = 35.944; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 64.481; pointY = 45.402; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 50.961; pointY = 49.592; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 59.784; pointY = 62.224; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 51.659; pointY = 68.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 42.836; pointY = 56.066; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 33.759; pointY = 68.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 25.634; pointY = 62.224; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 34.521; pointY = 49.592; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 21.0; pointY = 45.402; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 23.983; pointY = 35.944; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 68.607; pointY = 119.099; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); context.fillStyle = aStarColor; context.fill(); alignStroke = 0.0; context.beginPath(); pointX = 212.0; pointY = 125.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 213.0; pointY = 125.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 212.5; pointY = 124.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 212.0; pointY = 125.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); gradient = context.createLinearGradient(212.5, 125.0, 212.5, 124.0); color = "#FFFFFF"; gradient.addColorStop(0.0, color); color = "#A9A9A9"; gradient.addColorStop(1.0, color); context.fillStyle = gradient; context.fill(); // flip // Setup for Shadow Effect color = "rgba(0.0%, 0.0%, 0.0%, 0.5)"; context.save(); context.shadowColor = color; context.shadowBlur = 0.0; context.shadowOffsetX = 2.0 * Math.cos(8.377) * resolution; context.shadowOffsetY = 2.0 * Math.sin(8.377) * resolution; // round alignStroke = 0.0; context.beginPath(); pointX = 78.506; pointY = 70.251; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 66.155; pointY = 12.954; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 59.899; controlPoint1Y = 57.427; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 54.678; controlPoint2Y = 32.277; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 78.506; pointY = 70.251; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); gradient = context.createLinearGradient(69.301, 70.251, 69.301, 12.954); gradient.addColorStop(0.0, aDarkColor); gradient.addColorStop(1.0, aLightColor); context.fillStyle = gradient; context.fill(); // Shadow Effect context.restore(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Star/normal.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Star/normal.js index cf475c6..5b344ef 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Star/normal.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Star/normal.js @@ -1,150 +1,148 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // normal.js // normal // // Created by Giulio Cesare Solaroli on 3/15/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Star_normalWidth = 46.0; var kClipperz_PM_UI_Canvas_Star_normalHeight = 46.0; function Clipperz_PM_UI_Canvas_Star_normal(canvas, aColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Star_normalWidth + canvas.height / kClipperz_PM_UI_Canvas_Star_normalHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Star_normalWidth, canvas.height / kClipperz_PM_UI_Canvas_Star_normalHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Star_normalWidth, kClipperz_PM_UI_Canvas_Star_normalHeight); // * alignStroke = 0.0; context.beginPath(); pointX = 8.613; pointY = 15.583; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 18.563; pointY = 18.821; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 18.563; pointY = 7.347; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 26.799; pointY = 7.347; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 26.799; pointY = 18.821; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 36.749; pointY = 15.583; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 38.986; pointY = 22.677; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 28.846; pointY = 25.819; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 35.463; pointY = 35.293; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 29.369; pointY = 39.625; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 22.752; pointY = 30.675; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 15.944; pointY = 39.625; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 9.85; pointY = 35.293; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 16.515; pointY = 25.819; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 6.375; pointY = 22.677; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 8.613; pointY = 15.583; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); pointX = 42.081; pointY = 77.949; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); context.fillStyle = aColor; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/close.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/close.js index cd7ed90..21dfcc0 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/close.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/close.js @@ -1,153 +1,151 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // close.js // close // // Created by Giulio Cesare Solaroli on 3/14/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Tips_closeWidth = 310.0; var kClipperz_PM_UI_Canvas_Tips_closeHeight = 6.0; function Clipperz_PM_UI_Canvas_Tips_close(canvas, aColor, aBackgroundColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Tips_closeWidth + canvas.height / kClipperz_PM_UI_Canvas_Tips_closeHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Tips_closeWidth, canvas.height / kClipperz_PM_UI_Canvas_Tips_closeHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Tips_closeWidth, kClipperz_PM_UI_Canvas_Tips_closeHeight); // background alignStroke = 0.0; context.beginPath(); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 310.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aBackgroundColor; context.fill(); // grid // background alignStroke = 0.0; context.beginPath(); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 310.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aBackgroundColor; context.fill(); // toggle alignStroke = 0.0; context.beginPath(); pointX = 149.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 161.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 155.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 149.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aColor; context.fill(); context.restore(); } diff --git a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/open.js b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/open.js index 30c1c69..9c76865 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/open.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Canvas/Tips/open.js @@ -1,160 +1,158 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // // open.js // open // // Created by Giulio Cesare Solaroli on 3/14/10 // Copyright 2010 Clipperz // This code was generated by Opacity. You may use or modify it in any way. // var kClipperz_PM_UI_Canvas_Tips_openWidth = 310.0; var kClipperz_PM_UI_Canvas_Tips_openHeight = 6.0; function Clipperz_PM_UI_Canvas_Tips_open(canvas, aColor, aBackgroundColor) { var context = canvas.getContext("2d"); var alignStroke; var resolution; var path; var pointX; var pointY; var color; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kClipperz_PM_UI_Canvas_Tips_openWidth + canvas.height / kClipperz_PM_UI_Canvas_Tips_openHeight); context.save(); context.scale(canvas.width / kClipperz_PM_UI_Canvas_Tips_openWidth, canvas.height / kClipperz_PM_UI_Canvas_Tips_openHeight); context.clearRect(0.0, 0.0, kClipperz_PM_UI_Canvas_Tips_openWidth, kClipperz_PM_UI_Canvas_Tips_openHeight); // background alignStroke = 0.0; context.beginPath(); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 310.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aBackgroundColor; context.fill(); // grid // background alignStroke = 0.0; context.beginPath(); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 310.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 0.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 310.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); context.fillStyle = aBackgroundColor; context.fill(); // Layer 1 alignStroke = 0.0; context.save(); context.translate(155.0, 3.0); context.rotate(-3.142); context.translate(-155.0, -3.0); context.beginPath(); pointX = 149.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 161.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 155.0; pointY = 0.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 149.0; pointY = 6.0; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); color = "#FFFFFF"; context.fillStyle = color; context.fill(); context.restore(); context.restore(); } 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 b9d7adf..58b7593 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/BaseComponent.js @@ -1,612 +1,606 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); //############################################################################# var _Clipperz_PM_Components_base_id_ = 0; //############################################################################# Clipperz.PM.UI.Common.Components.BaseComponent = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.BaseComponent.superclass.constructor.call(this, args); this._element = args.element || null; this._ids = {}; this._slots = {}; this._slotComponents = {}; this._components = {}; this._cachedSlots = {}; this._isModal = false; this._isActive = false; this._elementUsedToEnterModalState; this._isFullyRendered = false; this._renderingWaitingQueue = []; // this._slots = { // 'header': 'header', // 'body': 'body', // 'footer': 'footer' // }; return this; } //============================================================================= //TODO get back to MochiKit.Base.update as we are not extending anything //MochiKit.Base.update(Clipperz.PM.UI.Common.Components.BaseComponent.prototype, { Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.BaseComponent, /*Ext.Component*/ Object, { 'isClipperzPMComponent': true, //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.BaseComponent component"; }, 'componentId': function () { return this.getId('_id_'); }, //------------------------------------------------------------------------- /* 'slots': function() { return this._slots; }, */ 'slotComponents': function() { return this._slotComponents; }, //------------------------------------------------------------------------- 'components': function () { return this._components; }, 'addComponent': function (aComponent) { this.components()[aComponent.componentId()] = aComponent; }, 'removeComponent': function (aComponent) { var componentId; componentId = aComponent.componentId(); this.components()[componentId].remove(); delete this.components()[componentId]; }, //------------------------------------------------------------------------- /* 'domHelper': function() { return Clipperz.YUI.DomHelper; }, */ //------------------------------------------------------------------------- /* 'domHelperAppend': function(aValue) { Clipperz.YUI.DomHelper.append(this.element().dom, aValue); }, */ //------------------------------------------------------------------------- 'element': function() { -//MochiKit.Logging.logDebug(">>> BaseComponent.element"); return MochiKit.DOM.getElement(this._element); }, 'setElement': function(aNode) { this._element = aNode; }, //----------------------------------------------------- 'displayElement': function() { return this.element(); }, //------------------------------------------------------------------------- 'renderInNode': function(aDomNode) { this.setElement(aDomNode); this.render(); }, 'render': function() { this.clear(); this.renderSelf(); this.renderComponents(); if (this.shouldShowTranslationHints()) { this.renderTranslationHints(); } if (this.shouldShowElementWhileRendering()) { MochiKit.Style.showElement(this.displayElement()); }; this._isFullyRendered = true; MochiKit.Iter.forEach(this.renderingWaitingQueue(), MochiKit.Base.methodcaller('callback')); this.resetRenderingWaitingQueue(); }, 'renderSelf': function() { throw Clipperz.Base.exception.AbstractMethod; }, 'renderComponents': function() { var slotName; for (slotName in this.slotComponents()) { this.slotComponents()[slotName].renderInNode(this.elementForSlotNamed(slotName)); } }, //......................................................................... 'isFullyRendered': function () { return this._isFullyRendered; }, //......................................................................... 'renderingWaitingQueue': function () { return this._renderingWaitingQueue; }, 'resetRenderingWaitingQueue': function () { this._renderingWaitingQueue = []; }, //......................................................................... 'waitUntilFullyRendered': function () { var deferredResult; if (this.isFullyRendered() == true) { deferredResult = MochiKit.Async.succeed } else { deferredResult = new Clipperz.Async.Deferred("BaseComponent.waitUntilFullyRendered", {trace:false}); this.renderingWaitingQueue().push(deferredResult); } return deferredResult; }, //----------------------------------------------------- 'renderTranslationHints': function () { var translatableItems; translatableItems = MochiKit.Selector.findChildElements(this.displayElement(), ['[stringID]']); MochiKit.Iter.forEach(translatableItems, MochiKit.Base.method(this, 'enhanceTranslatableElement')) }, 'enhanceTranslatableElement': function (anElement) { //Clipperz.log(">>> enhanceTranslatableElement", anElement); // new Clipperz.PM.UI.Common.Components.TranslatorWidget({ // 'element': anElement // }); MochiKit.Signal.connect(anElement, 'onmouseenter', MochiKit.Base.partial(Clipperz.PM.UI.Common.Components.TranslatorWidget.show, anElement, MochiKit.DOM.getNodeAttribute(anElement, 'stringID'))); MochiKit.Signal.connect(anElement, 'onmouseleave', Clipperz.PM.UI.Common.Components.TranslatorWidget.hide); //Clipperz.log("<<< enhanceTranslatableElement"); }, //----------------------------------------------------- 'update': function(args) { throw Clipperz.Base.exception.AbstractMethod; }, 'updateSelf': function(args) { throw Clipperz.Base.exception.AbstractMethod; }, 'updateComponents': function(args) { throw Clipperz.Base.exception.AbstractMethod; }, //----------------------------------------------------- 'refresh': function() { throw Clipperz.Base.exception.AbstractMethod; }, 'refreshSelf': function() { throw Clipperz.Base.exception.AbstractMethod; }, 'refreshComponents': function(args) { throw Clipperz.Base.exception.AbstractMethod; }, //----------------------------------------------------- 'checkSlotNamed': function(aSlotName) { if (typeof(this._slots[aSlotName]) == 'undefined') { throw new Error("undefined slot"); }; }, //----------------------------------------------------- 'cachedSlots': function() { return this._cachedSlots; }, 'slotNamed': function(aSlotName) { var result; this.checkSlotNamed(aSlotName); if (typeof(this.cachedSlots()[aSlotName]) == 'undefined') { this.cachedSlots()[aSlotName] = new Clipperz.PM.UI.Common.Components.ComponentSlot(this,aSlotName); } result = this.cachedSlots()[aSlotName]; return result; }, //----------------------------------------------------- 'elementForSlotNamed': function(aSlotName) { return MochiKit.DOM.getElement(this._slots[aSlotName]); }, //----------------------------------------------------- 'componentForSlotNamed': function(aSlotName) { return this.slotComponents()[aSlotName]; }, 'setComponentForSlotNamed': function(aComponent, aSlotName) { var domNode; this.checkSlotNamed(aSlotName); if (this.slotComponents()[aSlotName] != null) { this.slotComponents()[aSlotName].remove(); } this.slotComponents()[aSlotName] = aComponent; // domNode = MochiKit.DOM.getElement(this.slotNamed(aSlotName)); domNode = this.elementForSlotNamed(aSlotName); if (domNode != null) { aComponent.renderInNode(domNode); } }, //----------------------------------------------------- /* 'purgeListeners': function() { -//MochiKit.Logging.logDebug(">>> Clipperz.PM.UI.Common.Components.BaseComponent.purgeListeners [" + this + "]"); -//MochiKit.Logging.logDebug("--- " + this + ".purgeListeners"); Clipperz.NotificationCenter.unregister(this); MochiKit.Signal.disconnectAllTo(this); -//MochiKit.Logging.logDebug("<<< Clipperz.PM.UI.Common.Components.BaseComponent.purgeListeners"); }, */ //----------------------------------------------------- 'clear': function() { var slotName; var componentId; MochiKit.Signal.disconnectAllTo(this); for (slotName in this.slotComponents()) { this.slotComponents()[slotName].clear(); } for (componentId in this.components()) { this.components()[componentId].clear(); } // if (this.element() != null) { // this.element().innerHTML = ""; // } if (this.displayElement() != null) { if (this.element() != this.displayElement()) { MochiKit.DOM.removeElement(this.displayElement()); } else { this.displayElement().innerHTML = ""; } } if (this.isModal()) { // TODO: cleanup when the closed element was shown modally. } }, 'remove': function() { var slotName; var componentId; for (slotName in this.slotComponents()) { this.slotComponents()[slotName].remove(); delete this.slotComponents()[slotName]; } for (componentId in this.components()) { this.components()[componentId].remove(); delete this.components()[componentId]; } this.clear(); MochiKit.Signal.disconnectAll(this); }, 'append': function(aNode, aValue) { return Clipperz.DOM.Helper.append(aNode, aValue); }, 'insertBefore': function (aNode, aValue) { return Clipperz.DOM.Helper.insertBefore(aNode, aValue); }, 'insertAfter': function (aNode, aValue) { return Clipperz.DOM.Helper.insertAfter(aNode, aValue); }, //------------------------------------------------------------------------- 'getId': function(aValue) { var result; if (typeof(aValue) != 'undefined') { result = this._ids[aValue]; if (typeof(result) == 'undefined') { _Clipperz_PM_Components_base_id_ ++; result = "Clipperz_PM_Components_" + aValue + "_" + _Clipperz_PM_Components_base_id_; this._ids[aValue] = result; } } else { // result = Clipperz.PM.UI.Common.Components.BaseComponent.superclass.getId.call(this); throw "call to BaseComponent.getId with an undefined value"; } return result; }, 'getAnchor': function (aValue) { return '#' + this.getId(aValue); }, //------------------------------------------------------------------------- 'getElement': function(aValue) { return Clipperz.DOM.get(this.getId(aValue)); }, //------------------------------------------------------------------------- 'hideElement': function(anElementName) { MochiKit.Style.hideElement(this.getElement(anElementName)); }, 'showElement': function(anElementName) { MochiKit.Style.showElement(this.getElement(anElementName)); }, //------------------------------------------------------------------------- 'activate': function () { this._isActive = true; }, 'deactivate': function () { this._isActive = false; }, 'isActive': function () { return this._isActive; }, //------------------------------------------------------------------------- 'hideSlot': function(aSlotName) { if (this.componentForSlotNamed(aSlotName)) { this.componentForSlotNamed(aSlotName).deactivate(); } MochiKit.Style.hideElement(this.elementForSlotNamed(aSlotName)); }, 'showSlot': function(aSlotName) { if (this.componentForSlotNamed(aSlotName)) { this.componentForSlotNamed(aSlotName).activate(); } MochiKit.Style.showElement(this.elementForSlotNamed(aSlotName)); }, //------------------------------------------------------------------------- 'shouldShowTranslationHints': function () { return false; }, 'shouldShowElementWhileRendering': function() { return true; }, // 'shouldRemoveElementWhenClearningUp': function () { // return true; // }, //------------------------------------------------------------------------- 'isModal': function() { return this._isModal; }, 'setIsModal': function(aValue) { this._isModal = aValue; }, //------------------------------------------------------------------------- 'elementUsedToEnterModalState': function () { return this._elementUsedToEnterModalState; }, 'setElementUsedToEnterModalState': function (aValue) { this._elementUsedToEnterModalState = aValue; }, //------------------------------------------------------------------------- 'modalDialogMask': function () { return 'modalDialogMask'; }, 'modalDialog': function () { return 'modalDialog'; }, 'modalDialogFrame': function() { return 'modalDialogFrame' }, //------------------------------------------------------------------------- 'deferredShowModal': function(args) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("BaseComponent.deferredShowModal", {trace:false}); deferredResult.addMethod(this, 'setIsModal', true); deferredResult.addCallback(MochiKit.Style.showElement, this.modalDialogMask()); deferredResult.addCallback(MochiKit.Base.bind(function(someArgs) { var result; var duration; var from; var to; duration = someArgs.duration || 0.4; this.setElementUsedToEnterModalState(someArgs.openFromElement); from = Clipperz.Style.getSizeAndPosition(someArgs.openFromElement); this.renderInNode(this.modalDialog()); MochiKit.DOM.addElementClass(this.modalDialog(), 'fixed'); to = Clipperz.Style.getSizeAndPosition(this.displayElement()); Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition = Clipperz.Base.deepClone(to); MochiKit.Style.hideElement(this.displayElement()); MochiKit.Style.showElement(this.modalDialogFrame()); result = {from:from, to:to, duration:duration}; return result; }, this, args)); deferredResult.addCallback(Clipperz.Visual.deferredResize, this.modalDialogFrame()); deferredResult.addCallback(MochiKit.Base.bind(function(someArgs) { MochiKit.Style.hideElement(this.modalDialogFrame()); MochiKit.Style.showElement(this.displayElement()); }, this)); deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'deferredHideModal': function(args) { var deferredResult; args = args || {}; deferredResult = new Clipperz.Async.Deferred("BaseComponent.deferredHideModal", {trace:false}); deferredResult.addCallback(MochiKit.Base.bind(function(someArgs) { var result; var from; var toElement; var to; var duration; toElement = args.closeToElement || this.elementUsedToEnterModalState(); duration = someArgs.duration || 0.4; from = Clipperz.Style.getSizeAndPosition(this.displayElement()); to = Clipperz.Style.getSizeAndPosition(toElement); MochiKit.Style.hideElement(this.displayElement()); MochiKit.Style.showElement(this.modalDialogFrame()); result = {from:from, to:to, duration:duration}; return result; }, this, args)); deferredResult.addCallback(Clipperz.Visual.deferredResize, this.modalDialogFrame()); deferredResult.addCallback(MochiKit.Base.bind(function() { MochiKit.Style.hideElement(this.modalDialogFrame()); MochiKit.Style.hideElement(this.modalDialogMask()); }, this)); deferredResult.addMethod(this, 'setIsModal', false); deferredResult.addMethod(this, 'clear'); // ############## deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.PM.UI.Common.Components.BaseComponent_modalDialog = function() { Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:'modalDialogWrapper', cls:'modalDialogWrapper', children:[ {tag:'div', id:'modalDialogMask', cls:'modalDialogMask'}, {tag:'div', id:'modalDialogFrame', cls:'modalDialogFrame' /*, html:"modal dialog frame"*/}, {tag:'div', id:'modalDialog', cls:'modalDialog'} // {tag:'div', id:'modalDialog', cls:'modalDialog', children:[{tag:'div'}]} ]} ); // MochiKit.Style.hideElement('modalDialogWrapper'); MochiKit.Style.hideElement('modalDialogMask'); MochiKit.Style.hideElement('modalDialogFrame'); // MochiKit.Style.hideElement('modalDialog'); }; //Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition = {'x':'X', 'y':'Y'}; MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.BaseComponent_modalDialog); 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 1010c9d..1268118 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Button.js @@ -1,113 +1,111 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.Button = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.Button.superclass.constructor.apply(this, arguments); this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); this._isDefault = args.isDefault || false; this.render(); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Button, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.Button component"; }, //------------------------------------------------------------------------- 'text': function () { return this._text; }, 'isDefault': function () { return this._isDefault; }, //------------------------------------------------------------------------- 'renderSelf': function () { /* 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()} ]}, {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('button'), 'default'); } // 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('button'), 'hover'); }, 'handleOnMouseLeave': function (anEvent) { MochiKit.DOM.removeElementClass(this.getId('button'), 'hover'); MochiKit.DOM.removeElementClass(this.getId('button'), 'clicked'); }, 'handleOnMouseDown': function (anEvent) { 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/ComponentSlot.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ComponentSlot.js index 7f56c1e..2f82359 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ComponentSlot.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ComponentSlot.js @@ -1,61 +1,59 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); //############################################################################# Clipperz.PM.UI.Common.Components.ComponentSlot = function(aComponent, aSlotName) { this._component = aComponent; this._slotName = aSlotName; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.ComponentSlot, Object, { //------------------------------------------------------------------------- 'slotName': function() { return this._slotName; }, 'component': function() { return this._component; }, //------------------------------------------------------------------------- 'setContent': function(aComponent) { this.component().setComponentForSlotNamed(aComponent, this.slotName()); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js index 2db2489..bf00ffc 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/FaviconComponent.js @@ -1,88 +1,86 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.FaviconComponent = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.FaviconComponent.superclass.constructor.apply(this, arguments); this.render(); this.setSrc(args.src); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.FaviconComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.FaviconComponent component"; }, //------------------------------------------------------------------------- 'src': function () { return this.element().src; }, 'setSrc': function (aValue) { this.element().src = (aValue || Clipperz.PM.Strings.getValue('defaultFaviconUrl')); }, //------------------------------------------------------------------------- 'clear': function () {}, //------------------------------------------------------------------------- 'renderSelf': function () { MochiKit.Signal.connect(this.element(), 'onerror', this, 'setDefaultFavicon'); MochiKit.Signal.connect(this.element(), 'onabort', this, 'setDefaultFavicon'); MochiKit.Signal.connect(this.element(), 'onload', this, 'handleOnLoad'); }, //------------------------------------------------------------------------- 'setDefaultFavicon': function (anEvent) { MochiKit.Signal.disconnectAll(anEvent.src()); this.setSrc(null); }, 'handleOnLoad': function (anEvent) { MochiKit.Signal.disconnectAll(anEvent.src()); -//console.log("HANDLE ON LOAD", anEvent, anEvent.src().src); + if (anEvent.src().complete == false) { this.setSrc(null); } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js index 2788b79..020290b 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js @@ -1,161 +1,155 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar.superclass.constructor.apply(this, arguments); // this._openFromElement = args.openFromElement || null; this._onOkCloseToElement = args.onOkCloseToElement || null; this._onCancelCloseToElement = args.onCancelCloseToElement || null; this._canCancelWhileProcessing = ((typeof(args.canCancelWhileProcessing) == 'undefined') ? true : args.canCancelWhileProcessing); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar, Clipperz.PM.UI.Common.Components.SimpleMessagePanel, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar component"; }, //------------------------------------------------------------------------- /* 'openFromElement': function () { return this._openFromElement; }, */ //------------------------------------------------------------------------- 'onOkCloseToElement': function () { return this._onOkCloseToElement; }, 'setOnOkCloseToElement': function (anElement) { this._onOkCloseToElement = anElement; }, //------------------------------------------------------------------------- 'onCancelCloseToElement': function () { return this._onCancelCloseToElement; }, 'setOnCancelCloseToElement': function (anElement) { this._onCancelCloseToElement = anElement; }, //------------------------------------------------------------------------- 'canCancelWhileProcessing': function () { return this._canCancelWhileProcessing; }, //------------------------------------------------------------------------- 'deferredShowModal': function (someArgs, aResult) { if (someArgs['onOkCloseToElement'] != null) { this.setOnOkCloseToElement(someArgs['onOkCloseToElement']); } if (someArgs['onCancelCloseToElement'] != null) { this.setOnCancelCloseToElement(someArgs['onCancelCloseToElement']); } Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar.superclass.deferredShowModal.apply(this, arguments); return this.deferred(); }, //------------------------------------------------------------------------- 'showProgressBar': function () { var progressBarElement; this.getElement('container').innerHTML = ''; progressBarElement = this.append(this.getElement('container'), {tag:'div', cls:'progressBarWrapper'}); this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':progressBarElement})); if (this.canCancelWhileProcessing() == true) { this.setButtons([{text:"Cancel", result:'CANCEL'}]); } else { this.setButtons([]); } }, //------------------------------------------------------------------------- 'showFailure': function (someParameters) { // this.setType('ALERT'); this.setType(someParameters['type']); // this.setTitle("Login failed"); this.setTitle(someParameters['title']); // this.setText("Wrong passphrase; the unlock has failed."); this.setText(someParameters['text']); // this.getElement('container').innerHTML = ''; this.getElement('container').innerHTML = ''; // this.setButtons([{text:"Close", result:'CANCEL', isDefault:true}]); this.setButtons(someParameters['buttons']); }, //------------------------------------------------------------------------- 'closeOk': function () { -//console.log("=== closeOk"); this.showProgressBar(); MochiKit.Async.callLater(0.5, MochiKit.Base.method(this.deferred(), 'callback')); this._deferred = null; }, 'closeCancel': function () { -//console.log("=== closeCancel"); this.deferredHideModal({closeToElement:this.onCancelCloseToElement()}); this.deferred().cancel(); this._deferred = null; }, //------------------------------------------------------------------------- 'deferredDone': function () { -//console.log("=== deferredDone"); return this.deferredHideModal({closeToElement:this.onOkCloseToElement()}); }, 'deferredError': function (someParameters) { -//console.log("=== deferredError"); this.showFailure(someParameters); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js index 089e3d4..78e8c9b 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js @@ -1,137 +1,122 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay = function(anElement, args) { args = args || {}; -//MochiKit.Logging.logDebug(">>> new TextFormField"); Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay.superclass.constructor.call(this, anElement, args); this._wrapperElement = null; this._entropyElement = null; this.render(); -//MochiKit.Logging.logDebug("<<< new TextFormField"); return this; }; Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay, Clipperz.PM.UI.Common.Components.BaseComponent, { 'toString': function() { return "Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay"; }, //----------------------------------------------------- 'wrapperElement': function() { return this._wrapperElement; }, 'setWrapperElement': function(aValue) { this._wrapperElement = aValue; }, //----------------------------------------------------- 'passwordElement': function() { return this.element(); }, //----------------------------------------------------- 'entropyElement': function() { return this._entropyElement; }, 'setEntropyElement': function(aValue) { this._entropyElement = aValue; }, //----------------------------------------------------- 'render': function() { /* MochiKit.Signal.disconnectAllTo(this); this.setWrapperElement(this.element().wrap({tag:'div'})); this.setEntropyElement(Clipperz.DOM.Helper.append(this.wrapperElement().dom, {tag:'div', cls:'passwordEntropy', html:" "}, true)); // this.setEntropyElement(Clipperz.DOM.Helper.insertBefore(this.element(), {tag:'div', cls:'passwordEntropy', html:" "}, true)); this.entropyElement().wrap({tag:'div', cls:'passwordEntropyWrapper'}); this.updateEntropyElement(); this.connect('onkeyup', 'updateEntropyElement'); this.connect('onchange', 'updateEntropyElement'); this.connect('onblur', 'updateEntropyElement'); */ MochiKit.Signal.disconnectAllTo(this); this.setEntropyElement(this.element()); this.entropyElement().addClass("entropyLevelIndicator"); this.updateEntropyElement(); this.connect('onkeyup', 'updateEntropyElement'); this.connect('onchange', 'updateEntropyElement'); this.connect('onblur', 'updateEntropyElement'); }, //----------------------------------------------------- 'computeEntropyForString': function(aValue) { return Clipperz.PM.Crypto.passwordEntropy(aValue); }, //----------------------------------------------------- 'updateEntropyElement': function(anEvent) { -/* -//MochiKit.Logging.logDebug(">>> PasswordEntropyDisplay.updateEntropyElement"); - var maxExtent; - var entropy; - - entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); -//MochiKit.Logging.logDebug("--- PasswordEntropyDisplay.updateEntropyElement - entropy: " + entropy); - this.entropyElement().setStyle('background-position', "0px " + -entropy + "px"); - this.entropyElement().setWidth(this.passwordElement().getWidth() * (entropy/128)); -//MochiKit.Logging.logDebug("<<< PasswordEntropyDisplay.updateEntropyElement"); -*/ var entropy; entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); if (entropy == 0) { this.entropyElement().setStyle('background-position', "0px 26px"); } else { this.entropyElement().setStyle('background-position', "0px -" + (128-entropy)*26 + "px"); } }, //----------------------------------------------------- __syntaxFix__: '__syntaxFix__' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js index 5991530..6638008 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/ProgressBar.js @@ -1,70 +1,68 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.ProgressBar = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.ProgressBar.superclass.constructor.apply(this, arguments); this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); this.renderSelf(); MochiKit.Signal.connect(Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController, 'updateProgress', this, 'updateProgressHandler') return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.ProgressBar, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.ProgressBar component"; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(this.element(), {tag:'div', cls:'loadingBar', children:[ {tag:'div', cls:'loadingBarProgressBox', children:[ {tag:'div', id:this.getId('loadingBarProgress'), cls:'loadingBarProgress'} ]} ]}); }, //------------------------------------------------------------------------- 'updateProgressHandler': function (anEvent) { MochiKit.Style.setElementDimensions(this.getId('loadingBarProgress'), {w: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 1d816a9..8c98811 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js @@ -1,297 +1,287 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Common.Components.SimpleMessagePanel = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.SimpleMessagePanel.superclass.constructor.apply(this, arguments); this._title = args.title || Clipperz.Base.exception.raise('MandatoryParameter'); this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); this._type = args.type || Clipperz.Base.exception.raise('MandatoryParameter'); // ALERT, INFO, ERROR this._buttons = args.buttons || Clipperz.Base.exception.raise('MandatoryParameter'); this._buttonComponents = []; this._deferred = null; this.renderModalMask(); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.SimpleMessagePanel, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.SimpleMessagePanel component"; }, //------------------------------------------------------------------------- 'deferred': function() { if (this._deferred == null) { this._deferred = new Clipperz.Async.Deferred("SimpleMessagePanel.deferred", {trace:false}); } return this._deferred; }, //------------------------------------------------------------------------- 'title': function () { return this._title; }, 'setTitle': function (aValue) { this._title = aValue; if (this.getElement('title') != null) { this.getElement('title').innerHTML = aValue; } }, //------------------------------------------------------------------------- 'text': function () { return this._text; }, 'setText': function (aValue) { this._text = aValue; if (this.getElement('text') != null) { this.getElement('text').innerHTML = aValue; } }, //------------------------------------------------------------------------- 'type': function () { return this._type; }, 'setType': function (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 () { return this._buttons; }, 'setButtons': function (someValues) { MochiKit.Iter.forEach(this.buttonComponents(), MochiKit.Base.methodcaller('clear')); this._buttons = someValues; if (this.getElement('buttonArea') != null) { this.renderButtons(); } }, //......................................................................... 'buttonComponents': function () { return this._buttonComponents; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(this.element(), {tag:'div', cls:'SimpleMessagePanel', id:this.getId('panel'), 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:'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:[]} ]}); Clipperz.PM.UI.Canvas.marks[this.icon()](this.getElement('icon'), "#ffffff"); MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'keyDownHandler'); this.renderButtons(); }, //------------------------------------------------------------------------- 'renderButtons': function () { this.getElement('buttonArea').innerHTML = ''; MochiKit.Base.map(MochiKit.Base.bind(function (aButton) { var buttonElement; var buttonComponent; // element = this.append(this.getElement('buttonArea'), {tag:'div', cls:'button' + (aButton['isDefault'] === true ? ' default' : ''), children:[ // {tag:'a', href:'#'/*, id:this.getId('buttonLink')*/, html:aButton['text']} // ]}); buttonElement = this.append(this.getElement('buttonArea'), {tag:'div'}); buttonComponent = new Clipperz.PM.UI.Common.Components.Button({'element':buttonElement, 'text':aButton['text'], 'isDefault':aButton['isDefault']}); this.buttonComponents().push(buttonComponent); MochiKit.Signal.connect(buttonComponent, 'onclick', MochiKit.Base.method(this, 'buttonEventHandler', aButton)); }, this), MochiKit.Iter.reversed(this.buttons())); }, //------------------------------------------------------------------------- 'displayElement': function() { return this.getElement('panel'); }, //------------------------------------------------------------------------- 'closeOk': function () { this.deferred().callback(); this._deferred = null; }, 'closeCancel': function () { this.deferred().cancel(); this._deferred = null; }, 'closeError': function () { this.deferred().errback(); this._deferred = null; }, //------------------------------------------------------------------------- 'buttonEventHandler': function(aButton, anEvent) { anEvent.preventDefault(); // MochiKit.Signal.signal(this, 'cancelEvent'); switch (aButton['result']) { case 'OK': -//console.log("==> OK"); this.closeOk(); break; case 'CANCEL': -//console.log("==> CANCEL"); this.closeCancel(); break; default: -//console.log("==> ????"); this.closeError(); break; } -//console.log("<=="); }, //------------------------------------------------------------------------- 'deferredShow': function (someArgs, aResult) { this.deferredShowModal(someArgs); this.deferred().addMethod(this, 'deferredHideModal', {closeToElement:someArgs.onOkCloseToElement }); this.deferred().addErrback (MochiKit.Base.method(this, 'deferredHideModal', {closeToElement:someArgs.onCancelCloseToElement })); this.deferred().addCallback(MochiKit.Async.succeed, aResult); return this.deferred(); }, //------------------------------------------------------------------------- 'modalDialogMask': function () { return this.getId('modalDialogMask'); }, 'modalDialog': function () { return this.getId('modalDialog'); }, 'modalDialogFrame': function() { return this.getId('modalDialogFrame'); }, //------------------------------------------------------------------------- 'renderModalMask': function () { Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper simpleMessagePanelMask', children:[ {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask simpleMessagePanelMask'}, {tag:'div', id:this.getId('modalDialogFrame'), cls:'modalDialogFrame simpleMessagePanelMask'}, {tag:'div', id:this.getId('modalDialog'), cls:'modalDialog simpleMessagePanelMask'} ]} ); MochiKit.Style.hideElement(this.getId('modalDialogMask')); MochiKit.Style.hideElement(this.getId('modalDialogFrame')); }, //------------------------------------------------------------------------- 'keyDownHandler': function (anEvent) { if (anEvent.key().string == 'KEY_ENTER') { anEvent.preventDefault(); -//console.log("13 - RETURN ?", this); this.closeOk(); -//console.log('<<< 13') } if (anEvent.key().string == 'KEY_ESCAPE') { anEvent.preventDefault(); -//console.log("27 - ESC ?", this); this.closeCancel(); -//console.log("<<< 27"); } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js index 936514a..1e2a690 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js @@ -1,66 +1,64 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.TabPanelComponent = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.TabPanelComponent.superclass.constructor.call(this, args); this._tabPanelController = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.TabPanelComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { 'toString': function () { return "Clipperz.PM.UI.Common.Components.TabPanelComponent component"; }, //------------------------------------------------------------------------- 'tabPanelControllerConfiguration': function() { return this._tabPanelControllerConfiguration; }, 'tabPanelController': function() { if (this._tabPanelController == null) { this._tabPanelController = new Clipperz.PM.UI.Common.Controllers.TabPanelController({component:this, configuration:this.tabPanelControllerConfiguration()}); } return this._tabPanelController; }, 'initiallySelectedTab': function() { return this._initiallySelectedTab; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js index 8df7e0e..6517d2a 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js @@ -1,214 +1,205 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.Tooltip = function(args) { args = args || {}; Clipperz.PM.UI.Common.Components.Tooltip.superclass.constructor.apply(this, arguments); this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); this._position = args.position || 'BELOW'; // 'BELOW', 'ABOVE', 'LEFT', 'RIGHT' this._boxDimensions = null; this._enabled = (typeof(args.enabled) == 'undefined' ? true : args.enabled); this._isVisible = false; this.renderSelf(); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.Tooltip component"; }, //------------------------------------------------------------------------- 'text': function () { return this._text; }, 'setText': function (aValue) { this._text = aValue; }, //------------------------------------------------------------------------- 'position': function () { return this._position; }, 'setPosition': function (aValue) { this._position = aValue; }, //------------------------------------------------------------------------- 'enabled': function () { return this._enabled; }, 'setIsEnabled': function (aValue) { this._enabled = aValue; }, //------------------------------------------------------------------------- 'isVisible': function () { return this._isVisible; }, 'setIsVisible': function (aValue) { this._isVisible = aValue; }, //------------------------------------------------------------------------- 'renderSelf': function() { // this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ // this.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ {tag:'div', cls:'tooltip_text', children:[ {tag:'span', html:this.text()} ]}//, // {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} ]}, {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} ]}); this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); // this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; MochiKit.Style.hideElement(this.displayElement()); MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); }, //----------------------------------------------------- 'displayElement': function() { return this.getElement('tooltip'); }, //------------------------------------------------------------------------- 'boxDimensions': function () { return this._boxDimensions; }, //------------------------------------------------------------------------- 'show': function () { var elementSizeAndPosition; var arrowPosition; var bodyPosition; if (this.isVisible() == false) { arrowPosition = {}; bodyPosition = {}; this.setIsVisible(true); elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); -//console.log("ELEMENT SIZE AND POSITION", Clipperz.Base.serializeJSON(elementSizeAndPosition)); -//console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions())); switch (this.position()) { case 'ABOVE': -//console.log("ABOVE"); // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; // arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); // arrowPosition.y = elementSizeAndPosition.position.y - 13; break; case 'BELOW': -//console.log("BELOW"); // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; // arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); // arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; break; case 'LEFT': -//console.log("LEFT"); // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); // arrowPosition.x = elementSizeAndPosition.position.x -13; // arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); break; case 'RIGHT': -//console.log("RIGHT"); // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13; bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); // arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w; // arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); break; } -//console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y); MochiKit.Style.setElementPosition(this.getId('tooltip'), bodyPosition); // MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); // MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); } }, 'hide': function () { if (this.isVisible() == true) { MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); this.setIsVisible(false); } }, //------------------------------------------------------------------------- /* 'shouldRemoveElementWhenClearningUp': function () { return false; }, */ //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.PM.UI.Common.Components.Tooltip.initTooltips = function () { Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'}); } MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Common.Components.Tooltip.initTooltips); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js index c41fc7c..ba58edd 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js @@ -1,167 +1,165 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Common.Components.TranslatorWidget = function(args) { Clipperz.log(">>> TranslatorWidget.new"); args = args || {}; Clipperz.PM.UI.Common.Components.TranslatorWidget.superclass.constructor.apply(this, arguments); // this._element = args.element || Clipperz.Base.exception.raise('MandatoryParameter'); // this._stringID = args.stringID || MochiKit.DOM.getNodeAttribute(this.element(), 'stringID') || Clipperz.Base.exception.raise('MandatoryParameter'); // MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); // MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); Clipperz.log("<<< TranslatorWidget.new"); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.TranslatorWidget, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Common.Components.TranslatorWidget component"; }, //------------------------------------------------------------------------- /* 'renderSelf': function() { this.append(this.element(), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ {tag:'div', cls:'tooltip_text', children:[ {tag:'span', html:this.text()} ]}, {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} ]}, {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} ]}); this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); // this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; MochiKit.Style.hideElement(this.displayElement()); MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); }, */ //----------------------------------------------------- /* 'displayElement': function() { return this.getElement('tooltip'); }, */ //------------------------------------------------------------------------- /* 'boxDimensions': function () { return this._boxDimensions; }, */ //------------------------------------------------------------------------- 'show': function (anElement, aStringID) { Clipperz.log(">>> Clipperz.PM.UI.Common.Components.TranslatorWidget.show: " + aStringID); /* var elementSizeAndPosition; var arrowPosition; var bodyPosition; arrowPosition = {}; bodyPosition = {}; elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); switch (this.position()) { case 'ABOVE': MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); arrowPosition.y = elementSizeAndPosition.position.y - 13; break; case 'BELOW': MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; break; case 'LEFT': MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); arrowPosition.x = elementSizeAndPosition.position.x -13; arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); break; case 'RIGHT': MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); break; } // MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); */ }, //------------------------------------------------------------------------- 'hide': function () { Clipperz.log("<<< Clipperz.PM.UI.Common.Components.TranslatorWidget.hide"); // MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# Clipperz.PM.UI.Common.Components.TranslatorWidget._widget = null; Clipperz.PM.UI.Common.Components.TranslatorWidget.widget = function () { if (Clipperz.PM.UI.Common.Components.TranslatorWidget._widget == null) { Clipperz.PM.UI.Common.Components.TranslatorWidget._widget = new Clipperz.PM.UI.Common.Components.TranslatorWidget(); } return Clipperz.PM.UI.Common.Components.TranslatorWidget._widget; } Clipperz.PM.UI.Common.Components.TranslatorWidget.show = function (anElement, aStringID) { Clipperz.PM.UI.Common.Components.TranslatorWidget.widget().show(anElement, aStringID); } Clipperz.PM.UI.Common.Components.TranslatorWidget.hide = function () { Clipperz.PM.UI.Common.Components.TranslatorWidget.widget().hide(); } //############################################################################# diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js index 5fd10f9..77d59a5 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js @@ -1,264 +1,256 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); Clipperz.PM.UI.Common.Controllers.DirectLoginRunner = function(args) { this._directLogin = args['directLogin'] || Clipperz.Base.exception.raise('MandatoryParameter'); this._target = Clipperz.PM.Crypto.randomKey(); return this; } MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.prototype, { 'toString': function() { return "Clipperz.PM.UI.Common.Controllers.DirectLoginRunner"; }, //----------------------------------------------------------------------------- 'directLogin': function () { return this._directLogin; }, //----------------------------------------------------------------------------- 'target': function () { return this._target; }, //============================================================================= 'setWindowTitle': function (aWindow, aTitle) { aWindow.document.title = aTitle; }, 'setWindowBody': function (aWindow, anHTML) { aWindow.document.body.innerHTML = anHTML; }, //============================================================================= 'initialWindowSetup': function (aWindow) { this.setWindowTitle(aWindow, "Loading Clipperz Direct Login"); this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3("Loading Clipperz Direct Login ..."))); }, //----------------------------------------------------------------------------- 'updateWindowWithDirectLoginLabel': function (aWindow, aLabel) { var titleText; var bodyText; titleText = "Loading '__label__' Direct Login".replace(/__label__/, aLabel) bodyText = "Loading '__label__' Direct Login... ".replace(/__label__/, aLabel) this.setWindowTitle(aWindow, titleText); this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3(bodyText))); }, //----------------------------------------------------------------------------- 'updateWindowWithHTMLContent': function (aWindow, anHtml) { this.setWindowBody(aWindow, anHtml); }, //============================================================================= 'submitLoginForm': function(aWindow, aSubmitFunction) { MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function () { var formElement; var submitButtons; formElement = MochiKit.DOM.getElement('directLoginForm'); submitButtons = MochiKit.Base.filter(function(anInputElement) { return ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('type').toLowerCase() == 'submit')); }, formElement.elements); if (submitButtons.length == 0) { if (typeof(formElement.submit) == 'function') { formElement.submit(); } else { aSubmitFunction.apply(formElement); } /* var formSubmitFunction; formSubmitFunction = MochiKit.Base.method(formElement, 'submit'); if (Clipperz_IEisBroken == true) { formElement.submit(); } else { formSubmitFunction(); } */ } else { submitButtons[0].click(); } }, this)); }, //------------------------------------------------------------------------- 'runSubmitFormDirectLogin': function (aWindow, someAttributes) { var html; var formElement; var submitFunction; formElement = MochiKit.DOM.FORM({ 'id':'directLoginForm', 'method':someAttributes['formAttributes']['method'], 'action':someAttributes['formAttributes']['action'] }); submitFunction = formElement.submit; MochiKit.DOM.appendChildNodes(formElement, MochiKit.Base.map(function (anInputAttributes) { return MochiKit.DOM.INPUT({'type':'hidden', 'name':anInputAttributes[0], 'value':anInputAttributes[1]}); }, MochiKit.Base.items(someAttributes['inputValues']))); html = ''; html += '<h3>Loading ' + someAttributes['label'] + ' ...</h3>'; html += MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV(), MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV({style:'display:none; visibility:hidden;'}), formElement)).innerHTML; this.updateWindowWithHTMLContent(aWindow, html); this.submitLoginForm(aWindow, submitFunction); }, //------------------------------------------------------------------------- 'runHttpAuthDirectLogin': function(aWindow, someAttributes) { var completeUrl; var url; -//console.log("runHttpAuthDirectLogin", someAttributes); url = someAttributes['inputValues']['url']; if (/^https?\:\/\//.test(url) == false) { url = 'http://' + url; } if (Clipperz_IEisBroken === true) { completeUrl = url; } else { var username; var password; username = someAttributes['inputValues']['username']; password = someAttributes['inputValues']['password']; /(^https?\:\/\/)?(.*)/.test(url); completeUrl = RegExp.$1 + username + ':' + password + '@' + RegExp.$2; } window.open(completeUrl, this.target()); }, //============================================================================= 'runDirectLogin': function (aWindow) { var deferredResult; -//console.log(">>> runDirectLogin"); deferredResult = new Clipperz.Async.Deferred("DirectLoginRunner.openDirectLogin", {trace:false}); deferredResult.addMethod(this, 'initialWindowSetup', aWindow); deferredResult.addMethod(this.directLogin(), 'label'); deferredResult.addMethod(this, 'updateWindowWithDirectLoginLabel', aWindow); deferredResult.collectResults({ 'type': MochiKit.Base.method(this.directLogin(), 'type'), 'label': MochiKit.Base.method(this.directLogin(), 'label'), 'formAttributes': MochiKit.Base.method(this.directLogin(), 'formAttributes'), 'inputValues': MochiKit.Base.method(this.directLogin(), 'inputValues') }); -//deferredResult.addCallback(function (aValue) { console.log("SOME ATTRIBUTES", aValue); return aValue; }); deferredResult.addCallback(MochiKit.Base.bind(function (someAttributes) { -//console.log("SOME ATTRIBUTES", someAttributes); switch (someAttributes['type']) { case 'http_auth': this.runHttpAuthDirectLogin(aWindow, someAttributes); break; case 'simple_url': this.runSimpleUrlDirectLogin(aWindow, someAttributes); break; default: this.runSubmitFormDirectLogin(aWindow, someAttributes); break; } }, this)); deferredResult.callback(); -//console.log("<<< runDirectLogin"); return deferredResult; }, //============================================================================= 'run': function () { var newWindow; newWindow = window.open(Clipperz.PM.Strings.getValue('directLoginJumpPageUrl'), this.target()); return this.runDirectLogin(newWindow); }, //============================================================================= 'test': function () { var iFrame; var newWindow; iFrame = MochiKit.DOM.createDOM('iframe'); MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, iFrame); newWindow = iFrame.contentWindow; return this.runDirectLogin(newWindow); }, //============================================================================= __syntaxFix__: "syntax fix" }); //----------------------------------------------------------------------------- Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin = function (aDirectLogin) { var runner; runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin}); return runner.run(); }; //----------------------------------------------------------------------------- Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.testDirectLogin = function (aDirectLogin) { var runner; -//console.log(">>>>>> TESTING DIRECT LOGIN"); runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin}); return runner.test(); }; //----------------------------------------------------------------------------- diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js index 41fe17f..52d81d4 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js @@ -1,140 +1,138 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); Clipperz.PM.UI.Common.Controllers.ProgressBarController = function(args) { args = args || {}; this._numberOfSteps = 0; this._currentStep = 0; 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'); return this; } MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.ProgressBarController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Common.Controllers.ProgressBarController"; }, //----------------------------------------------------------------------------- 'numberOfSteps': function() { return this._numberOfSteps; }, 'setNumberOfSteps': function (aValue) { this._numberOfSteps = aValue; }, 'updateNumberOfSteps': function (aValue) { this._numberOfSteps += aValue; }, //----------------------------------------------------------------------------- 'currentStep': function() { return this._currentStep; }, 'advanceCurrentStep': function () { this._currentStep ++; }, //----------------------------------------------------------------------------- 'completedPercentage': function () { var result; //Clipperz.log(">>> completedPercentage" + this.currentStep() + "/" + this.numberOfSteps(), this.currentStep() / this.numberOfSteps()); if (this.numberOfSteps() == 0) { result = 0; } else { result = (Math.min(100, 100 * (this.currentStep() / this.numberOfSteps()))); } //Clipperz.log("<<< completedPercentage", result); return result; }, //----------------------------------------------------------------------------- 'resetStatus': function () { this._numberOfSteps = 0; this._currentStep = 0; }, //----------------------------------------------------------------------------- 'updateProgress': function () { //Clipperz.log(">>> updateProgress: " + this.completedPercentage() + "%"); MochiKit.Signal.signal(this, 'updateProgress', this.completedPercentage()); }, //============================================================================= 'initProgressHandle': function (anEvent) { //Clipperz.log(">>> initProgressHandle - steps: " + (anEvent != null ? anEvent['steps'] : 0)); this.resetStatus(); if (anEvent != null) { this.setNumberOfSteps(anEvent['steps']); } MochiKit.Signal.signal(this, 'initProgress'); this.updateProgress(); }, //............................................................................. 'updateProgressHandle': function (anEvent) { this.updateNumberOfSteps(anEvent['extraSteps']); //Clipperz.log("=== updateProgressHandle - steps: " + this.numberOfSteps() + " (extra " + anEvent['extraSteps'] + ")"); this.updateProgress(); }, //............................................................................. 'advanceProgressHandle': function (anEvent) { this.advanceCurrentStep(); //Clipperz.log("--- advanceProgressHandle: " + this.currentStep() + "/" + this.numberOfSteps()); this.updateProgress(); }, //............................................................................. 'progressDoneHandle': function (anEvent) { //Clipperz.log("<<< progressDoneHandle: " + this.currentStep() + "/" + this.numberOfSteps()); this.resetStatus(); MochiKit.Signal.signal(this, 'progressDone'); }, //============================================================================= __syntaxFix__: "syntax fix" }); Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController = new Clipperz.PM.UI.Common.Controllers.ProgressBarController(); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js index 341fde9..d3e86de 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js @@ -1,185 +1,183 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); Clipperz.PM.UI.Common.Controllers.TabPanelController = function(args) { args = args || {}; this._component = args.component; this._configuration = args.configuration; this._isEnabled = args.enabled || true; this._selectedTab = null; return this; } MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.TabPanelController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Common.Controllers.TabPanelController"; }, //----------------------------------------------------------------------------- 'component': function() { return this._component; }, 'configuration': function() { return this._configuration; }, //----------------------------------------------------------------------------- 'getElement': function(anElementID) { return this.component().getElement(anElementID); }, 'tabForTabElement': function(anElement) { var result; for (result in this.configuration()) { if (this.getElement(this.configuration()[result]['tab']) == anElement) { break; } } return result; }, //----------------------------------------------------------------------------- 'setupTab': function(aConfiguration) { var tabElement; tabElement = this.getElement(aConfiguration['tab']); MochiKit.DOM.removeElementClass(tabElement, 'selected'); MochiKit.Signal.connect(tabElement, 'onclick', this, 'handleTabClick') }, 'setupPanel': function(aConfiguration) { this.hidePanel(aConfiguration['panel']); }, 'setup': function(args) { args = args || {}; MochiKit.Base.map(MochiKit.Base.method(this, 'setupTab'), MochiKit.Base.values(this.configuration())); MochiKit.Base.map(MochiKit.Base.method(this, 'setupPanel'), MochiKit.Base.values(this.configuration())); this.selectTab(args.selected); }, //----------------------------------------------------------------------------- 'hidePanel': function(aPanel) { MochiKit.DOM.removeElementClass(this.getElement(aPanel), 'selected'); }, 'selectTab': function(aTab) { if ((aTab != this.selectedTab()) && (this.isEnabled())) { if (this.selectedTab() != null) { MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['tab']), 'selected'); MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['panel']), 'selected'); } if (aTab != null) { MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['tab']), 'selected'); MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['panel']), 'selected'); } this.setSelectedTab(aTab); MochiKit.Signal.signal(this, 'tabSelected', aTab); } }, //----------------------------------------------------------------------------- 'selectedTab': function() { return this._selectedTab; }, 'setSelectedTab': function(aTab) { this._selectedTab = aTab; }, //----------------------------------------------------------------------------- 'selectedTabElement': function() { var result; if (this.selectedTab() != null) { result = this.getElement(this.configuration()[this.selectedTab()]['tab']); } else { result = null; } return null; }, 'selectedTabPanelElement': function() { var result; if (this.selectedTab() != null) { result = this.getElement(this.configuration()[this.selectedTab()]['panel']); } else { result = null; } return result; }, //----------------------------------------------------------------------------- 'handleTabClick': function(anEvent) { this.selectTab(this.tabForTabElement(anEvent.src())); anEvent.preventDefault(); }, //============================================================================= 'isEnabled': function () { return this._isEnabled; }, 'enable': function () { this._isEnabled = true; MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) { MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled'); }, this), MochiKit.Base.keys(this.configuration())); }, 'disable': function () { this._isEnabled = false; MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) { MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled'); }, this), MochiKit.Base.keys(this.configuration())); }, //============================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js index ef38bc6..c13d96a 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js @@ -1,28 +1,26 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ // Still empty, but here it should be reasonable to factor in code duplicated between // - DirectLoginWizardController // - NewUserWizardController
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/UI/Compact/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/Compact/MainController.js index ea987cd..f0ccdfb 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Compact/MainController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Compact/MainController.js @@ -1,56 +1,54 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Compact'); Clipperz.PM.UI.Compact.MainController = function() { // this._loginPanel = null; // this._user = null; // // this._isRunningCompact = false; // // Clipperz.NotificationCenter.register(null, 'userConnected', this, 'userConnectedCallback'); // Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); // // Clipperz.NotificationCenter.register(null, 'EXCEPTION', this, 'reportException'); return this; } MochiKit.Base.update(Clipperz.PM.UI.Compact.MainController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Compact.MainController"; }, //----------------------------------------------------------------------------- 'run': function(shouldShowRegistrationForm) { -MochiKit.Logging.logDebug("running " + this.toString()); + Clipperz.logDebug("running " + this.toString()); }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" });
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js index 32dfa63..abf4758 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardDetail.js @@ -1,299 +1,293 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ 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/Mobile/Components/CardList.js b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js index a4aa212..a0e4879 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/CardList.js @@ -1,254 +1,248 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Mobile.Components'); Clipperz.PM.UI.Mobile.Components.CardList = function(args) { args = args || {}; Clipperz.PM.UI.Mobile.Components.CardList.superclass.constructor.apply(this, arguments); this._cardDetail = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Mobile.Components.CardList, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Mobile.Components.CardList component"; }, //------------------------------------------------------------------------- '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:'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.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(); } else { if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) { anEvent.target().value = ""; } if (anEvent.type() == 'keyup') { MochiKit.Signal.signal(this, 'searchEvent', anEvent.target().value); } } }, //------------------------------------------------------------------------- 'update': function (someObjects) { var cardListPanel; var i,c; cardListPanel = this.getElement('cardListPanel'); cardListPanel.innerHTML = ''; c = someObjects.length; for (i=0; i<c; i++) { this.append(cardListPanel, {tag:'li', cls:'cardListItem', id:('cardListItem_' + someObjects[i]['_reference']), children:[ {tag:'img', src:(someObjects[i]['favicon'] ? someObjects[i]['favicon'] : 'data:application/octet-stream;charset=utf-8;base64,AAABAAEAFxcAAAEAGAD8BgAAFgAAACgAAAAXAAAALgAAAAEAGAAAAAAAAAAAABIXAAASFwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////9zAC////////////////////////////////////////////////////////////////////////////////////////////9pAG////////////////////////////////////////////////////////////////////////////////////////////9rAC////////////////////////////////////////////////////////////////////////////////////////////9yAHP////////////////////////IyMizs7O6urrq6ur////////////Ozs6zs7Ozs7Pq6ur///////////////////////8AAAD////////////////////V1dWXl5eXl5eXl5elpaX4+Pj////Ozs6Xl5eXl5eXl5eenp7///////////////////////8AAAD////////////////////Ozs6Xl5eXl5eXl5eXl5fBwcHq6uqenp6Xl5eXl5eXl5eXl5f///////////////////////8AAAD////////////////////j4+OXl5eXl5eXl5eXl5eXl5elpaWXl5eXl5eXl5eXl5ezs7P///////////////////////8AAAD////////////////////////IyMiXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eenp7x8fH////////////////////////////////////////////////////4+PilpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5fOzs7////////////////////////////////////////////////////////q6uq6urqXl5eXl5eXl5eXl5eXl5eXl5eenp7V1dX4+Pj///////////////////////8AAAD////////////4+PjOzs6lpaWXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5e6urrj4+P///////////////8AAAD////////////BwcGXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fx8fH///////////8AAAD///////////+zs7OXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5eXl5fj4+P///////////8AAAD////////////IyMiXl5eXl5eXl5eXl5e6urqXl5eXl5eXl5eXl5esrKylpaWXl5eXl5eXl5eenp7x8fH///////////8AAAD////////////////Ozs7Ozs7V1dX4+Pj///+Xl5eXl5eXl5eXl5fOzs7////q6urOzs7Ozs7q6ur///////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD///////////////////////////////////+Xl5eXl5eXl5eXl5fOzs7///////////////////////////////////8AAAD////////////////////////////////////IyMiXl5eXl5eenp7x8fH///////////////////////////////////8AAAD////////////////////////////////////////j4+Pj4+Px8fH///////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAD///////////////////////////////////////////////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAo=')}, {tag:'a', id:('cardListReference_' + someObjects[i]['_reference']), href:'#', html:someObjects[i]['label']} ]}) MochiKit.Signal.connect('cardListItem_' + someObjects[i]['_reference'], 'onclick', this, 'cardListClickHandler'); } }, 'cardListClickHandler': function (anEvent) { anEvent.preventDefault(); if (/(cardListReference_|cardListItem_)/.test(anEvent.target().id)) { var cardListReference; cardListReference = anEvent.target().id.match(/(cardListReference_|cardListItem_)(.*)/)[2]; -//console.log("Showing detail for card named", cardListReference); MochiKit.Signal.signal(this, 'selectedCard', cardListReference); } }, //========================================================================= 'cardDetail': function (someData) { if (this._cardDetail == null) { this._cardDetail = new Clipperz.PM.UI.Mobile.Components.CardDetail({element:this.getElement('cardDetail')}); } return this._cardDetail; }, //------------------------------------------------------------------------- 'removeCardDetail': function () { if (this._cardDetail != null) { this._cardDetail.remove(); this._cardDetail = null; } }, //========================================================================= 'showCard': function (someData) { var deferredResult; var offset; offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); this.cardDetail().render(); this.cardDetail().setCardReference(someData['_reference']); MochiKit.Style.setElementPosition(this.cardDetail().element(), {x:offset}); new MochiKit.Visual.Sequence([ // new MochiKit.Visual.Move(this.cardDetail().element(), {x:offset, y:45, mode:'absolute', duration:0, sync:true}), new MochiKit.Visual.Parallel([ new MochiKit.Visual.Move(this.getElement('cardList'), {x:-offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:0, y:45, mode:'absolute', transition:MochiKit.Visual.Transitions.linear, sync:true}), // new MochiKit.Visual.ScrollTo('toolbar', {sync:true}), MochiKit.Visual.appear ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) ], {duration:1, sync:true}), MochiKit.Visual.fade(this.getElement('cardList'), {duration:0, sync:true}) ], {}) MochiKit.DOM.getElement('pageTitle').innerHTML = someData['title']; return true; }, //------------------------------------------------------------------------- 'showCardDetails': function (someData) { return this.cardDetail().showCardDetails(someData); }, //========================================================================= 'backButtonClickHandler': function (anEvent) { var offset; anEvent.preventDefault(); MochiKit.DOM.getElement('pageTitle').innerHTML = "cards"; offset = ((MochiKit.DOM.getNodeAttribute(MochiKit.DOM.currentDocument().body, 'orientation') == 'portrait') ? 320 : 480); MochiKit.Style.setElementPosition(this.getElement('cardList'), {x:-offset}); MochiKit.DOM.showElement(this.getElement('cardList')); new MochiKit.Visual.Parallel([ new MochiKit.Visual.Move(this.getElement('cardList'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), new MochiKit.Visual.Move(this.getElement('cardDetail'), {x:offset, y:0, mode:'relative', transition:MochiKit.Visual.Transitions.linear, sync:true}), MochiKit.Visual.fade (this.getElement('cardDetail'), { transition:MochiKit.Visual.Transitions.linear, sync:true}), MochiKit.Visual.fade ('backButton', { transition:MochiKit.Visual.Transitions.linear, sync:true}) ], {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 index eafcdbc..3aeac0c 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Components/LoginForm.js @@ -1,356 +1,347 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ 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 index 12a61f7..9951f44 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Mobile/Controllers/MainController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Mobile/Controllers/MainController.js @@ -1,393 +1,381 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Mobile.Controllers'); Clipperz.PM.UI.Mobile.Controllers.MainController = function() { - this._jQTouch = null; +// 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.initjQTouch(); // this.showAddToHomeScreenBaloon(); // this.selectInitialProxy(); }, - +/* 'initjQTouch': function () { var jqt; jqt = new $.jQTouch({ icon: 'data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAAHIAAAByCAIAAAAAvxIqAAAD8GlDQ1BJQ0MgUHJvZmlsZQAAKJGNVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIuxoVH1sNfIcHeNwfa6/9zdVappwMknkJsVz19HvFpgJSpO64PIN5G+fAp30Hc8TziHS4miFhheJbjLMMzHB8POFPqKGKWi6TXtSriJcT9MzH5bAzzHIK1I08t6hq6zHpRdu2aYdJYuk9Q/881bzZa8Xrx6fLmJo/iu4/VXnfH1BB/rmu5ScQvI77m+BkmfxXxvcZcJY14L0DymZp7pML5yTcW61PvIN6JuGr4halQvmjNlCa4bXJ5zj6qhpxrujeKPYMXEd+q00KR5yNAlWZzrF+Ie+uNsdC/MO4tTOZafhbroyXuR3Df08bLiHsQf+ja6gTPWVimZl7l/oUrjl8OcxDWLbNU5D6JRL2gxkDu16fGuC054OMhclsyXTOOFEL+kmMGs4i5kfNuQ62EnBuam8tzP+Q+tSqhz9SuqpZlvR1EfBiOJTSgYMMM7jpYsAEyqJCHDL4dcFFTAwNMlFDUUpQYiadhDmXteeWAw3HEmA2s15k1RmnP4RHuhBybdBOF7MfnICmSQ2SYjIBM3iRvkcMki9IRcnDTthyLz2Ld2fTzPjTQK+Mdg8y5nkZfFO+se9LQr3/09xZr+5GcaSufeAfAww60mAPx+q8u/bAr8rFCLrx7s+vqEkw8qb+p26n11Aruq6m1iJH6PbWGv1VIY25mkNE8PkaQhxfLIF7DZXx80HD/A3l2jLclYs061xNpWCfoB6WHJTjbH0mV35Q/lRXlC+W8cndbl9t2SfhU+Fb4UfhO+F74GWThknBZ+Em4InwjXIyd1ePnY/Psg3pb1TJNu15TMKWMtFt6ScpKL0ivSMXIn9QtDUlj0h7U7N48t3i8eC0GnMC91dX2sTivgloDTgUVeEGHLTizbf5Da9JLhkhh29QOs1luMcScmBXTIIt7xRFxSBxnuJWfuAd1I7jntkyd/pgKaIwVr3MgmDo2q8x6IdB5QH162mcX7ajtnHGN2bov71OU1+U0fqqoXLD0wX5ZM005UHmySz3qLtDqILDvIL+iH6jB9y2x83ok898GOPQX3lk3Itl0A+BrD6D7tUjWh3fis58BXDigN9yF8M5PJH4B8Gr79/F/XRm8m241mw/wvur4BGDj42bzn+Vmc+NL9L8GcMn8F1kAcXjEKMJAAAAACXBIWXMAAAsTAAALEwEAmpwYAAABbmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iPgogICAgICAgICA8ZGM6c3ViamVjdD4KICAgICAgICAgICAgPHJkZjpCYWcvPgogICAgICAgICA8L2RjOnN1YmplY3Q+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgrlPw1BAAAd7klEQVR4nO19eZQV13nn797a3tr7yg5ikxCIHRohkACBEFqsJY4z8T52nPHYPp74JJ54bMfOsRMf2Z44OZ7EJ16iDLIsS5ZlydJY+2Ii1haiAQFCNGvTNHS/9/pt9Wq93/xRb+9u6OU1wif9O3Wq6223bv3qu7/vu9+9txqYwAQmMIEJTGACE5jABCbwnxTs/a4AHnjggY0bNwohxl4U5/xnP/tZe3v72Iv6g8fDDz9MlcOHP/zh9/uCAEB+vysA27YBkHAh7KK3aSRlMIDAFcZl13UrW73R4f2nNQvXYGYMjANUROkVyWXZvbBIDcLXOH4VHBGuGVoBgAMMYGAAERhAeekfyC8r+svA3n8nUYxrilYXxAFkScz6sKENlgHkfc5AYmSyMc64dmglEOW4pOyOUSlZxS9Y4RVjIHeEcjy+uGZoJYBErmlTdk/5V0NQxnLkUgXiswrimqEVAIkcTQU685+BioJsyikAkDXbCVqHABWslcpopcJfopIuTIFZMSECQ0GAWBGJA2j13mQspw8MeRumayJczeNaorVMW7MxVqkUgIEox6Yo7CdEYAhQji+UuKxyWgcFA0SWWbompODaoRUD7K40Hri8dJIgIVjRt99fXEu0FhNKpWabbfulYJTthjGAXLqW5PVapRUYwGyuj1AcGGTBQAJiQgQGotDFQkFkBwkGcpZbiAK8nqsgEsC10te6FmglAESCeZFAltPiMGvQSAtALhYAsrSSmLDWLIg8Wt0iQgdoa7nXKupm5TuvwgW5NEFrFp6kilyEVGAWGERSvT0rsWgwkEtZeZ2g1YNnX1llRIHNYlq9Dy6Tc4EgciHcPzwRuP/++9Pp9KuvvuoNk1QKRAQIKjBSrABFx9l2P2jvgIFcCAFyxyNunTVj2h/dt82nad/8zg+G+ZPh0ur3+7/70HdnXTdrz54927dvf+qpp7q7u0dbzxJkaaVSESjYbFHbz3NKJSksIOuySFTSZQX8/lvWrPjQg3dvWr92UktTV/eFH/30kYu9fcP57XBpXbOmbebMGURi1apVq1at+upX/9czTz+9/ZGf79q1a8yjciKrjCgKPEvcF8o7tRggBiRIuCQqE2DNnjXjvrs2P3jvHTfMn6sosmmayWSiqaF2w/q2X/zqt8MpYbi0Pvjgg4xzYaXgpIhrLY31f/aZP//EJz6+e/fu7du3P/3Ms5cuXRrlRQjynHhRp55KDgbpdJUIQDbf6hnsGKw1FAysu3nlnzxw94Z1bfX1dY5tO44BV6gwDVcmId+7dWMlaa2urr5j8+0kXLgW4yoTJukpwSQu+2+5Ze0t69Z9/aunnvnts9t//os9e/aO/MIIwi2JBMqZ9YS1zGXlDgRlIwHhQjijE4F5c2Y9eM8dH7hr8/Vzr+MSt03TTPerkutTuCSrINW2kpaptK1YNG3KpLNdV1a/YdG6fv26GTNnuJbByQWTwRQmSZKwyYoLMya4Nqml4bOf+++f/PhHd+7c9cijjz373O96+4alQQCIBIQrhFuqrQNsVgwwWO/TbEfLJRJCjEyOqsKhDevaPnT/tnVrVtbVVlu27ZhpmVl+iWRNYpIMcIDAFZU5KcdsrK3efNuan2z/1RVLHhatD95/Hxgn12CMgbw0vgBjjKuMXC4M0pOOLklycMNt6zZsuPXUyZO/efq3jz72RPv+t69culegtxXKH0DrQB3wDgi5/quLgt+7AhbMn/PgvVvu2bpp7uyZnDPbNKx0ROW2ooBzCVwCGIQAIxCBQ1EVltZdV7l787qfPvLkFVvklWltbGzccNt6YWUYOeBK9pqLXQqXGeOycMiOuWZEcN/USY3/44uf+/QnP/YfO3c98ugvf/fiy9FobKjyCUTCpWy/s6jkkoNSqS3skR0vIEFCkHAvf7011VWb1q/54/vvXLt6WU11tW2ZrpngyAS5KyscXAI4iCBcMMpOWgBBEJd9CqKm6Vu2aP6cWdOOd54ZK60bb1s/eXKrldEVr7kVsZGj2LMRxrgqMUcSGaEnbV1SpNDmjetu33jric7Op37z7GNP/Lrj0DuD8SqyXU+IrHqW8VvSNSjrdCH7KYmsvA4RCSxaMO/Be7bcs3XDdTOnc8ZsM+2kuzVmKpwYl8A4gKx5gmXbfvYAAIFLqkyGaVZXBbfc2lYBWh+47wMggrCYoiBvU0DBlLIXKbLHTOIS4+SQExHxXof5Zk5p/PKXPv+ZT33s9zvefPTxJ198+fX+eKLAKuWttcxlDTDYEmXIcQoAjMj1rLXMZdXX1tx+25oPfmDrmpVLqsJh28oIIyKTHuK2JDEwzzxF1iVmzbOYU++MHIIpisYyumPL226/+V8efsK5bFh5BVqnTpmybm2bbegcAkzKznIgKr0wkXtHZAc/iAAwLktMSCIjMklHl/xSeNuWW7du3nj8vfd+/fRzv3zymSPHjgPw4k0ityhuHZTZPK2D9LgYuQRBJNyc11qy6Po/uueOu7asnzl9GgM5ZkKkzviZoXABzzwJIBdMADyXEfemKnnH3mwwBpY9KVc0hSVM01w0f9YN82YdPPLe6GndvOm2pqYGQ0+qipQjseiCy7qSVEqHRzTjXFI4OYrb5yZ6BfPNmd70lb/8/H/79Eff2LHz4UceD/h9wnUgRDmVA5kt7hqIXMo1a7ACwhWO01BX88cf2PpfHty2avnicDDgWDrpFxSk/MzmHGBSzr95I7gsSxwxMAbGQBxEYLl9Yd4CgUk+hWUyZtAf2Lph9eVpvdyMMMbYs089dsfmjbaR0nwhICthOZPMbdmXOUdMBLjZg8KnORUWthC2Q7LLw5K/1rJhGBlVVbmTCIme3J27jPvK39ocoV7YKpwENTtyfSaTqQqHOBPCjMsirrGMxAisaNJc9oCVHGT3vGjPAF7yDpfITvdG01wJH363c+uffskwraGou5y1zr5u1uoVSy0jI3MGzpF3CESFrcRsaWhNyHk2xjlXVHIh+pxkrwyfxqtclzMigmBe4UPSivLj3I6RICJBIqQJnjmnIqkwh/Gcz/ES5IUpiGzAxnPdNZ4z5LywMoDAOASYrGk8plvW/FlTFi+YvXv/kdHQeueWjbU11YaelNRAzsGW+qtyTUCRBytuy6LoHuQsl0myRDLpqptwhOxCAs9rqyj9eZk4oLQO3idCdmM+iqtM53nz9NpNfg4s5ayVsQK/xLPBMssJQj6uyjLLCxVgkk9T0knDFwjcuWHVaGiVJeneu7Y4tsVATFJzjRrZRsGkrBV4zV84gAPk55rJhebPvD6lneUUZVwzzmWVuSCzkJwelNlifoGi9gGAGEOIp4rUMN8pYIWDPJtULAI5YSWWlVTPeIlyFFPhJUHVfFKy3zLljWsWPxTwp/TMyGi94fp5S2+60TIzmqqAK1lCyYGdgHEJ+jlkeqB3I9MFMwonBWHBixaYDK5BqYIShlYPtR5qPbQGyAFwDRAQTqny5oKY7LG4HLNsqN6Bd0fzg4zFhKJgsN5Bll9WOChQyQr+iigXJOReCmKy6pPchG3Omtq84qZ5r+06MDJa7966KRTwZwxD0kIw+hB/B5G30H8QyfeQPgs7CVE6U7d4CmUxOMBlKGH4WhCYjPBchGbBPwVKFZgMYQFOSc+isC8S2WJmB0lxFZ14YAWGVFWAeM6JFcWqlJvmhXw8kL/xAJP9fiWRMWUlsO225SOjVVXVbXdstB3B4wfZwR8jfgiZbm9MpETlhwlyYMZgxNB/FHgZnEFrRGg2ahai5kb4WsEVCCvX0Sp2WZcV2QKzrNxy84QWuGalNpu3guIDzzsxEM/63oIs5E4toGh+hfWZlrxu5Q211aFYPDVcWpfedOON82dbtu07sx3nXoAMMEAaNo8DwQrXCBCMS8hcQu9OyBpCs1G/HLVL4WsGOMgqUl5RwmNJQrbIa5U4MZQ2HFa6L9PWHJvFzT8byeZdmWe2yPcLmKT6VYrp1pTm2jVL5z/32iDLwAan6rOf+si6taudZLev8/uM9MtGt6NC3mLIRaYXsQ707kD6JJgMrR5czWW1Sw22oLmicFDwhKUDt1lac28ylN+M4o0V3R42YI+8TXg/55ysVNqQZcVx3f/3+lsDr28Qaw0GA1s23mLarhTbzY3eETT20cEr30mjdw/69iA0E03rUbccchCuVS61JRRjQGCAIXWgzGAHD12pYLnFCpv3ltnvQPUFVClhWmbb4tnNDTUX+/rLrmkQa13btvxzn/pTx3H8p34o6acrb6qDIn91Vj+iB9D/NiDga4akFSVSS0W2kJbNezYxiCWiKH4o2CYKRoqylyh6M49SlyjJZCXTGVETDhzpPH/kRFfZ1Qxiivdu3SjLEqwos/rAclW9avDsJnMBpx7Fse8hsjuX3i7rK3sKkGfcBTyP5w6yCe99J7sXInec/0L+uLgXXlaOyKVmBFxTljiERcLdesvCgYvCyq21vq7277/2xYBPcUmyGjba1ctJDjA3ye1EiQ8Yb3iWaycQexv6afiaoNYOYrPFCuvZLyu24sGkEwXnM0iSM29BeYvOvvT8mG0Z6VS8Pxrpj6dcIsZITGqpf+a1t+NJvbj65dpaU1PTr4sWpgb8ZJrMrl5pVa9mdkxJHVajv1fi+ySjuxCNjDe8U/QfReokmtajcT0kDcIq19ZiOkRx+82FBPluqxdpZV96LTUfsRYrbD4lyMEIwrIsR8/YaUOYFhPEOGc+nyakQHfMfvPAKcMub86DcOMPBJctWXzX1k0bb1k5e3qzyoVlmrZgIMacmJI8rMb+Q020S2bP1eMXgABC0zH5bgSmQtil6RgM5rtQFJaiaPVmPmWFLI8exWVJLAYIsmxHN9y0CdOWXMEkiWmaRrK/O+buPnT2+df37W7viEUHGQy9HCWBYGjZ0sXbNm/YtG7ldVMbFeaYpukIBjBmx+TUEV//m2qyXTIvXSV+CZA0tNyO+lUA5TJqZfkt76v5lFXRz7MdqhyhJblBno1bGSCEabm6ibTJTVcWgnHONE2D7L8QFzs7zjz/RvvetzqikcsNLQ+LiVAovHz50js337rx5uUzJ9fJcEzTyPOrpo9o8Z1a8m3J6h13fj2aapegdQskX26tvCgIAkoNtpjZgoWiQKuXnQFBkGmLtMl1SzZdxSUmsSybPQnadfDM82+8tbu9IxrpHU41R0ZAuKp6xfKl225ff9vNS6a31Mhk5+2X21FFP+KL79bSHZLVN778CiA4FVPugVoHYZcSStkeUZmdUqm1slyClYRpU9qS05ZquqogLnFoqgol0JOgXYfOvfBG++72jkjfsNgsPuFoUFVds3LF0m2333rr6oXTmqs4WZZh2h6/TlRNH/Un92rpg5IdGdt5hgYBai0m3w3/lFzWsTgILRNZrw4sqwwgEmTZSFtK2tZMVxPEOSefpkEO9CRo9+FzL/x+/659HZG+Uc6AGuvlVtfUrlq5bNumdetWLpjaFOaukbNfcCem6cd8qX0+/bBkRytxtlIQIPsx6S6EZmXDg9IkbHZNYtZIyWPTdFjaUnXbbwgtZ5sKU4IXE9j9zrnn39i/u72jr3e088lyqNiF1tTWrV65bNumW25ZccOUBj9cwzQMhyQQSU5Myxzzp9p9maOSE6vkaT0n1roFoTmlNlv8DUFCmLaUtrW07TeFTxCXGGmaytTgxQT2HDn//Bv7d+07MHY286i8+NXW1betXHbnprVrl82bXOeHq5uG6RAHSLKjmvFuIH3AZxyR3HhlzkcAV9C6BaHZEFbuLQJAwjVsnra1tBOwXJ8LLjFomsKU4KUk9h7pfmHH2zv3Hui9dLEyNSnCOMZEdfUNa1Yvv3PjzTcvnt1aq1qZpG074DKE3dLzkM94r6I2q6J1CwLTiz2YcO2uRH1a1HLmSpxrgareFPYevfDCjgM79x64dLGnQqcfBFcjlG9oaFq9atmXPrF1drNmu7y2/8ma+PPjo7NboTVCONm3GExTnE22giu9Kf7dR/fs2nfgYs+Fip54cIx31g8A+vouvXfkQLWccYgH0vuqEy+NSwLXyaDnFVj9YJRPoGiq0+S7IFwnLOvxC+9eHU4xtoz/cFFbFfzJ331mxtRWlulqivxUEplxaSQMcE1YUQSn5YYLCUQ+2XZs02Hhm2+asWP/yUhcv3JRY8a408oY+9YXP7ipbaFppJqjD2t29zgKDwPsFIQF/6RszhAEICDrKZ35/eEFsxqf33ncssd90fG40/qRe9d+/sO3G5Zbl3gmnNk/7mLOACsCOQC1Nve4IcE480vpaEqZ3FRXHVJff+vUOFdinGldcv2M7//Vh7ikBvX2huSzjF2tfLjRC18zJBVwvTFwWRYK9IjuWzS7uTemHz5ZsRB1UIwjrXXVwX/+2kcmN9dzs6s18XNO5vidqxzChZNCYFJhDJHIp9iObacs36oFre3HLlzoG2QgulIYL1o5Y9/6wn23rZxvGqnW5KOqc+kqpWU9MMBOg6vQaiGc7AgCQ1DNJHXGJf+S2Y0vt59OG5VcDlmM8aL1o/e0ffZD6zOW25j+Xdg8dFU59cAAKw5/E7iUHxtnHAFFj6TkxprQpMbgK+1nhRgXXRoXWpfdMP2hv7iPMTlk7G/KvPg+cOpBuCAbvgbAzU/LlWWhwuhLaXOn1tiOaD82LiJbeVrra0I//OsPtjTUSGbXJP1JjiHn1g4fBObCx71JicOHJwVqFSStMEWDyKfZruP069ryufXHz/Wf7kmOvYZlqDCtnLNvf+6utUuvs8zU5MyTmohc+TfDQIJd183XVtNJjhGGnEQQJnz12bHu7KA3hTQjlWGuUJfNrdtxsKc/VYF7X4wK0/qxu1f+2QOrM6bbYr4Udt6tSJk2AmfZBh2NAAujfKLDFcAA14AczAVb3ui3YJyCqh5JKOGgOnty+OX9F2ynkg8oqyStyxdM/fvP30lMqrY7mqw3KlXsebQl0crI1NHoR9THRphRJIAs+Gqy8oqcyCpC40ZvXJveHPCr0puHRzascnlUjNaGmuA//dU9TXXVitU9xXp2xDo4BGI0s4dukmVFVv2upaepqYadldhIAiMGuBYUPyRvAVQu3iLh1yzhuNGUsmhWuCdqvNtVMZGtDK0SZ9/+7Ja2hdMcMznV+q1K5VO9RgcLwTNiraJoz3ck955yls/UdJMsBGt5F8NIAiMCIKAGQE7OYL2NQj4jpTPDkpbPDe873t8br4zIVobWT9y97JP3LDFMp9V5vYoq1eNmZ90VGTREDPVLP3jx1Z2Hbm5b0RpIJu2QDCvEoyMpCRA2VB84gRzABhwv6mJMhLRMJKFqsnTjjMArB6KGVQGRrQCtqxZM+daf3yZIqnEONou9Yy/QQ8Sd2ePMUzXtO788tq/juOvYh08n7ly3ULEjSVEX5n0qN0ZQHBE4QeagHKdwAAfkyIrjk81Lca2lRmmslt84FB84aDtSjJXWxtrgD/5iS311UHW6p4lXRhwADQGTQqesFYqqvPKO+Y+PvE4kAPT1RVJUs2Fxo5nRdVFdJ1/gbNiWxQC4UBhgAhZgASZgAzbI8fsM4VJfUp0/WdNN9+DpseZkx0SrJPFvf+bWlTe0OlZqOr2soTKST2Cn7SWGqIrZvr/84Y54vOD63zl+dsacBTe0WClDEiTVKMN9GAQACIJsg9s5g/U2G8wCOeFAOq3L6Yy89DrtaFemKzKmdMGYBl0+vm3hllXTM4bZSrsDGMkVXha99rSY1aCoyv95uvPc+ZJhEhLOd37y4ul0k8rNi2ZzxGoaQc+YADu3uqx4E4AQnNmzWroVnpK58+X7aifVjekJYaO31tU3TvrGJ9oEsTpxpIV1jKUSxciI0CljoSrLb7wn/uHnO2jAv9DJ6OnOXtq6ZiYykYRTXadEZD68YM67AXLpxKwiyIrwK+bFqFwToBmN/LXDpjta7zVKWptrg//7C+trw37N7ZkuvclRmS4KgZ/M3GC4wYQT/PKP9sX6B4/8z3f3SOFpa+aqum4YQmvwRYdrsjQ0rQQQ/D4HwrnUL2Y2urIk9p4Y5XWNhlZZ4t/6dNuyeQ2ulZol7VBZhQbdGHrMKT3GJJ9P/YdnL7751rHLfLfj3a6FixbPDEcSpswhqrT0cM/C8wsrSk6dR1XQSet2Im0vnCbOR9E5qrkZo9HWj985f9Oy1kzGnCy95WeVifwBpJ3QeX2KT3Z3nMCTLw6+Oi8P28x8+2c7+9gMmTLnUnVxMzBckXUGW7UhChtjmDtFaDKRiy9sYXNaRnMtI7bWpddP/btPLXcsUxAx2CEek1gF+qkC/ERytumqKVH11z85FIld+W4lEvGLRvj2pXVWui9l+xr8aWk4Y2UMkIdeZMIAwsUI+uLMcRFWae7U0IsdrjvCbPeIrTWq4534ZH+4hgkjYk9512hLuA0jLaQcDN16c9wMaKr845d6T545P8zfvfjavicO+INBLWWIU7HwsAw299C9QWyWwbJw5CSOnWa2RTKRG75+b3SRSyNmacTW2h9PPPf7w0r93KXzW5lx0XDkqNMCICTHR9ZPz4MhaQVPJqZqktjdFfrez9tH8pQw6jjeu2rFTc3y6f4MfLIb0obhZNhgXoujP4nDJ1kkwRmRX9N6fau/+ZT79ItvjfSpZRidy3Jsa+e+g8f7fCuWLq6VopZlxp26tBsKyYnhxjpFcIkf759qOUxntV95+L2+yJBPzBoUlmUcvcC2tE3imZP9GdQHSLlixMkHLIslnL2Io6eZYUEiClQ37+xf/pV/e+/YuydGejkeRh+3njp99qW3umdcv2JOM3P0vrQTiNl1Gjf88uBPLhgcDOcS9Zf0kN+n/vOr9ut7j4+iJn19EV2etm6+m0kldIs1hYfxT8nywQCHaeHoaZy5yEmQwsFqb/zZ/inff2RvMj6SbE4pxtR5TSbiz+84bIfmLF8wVTZ7TIeiVp0jpLCS5nxY3iNu+Dr76zXJab9Q/71fHBLuKL3fkc7emfOWzavp6U/ZnKE2dKWVj7k1WdF+HOpk0QTjRH6fv0dr+8avjedebSd3TJ3XsaZaSDhvdRw90MWXLl3WpMYsI5mwwgk7EFJ0VboCR47g70ZqLUeYvP6rj1y41Dey5l9aD/dAp75+9Y1V7tlomlX74fddllkJRDjTjSNnmGlBAgVqWndEl3714WMnOk+OvhqF4iuB890XXth7rmX2iuunqK7ek3HkSCascCekmkN6Z4bTsWBvSgoElH/dob2yp3OMdcjo6dPx6s3L6p1UbyLDmqsgDXVxHIaNd07iTA8jQSpnVLfox+0t//iLPelkZcLwig26ZPT0SzuP9MszVy6aqVldluVEjYDh8CrNlAYKAkNMlzojiipnDvRO/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 `<body>` 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.addCallback(function () { Clipperz.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.addCallback(function () { Clipperz.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.addCallback(function () { Clipperz.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'); +// 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.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 d6b0574..82c8dfd 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AccountPanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AccountPanel.js @@ -1,150 +1,148 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.AccountPanel = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.AccountPanel.superclass.constructor.apply(this, arguments); // this._initiallySelectedTab = args.selected || 'ACCOUNT'; this._initiallySelectedTab = args.selected || 'PASSPHRASE'; this._tabPanelControllerConfiguration = { // 'ACCOUNT': { // tab: 'accountTab', // panel: 'accountPanel' // }, 'PASSPHRASE': { tab: 'passphraseTab', panel: 'passphrasePanel' }, 'OTP': { tab: 'OTPTab', panel: 'OTPPanel' }, 'PREFERENCES': { tab: 'preferencesTab', panel: 'preferencesPanel' }, 'LOGIN_HISTORY': { tab: 'loginHistoryTab', panel: 'loginHistoryPanel' } }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.AccountPanel, Clipperz.PM.UI.Common.Components.TabPanelComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.AccountPanel component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { //Clipperz.log("AccountPanel.renderSelf element", this.element()); this.append(this.element(), [ {tag:'div', cls:'header', children:[ {tag:'div', cls:'subPanelTabs', children:[ {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'}]} ]} ]} ]}, {tag:'div', cls:'body', children:[ {tag:'div', cls:'accountPanel', children:[ {tag:'div', cls:'subPanelContent', children:[ {tag:'ul', children:[ // {tag:'li', id:this.getId('accountPanel'), children:[ // {tag:'h3', html:"-- Account --"} // ]}, {tag:'li', id:this.getId('passphrasePanel'), children:[ {tag:'h3', cls:'changePassphrase', html:"Change passphrase"}, {tag:'form', id:this.getId('changePassphrase'), cls:'changePassphrase', children:[ {tag:'div', cls:'currentCredentials', children:[ {tag:'div', cls:'field username', children:[ {tag:'label', html:"username", 'for':this.getId('currentUsername')}, {tag:'input', id:this.getId('currentUsername')} ]}, {tag:'div', cls:'field passphrase', children:[ {tag:'label', html:"passphrase", 'for':this.getId('currentPassphrase')}, {tag:'input', id:this.getId('currentPassphrase')} ]} ]}, {tag:'div', cls:'newPassphrase', children:[ {tag:'div', cls:'field', children:[ {tag:'label', html:"new passphrase", 'for':this.getId('newPassphrase')}, {tag:'input', id:this.getId('newPassphrase')} ]}, {tag:'div', cls:'field', children:[ {tag:'label', html:"re-new passphrase", 'for':this.getId('reNewPassphrase')}, {tag:'input', id:this.getId('reNewPassphrase')} ]} ]}, {tag:'div', cls:'confirm', children:[ {tag:'input', type:'checkbox', id:this.getId('confirm')}, {tag:'label', html:"I understand that Clipperz will not be able to recover a lost passphrase", 'for':this.getId('confirm')} ]} ]}, {tag:'div', cls:'clear'}, {tag:'div', cls:'confirmButton', id:this.getId('confirmationButton'), children:[ {tag:'span', html:"change passphrase"} ]} ]}, {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:'li', id:this.getId('loginHistoryPanel'), children:[ // {tag:'h3', html:"-- Login History --"} ]} ]} ]} ]} ]}, {tag:'div', cls:'footer'} ]); this.tabPanelController().setup({selected:this.initiallySelectedTab()}); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AppPage.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AppPage.js index 3b3c8b4..da5fd76 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AppPage.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/AppPage.js @@ -1,75 +1,73 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.AppPage = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.AppPage.superclass.constructor.call(this, args); this._element = args.element || null; this._slots = { 'cardGrid' : this.getId('cardGrid'), // 'directLoginGrid' : this.getId('directLoginGrid'), 'accountPanel': this.getId('accountPanel'), 'dataPanel': this.getId('dataPanel'), 'toolsPanel': this.getId('toolsPanel'), 'userInfoBox': this.getId('userInfoBox'), 'tabSidePanel': this.getId('tabSidePanel') }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.AppPage, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.AppPage component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), {tag:'div', id:this.getId('userInfoBox'), cls:'userInfoBox'}); this.append(this.element(), {tag:'div', id:this.getId('sidePanels'), cls:'sidePanels'}); this.append(this.getId('sidePanels'), {tag:'div', id:this.getId('tabSidePanel'), cls:'tabSidePanel', children:[]}); this.append(this.element(), {tag:'div', id:this.getId('mainPanels'), cls:'mainPanels'}); this.append(this.getId('mainPanels'), {tag:'div', id:this.getId('cardGrid'), cls:'gridComponent cardGrid'}); // this.append(this.getId('mainPanels'), {tag:'div', id:this.getId('directLoginGrid'), cls:'gridComponent directLoginGrid'}); this.append(this.getId('mainPanels'), {tag:'div', id:this.getId('accountPanel'), cls:'otherPanel'}); this.append(this.getId('mainPanels'), {tag:'div', id:this.getId('dataPanel'), cls:'otherPanel'}); this.append(this.getId('mainPanels'), {tag:'div', id:this.getId('toolsPanel'), cls:'otherPanel'}); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/BookmarkletComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/BookmarkletComponent.js index 1835ca9..4cfca32 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/BookmarkletComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/BookmarkletComponent.js @@ -1,106 +1,104 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.BookmarkletComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.BookmarkletComponent.superclass.constructor.apply(this, arguments); MochiKit.Signal.connect(Clipperz.PM.Strings.Languages, 'switchLanguage', this, 'updateBookmarkletURLs'); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.BookmarkletComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.BookmarkletComponent component"; }, //------------------------------------------------------------------------- 'renderSelf': function() { // var bookmarkletUrl; // // if (Clipperz_IEisBroken == true) { // bookmarkletUrl = bookmarklet_ie; // } else { /// bookmarkletUrl = bookmarklet; // bookmarkletUrl = Clipperz.PM.Strings['bookmarklet']; // } this.append(this.element(), {tag:'div', cls:'bookmarklet', children: [ {tag:'div', id:this.getId('linkBlock'), cls:'bookmarklet_link', children:[ // {tag:'a', id:this.getId('link'), href:bookmarkletUrl, children:[ {tag:'a', id:this.getId('link'), href:'#', children:[ {tag:'div', cls:'icon'}, {tag:'div', cls:'text', children:[ {tag:'span', html:"add to Clipperz"} ]} ]} ]} ]}); new Clipperz.PM.UI.Common.Components.Tooltip({ element: this.getElement('linkBlock'), text: "Drag and drop the \"add to Clipperz\" link above to the bookmark bar.", position: 'BELOW' }); MochiKit.Signal.connect(this.getId('link'), 'onclick', this, 'handleOnclick'); this.updateBookmarkletURLs(); }, //------------------------------------------------------------------------- 'handleOnclick': function (anEvent) { anEvent.preventDefault(); Clipperz.log("BOOKMARKLET CLICK"); }, //------------------------------------------------------------------------- 'updateBookmarkletURLs': function () { var bookmarkletUrl; if (Clipperz_IEisBroken == true) { bookmarkletUrl = bookmarklet_ie; } else { // bookmarkletUrl = bookmarklet; bookmarkletUrl = Clipperz.PM.Strings.getValue('bookmarklet'); } this.getElement('link').href = bookmarkletUrl; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js index af33d85..8bb64f5 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js @@ -1,878 +1,872 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.CardDialogComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.CardDialogComponent.superclass.constructor.apply(this, arguments); this._tabPanelController = null; this._tabPanelControllerConfiguration = { 'DETAILS': { tab: 'detailTab', panel: 'detailTabpanel' }, 'DIRECT_LOGINS': { tab: 'directLoginTab', panel: 'directLoginTabpanel' }, 'SHARING': { tab: 'sharingTab', panel: 'sharingTabpanel' } }; this._tooltips = null; this._isSavingEnabled = false; this._hintMode = 'OFF'; // 'ON' this._fieldComponents = {}; this._directLoginComponents = {}; this._displayMode = 'fixed'; // 'scrollable'; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.CardDialogComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.CardDialogComponent component"; }, //------------------------------------------------------------------------- 'tabPanelController': function () { if (this._tabPanelController == null) { this._tabPanelController = new Clipperz.PM.UI.Common.Controllers.TabPanelController({ component:this, configuration:this._tabPanelControllerConfiguration }); MochiKit.Signal.connect(this._tabPanelController, 'tabSelected', this, 'handleTabSelected') } return this._tabPanelController; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(this.element(), {tag:'div', cls:'CardDialog mainDialog loading', id:this.getId('panel'), children: [ {tag:'form', id:this.getId('form'), children:[ // {tag:'input', type:'text', id:this.getId('hidden'), cls:'hidden'}, {tag:'div', cls:'header', children:[ {tag:'div', cls:'title', children:[ {tag:'input', type:'text', id:this.getId('title')} ]} ]}, {tag:'div', id:this.getId('body'), cls:'body', children:[ {tag:'div', cls:'tabs', children:[ {tag:'ul', cls:'tabs', children:[ {tag:'li', id:this.getId('detailTab'), children:[{tag:'span', html:"details"}]}, {tag:'li', id:this.getId('directLoginTab'), children:[ {tag:'span', html:"direct logins"}//, // {tag:'div', id:this.getId('addDirectLoginButton'), cls:'addDirectLoginButton', children:[ // {tag:'span', html:"+"} // ]} ]}, {tag:'li', id:this.getId('sharingTab'), children:[{tag:'span', html:"sharing"}]} ]} ]}, {tag:'div', cls:'tabPanels', children:[ {tag:'ul', cls:'tabPanels', children:[ {tag:'li', id:this.getId('detailTabpanel'), cls:'tabPanel', children:[ {tag:'div', id:this.getId('recordFields'), children:[ {tag:'table', cls:'fields', cellpadding:'0', id:this.getId('fieldTable'), cellspacing:'0', children:[ {tag:'thead', children:[ {tag:'tr', children:[ {tag:'th', cls:'fieldStateTH', html:""}, {tag:'th', cls:'fieldLabelTH', html:"label"}, {tag:'th', cls:'fieldLockTH', html:""}, {tag:'th', cls:'fieldValueTH', html:"value"}, {tag:'th', cls:'fieldActionTH', html:""}, {tag:'th', cls:'fieldDeleteTH', html:""} ]} ]}, {tag:'tfoot'}, {tag:'tbody', id:this.getId('tableBody'), children:[ {tag:'tr', id:this.getId('newFieldTR'), cls:'newFieldTR', children:[ {tag:'td', cls:'fieldState'}, {tag:'td', cls:'fieldLabel', children:[ {tag:'input', cls:'label', id:this.getId('newFieldLabel')} ]}, {tag:'td', cls:'fieldLock', children:[ {tag:'div', cls:'unlocked', id:this.getId('newFieldIsLocked')} ]}, {tag:'td', cls:'fieldValue', children:[ {tag:'div', cls:'unlocked', id:this.getId('newFieldValueWrapper'), children:[ {tag:'input', type:'text', cls:'value', id:this.getId('newFieldValue')} ]} ]}, {tag:'td', cls:'fieldAction', children:[ {tag:'div', html:' '} ]}, {tag:'td', cls:'fieldAddDelete', children:[ {tag:'div', cls:'new', children:[ {tag:'span', children:[ {tag:'a', href:'#', id:this.getId('newFieldAddButton'), html:"add"} ]} ]} ]} ]} ]} ]} ]}, {tag:'div', cls:'notes', children:[ {tag:'div', children:[ {tag:'textarea', id:this.getId('recordNote'), value:""} ]} ]} ]}, {tag:'li', id:this.getId('directLoginTabpanel'), cls:'tabPanel', children:[ {tag:'div', id:this.getId('directLoginsComponentContainer'), cls:'directLoginsComponentContainer', children:[ {tag:'div', id:this.getId('directLogins'), cls:'directLogins', children:[ {tag:'div', id:this.getId('addNewDirectLoginSplash'), cls:'addNewDirectLoginSplash', children:[ {tag:'h3', html:"Here you can add a Direct Login for this card: instant access to your favorit website!"}, {tag:'a', href:'#', id:this.getId('addNewDirectLoginSplashButton'), children:[{tag:'span', html:"Add Direct Login"}]} ]}, {tag:'div', id:this.getId('directLoginsList')}, {tag:'div', cls:'addDirectLoginListItem', id:this.getId('addDirectLoginListItem'), children:[{tag:'a', href:'#', id:this.getId('addNewDirectLoginListItemButton'), children:[{tag:'span', html:"Add Direct Login"}]}]} ]}, {tag:'div', id:this.getId('directLoginEditDetail'), cls:'directLoginEditDetail'} ]} ]}, {tag:'li', id:this.getId('sharingTabpanel'), cls:'tabPanel', children:[ {tag:'h2', html:"Coming soon!"} ]} ]} ]}, {tag:'div', cls:'mask', children:[ {tag:'div', id:this.getId('progress'), children:[ {tag:'h3', id:this.getId('progressDescription'), cls:'progressDescription', html:"Loading"}, {tag:'div', id:this.getId('progressBar')} ]}, {tag:'div', id:this.getId('error'), cls:'error', children:[ {tag:'div', cls:'img'}, {tag:'p', id:this.getId('errorMessage')} ]} ]} ]}, {tag:'div', cls:'footer', children:[ {tag:'div', cls:'buttonArea', children:[ {tag:'div', cls:'cancel', id:this.getId('cancelButton'), html:"cancel"}, {tag:'div', cls:'save disabled', id:this.getId('saveButton'), html:"save"} ]} ]} ]} ]}); this.insertAllTooltips(); this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':this.getElement('progressBar')})); this.tabPanelController().setup({selected:'DETAILS'}); // this.tabPanelController().setup({selected:'DIRECT_LOGINS'}); MochiKit.Style.hideElement(this.getId('error')); MochiKit.Style.hideElement(this.getElement('directLoginEditDetail')); MochiKit.Style.hideElement(this.getElement('addDirectLoginListItem')); this.plumbDetailsPanel(); MochiKit.Signal.connect(this.getId('cancelButton'), 'onclick', this, 'handleCancelEvent'); MochiKit.Signal.connect(this.getId('saveButton'), 'onclick', this, 'handleSaveEvent'); MochiKit.Signal.connect(this.getId('addNewDirectLoginSplashButton'), 'onclick', this, 'handleAddDirectLogin'); MochiKit.Signal.connect(this.getId('addNewDirectLoginListItemButton'), 'onclick', this, 'handleAddDirectLogin'); MochiKit.Signal.connect(MochiKit.DOM.currentDocument().body, 'onkeydown', this, 'handleKeyEvent'); }, //------------------------------------------------------------------------- 'displayMode': function () { return this._displayMode; }, 'setDisplayMode': function (aValue) { this._displayMode = aValue; }, //------------------------------------------------------------------------- 'plumbDetailsPanel': function () { MochiKit.Signal.connect(this.getId('title'), 'onfocus', MochiKit.Base.method(this, 'handleOnFocusEvent', this.getElement('title').parentNode)); MochiKit.Signal.connect(this.getId('title'), 'onblur', MochiKit.Base.method(this, 'handleLooseFocusEvent', this.getElement('title').parentNode)); MochiKit.Signal.connect(this.getId('title'), 'onchange', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('title'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('recordNote'), 'onfocus', MochiKit.Base.method(this, 'handleOnFocusEvent', MochiKit.Selector.findChildElements(this.element(), ['div.notes'])[0])); MochiKit.Signal.connect(this.getId('recordNote'), 'onblur', MochiKit.Base.method(this, 'handleLooseFocusEvent', MochiKit.Selector.findChildElements(this.element(), ['div.notes'])[0])); MochiKit.Signal.connect(this.getId('recordNote'), 'onchange', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('recordNote'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('newFieldValue'), 'onkeydown', this, 'handleKeyDownOnNewFieldValue'); MochiKit.Signal.connect(this.getId('newFieldLabel'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('newFieldIsLocked'), 'onclick', this, 'toggleNewFieldIsHidden'); MochiKit.Signal.connect(this.getId('newFieldValue'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('newFieldAddButton'), 'onclick', this, 'handleAddClick'); }, //------------------------------------------------------------------------- 'insertAllTooltips': function () { var tooltips; var tooltipEnabled; tooltips = {}; tooltipEnabled = (this.hintMode() == 'ON'); tooltips['title'] = new Clipperz.PM.UI.Common.Components.Tooltip({ 'element': this.getElement('title'), 'text': "Insert here the title of the card", 'position': 'RIGHT' }); this.addComponent(tooltips['title']); MochiKit.Signal.connect(this.getId('title'), 'onfocus', MochiKit.Base.method(this, 'showTooltipOnFocus', 'title')); MochiKit.Signal.connect(this.getId('title'), 'onblur', MochiKit.Base.method(this, 'hideTooltipOnBlur', 'title')); tooltips['newFieldTR'] = new Clipperz.PM.UI.Common.Components.Tooltip({ 'element': this.getElement('newFieldTR'), 'text': "Insert your card new values here", 'position': 'RIGHT' }); this.addComponent(tooltips['newFieldTR']); MochiKit.Signal.connect(this.getId('newFieldLabel'), 'onfocus', MochiKit.Base.method(this, 'showTooltipOnFocus', 'newFieldTR')); MochiKit.Signal.connect(this.getId('newFieldValue'), 'onblur', MochiKit.Base.method(this, 'hideTooltipOnBlur', 'newFieldTR')); tooltips['recordNote'] = new Clipperz.PM.UI.Common.Components.Tooltip({ 'element': this.getElement('recordNote'), 'text': "You can insert some notes here", 'position': 'RIGHT' }); this.addComponent(tooltips['recordNote']); MochiKit.Signal.connect(this.getId('recordNote'), 'onfocus', MochiKit.Base.method(this, 'showTooltipOnFocus', 'recordNote')); MochiKit.Signal.connect(this.getId('recordNote'), 'onblur', MochiKit.Base.method(this, 'hideTooltipOnBlur', 'recordNote')); this._tooltips = tooltips; }, //......................................................................... 'updateAllTooltipsEnabledMode': function (aStatus) { var tooltipLabel; var tooltipEnabled; tooltipEnabled = (aStatus == 'ON') ? true : false; for (tooltipLabel in this.tooltips()) { this.tooltips()[tooltipLabel].setIsEnabled(tooltipEnabled); } }, //......................................................................... 'tooltips': function () { return this._tooltips; }, //......................................................................... 'showTooltipOnFocus': function (aTooltip, anEvent) { MochiKit.Async.callLater(0.5, MochiKit.Base.method(this.tooltips()[aTooltip], 'show')); }, //......................................................................... 'hideTooltipOnBlur': function (aTooltip, anEvent) { this.tooltips()[aTooltip].hide(); }, //------------------------------------------------------------------------- 'displayElement': function() { return this.getElement('panel'); }, //------------------------------------------------------------------------- 'fieldComponents': function () { return this._fieldComponents; }, //------------------------------------------------------------------------- 'directLoginComponents': function () { return this._directLoginComponents; }, //------------------------------------------------------------------------- 'hintMode': function () { return this._hintMode; }, 'setHintMode': function (aValue) { if (this._hintMode != aValue) { this._hintMode = aValue; this.updateAllTooltipsEnabledMode(this._hintMode); // if (this._hintMode == 'ON') { // this.enableHints(); // } } }, //------------------------------------------------------------------------- 'focusOnNewFieldLabel': function () { this.getElement('newFieldLabel').focus(); }, //========================================================================= 'isSavingEnabled': function () { return this._isSavingEnabled; }, 'setShouldEnableSaving': function (aValue) { this._isSavingEnabled = aValue || this.newFieldHasPendingChanges(); if (this._isSavingEnabled == true) { MochiKit.DOM.addElementClass(this.getElement('panel'), 'hasPendingChanges'); MochiKit.DOM.removeElementClass(this.getId('saveButton'), 'disabled'); } else { MochiKit.DOM.removeElementClass(this.getElement('panel'), 'hasPendingChanges'); MochiKit.DOM.addElementClass(this.getId('saveButton'), 'disabled'); } }, //========================================================================= 'title': function () { return this.getElement('title').value; }, 'setTitle': function (aValue) { this.renderTitle(aValue); }, //------------------------------------------------------------------------- 'renderTitle': function (aValue) { this.getElement('title').value = Clipperz.Base.sanitizeString(aValue); }, //------------------------------------------------------------------------- 'setFocusOnTitleField': function () { this.getElement('title').focus(); }, //------------------------------------------------------------------------- 'disableCardTitleEditing': function () { this.getElement('title').disabled = true; MochiKit.DOM.addElementClass(this.getElement('title').parentNode, 'disabled'); }, 'enableCardTitleEditing': function () { this.getElement('title').disabled = false; MochiKit.DOM.removeElementClass(this.getElement('title').parentNode, 'disabled'); }, //========================================================================= 'notes': function () { return this.getElement('recordNote').value; }, 'setNotes': function (aValue) { this.renderNotes(aValue); }, //------------------------------------------------------------------------- 'renderNotes': function (aValue) { var noteElement; noteElement = this.getElement('recordNote'); if ((aValue != null) && (typeof(aValue) != 'undefined')) { noteElement.value = aValue; } else { noteElement.value = ""; } this.fixNotesHeight(); }, //========================================================================= 'addFieldRowComponent': function (aFieldComponent) { var fieldTR; fieldTR = this.insertBefore(this.getElement('newFieldTR'), {tag:'tr', id:'recordFieldReferece_'+aFieldComponent.reference()}); aFieldComponent.renderInNode(fieldTR); this.fieldComponents()[aFieldComponent.reference()] = aFieldComponent; }, //========================================================================= 'addDirectLoginComponent': function (aDirectLoginComponent) { var directLoginDIV; if (MochiKit.Base.keys(this.directLoginComponents()).length == 0) { this.hideNewDirectLoginSplash(); } directLoginDIV = this.append(this.getElement('directLoginsList'), {tag:'div', cls:'directLoginItem'}); aDirectLoginComponent.renderInNode(directLoginDIV); this.directLoginComponents()[aDirectLoginComponent.reference()] = aDirectLoginComponent; }, 'removeDirectLoginComponent': function (aDirectLoginComponent) { delete this.directLoginComponents()[aDirectLoginComponent.reference()]; aDirectLoginComponent.remove(); if (MochiKit.Base.keys(this.directLoginComponents()).length == 0) { this.showNewDirectLoginSplash(); } }, //========================================================================= 'showNewDirectLoginSplash': function () { MochiKit.Style.showElement(this.getElement('addNewDirectLoginSplash')); MochiKit.Style.hideElement(this.getElement('addDirectLoginListItem')); }, 'hideNewDirectLoginSplash': function () { MochiKit.Style.hideElement(this.getElement('addNewDirectLoginSplash')); MochiKit.Style.showElement(this.getElement('addDirectLoginListItem')); }, //========================================================================= 'renderDirectLoginEditingComponent': function (aDirectLoginEditingComponent) { aDirectLoginEditingComponent.renderInNode(this.getElement('directLoginEditDetail')); }, 'placeDirectLoginEditingComponent': function () { var width; width = MochiKit.Style.getElementDimensions(this.getElement('directLoginsComponentContainer'))['w']; return Clipperz.Async.callbacks("CardDialogComponent.renderDirectLoginEditingComponent", [ MochiKit.Base.bind(function () { MochiKit.Style.setElementPosition (this.getElement('directLoginEditDetail'), {x:width, y:-MochiKit.Style.getElementDimensions(this.getElement('directLogins'))['h']}); MochiKit.Style.setElementDimensions(this.getElement('directLoginEditDetail'), {w:width}); }, this), MochiKit.Base.noop ], {trace:false}); }, //========================================================================= 'newFieldLabel': function () { return this.getElement('newFieldLabel').value; }, 'setNewFieldLabel': function (aValue) { this.getElement('newFieldLabel').value = aValue; }, //------------------------------------------------------------------------- 'newFieldValue': function () { return this.getElement('newFieldValue').value; }, 'setNewFieldValue': function (aValue) { this.getElement('newFieldValue').value = aValue; }, //------------------------------------------------------------------------- 'newFieldIsHidden': function () { return MochiKit.DOM.hasElementClass(this.getElement('newFieldIsLocked'), 'locked'); }, 'setNewFieldIsHidden': function (aValue) { MochiKit.DOM.setElementClass(this.getElement('newFieldIsLocked'), (aValue ? 'locked': 'unlocked')); MochiKit.DOM.setElementClass(this.getElement('newFieldValueWrapper'), (aValue ? 'locked': 'unlocked')); }, 'toggleNewFieldIsHidden': function (anEvent) { anEvent.preventDefault(); this.setNewFieldIsHidden(! this.newFieldIsHidden()); MochiKit.Signal.signal(this, 'changedValue'); }, //------------------------------------------------------------------------- 'newFieldHasPendingChanges': function () { return ((this.newFieldLabel() != '') || (this.newFieldValue() != '') || (this.newFieldIsHidden() == true)); }, 'resetNewFieldInputs': function () { this.setNewFieldLabel(''); this.setNewFieldValue(''); this.setNewFieldIsHidden(false); }, //========================================================================= 'handleKeyDownOnNewFieldValue': function (anEvent) { MochiKit.Signal.signal(this, 'keyPressed', anEvent); /* if ((anEvent.key().string == 'KEY_TAB') && this.newFieldHasPendingChanges()) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'addField'); this.getElement('newFieldLabel').focus(); } */ }, //------------------------------------------------------------------------- 'handleAddClick': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'addField'); this.getElement('newFieldLabel').focus(); }, //========================================================================= 'handleDeleteClick': function (aFieldKey, anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'deleteField', aFieldKey); }, //------------------------------------------------------------------------- 'toggleLock': function (aFieldKey, anEvent) { var shouldRedrawAsLocked; var currentTRElement; anEvent.preventDefault(); currentTRElement = Clipperz.DOM.get(aFieldKey); shouldRedrawAsLocked = (MochiKit.DOM.hasElementClass(currentTRElement, 'locked') ? false : true); this.renderFieldTR(currentTRElement, { label:MochiKit.Selector.findChildElements(currentTRElement, ['td.fieldLabel input'])[0].value, value:MochiKit.Selector.findChildElements(currentTRElement, ['td.fieldValue input'])[0].value }, shouldRedrawAsLocked, MochiKit.DOM.hasElementClass(currentTRElement, 'new')); }, //========================================================================= 'fixNotesHeight': function () { var element; element = this.getElement('recordNote'); if (element.scrollHeight == 0) { MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, 'fixNotesHeight')); } else { var textareaHeight; textareaHeight = Math.min(Math.max(50, element.scrollHeight), 500); MochiKit.Style.setElementDimensions(element, {h:textareaHeight}, 'px'); MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, 'fixRendering')); } }, //------------------------------------------------------------------------- 'fixRendering': function () { // var height; var y; var scrollHeight; var viewportHeight; var viewportY; var footerElement; var footerElementPosition; var footerElementDimensions; var footerComputedHeight; // height = MochiKit.Style.getElementDimensions(this.displayElement())['h']; y = MochiKit.Style.getElementPosition(this.displayElement())['y']; footerElement = MochiKit.Selector.findChildElements(this.displayElement(), ['div.footer'])[0]; footerElementPosition = MochiKit.Style.getElementPosition(footerElement); footerElementDimensions = MochiKit.Style.getElementDimensions(footerElement); footerComputedHeight = footerElementPosition['y'] + footerElementDimensions['h'] - y; // scrollHeight = this.displayElement().scrollHeight; scrollHeight = footerComputedHeight; viewportHeight = MochiKit.Style.getViewportDimensions()['h']; viewportY = MochiKit.Style.getViewportPosition()['y']; if ((y + scrollHeight) > (viewportY + viewportHeight)) { this.setDisplayMode('scrollable'); MochiKit.DOM.addElementClass(this.element(), 'scrollable'); MochiKit.DOM.removeElementClass(this.element(), 'fixed'); MochiKit.Style.setElementPosition(this.displayElement(), {y:Math.max(0, Math.min(y, (viewportY + viewportHeight) - scrollHeight))}, 'px'); MochiKit.Visual.ScrollTo(this.displayElement(), {duration:0.5}); } else { this.setDisplayMode('fixed'); MochiKit.DOM.removeElementClass(this.element(), 'scrollable'); MochiKit.DOM.addElementClass(this.element(), 'fixed'); } }, //========================================================================= 'unselectCurrentSelectedItems': function () { MochiKit.Iter.forEach(MochiKit.Selector.findChildElements(this.displayElement(), ['.selectedField']), function (anElement) { MochiKit.DOM.removeElementClass(anElement, 'selectedField'); }); }, //========================================================================= 'hideProgressMask': function () { MochiKit.DOM.removeElementClass(this.getId('panel'), 'loading'); }, 'showProgressMask': function () { this.getElement('progressDescription').innerHTML = "Saving"; MochiKit.DOM.addElementClass(this.getId('panel'), 'loading'); }, 'showError': function (anError) { -//console.log(">>> showError", anError); MochiKit.Style.hideElement(this.getId('progress')); this.getElement('errorMessage').innerHTML = Clipperz.PM.Strings.errorDescriptionForException(anError['message']); MochiKit.Style.showElement(this.getId('error')); }, //------------------------------------------------------------------------- 'cancel': function () { /* var deferredResult; deferredResult = new Clipperz.Async.Deferred("CardDialogComponent.cancel", {trace:false}); deferredResult.addCallback(MochiKit.Base.method(this, 'isSavingEnabled')); deferredResult.addIf([ MochiKit.Base.method(this, 'askConfirmationForLoosingPendingChanges') ], []); deferredResult.addCallback(MochiKit.Base.partial(MochiKit.Signal.signal, this, 'cancel')); deferredResult.callback(); return deferredResult; */ MochiKit.Signal.signal(this, 'cancel'); }, 'handleCancelEvent': function (anEvent) { anEvent.preventDefault(); this.cancel(); }, //------------------------------------------------------------------------- 'handleSaveEvent': function (anEvent) { anEvent.preventDefault(); if (! MochiKit.DOM.hasElementClass(anEvent.src(), 'disabled')) { MochiKit.Signal.signal(this, 'save'); } }, //------------------------------------------------------------------------- 'handleAddDirectLogin': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'addDirectLogin'); }, //------------------------------------------------------------------------- 'handleOnFocusEvent': function (anElement, anEvent) { this.unselectCurrentSelectedItems(); MochiKit.DOM.addElementClass(anElement, 'selectedField'); }, 'handleLooseFocusEvent': function (anElement, anEvent) { this.unselectCurrentSelectedItems(); }, //------------------------------------------------------------------------- 'handleTabSelected': function (aSelectedTab) { this.unselectCurrentSelectedItems(); switch (aSelectedTab) { case 'DETAILS': // MochiKit.Style.hideElement(this.getElement('addDirectLoginButton')); break; case 'DIRECT_LOGINS': // MochiKit.Style.showElement(this.getElement('addDirectLoginButton')); break; case 'SHARING': // MochiKit.Style.hideElement(this.getElement('addDirectLoginButton')); break; } }, //------------------------------------------------------------------------- 'handleKeyEvent': function (anEvent) { -//console.log("####", anEvent.key().string); if (anEvent.key().string == 'KEY_ESCAPE') { MochiKit.Signal.signal(this, 'changedValue'); this.cancel(); } else if (anEvent.key().string == 'KEY_ENTER') { if (anEvent.target().nodeName == 'TEXTAREA') { } else { anEvent.preventDefault(); } } }, //========================================================================= 'askConfirmationForLoosingPendingChanges': function () { var deferredResult; var confirmationDialog; confirmationDialog = new Clipperz.PM.UI.Common.Components.SimpleMessagePanel({ title: "Alert", text: "Should lost pending changes?", type: 'ALERT', buttons: [ {text:"Cancel", result:'CANCEL', isDefault:true}, {text:"Ok", result:'OK'} ] }); deferredResult = new Clipperz.Async.Deferred("CardDialogComponent.askConfirmationForLoosingPendingChanges", {trace:false}); // deferredResult = confirmationDialog.deferredShow({openFromElement:anEvent.src(), onOkCloseToElement:MochiKit.DOM.currentDocument().body, onCancelCloseToElement:anEvent.src()}); deferredResult.addMethod(confirmationDialog, 'deferredShow', { 'openFromElement': this.getElement('cancelButton'), 'onOkCloseToElement': null, // this.getElement('cancelButton'), 'onCancelCloseToElement': this.getElement('cancelButton') }); -// deferredResult.addCallback(function () { console.log("DELETE: " + anObject.toString(), anObject); }); -// deferredResult.addErrbackPass(function () { console.log("skip deletion: " + anObject.toString(), anObject); }); deferredResult.callback(); return deferredResult; }, //========================================================================= 'showDirectLoginEditingComponent': function () { var width; var transition; var duration; width = MochiKit.Style.getElementDimensions(this.getElement('directLoginsComponentContainer'))['w']; transition = MochiKit.Visual.Transitions.sinoidal; duration = 1; return Clipperz.Async.callbacks("CardDialogComponent.showDirectLoginEditingComponent", [ MochiKit.Base.method(this, 'disableCardTitleEditing'), MochiKit.Base.method(this.tabPanelController(), 'disable'), MochiKit.Base.bind(function () { MochiKit.Style.setElementPosition (this.getElement('directLoginEditDetail'), {x:width, y:-MochiKit.Style.getElementDimensions(this.getElement('directLogins'))['h']}); MochiKit.Style.setElementDimensions(this.getElement('directLoginEditDetail'), {w:width}); MochiKit.Style.showElement(this.getElement('directLoginEditDetail')); MochiKit.Style.setOpacity(this.getElement('directLoginEditDetail'), 0); MochiKit.Style.setElementDimensions(this.getElement('directLoginsComponentContainer'), { h:Math.max( MochiKit.Style.getElementDimensions(this.getElement('directLogins'))['h'], MochiKit.Style.getElementDimensions(this.getElement('directLoginEditDetail'))['h'] ) }); // MochiKit.Style.setElementDimensions(this.getElement('directLoginsComponentContainer'), {h:MochiKit.Style.getElementDimensions(this.getElement('directLogins'))['h']}); }, this), MochiKit.Base.partial(Clipperz.Visual.deferredAnimations, MochiKit.Visual.Parallel, [ new MochiKit.Visual.Move(this.getElement('directLogins'), {x:-width, y:0, mode:'relative', transition:transition, sync:true}), new MochiKit.Visual.Opacity(this.getElement('directLogins'), {from:1.0, to:0.0, transition:transition, sync:true}), new MochiKit.Visual.Move(this.getElement('directLoginEditDetail'), {x:-width, y:0, mode:'relative', transition:transition, sync:true}), new MochiKit.Visual.Opacity(this.getElement('directLoginEditDetail'), {from:0.0, to:1.0, transition:transition, sync:true}) ], {duration:duration}), MochiKit.Base.noop ], {trace:false}); }, //------------------------------------------------------------------------- 'hideDirectLoginEditingComponent': function () { var width; var transition; var duration; width = MochiKit.Style.getElementDimensions(this.getElement('directLoginsComponentContainer'))['w']; transition = MochiKit.Visual.Transitions.sinoidal; duration = 1; return Clipperz.Async.callbacks("CardDialogComponent.hideDirectLoginEditingComponent", [ MochiKit.Base.partial(Clipperz.Visual.deferredAnimations, MochiKit.Visual.Parallel, [ new MochiKit.Visual.Move(this.getElement('directLogins'), {x:width, y:0, mode:'relative', transition:transition, sync:true}), new MochiKit.Visual.Opacity(this.getElement('directLogins'), {from:0.0, to:1.0, transition:transition, sync:true}), new MochiKit.Visual.Move(this.getElement('directLoginEditDetail'), {x:width, y:0, mode:'relative', transition:transition, sync:true}), new MochiKit.Visual.Opacity(this.getElement('directLoginEditDetail'), {from:1.0, to:0.0, transition:transition, sync:true}) ], {duration:duration}), // MochiKit.Base.partial(MochiKit.Visual.appear, this.getElement('addDirectLoginButton'), {duration:0.3}), Clipperz.Async.clearResult, MochiKit.Base.partial(MochiKit.Style.hideElement, this.getElement('directLoginEditDetail')), // MochiKit.Base.partial(MochiKit.Style.showElement, this.getElement('directLogins')), MochiKit.Base.partial(MochiKit.Style.setElementDimensions, this.getElement('directLoginsComponentContainer'), {h:MochiKit.Style.getElementDimensions(this.getElement('directLogins'))['h']}), MochiKit.Base.method(this, 'enableCardTitleEditing'), MochiKit.Base.method(this.tabPanelController(), 'enable') ], {trace:false}); }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js index 2e61f5f..0cee650 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js @@ -1,179 +1,173 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent.superclass.constructor.apply(this, arguments); this._reference = args.reference || Clipperz.Base.exception.raise('MandatoryParameter'); this._faviconComponent = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent component"; }, //------------------------------------------------------------------------- 'reference': function () { return this._reference; }, //------------------------------------------------------------------------- 'renderSelf': function() { -//console.log(">>> CardDialogRecordDirectLoginComponent.renderSelf"); this.append(this.element(), [ {tag:'div', cls:'cardDialogRecordDirectLoginComponent_favicon', children:[ {tag:'img', cls:'favicon', id:this.getId('favicon')} ]}, {tag:'div', cls:'cardDialogRecordDirectLoginComponent_label', children:[ {tag:'input', id:this.getId('label'), type:'text'} ]}, {tag:'div', cls:'open', children:[ {tag:'span', children:[ {tag:'a', href:'open', id:this.getId('open'), html:' '} ]} ]}, {tag:'div', cls:'edit', children:[ {tag:'span', children:[ {tag:'a', href:'edit', id:this.getId('edit'), html:"edit"} ]} ]}, {tag:'div', cls:'delete', children:[ {tag:'span', children:[ {tag:'a', href:'delete', id:this.getId('delete'), html:"delete"} ]} ]} /* {tag:'td', cls:'fieldState'}, {tag:'td', cls:'fieldLabel', children:[ {tag:'input', cls:'label', id:this.getId('label')} ]}, {tag:'td', cls:'fieldLock', children:[ {tag:'div', cls:'unlocked', id:this.getId('isHidden')} ]}, {tag:'td', cls:'fieldValue', children:[ {tag:'div', cls:'unlocked', id:this.getId('valueWrapper'), children:[ {tag:'input', type:'text', cls:'value', id:this.getId('value')} ]} ]}, {tag:'td', cls:'fieldAddDelete', children:[ {tag:'div', cls:'delete', children:[ {tag:'span', children:[ {tag:'a', href:'#', id:this.getId('delete'), html:"delete"} ]} ]} ]} */ ]); MochiKit.Signal.connect(this.getId('label'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('open'), 'onclick', this, 'openDirectLogin'); MochiKit.Signal.connect(this.getId('edit'), 'onclick', this, 'editDirectLogin'); MochiKit.Signal.connect(this.getId('delete'), 'onclick', this, 'deleteDirectLogin'); }, //------------------------------------------------------------------------- 'shouldShowElementWhileRendering': function () { return false; }, //------------------------------------------------------------------------- 'faviconComponent': function () { if (this._faviconComponent == null) { -//console.log("created the FAVICON component"); this._faviconComponent = new Clipperz.PM.UI.Common.Components.FaviconComponent({element:this.getId('favicon')}); } return this._faviconComponent; }, //========================================================================= 'label': function () { return this.getElement('label').value; }, 'setLabel': function (aValue) { this.getElement('label').value = Clipperz.Base.sanitizeString(aValue); }, //------------------------------------------------------------------------- 'favicon': function () { // return this.getElement('favicon').src; return this.faviconComponent().src(); }, 'setFavicon': function (aValue) { // this.getElement('favicon').src = Clipperz.Base.sanitizeString(aValue); this.faviconComponent().setSrc(Clipperz.Base.sanitizeString(aValue)); }, //========================================================================= 'openDirectLogin': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'openDirectLogin', this.reference()); }, //------------------------------------------------------------------------- 'editDirectLogin': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'editDirectLogin', this.reference()); -//console.log("EDIT DIRECT LOGIN"); }, //------------------------------------------------------------------------- 'deleteDirectLogin': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'deleteDirectLogin', this.reference()); -//console.log("DELETE DIRECT LOGIN"); }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js index b58062c..689406a 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js @@ -1,187 +1,183 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent.superclass.constructor.apply(this, arguments); this._reference = args.reference || Clipperz.Base.exception.raise('MandatoryParameter'); this._actionType = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent component"; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(this.element(), [ {tag:'td', cls:'fieldState'}, {tag:'td', cls:'fieldLabel', children:[ {tag:'input', cls:'label', id:this.getId('label')} ]}, {tag:'td', cls:'fieldLock', children:[ {tag:'div', cls:'unlocked', id:this.getId('isHidden')} ]}, {tag:'td', cls:'fieldValue', children:[ {tag:'div', cls:'unlocked', id:this.getId('valueWrapper'), children:[ {tag:'input', type:'text', cls:'value', id:this.getId('value')} ]} ]}, {tag:'td', cls:'fieldAction', children:[ {tag:'a', href:'#', id:this.getId('actionLink'), html:' '} ]}, {tag:'td', cls:'fieldAddDelete', children:[ {tag:'div', cls:'delete', children:[ {tag:'span', children:[ {tag:'a', href:'#', id:this.getId('delete'), html:"delete"} ]} ]} ]} ]); MochiKit.Signal.connect(this.getId('label'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('isHidden'), 'onclick', this, 'toggleIsHidden'); MochiKit.Signal.connect(this.getId('value'), 'onkeyup', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'changedValue')); MochiKit.Signal.connect(this.getId('actionLink'), 'onclick', this, 'handleActionLink'); MochiKit.Signal.connect(this.getId('delete'), 'onclick', this, 'deleteField'); // MochiKit.Signal.connect(this.getId('delete'), 'onclick', MochiKit.Base.partial(MochiKit.Signal.signal, this, 'deleteField', this.reference())); }, //------------------------------------------------------------------------- 'shouldShowElementWhileRendering': function () { return false; }, //========================================================================= 'reference': function () { return this._reference; }, //========================================================================= 'label': function () { return this.getElement('label').value; }, 'setLabel': function (aValue) { // this.getElement('label').value = Clipperz.Base.sanitizeString(aValue); this.getElement('label').value = aValue; }, //========================================================================= 'value': function () { return this.getElement('value').value; }, 'setValue': function (aValue) { // this.getElement('value').value = Clipperz.Base.sanitizeString(aValue); this.getElement('value').value = aValue; }, //------------------------------------------------------------------------- 'actionType': function () { return this._actionType; }, 'setActionType': function (anActionType) { this._actionType = anActionType; switch (this._actionType) { case 'NONE': MochiKit.Style.hideElement(this.getId('actionLink')); MochiKit.DOM.setElementClass(this.getId('actionLink'), ''); break; case 'URL': MochiKit.Style.showElement(this.getId('actionLink')); MochiKit.DOM.setElementClass(this.getId('actionLink'), 'url'); break; case 'EMAIL': MochiKit.Style.showElement(this.getId('actionLink')); MochiKit.DOM.setElementClass(this.getId('actionLink'), 'email'); break; case 'PASSWORD': MochiKit.Style.showElement(this.getId('actionLink')); MochiKit.DOM.setElementClass(this.getId('actionLink'), 'password'); break; } }, //========================================================================= 'isHidden': function () { // return this.getElement('value').value; return MochiKit.DOM.hasElementClass(this.getElement('isHidden'), 'locked'); }, 'setIsHidden': function (aValue) { // this.getElement('value').value = Clipperz.Base.sanitizeString(aValue); MochiKit.DOM.setElementClass(this.getElement('isHidden'), (aValue ? 'locked': 'unlocked')); MochiKit.DOM.setElementClass(this.getElement('valueWrapper'), (aValue ? 'locked': 'unlocked')); }, 'toggleIsHidden': function (anEvent) { anEvent.preventDefault(); this.setIsHidden(! this.isHidden()); MochiKit.Signal.signal(this, 'changedValue'); }, //========================================================================= 'handleActionLink': function (anEvent) { anEvent.preventDefault(); - -//console.log("ACTION LINK - " + this.actionType()); MochiKit.Signal.signal(this, 'performAction', this.reference(), anEvent.target()); }, //========================================================================= 'deleteField': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'deleteField', this.reference()); }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js index 391c379..41e32a0 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ColumnManager.js @@ -1,200 +1,198 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.ColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.ColumnManager.superclass.constructor.call(this, args); this._name = args.name || Clipperz.Base.exception.raise('MandatoryParameter'); this._selector = args.selector || Clipperz.Base.exception.raise('MandatoryParameter');; this._label = args.label || null; this._isSortable = args.sortable || false; this._comparator = args.comparator || null; this._sorted = args.sorted || 'UNSORTED'; // 'ASCENDING' | 'DESCENDING' | 'UNSORTED' this._cssClass = args.cssClass || ''; this._signalIdentifiers = []; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.ColumnManager, Clipperz.PM.UI.Common.Components.BaseComponent, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.ColumnManager - " + this._name; }, 'name': function () { return this._name; }, 'label': function () { return this._label; }, 'selector': function () { return this._selector; }, 'comparator': function() { return this._comparator; }, 'cssClass': function() { return this._cssClass; }, //------------------------------------------------------------------------- 'isSortable': function () { return this._isSortable; }, //------------------------------------------------------------------------- 'sorted': function () { return this._sorted; }, 'isSorted': function () { return (this.sorted() != 'UNSORTED'); }, 'setSorted': function(aValue) { this._sorted = aValue; this.updateSortIcon(); }, //------------------------------------------------------------------------- 'signalIdentifiers': function () { return this._signalIdentifiers; }, 'resetSignalIdentifiers': function () { this._signalIdentifiers = []; }, //------------------------------------------------------------------------- 'disconnectRowsSignals': function () { MochiKit.Base.map(MochiKit.Signal.disconnect, this.signalIdentifiers()); this.resetSignalIdentifiers(); }, 'connectEvent': function () { var ident; ident = MochiKit.Signal.connect.apply(null, arguments); this.signalIdentifiers().push(ident); }, //------------------------------------------------------------------------- 'renderHeader': function(aTRElement) { var thElement; thElement = Clipperz.DOM.Helper.append(aTRElement, {tag:'th', cls:(this.cssClass() + 'TH'), id:this.getId('sortLink'), children:[ {tag:'span', html:this.label() ? this.label() : ' '} ]}); if (this.isSortable()) { Clipperz.DOM.Helper.append(thElement, {tag:'span', cls:'sortable', children:[ {tag:'a', href:'#'/*, id:this.getId('sortLink')*/, html:' '} ]}); MochiKit.DOM.addElementClass(thElement, 'sortable'); MochiKit.Signal.connect(thElement, 'onclick', this, 'handleClickOnSortingCriteria'); }; this.updateSortIcon(); }, //------------------------------------------------------------------------- 'toggleSorting': function () { var result; switch (this.sorted()) { case 'UNSORTED': result = 'ASCENDING'; break; case 'ASCENDING': result = 'DESCENDING'; break; case 'DESCENDING': result = 'ASCENDING'; break; default: result = 'UNSORTED'; break; } this.setSorted(result); return result; }, //------------------------------------------------------------------------- 'sortElementClass': function () { return this.sorted().toLowerCase(); }, //------------------------------------------------------------------------- 'updateSortIcon': function () { if (this.isSortable()) { MochiKit.DOM.removeElementClass(this.getId('sortLink'), 'ascending'); MochiKit.DOM.removeElementClass(this.getId('sortLink'), 'descending'); MochiKit.DOM.removeElementClass(this.getId('sortLink'), 'unsorted'); MochiKit.DOM.addElementClass(this.getId('sortLink'), this.sortElementClass()); } }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[{tag:'span', html:anObject[this.name()]}]}); }, //----------------------------------------------------- 'handleClickOnSortingCriteria': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'sort', this); }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js index d3aa175..3d0ba76 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js @@ -1,68 +1,66 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.CreateNewCardSplashComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.CreateNewCardSplashComponent.superclass.constructor.apply(this, arguments); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.CreateNewCardSplashComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.CreateNewCardSplashComponent component"; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(this.element(), [ {tag:'div', cls:'createNewCardSplash', id:this.getId('button'), children:[ {tag:'span', html:"Create New Card"} ]} ]); MochiKit.Signal.connect(this.getElement('button'), 'onclick', this, 'handleClick'); }, //------------------------------------------------------------------------- 'handleClick': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'addCard', this.element()); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); 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 462d864..23f6710 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DataPanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DataPanel.js @@ -1,116 +1,114 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.DataPanel = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DataPanel.superclass.constructor.apply(this, arguments); this._initiallySelectedTab = args.selected || 'OFFLINE_COPY'; this._tabPanelControllerConfiguration = { 'OFFLINE_COPY': { tab: 'offlineCopyTab', panel: 'offlineCopyPanel' }, 'SHARING': { tab: 'sharingTab', panel: 'sharingPanel' }, 'IMPORT': { tab: 'importTab', panel: 'importPanel' }, 'EXPORT': { tab: 'exportTab', panel: 'exportPanel' } }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DataPanel, Clipperz.PM.UI.Common.Components.TabPanelComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.DataPanel component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', cls:'header', children:[ {tag:'div', cls:'subPanelTabs', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('offlineCopyTab'), children:[{tag:'a', href:'#', html:'Offline copy'}], cls:'first'}, {tag:'li', id:this.getId('sharingTab'), children:[{tag:'a', href:'#', html:'Sharing'}]}, {tag:'li', id:this.getId('importTab'), children:[{tag:'a', href:'#', html:'Import'}]}, {tag:'li', id:this.getId('exportTab'), children:[{tag:'a', href:'#', html:'Export'}]} ]} ]} ]}, {tag:'div', cls:'body', children:[ {tag:'div', cls:'accountPanel', children:[ {tag:'div', cls:'subPanelContent', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('offlineCopyPanel'), children:[ // {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:'li', id:this.getId('importPanel'), children:[ // {tag:'h3', html:"Import"} ]}, {tag:'li', id:this.getId('exportPanel'), children:[ // {tag:'h3', html:"Export"} ]} ]} ]} ]} ]}, {tag:'div', cls:'footer'} ]); 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/DateColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DateColumnManager.js index ea55ba4..b305045 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DateColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DateColumnManager.js @@ -1,69 +1,67 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.DateColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DateColumnManager.superclass.constructor.call(this, args); this._format = args.format || Clipperz.Base.exception.raise('MandatoryParameter'); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DateColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.DateColumnManager component"; }, //------------------------------------------------------------------------- 'format': function () { return this._format; }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ { tag:'span', title:Clipperz.PM.Date.formatDateWithTemplate(anObject[this.name()], "D, d M Y H:i:s"), html:Clipperz.PM.Date.formatDateWithTemplate(anObject[this.name()], this.format()) } ]}); }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js index fe59494..6efe4c6 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js @@ -1,67 +1,65 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager.superclass.constructor.call(this, args); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager, Clipperz.PM.UI.Web.Components.LinkColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager component"; }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { var tdElement; var linkElement; tdElement = Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ {tag:'div', cls:'delete', children:[ {tag:'span', children:[ {tag:'a', href:'delete', html:"delete"} ]} ]} ]}); linkElement = MochiKit.DOM.getFirstElementByTagAndClassName('a', null, tdElement); // MochiKit.Signal.connect(linkElement, 'onclick', MochiKit.Base.method(this, 'handleLinkClick', anObject['_rowObject'])); this.connectEvent(linkElement, 'onclick', MochiKit.Base.method(this, 'handleLinkClick', anObject['_rowObject'])); }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js index a1f0f9f..2dad703 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js @@ -1,87 +1,85 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ /* Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.DirectLoginColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DirectLoginColumnManager.superclass.constructor.call(this, args); this._actionMethod = args.actionMethod || null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.DateColumnManager component"; }, //------------------------------------------------------------------------- 'actionMethod': function () { return this._actionMethod; }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { var tdElement; var linkElement; tdElement = Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ {tag:'div', cls:'directLogin_directLogin', children:[ {tag:'div', cls:'directLogin_directLogin_body', children:[ {tag:'a', href:'#', html:anObject[this.name()]} ]} ]} ]}); linkElement = MochiKit.DOM.getFirstElementByTagAndClassName('a', null, tdElement); // MochiKit.Signal.connect(linkElement, 'onclick', MochiKit.Base.method(this, 'handleLinkClick', anObject['_rowObject'])); this.connectEvent(linkElement, 'onclick', MochiKit.Base.method(this, 'handleLinkClick', anObject['_rowObject'])); }, //----------------------------------------------------- 'handleLinkClick': function (anObject, anEvent) { anEvent.preventDefault(); if (this.actionMethod() != null) { this.actionMethod()(anObject, anEvent); } }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); */
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js index 1a76b0c..f5f99d4 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js @@ -1,165 +1,163 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent.superclass.constructor.apply(this, arguments); this._formFieldName = args.formFieldName || Clipperz.Base.exception.raise('MandatoryParameter'); this._fields = args.fields || Clipperz.Base.exception.raise('MandatoryParameter'); this._initiallySelectedFieldKey = args.selectedFieldKey || null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent component"; }, //------------------------------------------------------------------------- 'formFieldName': function () { return this._formFieldName; }, //------------------------------------------------------------------------- 'fields': function () { return this._fields; }, //------------------------------------------------------------------------- 'selectedValue': function () { var result; result = this.getElement('select').value; if (result == '---') { result = null; } return result; }, 'initiallySelectedFieldKey': function () { return this._initiallySelectedFieldKey; }, //========================================================================= 'renderSelf': function() { var initiallySelectedOptions; this.append(this.element(), {tag:'div', id:this.getId('div'), cls:'binding', children:[ {tag:'span', cls:'formFieldName', html:this.formFieldName()}, {tag:'span', cls:'fieldLock', id:this.getId('isHidden'), children:[ {tag:'a', href:'#', id:this.getId('showHide'), html:' '} ]}, {tag:'input', id:this.getId('input'), cls:'formFieldExampleValue', disabled:true, value:''}, {tag:'select', name:this.formFieldName(), id:this.getId('select'), cls:'formFieldMatchinCardField', children: MochiKit.Base.flattenArguments( {tag:'option', value:'---', html:"---"}, MochiKit.Base.map( MochiKit.Base.bind(function (aField) { return {tag:'option', value:aField['reference'], html:aField['label']}; }, this), this.fields() ) ) } ]}); MochiKit.Signal.connect(this.getElement('select'), 'onchange', this, 'handleSelectChange'); MochiKit.Signal.connect(this.getElement('showHide'), 'onclick', this, 'handleShowHide'); if (! MochiKit.Base.isUndefinedOrNull(this.initiallySelectedFieldKey())) { initiallySelectedOptions = MochiKit.Selector.findChildElements(this.element(), ['option[value=' + this.initiallySelectedFieldKey() + ']']); if (initiallySelectedOptions.length == 1) { MochiKit.DOM.updateNodeAttributes(initiallySelectedOptions[0], {selected:true}); this.handleSelectChange(); } } }, //------------------------------------------------------------------------- 'setFieldValue': function (aValue) { this.getElement('input').value = aValue; }, 'isHidden': function () { return MochiKit.DOM.hasElementClass(this.getElement('div'), 'locked'); }, 'setIsHidden': function (aValue) { if (aValue == true) { MochiKit.DOM.addElementClass(this.getElement('div'), 'locked'); MochiKit.DOM.addElementClass(this.getElement('div'), 'showLocked'); } else { MochiKit.DOM.removeElementClass(this.getElement('div'), 'locked'); MochiKit.DOM.removeElementClass(this.getElement('div'), 'showLocked'); } }, 'isShowLocked': function () { return MochiKit.DOM.hasElementClass(this.getElement('div'), 'showLocked'); }, //------------------------------------------------------------------------- 'handleSelectChange': function (anEvent) { // this.getElement('input').value = this.valueOfField(anEvent.src().value); MochiKit.Signal.signal(this, 'bindChange', this); }, 'handleShowHide': function (anEvent) { anEvent.preventDefault(); if (this.isShowLocked()) { MochiKit.DOM.removeElementClass(this.getElement('div'), 'showLocked'); } else { MochiKit.DOM.addElementClass(this.getElement('div'), 'showLocked'); } }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js index 5114b1d..55d2c01 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js @@ -1,478 +1,475 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent.superclass.constructor.apply(this, arguments); this._tabPanelController = null; this._initiallySelectedTab = args.selected || 'TYPE'; this._tabPanelControllerConfiguration = { 'LABEL': { tab: 'labelTab', panel: 'labelTabpanel' }, 'TYPE': { tab: 'typeTab', panel: 'typeTabpanel' }, 'CONFIGURATION': { tab: 'configurationTab', panel: 'configurationTabpanel' }, 'BINDINGS': { tab: 'bindingsTab', panel: 'bindingsTabpanel' }, 'FAVICON': { tab: 'faviconTab', panel: 'faviconTabpanel' }, 'DONE': { tab: 'doneTab', panel: 'doneTabpanel' } }; this._directLoginReference = null; this._directLoginFavicon = null; this._updateFaviconCounter = 0; this._faviconComponent = null; this._bindingComponents = []; this._formValueComponents = []; return this; } //============================================================================= //Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent, Clipperz.PM.UI.Common.Components.TabPanelComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent component"; }, //========================================================================= 'directLoginReference': function () { return this._directLoginReference; }, //------------------------------------------------------------------------- 'setDirectLoginReference': function (aDirectLoginReference) { this._directLoginReference = aDirectLoginReference; return this._directLoginReference; }, //========================================================================= 'label': function () { return this.getElement('label').value }, 'setLabel': function (aValue) { -//console.log("##> LABEL: " + aValue); this.getElement('label').value = (aValue ? aValue : ''); }, //------------------------------------------------------------------------- 'favicon': function () { return this.getElement('faviconURL').value; }, 'setFavicon': function (aValue) { var regexp; var displayValue; regexp = new RegExp('^data\:\/\/.*', 'i'); if (regexp.test(aValue)) { displayValue = '' } else { displayValue = (aValue ? aValue : ''); } this.getElement('faviconURL').value = displayValue; this.faviconComponent().setSrc(aValue); }, // 'setFaviconData': function (aValue) { // this.getElement('faviconIcon').src = aValue; // }, 'directLoginFavicon': function () { return this._directLoginFavicon; }, 'setDirectLoginFavicon': function (aValue) { this._directLoginFavicon = aValue; this.setFavicon(aValue); }, //------------------------------------------------------------------------- 'bookmarkletConfiguration': function () { return this.getElement('bookmarkletConfiguration').value }, 'setBookmarkletConfiguration': function (aValue) { this.getElement('bookmarkletConfiguration').value = aValue; }, 'highlightConfigurationSyntaxError': function () { MochiKit.DOM.addElementClass(this.getElement('bookmarkletConfiguration'), 'error'); }, 'removeHighlightConfigurationSyntaxError': function () { MochiKit.DOM.removeElementClass(this.getElement('bookmarkletConfiguration'), 'error'); }, //========================================================================= 'disableAllPanels': function () { this.getElement('label').disabled = true; MochiKit.DOM.addElementClass(this.getElement('label').parentNode, 'disabled'); this.tabPanelController().selectTab(null); }, //------------------------------------------------------------------------- // 'disableLabelField': function () { // this.getElement('label').disabled = true; // MochiKit.DOM.addElementClass(this.getElement('label').parentNode, 'disabled'); // }, 'enableLabelField': function () { this.getElement('label').disabled = false; MochiKit.DOM.removeElementClass(this.getElement('label').parentNode, 'disabled'); this.tabPanelController().selectTab('LABEL'); }, //------------------------------------------------------------------------- // 'disableTypeField': function () { // this.tabPanelController().selectTab(null); // }, 'enableTypeField': function () { this.tabPanelController().selectTab('TYPE'); }, //------------------------------------------------------------------------- // 'disableConfigurationField': function () { // this.tabPanelController().selectTab(null); // }, 'enableConfigurationField': function () { this.tabPanelController().selectTab('CONFIGURATION'); }, //------------------------------------------------------------------------- // 'disableBindingFields': function () { // this.tabPanelController().selectTab(null); // }, 'enableBindingFields': function () { this.tabPanelController().selectTab('BINDINGS'); }, //------------------------------------------------------------------------- // 'disableFaviconField': function () { // this.tabPanelController().selectTab(null); // }, 'enableFaviconField': function () { this.tabPanelController().selectTab('FAVICON'); }, //------------------------------------------------------------------------- 'enableDonePanel': function () { this.tabPanelController().selectTab('DONE'); }, //========================================================================= 'shouldShowElementWhileRendering': function() { return false; }, //========================================================================= 'faviconComponent': function () { if (this._faviconComponent == null) { this._faviconComponent = new Clipperz.PM.UI.Common.Components.FaviconComponent({element:this.getId('favicon')}); } return this._faviconComponent; }, //========================================================================= 'tabPanelController': function () { if (this._tabPanelController == null) { this._tabPanelController = new Clipperz.PM.UI.Common.Controllers.TabPanelController({ component:this, configuration:this._tabPanelControllerConfiguration }); MochiKit.Signal.connect(this._tabPanelController, 'tabSelected', this, 'handleTabSelected') } return this._tabPanelController; }, //------------------------------------------------------------------------- 'renderSelf': function() { var bookmarkletComponent; this.append(this.element(), {tag:'div', cls:'directLoginEditing', id:this.getId('panel'), children: [ // {tag:'div', cls:'back', children:[ // {tag:'a', href:'#', id:this.getId('back'), html:" "} // ]}, {tag:'form', id:this.getId('form'), cls:'directLoginEditingForm', children:[ {tag:'div', cls:'title', children:[ {tag:'img', id:this.getId('favicon'), cls:'favicon'}, {tag:'input', type:'text', id:this.getId('label')} //, // {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.LABEL.description')}]}, ]}, {tag:'div', cls:'tabContainer', children:[ {tag:'ul', cls:'tabs', children:[ {tag:'li', id:this.getId('labelTab'), children:[{tag:'span', html:"label"}]}, {tag:'li', id:this.getId('typeTab'), children:[{tag:'span', html:"type"}]}, {tag:'li', id:this.getId('configurationTab'), children:[{tag:'span', html:"configuration"}]}, {tag:'li', id:this.getId('bindingsTab'), children:[{tag:'span', html:"bindings"}]}, {tag:'li', id:this.getId('faviconTab'), children:[{tag:'span', html:"favicon"}]}, {tag:'li', id:this.getId('doneTab'), children:[{tag:'span', html:"done"}]} ]}, {tag:'ul', cls:'tabPanels', children:[ {tag:'li', id:this.getId('labelTabpanel'), cls:'tabPanel label', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.LABEL.description')}]} ]}, {tag:'li', id:this.getId('typeTabpanel'), cls:'tabPanel type', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.TYPE.description')}]}, {tag:'h2', html:"type"} ]}, {tag:'li', id:this.getId('configurationTabpanel'), cls:'tabPanel configuration', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.CONFIGURATION.description')}]}, {tag:'div', cls:'bookmarkletConfigurationWrapper', children:[ {tag:'textarea', id:this.getId('bookmarkletConfiguration'), value:""}, // {tag:'div', cls:'bookmarkletComponentWrapper', children:[{tag:'div', id:this.getId('bookmarkletComponent'), cls:'bookmarkletComponent'}]} {tag:'div', id:this.getId('bookmarkletComponent'), cls:'bookmarkletComponent'} ]} ]}, {tag:'li', id:this.getId('bindingsTabpanel'), cls:'tabPanel bindings', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.BINDINGS.description')}]}, {tag:'div', cls:'bindings', id:this.getId('bindings'), children:[]}, {tag:'div', cls:'formValues', id:this.getId('formValues'), children:[]} ]}, {tag:'li', id:this.getId('faviconTabpanel'), cls:'tabPanel favicon', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.FAVICON.description')}]}, {tag:'div', cls:'favicon', children:[ {tag:'input', type:'text', id:this.getId('faviconURL')} ]} ]}, {tag:'li', id:this.getId('doneTabpanel'), cls:'tabPanel done', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', id:this.getId('doneDescription')/*, html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.DONE.description')*/}]} ]} ]} ]} ]}, {tag:'div', cls:'clear'} ]}); bookmarkletComponent = new Clipperz.PM.UI.Web.Components.BookmarkletComponent({element:this.getElement('bookmarkletComponent')}); bookmarkletComponent.render(); this.tabPanelController().setup(/*{selected:this.initiallySelectedTab()}*/); MochiKit.Signal.connect(this.getId('label'), 'onchange', this, 'changedValue'); MochiKit.Signal.connect(this.getId('label'), 'onkeyup', this, 'changedValue'); MochiKit.Signal.connect(this.getId('bookmarkletConfiguration'), 'onchange', this, 'changedValue'); MochiKit.Signal.connect(this.getId('bookmarkletConfiguration'), 'onkeyup', this, 'changedValue'); MochiKit.Signal.connect(this.getId('faviconURL'), 'onchange', this, 'changedValue'); MochiKit.Signal.connect(this.getId('faviconURL'), 'onkeyup', this, 'changedValue'); MochiKit.Signal.connect(this.getId('panel'), 'onkeydown',this, 'handleKeyEvent'); }, //------------------------------------------------------------------------- 'handleTabSelected': function (aSelectedTab) { switch (aSelectedTab) { case 'DETAILS': break; case 'DIRECT_LOGINS': MochiKit.Style.hideElement(this.getElement('backToDirectLoginList')); break; case 'SHARING': break; } }, //========================================================================= 'incrementUpdateFaviconCounter': function () { this._updateFaviconCounter ++; }, 'decrementUpdateFaviconCounter': function () { this._updateFaviconCounter --; }, 'updateFaviconCounter': function () { return this._updateFaviconCounter; }, //------------------------------------------------------------------------- 'updateFavicon': function () { this.decrementUpdateFaviconCounter(); if (this.updateFaviconCounter() == 0) { this.setFavicon(this.favicon()); } }, //========================================================================= 'bindingComponents': function () { return this._bindingComponents; }, 'clearAllBindingsComponents': function () { MochiKit.Iter.forEach(this.bindingComponents(), MochiKit.Base.methodcaller('remove')); this._bindingComponents = []; this.getElement('bindings').innerHTML = ''; }, 'addBindingComponent': function (aBindingComponent) { this.bindingComponents().push(aBindingComponent); aBindingComponent.renderInNode(this.append(this.getElement('bindings'), {tag:'div'})); }, //========================================================================= 'formValueComponents': function () { return this._formValueComponents; }, 'clearAllFormValueComponents': function () { MochiKit.Iter.forEach(this.formValueComponents(), MochiKit.Base.methodcaller('remove')); this._formValueComponents = []; this.getElement('formValues').innerHTML = ''; }, 'addFormValueComponent': function (aFormValueComponent) { this.formValueComponents().push(aFormValueComponent); aFormValueComponent.renderInNode(this.append(this.getElement('formValues'), {tag:'div'})); }, //========================================================================= 'changedValue': function (anEvent) { MochiKit.Signal.signal(this, 'changedValue', anEvent); this.incrementUpdateFaviconCounter(); MochiKit.Async.callLater(1, MochiKit.Base.method(this, 'updateFavicon')); }, //------------------------------------------------------------------------- 'handleBackClick': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'back'); }, //========================================================================= 'bottomMargin': function () { return MochiKit.Style.getElementPosition(this.element().parentNode)['y'] + MochiKit.Style.getElementDimensions(this.element())['h']; }, //========================================================================= 'focusOnLabelElement': function () { this.getElement('label').focus(); }, 'focusOnBookmarkletConfigurationElement': function () { this.getElement('bookmarkletConfiguration').focus(); }, 'focusOnFaviconElement': function () { this.getElement('faviconURL').focus(); }, //========================================================================= 'setDoneDescriptionWithKeys': function (someKeys) { // {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', id:this.getId('doneDescription')/*, html:Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.DONE.description')*/}]} this.getElement('doneDescription').innerHTML = Clipperz.PM.Strings.getValue('Wizards.DirectLoginWizard.DONE.description', someKeys); }, //========================================================================= 'handleKeyEvent': function (anEvent) { MochiKit.Signal.signal(this, 'keyPressed', anEvent); /* if (anEvent.key().string == 'KEY_ENTER') { if (anEvent.target().nodeName != 'TEXTAREA') { MochiKit.Signal.signal(this, 'moveForward'); anEvent.preventDefault(); } } else if (anEvent.key().string == 'KEY_TAB') { if ((anEvent.target().nodeName == 'INPUT') || (anEvent.target().nodeName == 'TEXTAREA')) { MochiKit.Signal.signal(this, 'moveForward'); anEvent.preventDefault(); } } */ }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js index fa57233..58b5b26 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js @@ -1,176 +1,169 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.DirectLoginEditingFormValueComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DirectLoginEditingFormValueComponent.superclass.constructor.apply(this, arguments); this._formFieldName = args.formFieldName || Clipperz.Base.exception.raise('MandatoryParameter'); this._fieldOptions = args.fieldOptions || Clipperz.Base.exception.raise('MandatoryParameter'); this._initialValue = args.initialValue || null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginEditingFormValueComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.DirectLoginEditingFormValueComponent component"; }, //------------------------------------------------------------------------- 'formFieldName': function () { return this._formFieldName; }, //------------------------------------------------------------------------- 'fieldOptions': function () { return this._fieldOptions; }, 'fieldType': function () { return this.fieldOptions()['type']; }, 'optionValues': function () { return MochiKit.Base.map(function (anOptionValue) { return { 'label': anOptionValue['label'] || anOptionValue['value'], 'value': anOptionValue['value'] } }, this.fieldOptions()['options']); }, //------------------------------------------------------------------------- 'selectedValue': function () { var result; result = this.getElement('select').value; if (result == '---') { result = null; } return result; }, 'initialValue': function () { return this._initialValue; }, //========================================================================= 'renderSelf': function() { -//console.log(">>> DirectLoginEditingFormValueComponent.renderSelf"); -//console.log("FIELD OPTIONS", this.fieldOptions()); -//console.log("OPTION VALUES", this.optionValues()); this.append(this.element(), {tag:'div', id:this.getId('div'), cls:'formValue', children:[ {tag:'span', cls:'formFieldName', html:this.formFieldName()}, {tag:'div', id:this.getId('values')} ]}); if ((this.fieldType() == 'radio') || (this.fieldType() == 'select')) { this.append(this.getElement('values'), {tag:'select', name:this.formFieldName(), id:this.getId('select'), cls:'formFieldMatchinCardField', children: MochiKit.Base.flattenArguments( // {tag:'option', value:'---', html:"---"}, MochiKit.Base.map( MochiKit.Base.bind(function (aValue) { return {tag:'option', value:aValue['value'], html:aValue['label']}; }, this), this.optionValues() ) ) } ); MochiKit.Signal.connect(this.getElement('select'), 'onchange', this, 'handleSelectChange'); if (! MochiKit.Base.isUndefinedOrNull(this.initialValue())) { var initiallySelectedOptions; initiallySelectedOptions = MochiKit.Selector.findChildElements(this.element(), ['option[value=' + this.initialValue() + ']']); if (initiallySelectedOptions.length == 1) { MochiKit.DOM.updateNodeAttributes(initiallySelectedOptions[0], {selected:true}); this.handleSelectChange(); } else { Clipperz.DOM.Helper.insertBefore(this.getElement('select').childNodes[0], {tag:'option', value:'---', html:"", selected:true}); } } else { Clipperz.DOM.Helper.insertBefore(this.getElement('select').childNodes[0], {tag:'option', value:'---', html:"", selected:true}); } } else if (this.fieldType() == 'checkbox') { this.append(this.getElement('values'), {tag:'input', type:'checkbox', name:this.formFieldName(), id:this.getId('checkbox'), cls:'formFieldMatchinCardField'} ); MochiKit.Signal.connect(this.getElement('checkbox'), 'onchange', this, 'handleSelectChange'); if (this.initialValue()) { MochiKit.DOM.updateNodeAttributes(this.getElement('checkbox'), {checked:true}); } } else { WTF = TODO; } -//console.log("<<< DirectLoginEditingFormValueComponent.renderSelf"); }, //========================================================================= 'handleSelectChange': function (anEvent) { -//console.log("handleSelectChange", anEvent, anEvent.src(), anEvent.src().value); var options; options = {}; options['fieldName'] = this.formFieldName(); if (this.fieldType() == 'checkbox') { options['selectedValue'] = (this.getElement('checkbox').checked ? 1 : null); } else { options['selectedValue'] = this.selectedValue(); } MochiKit.Signal.signal(this, 'formValueChange', options); }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js index d8dc941..b4fc24e 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js @@ -1,268 +1,266 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager.superclass.constructor.call(this, args); this._enterLeaveCounter = 0; this._selectedRowObject = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager component"; }, //------------------------------------------------------------------------- 'renderHeader': function(aTRElement) { Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager.superclass.renderHeader.call(this, aTRElement); Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, {tag:'div', cls:'DirectLoginListPopup', id:this.getId('DirectLoginListPopup'), children:[ {tag:'div', cls:'DirectLoginListPopup_body', children:[ {tag:'ul', id:this.getId('DirectLoginListPopup_list'), children:[ // {tag:'li', children:[ // {tag:'img', cls:'favicon', src:'http://www.microsoft.com/favicon.ico'}, // {tag:'a', href:'#', html:"Google Mail"} // ]}, // ... ]} ]}, {tag:'div', cls:'DirectLoginListPopup_footer'} ]}); MochiKit.Style.hideElement(this.getId('DirectLoginListPopup')); // BEWARE: use MochiKit.Signal.connect instead of this.connectEvent, as the HEADER is NOT redrawn after each refresh MochiKit.Signal.connect(this.getId('DirectLoginListPopup'), 'onmouseenter', this, 'handleDirectLoginListPopupEnter'); MochiKit.Signal.connect(this.getId('DirectLoginListPopup'), 'onmouseleave', this, 'handleDirectLoginListPopupLeave'); }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { var i,c; var directLoginsInfo; directLoginsInfo = anObject[this.name()]; TDElement = Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:'card_directLogins'}); c = Math.min(2, directLoginsInfo.length); for (i=0; i<c; i++) { var elementID; elementID = 'directLogin_' + directLoginsInfo[i]['_reference']; Clipperz.DOM.Helper.append(TDElement, {tag:'div', cls:'card_directLogin', children:[ {tag:'div', cls:'card_directLogin_body', children:[ {tag:'a', href:'#', id:elementID, html:directLoginsInfo[i]['label']} ]} ]}); // MochiKit.Signal.connect(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject'])); this.connectEvent(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject'])); } if (directLoginsInfo.length > 2) { var ellipsesElement; ellipsesElement = Clipperz.DOM.Helper.append(TDElement, {tag:'div', cls:'card_directLogin_ellipses', children:[ {tag:'div', cls:'card_directLogin_ellipses_body', children:[ {tag:'span', html:'…'} ]} ]}); /// MochiKit.Signal.connect(ellipsesElement, 'onmouseenter', MochiKit.Base.method(this, 'handleEllipsesEnter', anObject)); /// MochiKit.Signal.connect(ellipsesElement, 'onmouseleave', MochiKit.Base.method(this, 'handleEllipsesLeave')); // MochiKit.Signal.connect(TDElement, 'onmouseleave', MochiKit.Base.method(this, 'handleTDLeave')); this.connectEvent(TDElement, 'onmouseleave', MochiKit.Base.method(this, 'handleTDLeave')); } // MochiKit.Signal.connect(TDElement, 'onmouseenter', MochiKit.Base.method(this, 'handleTDEnter', anObject)); this.connectEvent(TDElement, 'onmouseenter', MochiKit.Base.method(this, 'handleTDEnter', anObject)); }, //========================================================================= /* 'handleEllipsesEnter': function (aRecordInfo, anEvent) { this._enterLeaveCounter ++; if (this._enterLeaveCounter > 2) { this._enterLeaveCounter = 2; } if (this._enterLeaveCounter == 1) { this.showDirectLoginListPopup(aRecordInfo, anEvent.src()); } }, 'handleEllipsesLeave': function (anEvent) { this._enterLeaveCounter --; MochiKit.Async.callLater(0.3, MochiKit.Base.bind(function () { if (this._enterLeaveCounter == 0) { this.hideDirectLoginListPopup(); } }, this)) }, */ //------------------------------------------------------------------------- 'handleTDEnter': function (aRecordInfo, anEvent) { if (MochiKit.Selector.findChildElements(anEvent.src(), ['div.card_directLogin_ellipses']).length > 0) { this._enterLeaveCounter ++; if (this._enterLeaveCounter > 2) { this._enterLeaveCounter = 2; } if (this._enterLeaveCounter == 1) { this.showDirectLoginListPopup(aRecordInfo, anEvent.src()); } } else { if (this._selectedRowObject != null) { this.hideDirectLoginListPopup(); } } }, 'handleTDLeave': function (anEvent) { this._enterLeaveCounter --; if (this._enterLeaveCounter < 0) { this._enterLeaveCounter = 0; } MochiKit.Async.callLater(0.3, MochiKit.Base.bind(function () { if (this._enterLeaveCounter == 0) { this.hideDirectLoginListPopup(); } }, this)) }, //------------------------------------------------------------------------- 'handleDirectLoginListPopupEnter': function (anEvent) { this._enterLeaveCounter ++; if (this._enterLeaveCounter > 2) { this._enterLeaveCounter = 2; } }, 'handleDirectLoginListPopupLeave': function (anEvent) { this._enterLeaveCounter --; if (this._enterLeaveCounter < 0) { this._enterLeaveCounter = 0; } MochiKit.Async.callLater(0.3, MochiKit.Base.bind(function () { if (this._enterLeaveCounter == 0) { this.hideDirectLoginListPopup(); } }, this)) }, //========================================================================= 'showDirectLoginListPopup': function (aRecordInfo, anElement) { var position; var directLoginsInfo; var directLoginsListElement; var ellipsesElement; ellipsesElement = MochiKit.Selector.findChildElements(anElement, ['div.card_directLogin_ellipses'])[0]; position = MochiKit.Style.getElementPosition(ellipsesElement); // position = MochiKit.Style.getElementPosition(anElement); position.x += 14; position.y -= 26; MochiKit.Style.setElementPosition(this.getId('DirectLoginListPopup'), position /*[, units='px'] */); directLoginsListElement = this.getElement('DirectLoginListPopup_list'); directLoginsListElement.innerHTML = ''; directLoginsInfo = aRecordInfo[this.name()]; c = directLoginsInfo.length; for (i=0; i<c; i++) { var elementID; var label; var trunkedLabel; label = directLoginsInfo[i]['label']; trunkedLabel = (label.length > 20 ? label.slice(0,20) + '…' : label); elementID = this.getId('directLoginList_' + directLoginsInfo[i]['_reference']); Clipperz.DOM.Helper.append(directLoginsListElement, {tag:'li', children:[ {tag:'div', children:[ {tag:'img', cls:'favicon', src:directLoginsInfo[i]['favicon']}, (label == trunkedLabel ? {tag:'a', href:'#', id:elementID, html:trunkedLabel} : {tag:'a', href:'#', id:elementID, title:label, html:trunkedLabel}) ]} ]}); // MochiKit.Signal.connect(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject'])); this.connectEvent(elementID, 'onclick', MochiKit.Base.method(this, 'handleDirectLoginClick', directLoginsInfo[i]['_rowObject'])); } // MochiKit.Style.showElement(this.getId('DirectLoginListPopup')); MochiKit.Visual.appear(this.getId('DirectLoginListPopup'), {duration:0.5}); MochiKit.Signal.signal(this, 'selectRow', aRecordInfo); this._selectedRowObject = aRecordInfo; }, //------------------------------------------------------------------------- 'hideDirectLoginListPopup': function () { if (this._selectedRowObject != null) { MochiKit.Signal.signal(this, 'unselectRow', this._selectedRowObject); MochiKit.Visual.fade(this.getId('DirectLoginListPopup'), {duration:0.5}); this._selectedRowObject = null; this._enterLeaveCounter = 0; } }, //========================================================================= 'handleDirectLoginClick': function (aDirectLogin, anEvent) { anEvent.preventDefault(); // aDirectLogin.runDirectLogin(); Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin(aDirectLogin); }, //------------------------------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/FaviconColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/FaviconColumnManager.js index 6297002..bdb044a 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/FaviconColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/FaviconColumnManager.js @@ -1,86 +1,84 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.FaviconColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.FaviconColumnManager.superclass.constructor.call(this, args); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.FaviconColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.FaviconColumnManager component"; }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { var faviconImageElement; var faviconUrl; faviconImageElement = this.getId('favicon'); faviconUrl = anObject[this.name()]; if (faviconUrl == null) { faviconUrl = Clipperz.PM.Strings.getValue('defaultFaviconUrl'); } Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ {tag:'img', id:faviconImageElement, src:faviconUrl} ]}); MochiKit.Signal.connect(faviconImageElement, 'onload', this, 'handleLoadedFaviconImage'); MochiKit.Signal.connect(faviconImageElement, 'onerror', this, 'handleMissingFaviconImage'); MochiKit.Signal.connect(faviconImageElement, 'onabort', this, 'handleMissingFaviconImage'); }, //----------------------------------------------------- 'handleLoadedFaviconImage': function(anEvent) { MochiKit.Signal.disconnectAllTo(anEvent.src()); if (anEvent.src().complete == false) { anEvent.src().src = Clipperz.PM.Strings.getValue('defaultFaviconUrl'); } }, //----------------------------------------------------- 'handleMissingFaviconImage': function(anEvent) { MochiKit.Signal.disconnectAllTo(anEvent.src()); anEvent.src().src = Clipperz.PM.Strings.getValue('defaultFaviconUrl'); }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js index 51d55f4..21dddc9 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/GridComponent.js @@ -1,259 +1,255 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.GridComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.GridComponent.superclass.constructor.apply(this, arguments); this._columnsManagers = args.columnsManagers; this._rowsObjects = []; this._noRowsGridComponent = null; this._slots = { 'headerSlot': this.getId('headerSlot') }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.GridComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.GridComponent component"; }, //------------------------------------------------------------------------- 'rows': function () { throw Clipperz.Base.exception.AbstractMethod; // return this._rows; }, //------------------------------------------------------------------------- 'columnsManagers': function () { return this._columnsManagers; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', cls:'header', children:[ {tag:'form', id:this.getId('searchForm'), cls:'search', children:[ {tag:'div', cls:'search', children:[ {tag:'input', type:'text', id:this.getId('search'), cls:'search', placeholder:"search", name:'textToSearch'/*, value:"clipperz"*/} ]}, {tag:'div', cls:'clearSearchButton', id:this.getId('clearSearch')}, // {tag:'input', type:'button', cls:'searchButton', name:'searchButton', value:"search"}, {tag:'div', cls:'headerSlot', id:this.getId('headerSlot')} ]} ]}, {tag:'div', cls:'body', children:[ {tag:'div', cls:'rows', id:this.getId('rows'), children:[ {tag:'table', cellpadding:'0', cellspacing:'0', cls:'rows', children:[ {tag:'thead', children:[ {tag:'tr', id:this.getId('thead_tr'), children:[]} ]}, {tag:'tbody', id:this.getId('gridRows'), children:[]} ]} ]}, {tag:'div', cls:'noRowsBlock', id:this.getId('noRowsBlock'), children:[]} ]}, {tag:'div', cls:'footer'} ]); this.renderHeader(); MochiKit.Signal.connect(this.getId('clearSearch'), 'onclick', this, 'clearSearchHandler'); }, //------------------------------------------------------------------------- 'renderHeader': function () { var headerElement; headerElement = this.getElement('thead_tr'); headerElement.innerHTML = ""; MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { aColumnManager.renderHeader(headerElement); }); }, //------------------------------------------------------------------------- 'update': function (someObjects) { this._rowsObjects = someObjects this.refresh(); this.focus(); }, 'focus': function () { this.getElement('search').focus(); }, //------------------------------------------------------------------------- 'startSearch': function () { -//console.log("--> startSearch"); MochiKit.DOM.addElementClass(this.getElement('search'), 'running'); }, 'endSearch': function () { MochiKit.DOM.removeElementClass(this.getElement('search'), 'running'); -//console.log("<-- startSearch"); }, //------------------------------------------------------------------------- 'disconnectColumnManagersRowsSignals': function () { MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { aColumnManager.disconnectRowsSignals(); }); }, //------------------------------------------------------------------------- 'refresh': function () { var gridRowsElement; var rowClass; this.disconnectColumnManagersRowsSignals(); { MochiKit.DOM.removeElementClass(this.getElement('search'), 'disabled'); // MochiKit.DOM.setNodeAttribute(this.getElement('search'), 'disabled', null); MochiKit.DOM.removeElementClass(this.element(), 'empty'); MochiKit.DOM.removeElementClass(this.element(), 'noRows'); } gridRowsElement = this.getElement('gridRows'); gridRowsElement.innerHTML = ""; MochiKit.DOM.removeElementClass(this.element(), 'empty'); rowClass = 'odd'; MochiKit.Iter.forEach(this._rowsObjects, MochiKit.Base.bind(function (aRowObject) { var cardRowElement; cardRowElement = this.append(gridRowsElement, {tag:'tr', id:this.getId(aRowObject['_reference']), cls:rowClass}); MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { aColumnManager.renderCell(cardRowElement, aRowObject); }); rowClass = (rowClass == 'odd') ? 'even' : 'odd'; }, this)); }, //----------------------------------------------------------------------------- 'filterElement': function () { return this.getElement('search'); }, //------------------------------------------------------------------------- 'shouldShowElementWhileRendering': function () { return false; }, //------------------------------------------------------------------------- 'selectRow': function (aRowObject) { MochiKit.DOM.addElementClass(this.getId(aRowObject['_reference']), 'selected'); }, 'unselectRow': function (aRowObject) { MochiKit.DOM.removeElementClass(this.getId(aRowObject['_reference']), 'selected'); }, //------------------------------------------------------------------------- /* 'passOpenDirectLogin': function(aDirectLoginReferenceId) { MochiKit.Signal.signal(this, 'openDirectLogin', aDirectLoginReferenceId); }, */ //------------------------------------------------------------------------- 'clearSearchHandler': function (anEvent) { var searchElement; anEvent.preventDefault(); searchElement = this.getElement('search'); searchElement.value = ""; searchElement.focus(); }, //------------------------------------------------------------------------- 'drawEmpty': function () { this.disconnectColumnManagersRowsSignals(); MochiKit.DOM.addElementClass(this.getElement('search'), 'disabled'); // MochiKit.DOM.setNodeAttribute(this.getElement('search'), 'disabled', 'disabled'); gridRowsElement = this.getElement('gridRows'); gridRowsElement.innerHTML = ""; MochiKit.DOM.addElementClass(this.element(), 'empty'); }, //------------------------------------------------------------------------- 'setNoRowsGridComponent': function (aComponent) { this.removeNoRowsGridComponent(); this._noRowsGridComponent = aComponent; this.disconnectColumnManagersRowsSignals(); MochiKit.DOM.addElementClass(this.getElement('search'), 'disabled'); // MochiKit.DOM.setNodeAttribute(this.getElement('search'), 'disabled', 'disabled'); gridRowsElement = this.getElement('gridRows'); gridRowsElement.innerHTML = ""; MochiKit.DOM.addElementClass(this.element(), 'noRows'); if (aComponent != null) { aComponent.renderInNode(this.getElement('noRowsBlock')); } }, 'removeNoRowsGridComponent': function () { if (this._noRowsGridComponent != null) { this._noRowsGridComponent.remove(); this._noRowsGridComponent = null; } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ImageColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ImageColumnManager.js index 3e03fcf..d1d9d7f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ImageColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ImageColumnManager.js @@ -1,65 +1,63 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.ImageColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.ImageColumnManager.superclass.constructor.call(this, args); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.ImageColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.ImageColumnManager component"; }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ {tag:'img', src:anObject[this.name()]} ]}); // return Clipperz.Async.callbacks("ImageColumnManager.renderCell", [ // this.selector(), // MochiKit.Base.bind(function (aValue) { // Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ // {tag:'img', src:aValue} // ]}); // }, this) // ], {trace:false}, anObject); }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LinkColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LinkColumnManager.js index f3f9cd5..69f735b 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LinkColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LinkColumnManager.js @@ -1,89 +1,87 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.LinkColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.LinkColumnManager.superclass.constructor.call(this, args); this._actionMethod = args.actionMethod || null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LinkColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.DateColumnManager component"; }, //------------------------------------------------------------------------- 'actionMethod': function () { return this._actionMethod; }, //------------------------------------------------------------------------- 'renderCell': function(aRowElement, anObject) { var tdElement; var linkElement; tdElement = Clipperz.DOM.Helper.append(aRowElement, {tag:'td', cls:this.cssClass(), children:[ {tag:'span', children:[ {tag:'a', href:'#', html:anObject[this.name()]} ]} ]}); linkElement = MochiKit.DOM.getFirstElementByTagAndClassName('a', null, tdElement); // MochiKit.Signal.connect(linkElement, 'onclick', MochiKit.Base.method(this, 'handleLinkClick', anObject['_rowObject'])); this.connectEvent(linkElement, 'onclick', MochiKit.Base.method(this, 'handleLinkClick', anObject['_rowObject'])); }, //----------------------------------------------------- 'handleLinkClick': function (anObject, anEvent) { anEvent.preventDefault(); if (this.actionMethod() != null) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("LinkColumnManager.handleLinkClick", {trace:false}); // deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'selectRow', anObject); deferredResult.addCallback(this.actionMethod(), anObject, anEvent); // deferredResult.addBothPass(MochiKit.Signal.signal, this, 'unselectRow', anObject); deferredResult.callback(); } }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js index a10ba4f..38a9421 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js @@ -1,178 +1,176 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.LoginForm = function(args) { args = args || {}; this._autocomplete = args.autocomplete || 'off'; Clipperz.PM.UI.Web.Components.LoginForm.superclass.constructor.apply(this, arguments); this._slots = { 'passphraseEntropy': this.getId('passphraseEntropy') }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.LoginForm component"; }, 'autocomplete': function () { return this._autocomplete; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(this.element(), {tag:'div', id:'loginBox', children:[ {tag:'div', cls:'header'}, {tag:'div', cls:'body', id:this.getId('body'), children:[ {tag:'div', id:this.getId('loginForm'), children:[ {tag:'div', children:[ {tag:'h4', html:'Login'}, // {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[ {tag:'form', id:this.getId('form'), cls:'loginForm', children:[ {tag:'label', html:'username', 'for':this.getId('usernameField')}, {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'}, {tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')}, {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'}, {tag:'div', cls:'translations', children:[ {tag:'h4', html:'choose your language'}, {tag:'ul', children:[ {tag:'li', cls:'selected', html:'english'}, {tag:'li', html:'italiano'}, {tag:'li', html:'dutch'}, {tag:'li', html:'french'}, {tag:'li', html:'spanish'}, {tag:'li', html:'chinese'}, {tag:'li', html:'japanese'}, {tag:'li', html:'portugal'}, {tag:'li', html:'arabic'} ]} ]}, {tag:'input', id:this.getId('submitButton'), type:'submit', value:'login', cls:'submit'} ]} ]} ]} ]}, {tag:'div', cls:'footer'} ]}); if (this.autocomplete() == 'off') { MochiKit.DOM.updateNodeAttributes(this.getElement('form'), {autocomplete:'off'}); } // Clipperz.Style.setBackgroundGradient(this.getElement('body'), {from:"#ff9955", to:"#ff6622"}) // this.setEntropyDisplay(new Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay(this.getElement('passphraseField'))); // MochiKit.Signal.connect(this.getId('otpCheckbox'), 'onclick', this, 'togglePasswordFields'); // this.showPassphraseField(); this.getElement('usernameField').focus(); MochiKit.Signal.connect(this.getElement('loginForm'), 'onsubmit', this, 'loginEventHandler'); }, //----------------------------------------------------------------------------- /* 'togglePasswordFields': function(anEvent) { var shouldUseOTP; shouldUseOTP = this.getElement('otpCheckbox').checked; if (shouldUseOTP == false) { this.showPassphraseField(); } else { this.showOTPFields(); } }, */ //----------------------------------------------------------------------------- /* 'showPassphraseField': function() { this.showElement('passphraseOption'); this.hideElement('otpOption'); }, */ //----------------------------------------------------------------------------- 'focusOnPassphraseField': function () { this.getElement('passphraseField').focus(); this.getElement('passphraseField').select(); }, //----------------------------------------------------------------------------- /* 'showOTPFields': function() { this.hideElement('passphraseOption'); this.showElement('otpOption'); }, */ //------------------------------------------------------------------------- 'loginEventHandler': function(anEvent) { // var username; // var passphrase; var signalArguments; anEvent.preventDefault(); // username = this.getElement('usernameField').value; // passphrase = this.getElement('passphraseField').value; // signalArguments = {username:username}; // signalArguments.passphrase = passphrase; signalArguments = { 'username': this.getElement('usernameField').value, 'passphrase': this.getElement('passphraseField').value }; MochiKit.Signal.signal(this, 'doLogin', signalArguments); }, //------------------------------------------------------------------------- 'submitButtonElement': function() { return this.getElement('submitButton'); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginPage.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginPage.js index 2894af8..3498e3f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginPage.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginPage.js @@ -1,203 +1,201 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.LoginPage = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.LoginPage.superclass.constructor.apply(this, arguments); this._slots = { 'loginForm': this.getId('loginBoxSlot') }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginPage, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.LoginPage component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', id:this.getId('loginBoxSlot')}, {tag:'div', id:'main', children:[ {tag:'div', id:'featurePoints', children:[ {tag:'table', children:[ {tag:'tr', children:[ {tag:'td', children:[ {tag:'div', cls:'block', children:[ {tag:'h3', html:'Clipperz is:'}, {tag:'ul', children:[ {tag:'li', html:'a secure and simple password manager'}, {tag:'li', html:'an effective single sign-on solution'}, {tag:'li', html:'a digital vault for your personal data'} ]} ]}, {tag:'div', cls:'block', children:[ {tag:'h3', html:'Clipperz benefits:'}, {tag:'ul', children:[ {tag:'li', html:'free and completely anonymous'}, {tag:'li', html:'access it any time from any computer'}, {tag:'li', html:'no software to download and nothing to install'}, {tag:'li', html:'avoid keeping secrets on your PC or on paper'} ]} ]} ]}, {tag:'td', children:[ {tag:'div', cls:'block', children:[ {tag:'h3', html:'Clipperz security:'}, {tag:'ul', children:[ {tag:'li', html:'your secretes are locally encrypted by your browser before being uploaded to Clipperz'}, {tag:'li', html:'the encryption key is a passphrase known only to you'}, {tag:'li', html:'Clipperz hosts your sensitive data in an encrypted form and could never access the data in its plain form'}, {tag:'li', html:'Clipperz is built upon standard encryption schemes, nothing fancies of homemade'}, {tag:'li', html:'you can review the source code anytime you like, but you need to know nothing about cryptography to be an happy user!'} ]} ]} ]} ]} ]} ]}, {tag:'div', cls:'activeFeatures', children:[ {tag:'div', id:this.getId('registerButton'), cls:'createAccountLink', children:[ {tag:'canvas', id:this.getId('registerButtonIcon')}, {tag:'a', href:'#', id:this.getId('createAccountLink'), cls:'createAccountLink', children:[ {tag:'span', cls:'payoff', html:"Free sign up!"}, {tag:'span', cls:'link', html:"Create account >>"} ]} ]}, {tag:'div', cls:'keepTogether', children:[ {tag:'div', id:this.getId('screenshotLink'), cls:'screenshotLink', children:[ {tag:'canvas', id:this.getId('lookIcon')}, {tag:'a', href:'#', cls:'screenshotLink', children:[ {tag:'span', cls:'payoff', html:"Look Clipperz!"}, {tag:'span', cls:'link', html:"screenshot tour >>"} ]} ]}, {tag:'div', id:this.getId('offlineLink'), cls:'offlineLink', children:[ {tag:'canvas', id:this.getId('downloadIcon')}, {tag:'a', href:'#', cls:'offlineLink', children:[ {tag:'span', cls:'payoff', html:"Download!"}, {tag:'span', cls:'link', html:"Offline version >>"} ]} ]} ]} ]} ]} ]); this.setRegistrationButtonIconDefaultColors(); this.setLookIconDefaultColors(); this.setDownloadIconDefaultColors(); // MochiKit.Signal.connect(this.getElement('createAccountLink'), 'onclick', this, 'handleCreateAccountLink') MochiKit.Signal.connect(this.getElement('registerButton'), 'onmouseenter', this, 'handleMouseEnterOnRegisterButtonIcon'); MochiKit.Signal.connect(this.getElement('registerButton'), 'onmouseleave', this, 'handleMouseLeaveOnRegisterButtonIcon'); MochiKit.Signal.connect(this.getElement('screenshotLink'), 'onmouseenter', this, 'handleMouseEnterOnLookIcon'); MochiKit.Signal.connect(this.getElement('screenshotLink'), 'onmouseleave', this, 'handleMouseLeaveOnLookIcon'); MochiKit.Signal.connect(this.getElement('offlineLink'), 'onmouseenter', this, 'handleMouseEnterOnDownloadIcon'); MochiKit.Signal.connect(this.getElement('offlineLink'), 'onmouseleave', this, 'handleMouseLeaveOnDownloadIcon'); MochiKit.Signal.connect(this.getElement('createAccountLink'), 'onclick', this, 'handleCreateAccountLink') }, //------------------------------------------------------------------------- 'setRegistrationButtonIconDefaultColors': function () { Clipperz.PM.UI.Canvas.registerButton.normal(this.getElement('registerButtonIcon'), "#eeeeee", "#eeeeee", "#ecab12", "#e14624", "#ffffff"); }, 'setRegistrationButtonIconHoverColors': function () { Clipperz.PM.UI.Canvas.registerButton.normal(this.getElement('registerButtonIcon'), "#cccccc", "#999999", "#ffb710", "#ff4d27", "#ffffff"); }, 'handleMouseEnterOnRegisterButtonIcon': function (anEvent) { this.setRegistrationButtonIconHoverColors(); }, 'handleMouseLeaveOnRegisterButtonIcon': function (anEvent) { this.setRegistrationButtonIconDefaultColors(); }, //------------------------------------------------------------------------- 'setLookIconDefaultColors': function () { Clipperz.PM.UI.Canvas.coverActions.look(this.getElement('lookIcon'), "#7e7e7e", "#ffffff", 1); }, 'setLookIconHoverColors': function () { Clipperz.PM.UI.Canvas.coverActions.look(this.getElement('lookIcon'), "#666666", "#ffffff", 2); }, 'handleMouseEnterOnLookIcon': function (anEvent) { this.setLookIconHoverColors(); }, 'handleMouseLeaveOnLookIcon': function (anEvent) { this.setLookIconDefaultColors(); }, //------------------------------------------------------------------------- 'setDownloadIconDefaultColors': function () { Clipperz.PM.UI.Canvas.coverActions.download(this.getElement('downloadIcon'), "#7e7e7e", "#ffffff", 1); }, 'setDownloadIconHoverColors': function () { Clipperz.PM.UI.Canvas.coverActions.download(this.getElement('downloadIcon'), "#666666", "#ffffff", 2); }, 'handleMouseEnterOnDownloadIcon': function (anEvent) { this.setDownloadIconHoverColors(); }, 'handleMouseLeaveOnDownloadIcon': function (anEvent) { this.setDownloadIconDefaultColors(); }, //------------------------------------------------------------------------- 'handleCreateAccountLink': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'createNewAccountClick', 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 26506e7..3fef6c5 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginProgress.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginProgress.js @@ -1,156 +1,153 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.LoginProgress = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.LoginProgress.superclass.constructor.apply(this, arguments); this._deferred = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginProgress, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.LoginProgress component"; }, //------------------------------------------------------------------------- 'deferred': function() { return this._deferred; }, 'setDeferred': function(aValue) { this._deferred = aValue; }, //------------------------------------------------------------------------- 'renderSelf': function() { // var loginProgressElement; // // loginProgressElement = MochiKit.DOM.getElement('loginProgress'); // // if (loginProgressElement == null) { // loginProgressElement = this.append(this.element(), {tag:'div', id:'loginProgress', cls:'LoginProgress'}, true); // } -//console.log(">> LoginProgress.renderSelf", this.element()); this.append(this.element(), {tag:'div', id:'loginProgress', cls:'LoginProgress', children: [ // this.append(loginProgressElement, [ {tag:'div', cls:'header', children:[ {tag:'h3', id:this.getId('title'), html:"login progress"} ]}, {tag:'div', cls:'body', children:[ {tag:'div', id:this.getId('progressBar')}, {tag:'div', id:this.getId('errorBox'), cls:'errorBox', children:[ // {tag:'div', cls:'img ALERT', children:[{tag:'div'}]}, {tag:'div', cls:'img ALERT', children:[{tag:'canvas', id:this.getId('canvas')}]}, {tag:'p', html:"Login failed"} ]} ]}, {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:'a', cls:'button', id:this.getId('button'), html:"cancel"} ]} ]} ]}); // ]); Clipperz.PM.UI.Canvas.marks['!'](this.getElement('canvas'), "#ffffff"); 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('button'), 'onclick', this, 'cancelEventHandler'); }, //------------------------------------------------------------------------- 'displayElement': function() { return MochiKit.DOM.getElement('loginProgress'); }, //------------------------------------------------------------------------- 'cancelEventHandler': function(anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'cancelEvent'); }, //------------------------------------------------------------------------- 'disableCancel': function() { MochiKit.Style.hideElement(this.getElement('buttonArea')); }, //------------------------------------------------------------------------- 'showErrorMessage': function() { // this.getElement('buttonLink').innerHTML = "close"; this.getElement('button').innerHTML = "close"; MochiKit.DOM.addElementClass(this.getElement('button'), 'default'); MochiKit.Style.hideElement(this.getElement('progressBar')); this.getElement('title').innerHTML = "Error"; MochiKit.Style.showElement(this.getElement('errorBox')); MochiKit.Style.showElement(this.getElement('buttonArea')); }, //------------------------------------------------------------------------- 'deferredHideModalAndRemove': function(someParameters, aResult) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("LoginProgress.deferredHideModalAndRemove", {trace:false}); deferredResult.addMethod(this, 'deferredHideModal'); deferredResult.addMethod(this, 'remove'); deferredResult.addCallback(function () { return aResult; }); deferredResult.callback(someParameters); return deferredResult; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js index feb16ad..06746d1 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js @@ -1,427 +1,419 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.NewUserCreationComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.NewUserCreationComponent.superclass.constructor.apply(this, arguments); this._tabPanelController = null; this._initiallySelectedTab = args.selected || 'CREDENTIALS'; this._tabPanelControllerConfiguration = { 'CREDENTIALS': { tab: 'credentialsTab', panel: 'credentialsTabpanel' }, 'CHECK_CREDENTIALS': { tab: 'checkCredentialsTab', panel: 'checkCredentialsTabpanel' }, 'TERMS_OF_SERVICE': { tab: 'termsOfServiceTab', panel: 'termsOfServiceTabpanel' }, 'CREATE_USER': { tab: 'createUserTab', panel: 'createUserTabpanel' } //, /* 'LOGIN': { tab: 'loginTab', panel: 'loginTabpanel' } */ }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.NewUserCreationComponent, Clipperz.PM.UI.Common.Components.TabPanelComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.NewUserCreationComponent component"; }, //========================================================================= 'disableAllPanels': function () { this.tabPanelController().selectTab(null); }, //------------------------------------------------------------------------- 'enableCredentialsPanel': function () { this.tabPanelController().selectTab('CREDENTIALS'); }, 'enableCheckCredentialsPanel': function () { this.tabPanelController().selectTab('CHECK_CREDENTIALS'); }, 'enableTermsOfServicePanel': function () { this.tabPanelController().selectTab('TERMS_OF_SERVICE'); }, 'enableCreateUserPanel': function () { this.tabPanelController().selectTab('CREATE_USER'); }, // 'enableLoginPanel': function () { // this.tabPanelController().selectTab('LOGIN'); // }, //========================================================================= 'shouldShowElementWhileRendering': function() { return false; }, //========================================================================= 'tabPanelController': function () { if (this._tabPanelController == null) { this._tabPanelController = new Clipperz.PM.UI.Common.Controllers.TabPanelController({ component:this, configuration:this._tabPanelControllerConfiguration }); MochiKit.Signal.connect(this._tabPanelController, 'tabSelected', this, 'handleTabSelected') } return this._tabPanelController; }, //------------------------------------------------------------------------- 'renderSelf': function() { -//console.log('** Clipperz.targetModalDimensionsAndPosition', Clipperz.Base.serializeJSON(Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition)); - this.append(this.element(), {tag:'div', cls:'NewUserCreation mainDialog', id:this.getId('panel'), children: [ {tag:'form', id:this.getId('form'), cls:'newUserCreationForm', children:[ {tag:'div', cls:'header', children:[ {tag:'div', cls:'title', children:[ {tag:'h3', id:this.getId('title'), html:"Create new user"} ]} ]}, {tag:'div', id:this.getId('body'), cls:'body', children:[ {tag:'div', cls:'tabContainer', children:[ {tag:'ul', cls:'tabs', children:[ {tag:'li', id:this.getId('credentialsTab'), children:[{tag:'span', html:"credentials"}]}, {tag:'li', id:this.getId('checkCredentialsTab'), children:[{tag:'span', html:"credentials check"}]}, {tag:'li', id:this.getId('termsOfServiceTab'), children:[{tag:'span', html:"terms of service"}]}, {tag:'li', id:this.getId('createUserTab'), children:[{tag:'span', html:"create user"}]} //, // {tag:'li', id:this.getId('loginTab'), children:[{tag:'span', html:"login"}]}, ]}, {tag:'ul', cls:'tabPanels', children:[ {tag:'li', id:this.getId('credentialsTabpanel'), cls:'tabPanel credentials', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.NewUserWizard.CREDENTIALS.description')}]}, {tag:'ul', cls:'credentials', children:[ {tag:'li', children:[{tag:'span', cls:'label', html:"username"}, {tag:'input', type:'text', id:this.getId('username')/*, value:'test'*/}]}, {tag:'li', children:[{tag:'span', cls:'label', html:"passphrase"}, {tag:'input', type:'password', id:this.getId('passphrase')/*, value:'test'*/}]} ]} ]}, {tag:'li', id:this.getId('checkCredentialsTabpanel'), cls:'tabPanel checkCredentials', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.NewUserWizard.CHECK_CREDENTIALS.description')}]}, {tag:'ul', cls:'credentials', children:[ {tag:'li', children:[{tag:'span', cls:'label', html:"re-passphrase"}, {tag:'input', type:'password', id:this.getId('re-passphrase')/*, value:'test'*/}]} ]} ]}, {tag:'li', id:this.getId('termsOfServiceTabpanel'), cls:'tabPanel termsOfService', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.NewUserWizard.TERMS_OF_SERVICE.description')}]}, {tag:'ul', cls:'termsOfService', children:[ {tag:'li', children:[{tag:'input', type:'checkbox', id:this.getId('awareOfUnrecoverablePassphrase')/*, checked:true*/}, {tag:'label', cls:'label', 'for':this.getId('awareOfUnrecoverablePassphrase'), html:"I understand that Clipperz will not be able to recover a lost passphrase."}]}, {tag:'li', children:[{tag:'input', type:'checkbox', id:this.getId('readTermsOfService')/*, checked:true*/}, {tag:'label', cls:'label', 'for':this.getId('readTermsOfService'), htmlString:"I have read and agreed to the <a href='http://www.clipperz.com/terms_of_service' target='_blank'>Terms of Service</a>."}]} ]} ]}, {tag:'li', id:this.getId('createUserTabpanel'), cls:'tabPanel createUser', children:[ {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.NewUserWizard.CREATE_USER.description')}]}, {tag:'ul', cls:'createUserStates', children:[ {tag:'li', cls:'creating', id:this.getId('creatingRegistering'), children:[{tag:'span', html:"registering user"}]}, {tag:'li', cls:'done', id:this.getId('creatingDone'), children:[{tag:'span', html:"done"}]}, {tag:'li', cls:'fail', id:this.getId('creatingFailed'), children:[{tag:'span', html:"fail"}]} ]} ]} //, // {tag:'li', id:this.getId('loginTabpanel'), cls:'tabPanel login', children:[ // {tag:'div', cls:'wizardStepDescription', children:[{tag:'span', html:Clipperz.PM.Strings.getValue('Wizards.NewUserWizard.LOGIN.description')}]}, // ]} ]} ]} ]}, {tag:'div', id:this.getId('footer'), cls:'footer', children:[ {tag:'div', cls:'buttonArea', children:[ // {tag:'div', cls:'cancel', id:this.getId('cancelButton'), html:"cancel"}, // {tag:'div', cls:'save disabled', id:this.getId('saveButton'), html:"save"} ]} ]} ]}, {tag:'div', cls:'clear'} ]}); this.tabPanelController().setup(); // MochiKit.Signal.connect(this.getId('panel'), 'onkeydown', this, 'handleKeyEvent'); MochiKit.Signal.connect(MochiKit.DOM.currentDocument().body, 'onkeydown', this, 'handleKeyEvent'); MochiKit.Signal.connect(this.getId('awareOfUnrecoverablePassphrase'), 'onchange', this, 'handleTermsOfServiceCheckboxChange'); MochiKit.Signal.connect(this.getId('readTermsOfService'), 'onchange', this, 'handleTermsOfServiceCheckboxChange'); }, //------------------------------------------------------------------------- /* 'resetContent': function () { this.getElement('username').value = ''; this.getElement('passphrase').value = ''; }, */ //------------------------------------------------------------------------- 'displayElement': function() { return this.getElement('panel'); }, //------------------------------------------------------------------------- 'handleTabSelected': function (aSelectedTab) { /* switch (aSelectedTab) { case 'DETAILS': break; case 'DIRECT_LOGINS': MochiKit.Style.hideElement(this.getElement('backToDirectLoginList')); break; case 'SHARING': break; } */ }, //========================================================================= 'username': function () { return this.getElement('username').value; }, 'usernameElement': function () { return this.getElement('username'); }, 'passphrase': function () { return this.getElement('passphrase').value; }, 'rePassphrase': function () { return this.getElement('re-passphrase').value; }, 'awareOfUnrecoverablePassphrase': function () { return this.getElement('awareOfUnrecoverablePassphrase').value; }, 'readTermsOfService': function () { return this.getElement('readTermsOfService').value; }, //========================================================================= /* 'incrementUpdateFaviconCounter': function () { this._updateFaviconCounter ++; }, 'decrementUpdateFaviconCounter': function () { this._updateFaviconCounter --; }, 'updateFaviconCounter': function () { return this._updateFaviconCounter; }, */ //------------------------------------------------------------------------- /* 'updateFavicon': function () { this.decrementUpdateFaviconCounter(); if (this.updateFaviconCounter() == 0) { this.setFavicon(this.favicon()); } }, */ //========================================================================= /* 'bindingComponents': function () { return this._bindingComponents; }, 'clearAllBindingsComponents': function () { MochiKit.Iter.forEach(this.bindingComponents(), MochiKit.Base.methodcaller('remove')); this._bindingComponents = []; this.getElement('bindings').innerHTML = ''; }, 'addBindingComponent': function (aBindingComponent) { this.bindingComponents().push(aBindingComponent); aBindingComponent.renderInNode(this.append(this.getElement('bindings'), {tag:'div'})); }, */ //========================================================================= /* 'formValueComponents': function () { return this._formValueComponents; }, 'clearAllFormValueComponents': function () { MochiKit.Iter.forEach(this.formValueComponents(), MochiKit.Base.methodcaller('remove')); this._formValueComponents = []; this.getElement('formValues').innerHTML = ''; }, 'addFormValueComponent': function (aFormValueComponent) { this.formValueComponents().push(aFormValueComponent); aFormValueComponent.renderInNode(this.append(this.getElement('formValues'), {tag:'div'})); }, */ //========================================================================= 'changedValue': function (anEvent) { MochiKit.Signal.signal(this, 'changedValue', anEvent); this.incrementUpdateFaviconCounter(); MochiKit.Async.callLater(1, MochiKit.Base.method(this, 'updateFavicon')); }, //------------------------------------------------------------------------- 'handleBackClick': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'back'); }, //========================================================================= 'bottomMargin': function () { var result; // TODO: WTF!!! // result = MochiKit.Style.getElementPosition(this.element())['y'] + // MochiKit.Style.getElementDimensions(this.element())['h']; // result = MochiKit.Style.getElementPosition(this.getElement('footer'))['y']; -//console.log("### bottomMargin"); -//console.log('displayElement', this.displayElement()); -//console.log('-- Clipperz.targetModalDimensionsAndPosition', Clipperz.Base.serializeJSON(Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition)); -//console.log('element', MochiKit.Style.getElementPosition('modalDialog') ['y'], MochiKit.Style.getElementDimensions('modalDialog')['h']); // result = 450; result = Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition['position']['y'] + Clipperz.PM.UI.Common.Components.BaseComponent.targetModalDimensionsAndPosition['dimensions']['h'] - 60; return result; }, //========================================================================= 'focusOnUsernameElement': function () { MochiKit.Async.callLater(0.1, MochiKit.Base.method(this.getElement('username'), 'focus')); }, 'focusOnRePassphraseElement': function () { this.getElement('re-passphrase').focus(); }, /* 'focusOnBookmarkletConfigurationElement': function () { this.getElement('bookmarkletConfiguration').focus(); }, 'focusOnFaviconElement': function () { this.getElement('faviconURL').focus(); }, */ //========================================================================= 'hideAllProgeressStates': function () { MochiKit.Style.hideElement(this.getElement('creatingRegistering')); MochiKit.Style.hideElement(this.getElement('creatingDone')); MochiKit.Style.hideElement(this.getElement('creatingFailed')); }, 'showProgressOnUserCreation': function () { //Clipperz.log(">>> NewUserCreationComponent.showProgressOnUserCreation"); this.hideAllProgeressStates(); MochiKit.Style.showElement(this.getElement('creatingRegistering')); }, 'showUserCreationDone': function () { //Clipperz.log(">>> NewUserCreationComponent.showUserCreationDone"); this.hideAllProgeressStates(); MochiKit.Style.showElement(this.getElement('creatingDone')); //Clipperz.log("<<< NewUserCreationComponent.showUserCreationDone"); }, 'showUserCreationFailed': function () { //Clipperz.log(">>> NewUserCreationComponent.showUserCreationFailed"); this.hideAllProgeressStates(); MochiKit.Style.showElement(this.getElement('creatingFailed')); }, //========================================================================= 'handleKeyEvent': function (anEvent) { MochiKit.Signal.signal(this, 'keyPressed', anEvent); /* if (anEvent.key().string == 'KEY_ENTER') { if (anEvent.target().nodeName != 'TEXTAREA') { MochiKit.Signal.signal(this, 'moveForward'); anEvent.preventDefault(); } } else if (anEvent.key().string == 'KEY_TAB') { if ((anEvent.target().nodeName == 'INPUT') || (anEvent.target().nodeName == 'TEXTAREA')) { MochiKit.Signal.signal(this, 'moveForward'); anEvent.preventDefault(); } } */ }, 'handleTermsOfServiceCheckboxChange': function (anEvent) { MochiKit.Signal.signal(this, 'changedValue'); }, //========================================================================= 'clear': function () { this.tabPanelController().selectTab(null); Clipperz.PM.UI.Web.Components.NewUserCreationComponent.superclass.clear.apply(this, arguments); }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/Page.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/Page.js index 3cc5a37..30cbeb2 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/Page.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/Page.js @@ -1,68 +1,66 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.Page = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.Page.superclass.constructor.apply(this, arguments); this._slots = { 'header': 'pageHeader', 'body': 'pageBody', 'footer': 'pageFooter' }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.Page, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.Page component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', id:'pageHeaderAndBody', cls:'pageHeaderAndBody', children:[ {tag:'div', id:'pageHeader', cls:'pageHeader'}, {tag:'div', id:'pageBody', cls:'pageBody'} ]}, {tag:'div', id:'pageFooter', cls:'pageFooter'} ]); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageFooter.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageFooter.js index dcf506f..df3ca0c 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageFooter.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageFooter.js @@ -1,67 +1,65 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.PageFooter = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.PageFooter.superclass.constructor.apply(this, arguments); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.PageFooter, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.PageFooter component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', cls:'footerWrapper', children:[ {tag:'div', cls:'footerContent', children:[ {tag:'canvas', id:this.getId('footerStarIcon'), cls:'footerStarIcon'}, {tag:'span', cls:'copyright', html:'Copyright © 2009-2013 Clipperz Srl'}, {tag:'a', href:'http://www.clipperz.com/terms_of_service', target:'_blank', html:'terms of service'}, {tag:'a', href:'http://www.clipperz.com/privacy_policy', target:'_blank', html:'privacy policy'}, {tag:'div', cls:'applicationVersion', htmlString:'application version: <a href="https://github.com/clipperz/password-manager/tree/' + Clipperz_version + '" target="github">' + Clipperz_version + '</a>'} ]} ]} ]); Clipperz.PM.UI.Canvas.star.normal(this.getElement('footerStarIcon'), "#7e7e7e"); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageHeader.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageHeader.js index b8f3b05..5e49fb5 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageHeader.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PageHeader.js @@ -1,191 +1,189 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.PageHeader = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.PageHeader.superclass.constructor.apply(this, arguments); this._newsIsOpen = args.newsIsOpen || false; this._animationDuration = args.animationDuration || 0.5; this._offset = 82; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.PageHeader, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.PageHeader component"; }, //------------------------------------------------------------------------- 'iframeURL': function () { // return './rss_view.html'; return 'http://www.clipperz.com/files/clipperz.com/appTips/index.html'; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', id:'miscLinks', children:[ {tag:'ul', children:[ {tag:'li', children:[{tag:'a', id:'donateHeaderLink', stringID:'pageHeader.donation', href:'http://www.clipperz.com/donations', target:'_blank', html:Clipperz.PM.Strings.getValue('pageHeader.donation')}]}, {tag:'li', children:[{tag:'a', id:'forumHeaderLink', stringID:'pageHeader.forum', href:'http://www.clipperz.com/forum', target:'_blank', html:Clipperz.PM.Strings.getValue('pageHeader.forum')}]}, {tag:'li', children:[{tag:'a', id:'creditsHeaderLink', stringID:'pageHeader.credits', href:'http://www.clipperz.com/credits', target:'_blank', html:Clipperz.PM.Strings.getValue('pageHeader.credits')}]}, {tag:'li', children:[{tag:'a', id:'feedbackHeaderLink', stringID:'pageHeader.feedback', href:'http://www.clipperz.com/contact', target:'_blank', html:Clipperz.PM.Strings.getValue('pageHeader.feedback')}]}, {tag:'li', children:[{tag:'a', id:'helpHeaderLink', stringID:'pageHeader.help', href:'http://www.clipperz.com/support/user_guide', target:'_blank', html:Clipperz.PM.Strings.getValue('pageHeader.help')}]} ]} ]}, {tag:'div', id:'logoFrame', children:[ {tag:'a', href:'http://www.clipperz.com', target:'_blank', children:[ // {tag:'h1', cls:'logo', html:"clipperz"}, {tag:'canvas', id:this.getId('logo'), cls:'logo'}, {tag:'h5', cls:'clipperzPayoff', html:"keep it to yourself!"} ]} ]}, {tag:'div', id:'news', cls:'hidden', children:[ // {tag:'div', cls:'close', children:[ // {tag:'a', href:'#', id:this.getId('closeTips'), html:'x'} // ]}, {tag:'div', id:'newsframe', children:[ {tag:'iframe', id:this.getId('iframe'), src:this.iframeURL()} ]}, {tag:'div', id:this.getId('newsGrip'), cls:'grip', children:[ {tag:'div', cls:'gripHandler', children:[]} ]} ]}, {tag:'div', id:'featureTabs', children:[ {tag:'table', children:[{tag:'tr', children:[ {tag:'td', children:[{tag:'div', id:'feature_store', children:[{tag:'canvas', cls:'featureIcon', id:this.getId('storeIcon')}, {tag:'span', html:"Store and manage your password and online credentials"}]}]}, {tag:'td', children:[{tag:'div', id:'feature_protect', children:[{tag:'canvas', cls:'featureIcon', id:this.getId('protectIcon')}, {tag:'span', html:"Protect all your sensitive data"}]}]}, {tag:'td', children:[{tag:'div', id:'feature_directLogin', children:[{tag:'canvas', cls:'featureIcon', id:this.getId('directLoginIcon')}, {tag:'span', html:"Login to your web services without entering any username or password"}]}]}, {tag:'td', children:[{tag:'div', id:'feature_share', children:[{tag:'canvas', cls:'featureIcon', id:this.getId('shareIcon')}, {tag:'span', html:"Share secret with family members and associates"}]}]} ]}]} ]} ]); Clipperz.PM.UI.Canvas.features.store(this.getElement('storeIcon'), "#ffffff"); Clipperz.PM.UI.Canvas.features.protect(this.getElement('protectIcon'), "#ffffff"); Clipperz.PM.UI.Canvas.features.directLogin(this.getElement('directLoginIcon'), "#ffffff"); Clipperz.PM.UI.Canvas.features.share(this.getElement('shareIcon'), "#ffffff", "#ffffff", "#ff0000"); MochiKit.Signal.connect(this.getElement('newsGrip'), 'onclick', this, 'toggleTips'); MochiKit.Signal.connect(this.getElement('iframe'), 'onload', this, 'handleIframeDidLoad'); this.setLogoDefaultColors(); }, //------------------------------------------------------------------------- 'switchToLoggedMode': function() { // MochiKit.Style.addElementClass(this.element(), 'logged'); MochiKit.Style.hideElement('featureTabs'); }, //------------------------------------------------------------------------- 'animationDuration': function () { return this._animationDuration; }, 'offset': function () { return this._offset; }, //------------------------------------------------------------------------- 'isNewsOpen': function () { return this._newsIsOpen; }, 'toggleNewsIsOpen': function () { this._newsIsOpen = !this._newsIsOpen; }, 'toggleTips': function(anEvent) { anEvent.preventDefault(); if (this.isNewsOpen() == true) { MochiKit.Visual.Move(Clipperz.DOM.get('news'), { x: 0, y: -this.offset(), mode: 'relative', duration: this.animationDuration(), beforeStart: function () { MochiKit.DOM.setElementClass(Clipperz.DOM.get('news'), 'hiding'); }, afterFinish: function () { Clipperz.DOM.get('newsframe').innerHTML = ""; MochiKit.DOM.setElementClass(Clipperz.DOM.get('news'), 'hidden'); } }) this.toggleNewsIsOpen(); } else { MochiKit.DOM.addElementClass('newsframe', 'loading'); MochiKit.Visual.Move(Clipperz.DOM.get('news'), { x: 0, y: this.offset(), mode: 'relative', duration: this.animationDuration(), beforeStart: MochiKit.Base.bind(function () { this.append(Clipperz.DOM.get('newsframe'), {tag:'iframe', id:this.getId('iframe'), src:this.iframeURL()}); MochiKit.Signal.connect(this.getElement('iframe'), 'onload', this, 'handleIframeDidLoad'); MochiKit.DOM.setElementClass(Clipperz.DOM.get('news'), 'opening'); }, this), afterFinish: function () { MochiKit.DOM.setElementClass(Clipperz.DOM.get('news'), 'open'); } }) this.toggleNewsIsOpen(); } }, 'setLogoDefaultColors': function () { Clipperz.PM.UI.Canvas.logo.normal(this.getElement('logo'), "clipperz", "28.0pt", "#ffffff"); }, //------------------------------------------------------------------------- 'handleIframeDidLoad': function (anEvent) { if (this.isNewsOpen() == false) { this.toggleTips(anEvent); } MochiKit.DOM.removeElementClass('newsframe', 'loading'); MochiKit.Signal.disconnectAllTo(this.getElement('iframe')); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js index 987e51e..5eb0c1f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/PasswordTooltip.js @@ -1,161 +1,159 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); Clipperz.PM.UI.Web.Components.PasswordTooltip = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.PasswordTooltip.superclass.constructor.apply(this, arguments); this._referenceElement = args.referenceElement || Clipperz.Base.exception.raise('MandatoryParameter'); this._text = args.text || Clipperz.Base.exception.raise('MandatoryParameter'); this._boxDimensions = null; this._isVisible = false; this.renderSelf(); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.PasswordTooltip, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.PasswordTooltip component"; }, //------------------------------------------------------------------------- 'referenceElement': function () { return this._referenceElement; }, //------------------------------------------------------------------------- 'text': function () { return this._text; }, 'setText': function (aValue) { this._text = aValue; }, //------------------------------------------------------------------------- 'isVisible': function () { return this._isVisible; }, 'setIsVisible': function (aValue) { this._isVisible = aValue; }, //------------------------------------------------------------------------- 'renderSelf': function() { this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'passwordTooltip', children:[ {tag:'div', id:this.getId('body'), cls:'passwordTooltip_body', children:[ {tag:'div', cls:'passwordTooltip_text', children:[ {tag:'span', html:this.text()} ]}, {tag:'div', id:this.getId('footer'), cls:'passwordTooltip_footer'} ]}, {tag:'div', id:this.getId('arrow'), cls:'passwordTooltip_arrow'} ]}); this._boxDimensions = MochiKit.Style.getElementDimensions(this.getId('body')); // this._boxDimensions.h += MochiKit.Style.getElementDimensions(this.getId('footer')).h; MochiKit.Style.hideElement(this.displayElement()); MochiKit.Signal.connect(this.element(), 'onmouseenter', this, 'show'); MochiKit.Signal.connect(this.element(), 'onmouseleave', this, 'hide'); }, //----------------------------------------------------- 'displayElement': function() { return this.getElement('tooltip'); }, //------------------------------------------------------------------------- 'boxDimensions': function () { return this._boxDimensions; }, //------------------------------------------------------------------------- 'show': function () { var elementSizeAndPosition; var arrowPosition; var bodyPosition; if (this.isVisible() == false) { arrowPosition = {}; bodyPosition = {}; this.setIsVisible(true); elementSizeAndPosition = Clipperz.Style.getSizeAndPosition(this.element()); MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); arrowPosition.y = elementSizeAndPosition.position.y - 13; MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); } }, 'hide': function () { if (this.isVisible() == true) { MochiKit.Visual.fade(this.displayElement(), {duration:0.4}); this.setIsVisible(false); } }, //------------------------------------------------------------------------- /* 'shouldRemoveElementWhenClearningUp': function () { return false; }, */ //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.PM.UI.Web.Components.PasswordTooltip.initTooltips = function () { Clipperz.DOM.Helper.insertBefore(MochiKit.DOM.currentDocument().body.childNodes[0], {tag:'div', id:'Clipperz_PM_UI_Web_Components_PasswordTooltip_wrapperNode'}); } MochiKit.DOM.addLoadEvent(Clipperz.PM.UI.Web.Components.PasswordTooltip.initTooltips); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/RulerComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/RulerComponent.js index 69c1ede..ad8d677 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/RulerComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/RulerComponent.js @@ -1,321 +1,318 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.RulerComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.RulerComponent.superclass.constructor.apply(this, arguments); this._translationContext = args.translationContext || Clipperz.Base.exception.raise('MandatoryParameter'); // this._steps = args.steps || Clipperz.Base.exception.raise('MandatoryParameter'); this._steps = args.steps; this._currentStep = -1; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.RulerComponent, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.RulerComponent component"; }, //------------------------------------------------------------------------- 'resetStatus': function (args) { args = args || {}; if (this.currentStep() != 0) { var shouldAnimateTransition; shouldAnimateTransition = args.animateTransition || false; if (shouldAnimateTransition) { this.moveToFirstStep(MochiKit.Base.method(this, 'cursorMoved')); } else { this._currentStep = 0; this.cursorMoved(); } } }, //------------------------------------------------------------------------- 'translationContext': function () { return this._translationContext; }, 'steps': function () { return this._steps; }, 'setSteps': function (aValue) { this._steps = aValue; this.renderStepsComponents(); this.resetStatus(); }, 'translatedStepDescription': function (aStep) { return Clipperz.PM.Strings.getValue(this.translationContext() + '.' + aStep + '.' + 'name'); }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.setElement(this.append(MochiKit.DOM.currentDocument().body, [ {tag:'div', id:this.getId('rulerWrapper'), cls:'rulerWrapper fixed', children:[ {tag:'div', cls:'ruler', children:[ {tag:'a', href:'#', id:this.getId('exit'), cls:'exit', html:' '}, {tag:'a', href:'#', id:this.getId('smallPreviousButton'), cls:'smallButton previous', html:' '}, {tag:'a', href:'#', id:this.getId('smallNextButton'), cls:'smallButton next', html:' '}, {tag:'div', cls:'marker', id:this.getId('marker'), children:[ {tag:'div', cls:'previous', id:this.getId('previousButton')}, {tag:'div', cls:'markerBody'}, {tag:'div', cls:'next', id:this.getId('nextButton')} ]}, {tag:'div', cls:'steps', id:this.getId('stepsFrame')}, // {tag:'div', cls:'steps' + ' ' + 'steps_' + this.steps().length, children:[ // {tag:'ul', id:this.getId('steps'), children:MochiKit.Base.map(MochiKit.Base.bind(function (aStep) { return {tag:'li', children:[{tag:'span', html:this.translatedStepDescription(aStep)}]}}, this), this.steps())} // ]}, {tag:'div', cls:'dots', id:this.getId('dotsFrame')} // {tag:'div', cls:'dots' + ' ' + 'steps_' + this.steps().length, children:[ // {tag:'ul', id:this.getId('dots'), children:MochiKit.Base.map(function (aStep) { return {tag:'li', children:[{tag:'span', html:'*'}]}}, this.steps())} // ]} ]} ]} ])); -//console.log("ELEMENT", this.element()); MochiKit.Signal.connect(this.getElement('exit'), 'onclick', this, 'handleExit'); MochiKit.Signal.connect(this.getElement('previousButton'), 'onclick', this, 'handlePrevious'); MochiKit.Signal.connect(this.getElement('smallPreviousButton'), 'onclick', this, 'handlePrevious'); MochiKit.Signal.connect(this.getElement('nextButton'), 'onclick', this, 'handleNext'); MochiKit.Signal.connect(this.getElement('smallNextButton'), 'onclick', this, 'handleNext'); this.enablePrevious(false); this.enableNext(false); // this.cursorMoved(); }, //......................................................................... 'renderStepsComponents': function () { var stepsFrame; var dotsFrame; stepsFrames = this.getElement('stepsFrame'); MochiKit.DOM.setElementClass(stepsFrames, 'steps'); MochiKit.DOM.addElementClass(stepsFrames, 'steps_' + this.steps().length); stepsFrames.innerHTML = ""; this.append(stepsFrames, {tag:'ul', id:this.getId('steps'), children:MochiKit.Base.map( MochiKit.Base.bind(function (aStep) { return {tag:'li', children:[{tag:'span', html:this.translatedStepDescription(aStep)}]}}, this), this.steps())} ); dotsFrames = this.getElement('dotsFrame'); MochiKit.DOM.setElementClass(dotsFrames, 'dots'); MochiKit.DOM.addElementClass(dotsFrames, 'steps_' + this.steps().length); dotsFrames.innerHTML = ""; this.append(dotsFrames, {tag:'ul', id:this.getId('dots'), children:MochiKit.Base.map( function (aStep) { return {tag:'li', children:[{tag:'span', html:'*'}]}; }, this.steps())} ); }, //------------------------------------------------------------------------- 'handleExit': function (anEvent) { anEvent.preventDefault(); MochiKit.Signal.signal(this, 'exit'); }, //------------------------------------------------------------------------- 'handlePrevious': function (anEvent) { anEvent.preventDefault(); // if (!MochiKit.DOM.hasElementClass(this.getElement('previousButton'), 'disabled')) { // this.moveBackward(); // } MochiKit.Signal.signal(this, 'moveBackward'); }, 'handleNext': function (anEvent) { anEvent.preventDefault(); // if (!MochiKit.DOM.hasElementClass(this.getElement('nextButton'), 'disabled')) { // this.moveForward(); // } MochiKit.Signal.signal(this, 'moveForward'); }, //------------------------------------------------------------------------- 'currentStep': function () { return this._currentStep; }, 'markerInitialOffset': function () { return -246; }, 'markerStepOffset': function () { return 410 / (this.steps().length - 1); // return 100; }, //------------------------------------------------------------------------- 'moveToFirstStep': function (aCallback) { var stepsToMove; stepsToMove = this._currentStep; this._currentStep = 0; this.enablePrevious(false); this.enableNext(false); // MochiKit.Signal.signal(this, 'moveBackward'); MochiKit.Base.map( function (anElement) { MochiKit.DOM.removeElementClass(anElement, 'selected'); }, MochiKit.Selector.findChildElements(this.element(), ['li.selected']) ); new MochiKit.Visual.Move(this.getElement('marker'), { x:-(this.markerStepOffset() * stepsToMove), mode:'relative', duration:(0.5 * (stepsToMove/2)), // afterFinish:MochiKit.Base.method(this, 'cursorMoved') afterFinish:MochiKit.Base.compose(MochiKit.Base.method(this, 'cursorMoved'), aCallback) }); }, 'moveBackward': function (aCallback) { this._currentStep --; this.enablePrevious(false); this.enableNext(false); // MochiKit.Signal.signal(this, 'moveBackward'); MochiKit.Base.map( function (anElement) { MochiKit.DOM.removeElementClass(anElement, 'selected'); }, MochiKit.Selector.findChildElements(this.element(), ['li.selected']) ); new MochiKit.Visual.Move(this.getElement('marker'), { x:-this.markerStepOffset(), mode:'relative', duration:0.5, // afterFinish:MochiKit.Base.method(this, 'cursorMoved') afterFinish:MochiKit.Base.compose(MochiKit.Base.method(this, 'cursorMoved'), aCallback) }); }, 'moveForward': function (aCallback) { this._currentStep ++; if (this._currentStep < this.steps().length) { this.enablePrevious(false); this.enableNext(false); // MochiKit.Signal.signal(this, 'moveForward'); MochiKit.Base.map( function (anElement) { MochiKit.DOM.removeElementClass(anElement, 'selected'); }, MochiKit.Selector.findChildElements(this.element(), ['li.selected']) ); new MochiKit.Visual.Move(this.getElement('marker'), { x:this.markerStepOffset(), mode:'relative', duration:0.5, // afterFinish:MochiKit.Base.method(this, 'cursorMoved') afterFinish:MochiKit.Base.compose(MochiKit.Base.method(this, 'cursorMoved'), aCallback) }); } else { MochiKit.Signal.signal(this, 'done'); } }, //------------------------------------------------------------------------- 'enablePrevious': function (aValue) { if (aValue == true) { MochiKit.DOM.removeElementClass(this.getElement('previousButton'), 'disabled'); MochiKit.DOM.removeElementClass(this.getElement('smallPreviousButton'), 'disabled'); } else { MochiKit.DOM.addElementClass(this.getElement('previousButton'), 'disabled'); MochiKit.DOM.addElementClass(this.getElement('smallPreviousButton'), 'disabled'); } }, // 'disablePrevious': function () { // MochiKit.DOM.addElementClass(this.getElement('previousButton'), 'disabled'); // }, //......................................................................... 'enableNext': function (aValue) { if (aValue == true) { MochiKit.DOM.removeElementClass(this.getElement('nextButton'), 'disabled'); MochiKit.DOM.removeElementClass(this.getElement('smallNextButton'), 'disabled'); } else { MochiKit.DOM.addElementClass(this.getElement('nextButton'), 'disabled'); MochiKit.DOM.addElementClass(this.getElement('smallNextButton'), 'disabled'); } }, // 'disableNext': function () { // MochiKit.DOM.addElementClass(this.getElement('nextButton'), 'disabled'); // }, //------------------------------------------------------------------------- 'cursorMoved': function () { MochiKit.Style.setElementPosition(this.getElement('marker'), {x:this.markerStepOffset() * this.currentStep() + this.markerInitialOffset()}) MochiKit.Signal.signal(this, 'cursorMoved'); MochiKit.DOM.addElementClass(this.getElement('steps').childNodes[this.currentStep()], 'selected'); MochiKit.DOM.addElementClass(this.getElement('dots').childNodes[this.currentStep()], 'selected'); }, //------------------------------------------------------------------------- 'setDisplayMode': function (aValue) { MochiKit.DOM.removeElementClass(this.getElement('rulerWrapper'), 'fixed'); MochiKit.DOM.removeElementClass(this.getElement('rulerWrapper'), 'scrollable'); MochiKit.DOM.addElementClass(this.getElement('rulerWrapper'), aValue); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TabSidePanel.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TabSidePanel.js index 666afe9..edcdb62 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TabSidePanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TabSidePanel.js @@ -1,190 +1,188 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.TabSidePanel = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.TabSidePanel.superclass.constructor.call(this, args); this._element = args.element || null; this._slots = { }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.TabSidePanel, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.TabSidePanel component"; }, //------------------------------------------------------------------------- 'deselectAllTabs': function() { var tabListItems; tabListItems = [ 'cardsLI', // 'directLoginLI', 'accountLI', 'dataLI', 'toolsLI' ]; //Clipperz.log("=== TabSidePanel.tabSelected anEvent.src().id", anEvent.src().id); for (var i in tabListItems) { //Clipperz.log("=== TabSidePanel.tabSelected aTabListItem", tabListItems[i]); MochiKit.DOM.removeElementClass(this.getId(tabListItems[i]), 'selected'); } }, 'selectTab': function(aTabName) { this.deselectAllTabs(); MochiKit.DOM.addElementClass(this.getId(this.listItemIdForTabNamed(aTabName)), 'selected'); MochiKit.Signal.signal(this, 'tabSelected', aTabName); }, 'tabNameForAnchorId': function(anId) { var result; switch(anId) { case 'cards_tabSidePanel': result = 'cards'; break; // case 'directLogins_tabSidePanel': // result = 'directLogins'; // break; case 'account_tabSidePanel': result = 'account'; break; case 'data_tabSidePanel': result = 'data'; break; case 'tools_tabSidePanel': result = 'tools'; break; } return result; }, 'listItemIdForTabNamed': function(aTabName) { var result; switch (aTabName) { case 'cards': result = 'cardsLI'; break; // case 'directLogins': // result = 'directLoginLI'; // break; case 'account': result = 'accountLI'; break; case 'data': result = 'dataLI'; break; case 'tools': result = 'toolsLI'; break; } return result; }, 'tabSelected': function (anEvent) { this.selectTab(this.tabNameForAnchorId(anEvent.src().id)); // anEvent.stop(); anEvent.preventDefault(); }, //------------------------------------------------------------------------- 'addCard': function (anEvent) { anEvent.stop(); MochiKit.Signal.signal(this, 'addCard', anEvent.src()); }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', cls:'header'}, {tag:'div', cls:'body', children:[ {tag:'ul', cls:'mainTabs', children:[ {tag:'li', id:this.getId('cardsLI'), cls:'cards', children:[ {tag:'a', id:'cards_tabSidePanel', href:'#', html:"cards"}, {tag:'div', cls:'selectionHighlighter', children:[ {tag:'img', src:'./images/old/main/tabs/selectionHighligher.png'}, {tag:'a', id:this.getId('addCardA'), cls:'add', href:'#', children:[ {tag:'span', html:"add"}, {tag:'h3', html:"+"} ]} ]} ]} ]}, {tag:'ul', cls:'otherTabs', children:[ {tag:'li', id:this.getId('accountLI'), children:[ {tag:'a', id:'account_tabSidePanel', href:'#', html:"account"}, {tag:'div', cls:'selectionHighlighter', children:[ {tag:'img', src:'./images/old/main/tabs/selectionHighligherGray.png'} ]} ]}, {tag:'li', id:this.getId('dataLI'), children:[ {tag:'a', id:'data_tabSidePanel', href:'#', html:"data"}, {tag:'div', cls:'selectionHighlighter', children:[ {tag:'img', src:'./images/old/main/tabs/selectionHighligherGray.png'} ]} ]}, {tag:'li', id:this.getId('toolsLI'), children:[ {tag:'a', id:'tools_tabSidePanel', href:'#', html:"tools"}, {tag:'div', cls:'selectionHighlighter', children:[ {tag:'img', src:'./images/old/main/tabs/selectionHighligherGray.png'} ]} ]} ]} ]}, {tag:'div', cls:'footer'} ]); MochiKit.Signal.connect('cards_tabSidePanel', 'onclick', this, 'tabSelected'); // MochiKit.Signal.connect('directLogins_tabSidePanel', 'onclick', this, 'tabSelected'); MochiKit.Signal.connect('account_tabSidePanel', 'onclick', this, 'tabSelected'); MochiKit.Signal.connect('data_tabSidePanel', 'onclick', this, 'tabSelected'); MochiKit.Signal.connect('tools_tabSidePanel', 'onclick', this, 'tabSelected'); MochiKit.Signal.connect(this.getId('addCardA'), 'onclick', this, 'addCard'); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TextColumnManager.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TextColumnManager.js index 3dc9ce9..9b1796a 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TextColumnManager.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/TextColumnManager.js @@ -1,50 +1,48 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); //############################################################################# Clipperz.PM.UI.Web.Components.TextColumnManager = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.TextColumnManager.superclass.constructor.call(this, args); return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.TextColumnManager, Clipperz.PM.UI.Web.Components.ColumnManager, { 'toString': function () { return "Clipperz.PM.UI.Web.Components.TextColumnManager component"; }, //----------------------------------------------------- '__syntax_fix__' : 'syntax fix' }); 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 0fa369f..034ed91 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ToolsPanel.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/ToolsPanel.js @@ -1,110 +1,108 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.ToolsPanel = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.ToolsPanel.superclass.constructor.apply(this, arguments); this._initiallySelectedTab = args.selected || 'PASSWORD_GENERATOR'; this._tabPanelControllerConfiguration = { 'PASSWORD_GENERATOR': { tab: 'passwordGeneratorTab', panel: 'passwordGeneratorPanel' }, 'BOOKMARKLET': { tab: 'bookmarkletTab', panel: 'bookmarkletPanel' }, 'COMPACT_EDITION': { tab: 'compactEditionTab', panel: 'compactEditionPanel' }, 'HTTP_AUTH': { tab: 'httpAuthTab', panel: 'httpAuthPanel' } }; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.ToolsPanel, Clipperz.PM.UI.Common.Components.TabPanelComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.ToolsPanel component"; }, //------------------------------------------------------------------------- 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ {tag:'div', cls:'header', children:[ {tag:'div', cls:'subPanelTabs', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('passwordGeneratorTab'), children:[{tag:'a', href:'#', html:'Password generator'}], cls:'first'}, {tag:'li', id:this.getId('bookmarkletTab'), children:[{tag:'a', href:'#', html:'Bookmarklet'}]}, {tag:'li', id:this.getId('compactEditionTab'), children:[{tag:'a', href:'#', html:'Compact edition'}]}, {tag:'li', id:this.getId('httpAuthTab'), children:[{tag:'a', href:'#', html:'HTTP Auth'}]} ]} ]} ]}, {tag:'div', cls:'body', children:[ {tag:'div', cls:'accountPanel', children:[ {tag:'div', cls:'subPanelContent', children:[ {tag:'ul', children:[ {tag:'li', id:this.getId('passwordGeneratorPanel'), children:[ // {tag:'h3', html:"Password generator"} ]}, {tag:'li', id:this.getId('bookmarkletPanel'), children:[ // {tag:'h3', html:"Bookmarklet"} ]}, {tag:'li', id:this.getId('compactEditionPanel'), children:[ // {tag:'h3', html:"Compact edition"} ]}, {tag:'li', id:this.getId('httpAuthPanel'), children:[ // {tag:'h3', html:"HTTP Auth"} ]} ]} ]} ]} ]}, {tag:'div', cls:'footer'} ]); this.tabPanelController().setup({selected:this.initiallySelectedTab()}); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js index 21ccf2a..fe46729 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js @@ -1,181 +1,178 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.UnlockPasswordComponent = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.UnlockPasswordComponent.superclass.constructor.apply(this, arguments); this._openFromElement = args.openFromElement || null; this._onOkCloseToElement = args.onOkCloseToElement || null; this._onCancelCloseToElement = args.onCancelCloseToElement || null; this._progressBarComponent = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.UnlockPasswordComponent, Clipperz.PM.UI.Common.Components.SimpleMessagePanel, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.UnlockPasswordComponent component"; }, //------------------------------------------------------------------------- 'getPassphrase': function () { /* var deferredResult; if (this.passphrase() == null) { this.deferredShowModal({'openFromElement': this.openFromElement()}); deferredResult = this.deferred(); } else { deferredResult = MochiKit.Async.succeed(this.passphrase()); } return deferredResult; */ this.deferredShowModal({'openFromElement': this.openFromElement()}); return this.deferred(); }, //------------------------------------------------------------------------- 'deferredShowModal': function (someParameters) { return Clipperz.Async.callbacks("UnlockPasswordComponent.deferredShowModal", [ MochiKit.Base.bind(Clipperz.PM.UI.Web.Components.UnlockPasswordComponent.superclass.deferredShowModal, this, someParameters), MochiKit.Base.method(this, 'getElement', 'passphrase'), MochiKit.Base.methodcaller('focus') ], {trace:false}) }, //------------------------------------------------------------------------- 'openFromElement': function () { return this._openFromElement; }, 'onOkCloseToElement': function () { return this._onOkCloseToElement; }, 'onCancelCloseToElement': function () { return this._onCancelCloseToElement; }, //------------------------------------------------------------------------- 'renderSelf': function() { Clipperz.PM.UI.Web.Components.UnlockPasswordComponent.superclass.renderSelf.apply(this, arguments); this.append(this.getElement('container'), {tag:'div', cls:'passphrase', children: [ // {tag:'form', id:this.getId('passphraseForm'), children:[ {tag:'input', id:this.getId('passphrase'), type:'password', name:'passphrase', value:''} // ]} ]}); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn', this, 'userSuccessfullyLoggedInHandler'); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userLoginFailed', this, 'userLoginFailedHandler'); // MochiKit.Async.callLater(0.1, MochiKit.Base.method(this.getElement('passphrase'), 'focus')); // this.getElement('passphrase').select(); }, //------------------------------------------------------------------------- 'showProgressBar': function () { var progressBarElement; this.getElement('container').innerHTML = ''; progressBarElement = this.append(this.getElement('container'), {tag:'div', cls:'progressBarWrapper'}); this.addComponent(new Clipperz.PM.UI.Common.Components.ProgressBar({'element':progressBarElement})); this.setButtons([{text:"Cancel", result:'CANCEL'}]); }, //------------------------------------------------------------------------- 'showFailure': function () { this.setType('ALERT'); this.setTitle("Login failed"); this.setText("Wrong passphrase; the unlock has failed."); this.getElement('container').innerHTML = ''; this.setButtons([{text:"Close", result:'CANCEL', isDefault:true}]); }, //------------------------------------------------------------------------- 'closeOk': function () { var passphrase; passphrase = this.getElement('passphrase').value; this.showProgressBar(); // this.deferred().callback(passphrase); MochiKit.Async.callLater(0.5, MochiKit.Base.method(this.deferred(), 'callback', passphrase)); this._deferred = null; }, 'closeCancel': function () { this.deferredHideModal({closeToElement:this.onCancelCloseToElement()}); this.deferred().cancel(); this._deferred = null; }, //------------------------------------------------------------------------- 'userSuccessfullyLoggedInHandler': function (anEvent) { this.deferredHideModal({closeToElement:this.onOkCloseToElement()}); }, 'userLoginFailedHandler': function (anEvent) { -//console.log("############### FAILED LOGIN ################"); this.showFailure(); }, //------------------------------------------------------------------------- /* 'deferredShow': function (someArgs, aResult) { this.deferredShowModal(someArgs); // this.deferred().addMethod(this, 'deferredHideModal', {closeToElement:someArgs.onOkCloseToElement }); // this.deferred().addErrback (MochiKit.Base.method(this, 'deferredHideModal', {closeToElement:someArgs.onCancelCloseToElement })); // this.deferred().addCallback(MochiKit.Async.succeed, aResult); return this.deferred(); }, */ //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js index d699dc6..fbf58e0 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/UserInfoBox.js @@ -1,343 +1,337 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Components'); Clipperz.PM.UI.Web.Components.UserInfoBox = function(args) { args = args || {}; Clipperz.PM.UI.Web.Components.UserInfoBox.superclass.constructor.apply(this, arguments); this._slots = { }; this._isLocked = false; this._lockTooltip = null; return this; } //============================================================================= Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.UserInfoBox, Clipperz.PM.UI.Common.Components.BaseComponent, { //------------------------------------------------------------------------- 'toString': function () { return "Clipperz.PM.UI.Web.Components.UserInfoBox component"; }, //------------------------------------------------------------------------- 'handleLogout': function(anEvent) { //Clipperz.log(">>> UserInfoBox.handleLogout"); anEvent.preventDefault(); MochiKit.Signal.signal(this, 'logout'); //Clipperz.log("<<< UserInfoBox.handleLogout"); }, //------------------------------------------------------------------------- 'lockTooltip': function () { return this._lockTooltip; }, //------------------------------------------------------------------------- 'isLocked': function () { return this._isLocked; }, 'setIsLocked': function (aValue) { this._isLocked = aValue; }, 'toggleLock': function(anEvent) { var deferredResult; var shouldLock; -//console.log(">>> UserInfoBox.toggleLock [locked: " + this.isLocked() + "]"); anEvent.preventDefault(); this.lockTooltip().hide(); shouldLock = (this.isLocked() == false); if (shouldLock) { var maskElement; this.setIsLocked(true); maskElement = this.getId('modalDialogMask'); deferredResult = Clipperz.Async.callbacks("UserInfoBox.toggleLock [lock]", [ MochiKit.Base.partial(MochiKit.DOM.addElementClass, this.element(), 'locked'), MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.appear, maskElement, {from:0.0, to:0.75, duration:0.5}), MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', MochiKit.Base.method(this, 'askForPassphrase')), MochiKit.Base.partial(MochiKit.Signal.signal, this, 'lock') ], {trace:false}); } else { deferredResult = Clipperz.Async.callbacks("UserInfoBox.toggleLock [unlock]", [ MochiKit.Base.partial(MochiKit.Signal.signal, this, 'unlock') ], {trace:false}); } -//console.log("<<< UserInfoBox.toggleLock"); return deferredResult; }, //------------------------------------------------------------------------- 'unlock': function () { var deferredResult; var maskElement; this.setIsLocked(false); maskElement = this.getId('modalDialogMask'); deferredResult = Clipperz.Async.callbacks("UserInfoBox.unlock", [ MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, maskElement, {from:0.75, to:0.0, duration:0.5}), // Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, maskElement, {from:0.75, to:0.0, duration:0.5}), MochiKit.Base.partial(MochiKit.DOM.removeElementClass, this.element(), 'locked') ], {trace:false}); }, //------------------------------------------------------------------------- 'askForPassphrase': function () { var unlockPasswordComponent; /* var deferredResult; deferredResult = new Clipperz.Async.Deferred("UserInfoBox.askForPassphrase", {trace:false}); deferredResult.addCallback(MochiKit.Async.succeed, 'test'); deferredResult.callback(); return deferredResult; */ -//console.log(">>> UserInfoBox.askForPassphrase"); unlockPasswordComponent = new Clipperz.PM.UI.Web.Components.UnlockPasswordComponent({ 'title': "Unlock account", 'text': "Insert the passprase to unlock the account", 'type': 'INFO', 'buttons': [ {text:"Cancel", result:'CANCEL'}, {text:"Unlock", result:'OK', isDefault:true} ], 'openFromElement': this.getElement('lock'), 'onOkCloseToElement': null, 'onCancelCloseToElement': this.getId('lock') }); -//console.log("<<< UserInfoBox.askForPassphrase"); return unlockPasswordComponent.getPassphrase(); }, //========================================================================= 'renderSelf': function(/*aContainer, aPosition*/) { this.append(this.element(), [ // {tag:'canvas', id:this.getId('canvas'), cls:'canvas', width:'188', height:'154'}, {tag:'div', cls:'header', children:[ {tag:'h1', html:"Welcome"}, {tag:'a', cls:'lockButton', href:'#', id:this.getId('lock'), html:' '} ]}, {tag:'div', cls:'body', children:[ {tag:'h3', id:this.getId('username'), html:""}, {tag:'ul', children:[ {tag:'li', id:this.getId('cards'), children:[ {tag:'span', id:this.getId('cardsNumber'), cls:'number', html:"-"}, {tag:'span', id:this.getId('cardsLabel'), html:"cards"} ]}, {tag:'li', id:this.getId('directLogins'), children:[ {tag:'span', id:this.getId('directLoginsNumber'), cls:'number', html:"-"}, {tag:'span', id:this.getId('directLoginsLabel'), html:"direct logins"} ]} ]}, {tag:'a', href:'#', id:this.getId('logout'), html:"logout >"} ]}, {tag:'div', cls:'footer'} ]); MochiKit.Signal.connect(this.getElement('logout'), 'onclick', this, 'handleLogout'); MochiKit.Signal.connect(this.getElement('lock'), 'onclick', this, 'toggleLock'); this._lockTooltip = new Clipperz.PM.UI.Common.Components.Tooltip({ element: this.getElement('lock'), text: "Click here to lock/unlock your account.", position: 'RIGHT' }); Clipperz.DOM.Helper.append(MochiKit.DOM.currentDocument().body, {tag:'div', id:this.getId('modalDialogWrapper'), cls:'modalDialogWrapper', children:[ {tag:'div', id:this.getId('modalDialogMask'), cls:'modalDialogMask userInfoBoxMask'} ]} ); MochiKit.Style.hideElement(this.getId('modalDialogMask')); // this.drawUserInfoBackground(this.getElement('canvas')); }, //------------------------------------------------------------------------- /* 'drawUserInfoBackground': function (canvas) { var kMyDrawingFunctionWidth = 188.0; var kMyDrawingFunctionHeight = 154.0; var context = canvas.getContext("2d"); var color; var resolution; var alignStroke; var path; var pointX; var pointY; var controlPoint1X; var controlPoint1Y; var controlPoint2X; var controlPoint2Y; var gradient; if (window.devicePixelRatio) resolution = window.devicePixelRatio; else resolution = 1.0; resolution *= 0.5 * (canvas.width / kMyDrawingFunctionWidth + canvas.height / kMyDrawingFunctionHeight); context.save(); context.scale(canvas.width / kMyDrawingFunctionWidth, canvas.height / kMyDrawingFunctionHeight); context.clearRect(0.0, 0.0, kMyDrawingFunctionWidth, kMyDrawingFunctionHeight); // Setup for Shadow Effect color = "rgba(0.0%, 0.0%, 0.0%, 0.667)"; context.save(); context.shadowColor = color; context.shadowBlur = 3.0; context.shadowOffsetX = 5.729 * Math.cos(7.592) * resolution; context.shadowOffsetY = 5.729 * Math.sin(7.592) * resolution; // Layer 1 alignStroke = 0.0; context.beginPath(); pointX = 169.5; pointY = 141.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.moveTo(pointX, pointY); pointX = 177.5; pointY = 133.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 173.889; controlPoint1Y = 141.5; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 177.5; controlPoint2Y = 137.889; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 177.5; pointY = 19.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 169.5; pointY = 11.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 177.5; controlPoint1Y = 15.111; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 173.889; controlPoint2Y = 11.5; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 18.5; pointY = 11.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 10.5; pointY = 19.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 14.111; controlPoint1Y = 11.5; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 10.5; controlPoint2Y = 15.111; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 10.5; pointY = 133.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); pointX = 18.5; pointY = 141.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; controlPoint1X = 10.5; controlPoint1Y = 137.889; controlPoint1X = (Math.round(resolution * controlPoint1X + alignStroke) - alignStroke) / resolution; controlPoint1Y = (Math.round(resolution * controlPoint1Y + alignStroke) - alignStroke) / resolution; controlPoint2X = 14.111; controlPoint2Y = 141.5; controlPoint2X = (Math.round(resolution * controlPoint2X + alignStroke) - alignStroke) / resolution; controlPoint2Y = (Math.round(resolution * controlPoint2Y + alignStroke) - alignStroke) / resolution; context.bezierCurveTo(controlPoint1X, controlPoint1Y, controlPoint2X, controlPoint2Y, pointX, pointY); pointX = 169.5; pointY = 141.5; pointX = (Math.round(resolution * pointX + alignStroke) - alignStroke) / resolution; pointY = (Math.round(resolution * pointY + alignStroke) - alignStroke) / resolution; context.lineTo(pointX, pointY); context.closePath(); gradient = context.createLinearGradient(94.0, 11.5, 94.0, 141.5); color = "#EE9B69"; gradient.addColorStop(0.0, color); color = "#E38D62"; gradient.addColorStop(1.0, color); context.fillStyle = gradient; context.fill(); // Shadow Effect context.restore(); context.restore(); }, */ //------------------------------------------------------------------------- 'updateUserDetails': function (someUserInfo) { var elementName; for (elementName in someUserInfo) { this.getElement(elementName).innerHTML = someUserInfo[elementName]; } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); 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 1ab2e69..3d9d6d3 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/AppController.js @@ -1,351 +1,348 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.AppController = function(args) { this._user = null; this._tabSlotNames = { //tabName: slotName 'cards': 'cardGrid', // 'directLogins': 'directLoginGrid', 'account': 'accountPanel', 'data': 'dataPanel', 'tools': 'toolsPanel' }; //controllers this._cardsController = null; // this._directLoginsController = null; this._filterController = null; // new Clipperz.PM.UI.Web.Controllers.FilterController(); //components this._appPage = null; this._userInfoBox = null; this._tabSidePanel = null; // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'editCard', this, 'handleEditCard'); // MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'deleteCard', this, 'handleDeleteCard'); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'userDataSuccessfullySaved', this, 'userDataSuccessfullySavedHandler'); return this; } MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.AppController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.AppController"; }, //----------------------------------------------------------------------------- 'setUser': function(anUser) { this._user = anUser; }, 'user': function() { return this._user; }, //----------------------------------------------------------------------------- /* 'tabSlotNames': function() { return this._tabSlotNames; }, */ 'slotNameForTab': function(aTabName) { return this._tabSlotNames[aTabName]; }, 'hideAllAppPageTabSlots': function() { var aTabName; for (aTabName in this._tabSlotNames) { this.appPage().hideSlot(this.slotNameForTab(aTabName)); } }, //----------------------------------------------------------------------------- 'appPage': function() { if (this._appPage == null) { this._appPage = new Clipperz.PM.UI.Web.Components.AppPage(); } return this._appPage; }, //----------------------------------------------------------------------------- 'tabSidePanel': function() { if (this._tabSidePanel == null) { this._tabSidePanel = new Clipperz.PM.UI.Web.Components.TabSidePanel(); } return this._tabSidePanel; }, //----------------------------------------------------------------------------- 'userInfoBox': function() { if (this._userInfoBox == null) { this._userInfoBox = new Clipperz.PM.UI.Web.Components.UserInfoBox(); MochiKit.Signal.connect(this._userInfoBox, 'logout', this, 'handleLogout'); MochiKit.Signal.connect(this._userInfoBox, 'lock', this, 'handleLock'); MochiKit.Signal.connect(this._userInfoBox, 'unlock', this, 'handleUnlock'); } return this._userInfoBox; }, //----------------------------------------------------------------------------- 'accountPanel': function () { if (this._accountPanel == null) { this._accountPanel = new Clipperz.PM.UI.Web.Components.AccountPanel(/*{selected:'Preferences'}*/); } return this._accountPanel; }, //......................................................................... 'dataPanel': function () { if (this._dataPanel == null) { this._dataPanel = new Clipperz.PM.UI.Web.Components.DataPanel(); } return this._dataPanel; }, //......................................................................... 'toolsPanel': function () { if (this._toolsPanel == null) { this._toolsPanel = new Clipperz.PM.UI.Web.Components.ToolsPanel(); } return this._toolsPanel; }, //----------------------------------------------------------------------------- 'filterController': function () { if (this._filterController == null) { this._filterController = new Clipperz.PM.UI.Web.Controllers.FilterController(); } return this._filterController; }, 'cardsController': function() { if (this._cardsController == null) { this._cardsController = new Clipperz.PM.UI.Web.Controllers.CardsController({'filterController':this._filterController}); } return this._cardsController; }, //----------------------------------------------------------------------------- /* 'directLoginsController': function() { //Clipperz.log(">>> AppController.directLoginsController"); if (this._directLoginsController == null) { this._directLoginsController = new Clipperz.PM.UI.Web.Controllers.DirectLoginsController({'filterController':this._filterController}); } //Clipperz.log("<<< AppController.directLoginsController"); return this._directLoginsController; }, */ //----------------------------------------------------------------------------- 'populateUserInfo': function() { var deferredResult; deferredResult = new Clipperz.Async.Deferred("AppController.populateUserInfo", {trace:false}); deferredResult.collectResults({ 'username': MochiKit.Base.methodcaller('displayName'), 'cardsNumber': [ MochiKit.Base.methodcaller('getRecords'), function (someResults) { return someResults.length; } ], 'directLoginsNumber': [ MochiKit.Base.methodcaller('getDirectLogins'), function (someResults) { return someResults.length; } ] }) deferredResult.addMethod(this.userInfoBox(), 'updateUserDetails'); deferredResult.callback(this.user()); return deferredResult; }, //----------------------------------------------------------------------------- 'run': function(args) { var deferredResult; var slot; var page; var user; slot = args.slot; user = args.user; this.setUser(user); slot.setContent(this.appPage()); this.appPage().slotNamed('userInfoBox').setContent(this.userInfoBox()); this.appPage().slotNamed('tabSidePanel').setContent(this.tabSidePanel()); this.appPage().slotNamed('accountPanel').setContent(this.accountPanel()); this.appPage().slotNamed('dataPanel').setContent(this.dataPanel()); this.appPage().slotNamed('toolsPanel').setContent(this.toolsPanel()); 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(Clipperz.Signal.NotificationCenter, 'downloadOfflineCopy', this, 'handleDownloadOfflineCopy'); deferredResult = new Clipperz.Async.Deferred("AppController.run", {trace:false}); deferredResult.addMethod(this.cardsController(), 'run', {slot:this.appPage().slotNamed('cardGrid'), user:user}); // deferredResult.addMethod(this.directLoginsController(), 'run', {slot:this.appPage().slotNamed('directLoginGrid'), user:user}); deferredResult.addMethod(this, 'populateUserInfo'); deferredResult.addCallback(MochiKit.Visual.ScrollTo, 'miscLinks', {duration:0}); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN'); deferredResult.addMethod(this.tabSidePanel(), 'selectTab', 'cards'); deferredResult.callback(); }, //----------------------------------------------------------------------------- 'handleTabSelected': function (selectedTabName) { var aTabName; var aSlotName; //Clipperz.log(">>> AppController.handleTabSelected", selectedTabName); this.hideAllAppPageTabSlots(); this.appPage().showSlot(this.slotNameForTab(selectedTabName)); switch (selectedTabName) { case 'cards': this.cardsController().focus(); break; // case 'directLogins': // this.directLoginsController().focus(); // break; case 'data': break; case 'account': break; case 'tools': break; } //Clipperz.log("<-- AppController.handleTabSelected", aTabName); }, //============================================================================= 'handleAddCard': function (aSourceElement) { //Clipperz.log("=== AppController.addCard", aSourceElement); this.cardsController().addCard(aSourceElement); }, //============================================================================= 'userDataSuccessfullySavedHandler': function (anEvent) { this.populateUserInfo(); }, //============================================================================= 'handleLogout': function(anEvent) { var deferredResult; deferredResult = new Clipperz.Async.Deferred("AppController.handleLogout", {trace:false}); deferredResult.addMethod(this.user(), 'logout'); deferredResult.addCallback(MochiKit.Signal.signal, this, 'logout'); deferredResult.callback(); return deferredResult; }, //----------------------------------------------------------------------------- 'handleLock': function (anEvent) { return Clipperz.Async.callbacks("AppController.handleLock", [ MochiKit.Base.method(this.cardsController(), 'deleteAllCleanTextData'), MochiKit.Base.method(this.user(), 'lock') ], {trace:false}); }, //............................................................................. 'handleUnlock': function (anEvent) { return Clipperz.Async.callbacks("AppController.handleUnock", [ MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress'), MochiKit.Base.method(this.user(), 'login'), MochiKit.Base.method(this.cardsController(), 'focus'), MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone'), MochiKit.Base.method(this.userInfoBox(), 'unlock') ], {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/Web/Controllers/CardDialogController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js index effde31..b1ff81f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js @@ -1,649 +1,646 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.CardDialogController = function(args) { args = args || {}; Clipperz.PM.UI.Web.Controllers.CardDialogController.superclass.constructor.call(this, args); this._record = args.record || Clipperz.Base.exception.raise('MandatoryParameter'); this._delegate = args.delegate || Clipperz.Base.exception.raise('MandatoryParameter'); this._referenceElement = null; this._cardDialogComponent = null; this._fieldsReferences = {}; this._directLoginReferences = {}; this._directLoginWizardController = null; this._directLoginEditingComponent = null; this._isDirectLoginEditingComponentVisible = false; return this; }; Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardDialogController, Object, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.CardDialogController"; }, //------------------------------------------------------------------------- 'record': function () { return this._record; }, 'delegate': function () { return this._delegate; }, //------------------------------------------------------------------------- 'fieldsReferences': function () { return this._fieldsReferences; }, 'directLoginReferences': function () { return this._directLoginReferences; }, //------------------------------------------------------------------------- 'referenceElement': function () { return this._referenceElement; }, 'setReferenceElement': function (anElement) { this._referenceElement = anElement; }, //------------------------------------------------------------------------- 'cardDialogComponent': function () { if (this._cardDialogComponent == null) { this._cardDialogComponent = new Clipperz.PM.UI.Web.Components.CardDialogComponent(); MochiKit.Signal.connect(this._cardDialogComponent, 'cancel', this, 'handleCancel'); MochiKit.Signal.connect(this._cardDialogComponent, 'save', this, 'handleSave'); MochiKit.Signal.connect(this._cardDialogComponent, 'addField', this, 'handleAddField'); MochiKit.Signal.connect(this._cardDialogComponent, 'changedValue', this, 'handleChangedValue'); MochiKit.Signal.connect(this._cardDialogComponent, 'addDirectLogin',this, 'handleAddDirectLogin'); MochiKit.Signal.connect(this._cardDialogComponent, 'keyPressed', this, 'handleCardDialogComponentKeyPressed'); } return this._cardDialogComponent; }, //========================================================================= 'directLoginWizardController': function () { if (this._directLoginWizardController == null) { this._directLoginWizardController = new Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController({ 'cardLabel': this.cardDialogComponent().title(), 'directLoginEditingComponent': this.directLoginEditingComponent() }) MochiKit.Signal.connect(this._directLoginWizardController, 'exit', this, 'handleHideDirectLoginEditingComponent'); MochiKit.Signal.connect(this._directLoginWizardController, 'done', this, 'handleCompleteDirectLoginEditingComponent'); } return this._directLoginWizardController; }, //------------------------------------------------------------------------- 'directLoginEditingComponent': function () { if (this._directLoginEditingComponent == null) { this._directLoginEditingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingComponent(); this.cardDialogComponent().renderDirectLoginEditingComponent(this._directLoginEditingComponent); // MochiKit.Signal.connect(this._directLoginEditingComponent, 'back', this, 'handleHideDirectLoginEditingComponent') // MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue', this, 'handleChangedValue'); // MochiKit.Signal.connect(this.__directLoginEditingComponent, 'keyPressed', this, 'handleDirectLoginEditingComponentKeyPressed'); } return this._directLoginEditingComponent; }, //------------------------------------------------------------------------- 'isDirectLoginEditingComponentVisible': function () { return this._isDirectLoginEditingComponentVisible; }, 'setIsDirectLoginEditingComponentVisible': function (aValue) { this._isDirectLoginEditingComponentVisible = aValue; }, //========================================================================= 'run': function (anElement) { var deferredResult; this.setReferenceElement(anElement); deferredResult = new Clipperz.Async.Deferred("CardDialogController.run", {trace:false}); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':11}); deferredResult.addMethod(this.cardDialogComponent(), 'deferredShowModal', {openFromElement:this.referenceElement()}); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this.record(), 'label'); deferredResult.addMethod(this.cardDialogComponent(), 'setTitle'); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addMethod(this, 'updateComponentState'); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'progressDone'); deferredResult.addMethod(this.cardDialogComponent(), 'fixRendering'); deferredResult.addMethod(this.cardDialogComponent(), 'hideProgressMask'); if (this.record().isBrandNew()) { deferredResult.addMethod(this.cardDialogComponent(), 'setHintMode', 'ON'); deferredResult.addMethod(this.cardDialogComponent(), 'setFocusOnTitleField'); } deferredResult.addErrback(MochiKit.Base.method(this.cardDialogComponent(), 'showError')); deferredResult.callback(); return deferredResult; }, //========================================================================= 'updateComponentState': function () { 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}); }, //------------------------------------------------------------------------- 'addCardDialogComponentWithField': function (aField) { var fieldComponent; fieldComponent = new Clipperz.PM.UI.Web.Components.CardDialogRecordFieldComponent({reference: aField.reference()}); MochiKit.Signal.connect(fieldComponent, 'changedValue', this, 'handleChangedValue'); MochiKit.Signal.connect(fieldComponent, 'performAction',this, 'handlePerformFieldAction'); MochiKit.Signal.connect(fieldComponent, 'deleteField', this, 'handleDeleteField'); // this.fieldsReferences().push({'field':aField, 'component':fieldComponent}); this.fieldsReferences()[aField.reference()] = {'field':aField, 'component':fieldComponent}; return Clipperz.Async.callbacks("CardDialogController.addCardDialogComponentWithField", [ MochiKit.Base.method(this.cardDialogComponent(), 'addFieldRowComponent', fieldComponent), MochiKit.Base.method(aField, 'label'), MochiKit.Base.method(fieldComponent, 'setLabel'), MochiKit.Base.method(aField, 'value'), MochiKit.Base.method(fieldComponent, 'setValue'), MochiKit.Base.method(aField, 'actionType'), MochiKit.Base.method(fieldComponent, 'setActionType'), MochiKit.Base.method(aField, 'isHidden'), MochiKit.Base.method(fieldComponent, 'setIsHidden') ], {trace:false}); }, //------------------------------------------------------------------------- 'addCardDialogComponentWithDirectLogin': function (aDirectLogin) { var directLoginComponent; directLoginComponent = new Clipperz.PM.UI.Web.Components.CardDialogRecordDirectLoginComponent({reference: aDirectLogin.reference()}); MochiKit.Signal.connect(directLoginComponent, 'changedValue', this, 'handleChangedValue'); MochiKit.Signal.connect(directLoginComponent, 'deleteDirectLogin', this, 'handleDeleteDirectLogin'); MochiKit.Signal.connect(directLoginComponent, 'editDirectLogin', this, 'handleEditDirectLogin'); MochiKit.Signal.connect(directLoginComponent, 'openDirectLogin', this, 'handleOpenDirectLogin'); this.directLoginReferences()[aDirectLogin.reference()] = {'directLogin':aDirectLogin, 'component':directLoginComponent}; return Clipperz.Async.callbacks("CardDialogController.addCardDialogComponentWithDirectLogin", [ MochiKit.Base.method(this.cardDialogComponent(), 'addDirectLoginComponent', directLoginComponent), MochiKit.Base.method(this, 'refreshDirectLoginComponent', this.directLoginReferences()[aDirectLogin.reference()]) ], {trace:false}); }, //------------------------------------------------------------------------- 'refreshDirectLoginComponent': function (aDirectLoginReference) { return Clipperz.Async.callbacks("CardDialogController.refreshDirectLoginComponent", [ MochiKit.Base.method(aDirectLoginReference['directLogin'], 'favicon'), // MochiKit.Base.method(aDirectLoginReference['directLogin'], 'faviconData'), MochiKit.Base.method(aDirectLoginReference['component'], 'setFavicon'), MochiKit.Base.method(aDirectLoginReference['directLogin'], 'label'), MochiKit.Base.method(aDirectLoginReference['component'], 'setLabel') ], {trace:false}); }, 'refreshDirectLoginComponents': function () { return Clipperz.Async.callbacks("CardDialogController.refreshDirectLoginComponents", [ MochiKit.Base.method(this, 'directLoginReferences'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'refreshDirectLoginComponent')), Clipperz.Async.collectAll ]) }, //------------------------------------------------------------------------- 'updateRecordValues': function () { return Clipperz.Async.callbacks('CardDialogController.updateRecordValues', [ MochiKit.Base.method(this.cardDialogComponent(), 'title'), MochiKit.Base.method(this.record(), 'setLabel'), MochiKit.Base.method(this.cardDialogComponent(), 'notes'), MochiKit.Base.method(this.record(), 'setNotes'), MochiKit.Base.method(this, 'fieldsReferences'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordFieldValues')), MochiKit.Base.method(this, 'directLoginReferences'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.method(this, 'updateRecordDirectLoginValues')), MochiKit.Base.method(this.directLoginEditingComponent(), 'directLoginReference'), MochiKit.Base.method(this.record(), 'directLoginWithReference'), MochiKit.Base.method(this, 'updateRecordDirectLoginDetails'), MochiKit.Base.noop ], {trace:false}); }, //------------------------------------------------------------------------- 'updateRecordFieldValues': function (aFieldReference) { var deferredResult; deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordFieldValues', [ MochiKit.Base.method(aFieldReference['component'], 'label'), MochiKit.Base.method(aFieldReference['field'], 'setLabel'), MochiKit.Base.method(aFieldReference['component'], 'value'), MochiKit.Base.method(aFieldReference['field'], 'setValue'), MochiKit.Base.method(aFieldReference['component'], 'isHidden'), MochiKit.Base.method(aFieldReference['field'], 'setIsHidden'), MochiKit.Base.method(aFieldReference['field'], 'actionType'), MochiKit.Base.method(aFieldReference['component'], 'setActionType') ], {trace:false}); return deferredResult; }, //------------------------------------------------------------------------- 'updateRecordDirectLoginValues': function (aDirectLoginReference) { var deferredResult; deferredResult = Clipperz.Async.callbacks('CardDialogController.updateRecordDirectLoginValues', [ MochiKit.Base.method(aDirectLoginReference['component'], 'label'), MochiKit.Base.method(aDirectLoginReference['directLogin'], 'setLabel') ], {trace:false}); return deferredResult; }, //------------------------------------------------------------------------- 'updateRecordDirectLoginDetails': function (aDirectLogin) { var result; if (MochiKit.Base.isUndefinedOrNull(aDirectLogin)) { result = MochiKit.Async.succeed(); } else { result = Clipperz.Async.callbacks("CardDialogController.updateRecordDirectLoginDetails", [ MochiKit.Base.method(this.directLoginEditingComponent(), 'label'), MochiKit.Base.method(aDirectLogin, 'setLabel'), MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'), MochiKit.Base.method(aDirectLogin, 'setFavicon') ], {trace:false}); } return result; }, //========================================================================= 'addField': function () { return this.record().addField({ 'label':this.cardDialogComponent().newFieldLabel(), 'value':this.cardDialogComponent().newFieldValue(), 'isHidden':this.cardDialogComponent().newFieldIsHidden() }); }, 'handleAddField': function () { return Clipperz.Async.callbacks("CardDialogController.handleAddField", [ MochiKit.Base.method(this, 'addField'), MochiKit.Base.method(this, 'addCardDialogComponentWithField'), MochiKit.Base.method(this.cardDialogComponent(), 'resetNewFieldInputs'), MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'), MochiKit.Base.method(this, 'handleChangedValue') ], {trace:false}) }, //------------------------------------------------------------------------- 'handlePerformFieldAction': function (aFieldID, aTargetElement) { -//console.log("### targetElement", aTargetElement); return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [ MochiKit.Base.method(this.record(), 'fields'), MochiKit.Base.itemgetter(aFieldID), Clipperz.Async.collectResults("CardDialogController.handleDeleteField <collect results>", { 'value': MochiKit.Base.methodcaller('value'), 'type': MochiKit.Base.methodcaller('actionType') }, {trace:false}), MochiKit.Base.bind(function (someValues) { switch (someValues['type']) { case 'NONE': throw "this event handler should not be triggered for fields with type 'NONE'"; break; case 'URL': var url; url = someValues['value']; if (/^https?\:\/\//.test(url) == false) { url = 'http://' + url; } window.open(url); break; case 'EMAIL': var url; url = 'mailto:' + someValues['value']; MochiKit.DOM.currentWindow().location = url; break; case 'PASSWORD': //Clipperz.log("SHOW PASSWORD " + someValues['value']); this.showPasswordTooltip(someValues['value'], aTargetElement); break; } }, this) ], {trace:false}); }, //------------------------------------------------------------------------- 'handleDeleteField': function (aFieldID) { return Clipperz.Async.callbacks("CardDialogController.handleDeleteField", [ MochiKit.Base.method(this.record(), 'fields'), MochiKit.Base.itemgetter(aFieldID), MochiKit.Base.method(this.record(), 'removeField'), MochiKit.Base.method(this, 'fieldsReferences'), MochiKit.Base.itemgetter(aFieldID), MochiKit.Base.itemgetter('component'), function (aComponent) { return Clipperz.Async.callbacks("CardDialogController.handleDeleteField [fade and remove]", [ MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}), // Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}), MochiKit.Base.method(aComponent, 'remove') ], {trace:false}); }, MochiKit.Base.bind(function () { delete this.fieldsReferences()[aFieldID]; }, this), MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'), MochiKit.Base.method(this, 'handleChangedValue') ], {trace:false}); }, //========================================================================= 'handleDeleteDirectLogin': function(aDirectLoginReference) { var cardDialogComponent; cardDialogComponent = this.cardDialogComponent(); return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin", [ MochiKit.Base.method(this.record(), 'directLogins'), MochiKit.Base.itemgetter(aDirectLoginReference), MochiKit.Base.methodcaller('remove'), MochiKit.Base.method(this, 'directLoginReferences'), MochiKit.Base.itemgetter(aDirectLoginReference), MochiKit.Base.itemgetter('component'), function (aComponent) { return Clipperz.Async.callbacks("CardDialogController.handleDeleteDirectLogin [fade and remove]", [ MochiKit.Base.partial(Clipperz.Visual.deferredAnimation, MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}),// Clipperz.Visual.deferredAnimation(MochiKit.Visual.fade, aComponent.element(), {from:1.0, to:0.0, duration:0.5}), /// MochiKit.Base.method(aComponent, 'remove') MochiKit.Base.method(cardDialogComponent, 'removeDirectLoginComponent', aComponent) ], {trace:false}); }, MochiKit.Base.bind(function () { delete this.directLoginReferences()[aDirectLoginReference]; }, this), MochiKit.Base.method(this.cardDialogComponent(), 'fixRendering'), MochiKit.Base.method(this, 'handleChangedValue') ], {trace:false}); }, //------------------------------------------------------------------------- 'handleOpenDirectLogin': function (aDirectLoginReference) { return Clipperz.Async.callbacks("CardDialogController.handleOpenDirectLogin", [ MochiKit.Base.method(this.record(), 'directLoginWithReference', aDirectLoginReference), Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin ], {trace:false}); }, //------------------------------------------------------------------------- 'handleEditDirectLogin': function (aDirectLoginReference) { return Clipperz.Async.callbacks("CardDialogController.handleEditDirectLogin", [ MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', true), MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', aDirectLoginReference), MochiKit.Base.method(this.cardDialogComponent(), 'placeDirectLoginEditingComponent'), MochiKit.Base.method(this.record(), 'directLoginWithReference', aDirectLoginReference), MochiKit.Base.method(this.directLoginWizardController(), 'runWithDirectLogin'), MochiKit.Base.method(this.directLoginWizardController(), 'fixRulerRendering', this.cardDialogComponent().displayMode()), MochiKit.Base.method(this.cardDialogComponent(), 'showDirectLoginEditingComponent') ], {trace:false}); }, //------------------------------------------------------------------------- 'handleHideDirectLoginEditingComponent': function () { return Clipperz.Async.callbacks("CardDialogController.handleHideDirectLoginEditingComponent", [ MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', false), MochiKit.Base.method(this.directLoginWizardController(), 'hideRuler'), MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', null), MochiKit.Base.method(this, 'refreshDirectLoginComponents'), MochiKit.Base.method(this.cardDialogComponent(), 'hideDirectLoginEditingComponent') ], {trace:false}) }, 'handleCompleteDirectLoginEditingComponent': function (someParameters) { return Clipperz.Async.callbacks("CardDialogController.handleCompleteDirectLoginEditingComponent", [ MochiKit.Base.method(this, 'setIsDirectLoginEditingComponentVisible', false), MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', null), MochiKit.Base.partial(MochiKit.Async.succeed, someParameters['hasJustBeenAdded']), Clipperz.Async.deferredIf("CardDialogController.handleCompleteDirectLoginEditingComponent - should addTheEditedDirectLogin", [ MochiKit.Base.method(this, 'addCardDialogComponentWithDirectLogin', someParameters['directLogin']) ], []), MochiKit.Base.method(this, 'refreshDirectLoginComponents'), MochiKit.Base.method(this, 'handleChangedValue'), MochiKit.Base.method(this.cardDialogComponent(), 'hideDirectLoginEditingComponent') ], {trace:false}) }, //========================================================================= 'handleChangedValue': function () { return Clipperz.Async.callbacks("CardDialogController.handleChangedValue", [ MochiKit.Base.method(this, 'updateRecordValues'), MochiKit.Base.method(this.record(), 'hasPendingChanges'), MochiKit.Base.method(this.cardDialogComponent(), 'setShouldEnableSaving') ], {trace:false}); }, //------------------------------------------------------------------------- 'handleSave': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleSave", {trace:false}); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':8}); deferredResult.addMethod(this.cardDialogComponent(), 'showProgressMask'); deferredResult.addMethod(this.cardDialogComponent(), 'newFieldHasPendingChanges'); deferredResult.addIf([ MochiKit.Base.method(this, 'addField') ], []) deferredResult.addMethod(this, 'saveChanges'); deferredResult.addMethod(this.cardDialogComponent(), 'deferredHideModal', {closeToElement:null}); deferredResult.addMethod(this.cardDialogComponent(), 'remove'); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed'); deferredResult.callback(); return deferredResult; }, //......................................................................... 'saveChanges': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleSave", {trace:false}); deferredResult.addMethod(this.delegate(), 'saveChanges'); deferredResult.addErrback(function (aValue) { Clipperz.log("SHIT HAPPENS!!"); return aValue; }); deferredResult.callback(); return deferredResult; }, //------------------------------------------------------------------------- 'handleCancel': function () { var deferredResult; if (this.isDirectLoginEditingComponentVisible()) { deferredResult = this.handleHideDirectLoginEditingComponent(); } else { deferredResult = new Clipperz.Async.Deferred("CardDialogController.handleCancel", {trace:false}); // deferredResult.addMethod(this.record(), 'hasPendingChanges'), deferredResult.addMethod(this.delegate(), 'hasPendingChanges'), deferredResult.addIf([ MochiKit.Base.method(this.cardDialogComponent(), 'askConfirmationForLoosingPendingChanges') ], []) deferredResult.addMethod(this.delegate(), 'revertChanges'); deferredResult.addMethod(this.cardDialogComponent(), 'deferredHideModal', {closeToElement:this.referenceElement()}); deferredResult.addMethod(this.cardDialogComponent(), 'remove'); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed'); deferredResult.callback(); } return deferredResult; }, //------------------------------------------------------------------------- 'handleAddDirectLogin': function () { return Clipperz.Async.callbacks("CardDialogController.handleAddDirectLogin", [ MochiKit.Base.method(this.record(), 'createNewDirectLogin'), MochiKit.Base.bind(function (aDirectLogin) { return Clipperz.Async.callbacks("CardDialogController.handleAddDirectLogin - directLogin", [ MochiKit.Base.method(this.cardDialogComponent(), 'newFieldHasPendingChanges'), Clipperz.Async.deferredIf("cardDialogComponent.newFieldHasPendingChanges", [ MochiKit.Base.method(this, 'handleAddField') ], []), MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginReference', aDirectLogin.reference()), MochiKit.Base.method(this.cardDialogComponent(), 'placeDirectLoginEditingComponent'), MochiKit.Base.method(this.directLoginWizardController(), 'runWithDirectLogin', aDirectLogin, true), MochiKit.Base.method(this.directLoginWizardController(), 'fixRulerRendering', this.cardDialogComponent().displayMode()), MochiKit.Base.method(this.cardDialogComponent(), 'showDirectLoginEditingComponent') ], {trace:false}); }, this) ], {trace:false}); }, //========================================================================= 'handleCardDialogComponentKeyPressed': function (anEvent) { if ((anEvent.key().string == 'KEY_TAB') && this.cardDialogComponent().newFieldHasPendingChanges()) { anEvent.preventDefault(); // MochiKit.Signal.signal(this.cardDialogComponent(), 'addField'); this.handleAddField() this.cardDialogComponent().focusOnNewFieldLabel(); } }, //========================================================================= 'showPasswordTooltip': function (aValue, anElement) { var passwordTooltip; passwordTooltip = new Clipperz.PM.UI.Web.Components.PasswordTooltip({ 'referebceElement': anElement, 'text': aValue }); passwordTooltip.show(); }, //========================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js index f58f0b8..68b5b9f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/CardsController.js @@ -1,204 +1,202 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.CardsController = function() { Clipperz.PM.UI.Web.Controllers.CardsController.superclass.constructor.apply(this, arguments); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'cardDialogComponentClosed', this, 'handleHideCard'); return this; } Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.CardsController, Clipperz.PM.UI.Web.Controllers.GridController, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.CardsController"; }, 'createGrid': function () { var grid; grid = new Clipperz.PM.UI.Web.Components.GridComponent({columnsManagers: [ new Clipperz.PM.UI.Web.Components.FaviconColumnManager({ 'name': 'Cards.favicon', 'selector': MochiKit.Base.methodcaller('favicon'), 'cssClass': 'favicon' }), new Clipperz.PM.UI.Web.Components.LinkColumnManager({ 'name': 'Cards.title', 'selector': MochiKit.Base.methodcaller('label'), 'label': 'title', 'cssClass': 'title', 'comparator': Clipperz.Base.caseInsensitiveCompare, 'sortable': true, 'sorted': 'ASCENDING', // 'actionMethod': function(anObject, anEvent) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'editCard', {objectData:anObject, element:anEvent.src()})} 'actionMethod': MochiKit.Base.method(this, 'handleShowCard') }), new Clipperz.PM.UI.Web.Components.DirectLoginsColumnManager({ 'name': 'Cards.directLogins', 'selector': MochiKit.Base.methodcaller('directLoginReferences'), 'label': 'direct logins', 'cssClass': 'directLogin' }), new Clipperz.PM.UI.Web.Components.DateColumnManager({ 'name': 'Cards.latestUpdate', 'selector': MochiKit.Base.methodcaller('updateDate'), 'label': 'latest update', 'cssClass': 'latestUpdate', 'format': 'd-m-Y', 'comparator': MochiKit.Base.compare, 'sortable': true, 'sorted': 'UNSORTED' }), new Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager({ 'name': 'Cards.delete', 'selector': MochiKit.Base.noop, 'cssClass': 'delete', // 'actionMethod': function(anObject, anEvent) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'deleteCard', {objectData:anObject, element:anEvent.src()})} 'actionMethod': MochiKit.Base.method(this, 'handleDeleteCard') }) ]}); grid.setComponentForSlotNamed(new Clipperz.PM.UI.Web.Components.BookmarkletComponent(), 'headerSlot'); return grid; }, //----------------------------------------------------------------------------- 'getRows': function () { //TODO relying on user() in GridController, bad code smell :| return this.user().getRecords(); }, //============================================================================= 'displayEmptyContent': function () { var emptyGridComponent; emptyGridComponent = new Clipperz.PM.UI.Web.Components.CreateNewCardSplashComponent(); return Clipperz.Async.callbacks("CardsController.displayEmptyContent", [ MochiKit.Base.method(this.grid(), 'setNoRowsGridComponent', emptyGridComponent), MochiKit.Base.bind(Clipperz.PM.UI.Web.Controllers.CardsController.superclass.displayEmptyContent, this) ], {trace:false}); }, 'displaySelectedRows': function (aFilter) { this.columnManagerWithName('Cards.directLogins').hideDirectLoginListPopup(); return Clipperz.PM.UI.Web.Controllers.CardsController.superclass.displaySelectedRows.apply(this, arguments); }, //============================================================================= 'handleShowCard': function (anObject, anEvent) { var cardDialogController; cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:anObject, delegate:this}); this.grid().selectRow(anObject); cardDialogController.run(anEvent.src()); }, //......................................................................... 'handleHideCard': function () { this.focus(); }, //----------------------------------------------------------------------------- 'addCard': function (aSourceElement) { return Clipperz.Async.callbacks("CardsController.addCard", [ Clipperz.Async.collectResults("CardsController.addCard <inner results>", { 'record': MochiKit.Base.method(this.user(), 'createNewRecord'), 'delegate': MochiKit.Base.partial(MochiKit.Async.succeed, this) }, {trace:false}), function (someParameters) { return new Clipperz.PM.UI.Web.Controllers.CardDialogController(someParameters); }, MochiKit.Base.methodcaller('run', aSourceElement) ], {trace:false}); }, //----------------------------------------------------------------------------- 'handleDeleteCard': function (anObject, anEvent) { var deferredResult; var confirmationDialog; // confirmationDialog = new Clipperz.PM.UI.Common.Components.SimpleMessagePanel({ confirmationDialog = new Clipperz.PM.UI.Common.Components.MessagePanelWithProgressBar({ 'title': "Delete Card", 'text': "Do you want to delete …", 'type': 'ALERT', 'buttons': [ {text:"Cancel", result:'CANCEL'}, {text:"Delete", result:'OK', isDefault:true} ], 'canCancelWhileProcessing': false }); deferredResult = new Clipperz.Async.Deferred("AppController.handleDeleteCard", {trace:false}); deferredResult.addCallback(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':5}), deferredResult.addMethod(this.grid(), 'selectRow', anObject); deferredResult.addMethod(confirmationDialog, 'deferredShowModal', { 'openFromElement': anEvent.src(), 'onOkCloseToElement': null, // MochiKit.DOM.currentDocument().body, 'onCancelCloseToElement': anEvent.src() }); // deferredResult.addCallback(function () { Clipperz.log("DELETE: " + anObject.toString(), anObject); }); deferredResult.addMethod(this.user(), 'deleteRecord', anObject); deferredResult.addBothPass(MochiKit.Base.method(this.grid(), 'unselectRow', anObject)); deferredResult.addMethod(this, 'saveChanges'); deferredResult.addMethod(confirmationDialog, 'deferredDone'); deferredResult.addErrbackPass(function (anError) { var result; if (! (anError instanceof MochiKit.Async.CancelledError)) { result = confirmationDialog.deferredError({ 'type': 'ALERT', 'title': "Error", 'text': Clipperz.PM.Strings.errorDescriptionForException(anError), 'buttons': [{text:"Close", result:'CANCEL', isDefault:true}] }) } else { result = anError; } return result; }); deferredResult.callback(); return deferredResult; }, //============================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js index c025a51..92ed6e3 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js @@ -1,608 +1,603 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController = function(args) { this._directLoginEditingComponent = args.directLoginEditingComponent || Clipperz.Base.exception.raise('MandatoryParameter'); this._cardLabel = args.cardLabel || Clipperz.Base.exception.raise('MandatoryParameter'); MochiKit.Signal.connect(this._directLoginEditingComponent, 'changedValue', this, 'handleChangedValue'); MochiKit.Signal.connect(this._directLoginEditingComponent, 'moveForward', this, 'handleMoveForward'); MochiKit.Signal.connect(this._directLoginEditingComponent, 'keyPressed', this, 'handleDirectLoginEditingComponentKeyPressed'); this._directLogin = null; this._directLoginHasJustBeenAdded = false; this._rulerComponent = null; this._steps = null; this._currentStepIndex = 0; this._isNextEnabled = false; this._recordFields = null; this._originalBindings = null; this._bindingComponents = []; this._formValueComponents = []; return this; } MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.DirectLoginWizardController"; }, //------------------------------------------------------------------------- 'directLogin': function () { return this._directLogin; }, //------------------------------------------------------------------------- 'directLoginHasJustBeenAdded': function () { return this._directLoginHasJustBeenAdded; }, 'setDirectLoginHasJustBeenAdded': function (aValue) { this._directLoginHasJustBeenAdded = aValue; }, //------------------------------------------------------------------------- 'directLoginEditingComponent': function () { return this._directLoginEditingComponent; }, //============================================================================= 'cardLabel': function () { return this._cardLabel; }, //============================================================================= 'resetCurrentStepIndex': function () { this._currentStepIndex = 0; this.rulerComponent().resetStatus(); }, //----------------------------------------------------------------------------- 'enableNext': function (aValue) { this.rulerComponent().enableNext(aValue); this._isNextEnabled = aValue; }, 'isNextEnabled': function () { return this._isNextEnabled; }, //----------------------------------------------------------------------------- 'enablePrevious': function (aValue) { this.rulerComponent().enablePrevious(aValue); }, //============================================================================= 'bindingComponents': function () { return this._bindingComponents; }, 'resetBindingComponents': function () { this.directLoginEditingComponent().clearAllBindingsComponents(); this._bindingComponents = []; }, //============================================================================= 'formValueComponents': function () { return this._formValueComponents; }, 'resetFormValueComponents': function () { this.directLoginEditingComponent().clearAllFormValueComponents(); this._formValueComponents = []; }, //============================================================================= 'recordFields': function () { return this._recordFields; }, 'setRecordFields': function (aValue) { this._recordFields = aValue; }, 'recordFieldWithReference': function (aReference) { var matchingValues; var result; matchingValues = MochiKit.Base.filter(function (aField) { return aField['reference'] == aReference; }, this.recordFields()); if (matchingValues.length == 0) { result = null; } else { result = matchingValues[0]; } return result; }, //----------------------------------------------------------------------------- 'originalBindings': function () { return this._originalBindings; }, 'setOriginalBindings': function (aValue) { -//console.log("BINDINGS", aValue); this._originalBindings = aValue; }, //============================================================================= 'rulerComponent': function () { if (this._rulerComponent == null) { this._rulerComponent = new Clipperz.PM.UI.Web.Components.RulerComponent({ translationContext:'Wizards.DirectLoginWizard' }); this._rulerComponent.render(); MochiKit.Signal.connect(this._rulerComponent, 'exit', this, 'handleExit'); MochiKit.Signal.connect(this._rulerComponent, 'done', this, 'done'); MochiKit.Signal.connect(this._rulerComponent, 'moveForward', this, 'handleMoveForward'); MochiKit.Signal.connect(this._rulerComponent, 'moveBackward', this, 'handleMoveBackward'); MochiKit.Signal.connect(this._rulerComponent, 'cursorMoved', this, 'handleCursorMoved'); } return this._rulerComponent; }, //----------------------------------------------------------------------------- 'showRuler': function (someSteps) { var rulerElement; this.setSteps(someSteps); rulerElement = this.rulerComponent().element(); this.directLoginEditingComponent().disableAllPanels(); MochiKit.Style.showElement(rulerElement); MochiKit.Style.setElementPosition(rulerElement, {x:-1000, y:this.directLoginEditingComponent().bottomMargin()}); new MochiKit.Visual.Move(rulerElement, { x:0, y:this.directLoginEditingComponent().bottomMargin(), mode:'absolute', duration:1, afterFinish:MochiKit.Base.method(this, 'handleCursorMoved') }); }, 'fixRulerRendering': function (aValue) { this.rulerComponent().setDisplayMode(aValue); }, //----------------------------------------------------------------------------- 'hideRuler': function () { new MochiKit.Visual.Move(this.rulerComponent().element(), {x:-1000, mode:'relative', duration:1}); }, 'doneWithRuler': function () { var rulerComponentElement; rulerComponentElement = this.rulerComponent().element(); new MochiKit.Visual.Move(this.rulerComponent().element(), { x:1000, mode:'relative', duration:1, // afterFinish:MochiKit.Base.partial(MochiKit.Style.hideElement, rulerComponentElement) afterFinish:function () { MochiKit.Style.hideElement(rulerComponentElement); } }); }, //============================================================================= 'addNewDirectLoginRulerSteps': function () { return MochiKit.Base.concat([ 'LABEL'], this.editDirectLoginRulerSteps()); }, 'editDirectLoginRulerSteps': function () { return [ /*'TYPE',*/ 'CONFIGURATION', 'BINDINGS','FAVICON', 'DONE']; }, //------------------------------------------------------------------------- 'runWithDirectLogin': function (aDirectLogin, hasJustBeenAdded) { this._directLogin = aDirectLogin; this.setDirectLoginHasJustBeenAdded(hasJustBeenAdded); return Clipperz.Async.callbacks("DirectLoginWizardController.runWithDirectLogin", [ MochiKit.Base.method(aDirectLogin, 'label'), MochiKit.Base.method(this.directLoginEditingComponent(), 'setLabel'), MochiKit.Base.method(aDirectLogin, 'favicon'), MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'), MochiKit.Base.method(aDirectLogin, 'bookmarkletConfiguration'), MochiKit.Base.method(this.directLoginEditingComponent(), 'setBookmarkletConfiguration'), MochiKit.Base.method(aDirectLogin, 'bindings'), MochiKit.Base.method(this, 'setOriginalBindings'), MochiKit.Base.method(aDirectLogin, 'record'), MochiKit.Base.methodcaller('fields'), MochiKit.Base.values, MochiKit.Base.partial(MochiKit.Base.map, Clipperz.Async.collectResults("Record.directLoginReferences - collectResults", { 'reference': MochiKit.Base.methodcaller('reference'), 'label': MochiKit.Base.methodcaller('label'), 'isHidden': MochiKit.Base.methodcaller('isHidden'), 'value': MochiKit.Base.methodcaller('value') }, {trace:false})), Clipperz.Async.collectAll, MochiKit.Base.method(this, 'setRecordFields'), MochiKit.Base.partial(MochiKit.Async.succeed, hasJustBeenAdded), Clipperz.Async.deferredIf("Direct login has just been added", [ MochiKit.Base.method(this, 'addNewDirectLoginRulerSteps') ], [ MochiKit.Base.method(this, 'editDirectLoginRulerSteps') ]), MochiKit.Base.method(this, 'showRuler') ], {trace:false}); }, //----------------------------------------------------------------------------- 'checkState': function () { var enablePrevious; var enableNext; enablePrevious = true; enableNext = false; this.directLoginEditingComponent().disableAllPanels(); switch(this.currentStep()) { case 'LABEL': this.directLoginEditingComponent().enableLabelField(); enableNext = (this.directLoginEditingComponent().label() != ''); enablePrevious = false; break; case 'TYPE': this.directLoginEditingComponent().enableTypeField(); enableNext = true; enablePrevious = true; break case 'CONFIGURATION': this.directLoginEditingComponent().enableConfigurationField(); enableNext = (this.directLoginEditingComponent().bookmarkletConfiguration() != ''); if (enableNext == true) { try { Clipperz.PM.DataModel.DirectLogin.checkBookmarkletConfiguration(this.directLoginEditingComponent().bookmarkletConfiguration()); this.directLoginEditingComponent().removeHighlightConfigurationSyntaxError(); } catch (e) { this.directLoginEditingComponent().highlightConfigurationSyntaxError(); enableNext = false; } } break; case 'BINDINGS': enableNext = MochiKit.Iter.every(this.bindingComponents(), function (aBindingComponent) { return aBindingComponent.selectedValue() != null; }) this.directLoginEditingComponent().enableBindingFields(); break; case 'FAVICON': enableNext = true; this.directLoginEditingComponent().enableFaviconField(); break; case 'DONE': enableNext = true; this.directLoginEditingComponent().enableDonePanel(); break; } if (this.currentStepIndex() > 0) { this.enablePrevious(enablePrevious); } else { this.enablePrevious(false); } this.enableNext(enableNext); }, //----------------------------------------------------------------------------- 'setFocus': function () { switch(this.currentStep()) { case 'LABEL': this.directLoginEditingComponent().focusOnLabelElement(); break; case 'TYPE': break; case 'CONFIGURATION': this.directLoginEditingComponent().focusOnBookmarkletConfigurationElement(); break; case 'BINDINGS': // this.directLoginEditingComponent().getElement('???').focus(); break; case 'FAVICON': this.directLoginEditingComponent().focusOnFaviconElement(); break; case 'DONE': break; } }, //============================================================================= 'steps': function () { return this._steps; }, 'setSteps': function (aValue) { this._steps = aValue; this.rulerComponent().setSteps(aValue); this.resetCurrentStepIndex(); }, 'currentStepIndex': function () { return this._currentStepIndex; }, 'currentStep': function () { return this.steps()[this.currentStepIndex()]; }, //============================================================================= 'handleExit': function () { MochiKit.Signal.signal(this, 'exit'); }, 'done': function () { this.doneWithRuler(); Clipperz.Async.callbacks("DirectLoginWizardController.done", [ MochiKit.Base.method(this.directLoginEditingComponent(), 'label'), MochiKit.Base.method(this.directLogin(), 'setLabel'), MochiKit.Base.method(this.directLoginEditingComponent(), 'bookmarkletConfiguration'), MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration'), // Bindings MochiKit.Base.method(this.directLoginEditingComponent(), 'bindingComponents'), // MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.bind(function (aBindingComponent) { Clipperz.Async.forEach(MochiKit.Base.bind(function (aBindingComponent) { -//console.log("aBindingComponent", aBindingComponent); -// this.directLogin(). return Clipperz.Async.callbacks("DirectLoginWizardController.done - update directLogin bindings", [ MochiKit.Base.method(this.directLogin(), 'bindings'), MochiKit.Base.itemgetter(aBindingComponent.formFieldName()), MochiKit.Base.methodcaller('setFieldKey', aBindingComponent.selectedValue()) ], {trace:false}); }, this)), MochiKit.Base.method(this.directLoginEditingComponent(), 'favicon'), MochiKit.Base.method(this.directLogin(), 'setFavicon'), MochiKit.Base.partial(MochiKit.Signal.signal, this, 'done', { 'directLogin': this.directLogin(), 'hasJustBeenAdded': this.directLoginHasJustBeenAdded() }) ], {trace:false}); }, //============================================================================= 'handleMoveBackward': function () { if (this._currentStepIndex > 0) { var afterMoveAction; this._currentStepIndex --; afterMoveAction = MochiKit.Base.noop; switch(this.currentStep()) { case 'LABEL': break; case 'TYPE': break; case 'CONFIGURATION': break; case 'BINDINGS': break; case 'FAVICON': break; case 'DONE': break; }; this.rulerComponent().moveBackward(afterMoveAction); } if (this._currentStepIndex == 0) { this.enablePrevious(false); } }, 'handleMoveForward': function () { if (this.isNextEnabled()) { var afterMoveAction; this._currentStepIndex ++; afterMoveAction = MochiKit.Base.noop; switch(this.currentStep()) { case 'LABEL': break; case 'TYPE': break; case 'CONFIGURATION': break; case 'BINDINGS': this.resetBindingComponents(); this.resetFormValueComponents(); afterMoveAction = MochiKit.Base.partial(Clipperz.Async.callbacks, "DirectLoginWizardController.handleMoveForward - BINDINGS", [ MochiKit.Base.method(this.directLogin(), 'setBookmarkletConfiguration', this.directLoginEditingComponent().bookmarkletConfiguration()), MochiKit.Base.method(this.directLogin(), 'favicon'), MochiKit.Base.method(this.directLoginEditingComponent(), 'setDirectLoginFavicon'), MochiKit.Base.method(this.directLogin(), 'bindings'), MochiKit.Base.values, Clipperz.Async.forEach(MochiKit.Base.bind(function (aBinding) { var bindingComponent; bindingComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingBindingComponent({ formFieldName: aBinding.key(), fields: this.recordFields(), selectedFieldKey: aBinding.fieldKey() }); this.bindingComponents().push(bindingComponent); MochiKit.Signal.connect(bindingComponent, 'bindChange', this, 'handleBindChange', bindingComponent); this.directLoginEditingComponent().addBindingComponent(bindingComponent); }, this)), MochiKit.Base.method(this.directLogin(), 'formValues'), MochiKit.Base.values, Clipperz.Async.forEach(MochiKit.Base.bind(function (aFormValue) { var formValueComponent; formValueComponent = new Clipperz.PM.UI.Web.Components.DirectLoginEditingFormValueComponent({ 'formFieldName': aFormValue.key(), 'fieldOptions': aFormValue.fieldOptions(), 'initialValue': aFormValue.value() }); this.formValueComponents().push(formValueComponent); MochiKit.Signal.connect(formValueComponent, 'formValueChange', this, 'handleFormValueChange', formValueComponent); this.directLoginEditingComponent().addFormValueComponent(formValueComponent); }, this)) ], {trace:false}); break; case 'FAVICON': break; case 'DONE': this.directLoginEditingComponent().setDoneDescriptionWithKeys({ '__cardName__': this.cardLabel(), '__directLoginName__': this.directLoginEditingComponent().label() }); break; }; this.rulerComponent().moveForward(afterMoveAction); }; }, 'handleCursorMoved': function () { this.checkState(); this.setFocus(); }, //------------------------------------------------------------------------- 'handleChangedValue': function (anEvent) { this.checkState(); }, //......................................................................... 'handleBindChange': function (aDirectLoginEditingBindingComponent) { var selectedField; selectedField = this.recordFieldWithReference(aDirectLoginEditingBindingComponent.selectedValue()); return Clipperz.Async.callbacks("DirectLoginWizardController.handleBindChange", [ MochiKit.Base.method(this.directLogin(), 'bindings'), MochiKit.Base.itemgetter(aDirectLoginEditingBindingComponent.formFieldName()), MochiKit.Base.methodcaller('setFieldKey', selectedField['reference']), function () { if (selectedField != null) { aDirectLoginEditingBindingComponent.setFieldValue(selectedField['value']); aDirectLoginEditingBindingComponent.setIsHidden(selectedField['isHidden']); } else { aDirectLoginEditingBindingComponent.setFieldValue(''); aDirectLoginEditingBindingComponent.setIsHidden(false); } }, MochiKit.Base.method(this, 'checkState') ], {trace:false}); }, //......................................................................... 'handleFormValueChange': function (someOptions) { return Clipperz.Async.callbacks("DirectLoginWizardController.handleFormValueChange", [ MochiKit.Base.method(this.directLogin(), 'formValues'), MochiKit.Base.itemgetter(someOptions['fieldName']), MochiKit.Base.methodcaller('setValue', someOptions['selectedValue']), MochiKit.Base.method(this, 'checkState') ], {trace:false}); }, //------------------------------------------------------------------------- 'handleDirectLoginEditingComponentKeyPressed': function (anEvent) { if (anEvent.key().string == 'KEY_ENTER') { if (anEvent.target().nodeName != 'TEXTAREA') { anEvent.preventDefault(); this.handleMoveForward(); } } else if (anEvent.key().string == 'KEY_TAB') { this.handleMoveForward(); if ((anEvent.target().nodeName == 'INPUT') || (anEvent.target().nodeName == 'TEXTAREA')) { anEvent.preventDefault(); } } else if ((anEvent.key().string == 'KEY_ARROW_RIGHT') && (anEvent.modifier().meta == true)) { this.handleMoveForward(); } else if ((anEvent.key().string == 'KEY_ARROW_LEFT') && (anEvent.modifier().meta == true)) { this.handleMoveBackward(); } else if (anEvent.key().string == 'KEY_ESCAPE') { anEvent.stop(); this.handleExit(); } }, //============================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js index 6ca3be4..7ab512a 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js @@ -1,142 +1,140 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ /* Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.DirectLoginsController = function() { Clipperz.PM.UI.Web.Controllers.DirectLoginsController.superclass.constructor.apply(this, arguments); return this; }; Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.DirectLoginsController, Clipperz.PM.UI.Web.Controllers.GridController, { 'createGrid': function () { return new Clipperz.PM.UI.Web.Components.GridComponent({columnsManagers: [ new Clipperz.PM.UI.Web.Components.FaviconColumnManager({ 'name': 'DirectLogins.favicon', 'selector': MochiKit.Base.methodcaller('favicon'), 'cssClass': 'favicon' }), // new Clipperz.PM.UI.Web.Components.LinkColumnManager({ new Clipperz.PM.UI.Web.Components.DirectLoginColumnManager({ 'name': 'DirectLogins.title', 'selector': MochiKit.Base.methodcaller('label'), 'label': 'title', 'cssClass': 'title', 'comparator': Clipperz.Base.caseInsensitiveCompare, 'sortable': true, 'sorted': 'ASCENDING', 'actionMethod': MochiKit.Base.methodcaller('runDirectLogin') }), // new Clipperz.PM.UI.Web.Components.TextColumnManager({ //should be StrengthColumnManager // 'label': 'strength', // 'cssClass': 'title', // 'selector': MochiKit.Base.methodcaller('label') //should be 'strength' or a strenght evaluation function // }), new Clipperz.PM.UI.Web.Components.LinkColumnManager({ 'name': 'DirectLogins.cardTitle', 'selector': MochiKit.Base.compose(MochiKit.Base.methodcaller('label'), MochiKit.Base.methodcaller('record')), 'label': 'card', 'cssClass': 'cardTitle', 'comparator': Clipperz.Base.caseInsensitiveCompare, 'sortable': true, 'sorted': 'UNSORTED', 'actionMethod': MochiKit.Base.method(this, 'handleShowCard') }), // new Clipperz.PM.UI.Web.Components.TextColumnManager({ //should be StrengthColumnManager // 'label': 'last access', // 'cssClass': 'title', // 'selector': MochiKit.Base.methodcaller('label') // // 'sortable': true, // // 'sorted': 'UNSORTED' // }), // new Clipperz.PM.UI.Web.Components.TextColumnManager({ // 'label': 'commands', // 'cssClass': 'title', // 'selector': MochiKit.Base.methodcaller('label'), //should be a function for commands display // }), new Clipperz.PM.UI.Web.Components.DeleteObjectColumnManager({ 'name': 'DirectLogins.delete', 'selector': MochiKit.Base.noop, 'cssClass': 'delete', // 'actionMethod': function(anObject, anEvent) { MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'deleteDirectLogin', {objectData:anObject, element:anEvent.src()})} 'actionMethod': MochiKit.Base.method(this, 'handleDeleteDirectLogin') }) ]}); }, //----------------------------------------------------------------------------- 'getRows': function () { // TODO: relying on user() in GridController, bad code smell :| return this.user().getDirectLogins(); }, //----------------------------------------------------------------------------- 'handleShowCard': function (anObject, anEvent) { var cardDialogController; cardDialogController = new Clipperz.PM.UI.Web.Controllers.CardDialogController({record:anObject.record()}) cardDialogController.run(anEvent.src()); }, //----------------------------------------------------------------------------- 'handleDeleteDirectLogin': function (anObject, anEvent) { var deferredResult; var confirmationDialog; confirmationDialog = new Clipperz.PM.UI.Common.Components.SimpleMessagePanel({ title: "Delete DirectLogin", text: "Do you want to delete …", type: 'ALERT', buttons: [ {text:"Cancel", result:'CANCEL', isDefault:true}, {text:"Delete", result:'OK'} ] }); deferredResult = new Clipperz.Async.Deferred("AppController.handleDeleteCard", {trace:false}); // deferredResult = confirmationDialog.deferredShow({openFromElement:anEvent.src(), onOkCloseToElement:MochiKit.DOM.currentDocument().body, onCancelCloseToElement:anEvent.src()}); deferredResult.addMethod(confirmationDialog, 'deferredShow', { 'openFromElement': anEvent.src(), 'onOkCloseToElement': null, // MochiKit.DOM.currentDocument().body, 'onCancelCloseToElement': anEvent.src() }); deferredResult.addCallback(function () { Clipperz.log("DELETE: " + anObject.toString(), anObject); }); deferredResult.addErrbackPass(function () { Clipperz.log("skip deletion: " + anObject.toString(), anObject); }); deferredResult.callback(); return deferredResult; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); */
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js index bfc093a..de59ec3 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/FilterController.js @@ -1,155 +1,153 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.FilterController = function(args) { args = args || {}; Clipperz.PM.UI.Web.Controllers.FilterController.superclass.constructor.call(this, args); this._filterElements = []; this._filter = ""; this._pendingSearchClicks = 0; return this; }; Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.FilterController, Object, { //----------------------------------------------------------------------------- 'getFilter': function () { return this._filter; }, '_setFilter': function (aFilterElement, aFilter) { if (aFilter != this._filter) { this._filter = aFilter; MochiKit.Signal.signal(this, 'filterUpdated', aFilter); this.updateFilterElements(aFilterElement, aFilter); } }, 'setFilter': function (aFilter) { this._setFilter(null, aFilter); }, //----------------------------------------------------------------------------- 'filterElements': function () { return this._filterElements; }, 'registerFilterElement': function (aFilterElement) { //Clipperz.log("=== FilterController.registerFilterElement", aFilterElement); this._filterElements.push(aFilterElement); MochiKit.Signal.connect(aFilterElement, 'onkeydown', this, 'searchClickHandler'); MochiKit.Signal.connect(aFilterElement, 'onfocus', this, 'searchClickHandler'); }, 'removeFilterElement': function (aFilterElement) { var i; var filterElements; for (i=0; i < filterElements; i++) { if (filterElements[i] == aFilterElement); filterElements.splice(i, 1); // TODO unregister/disconnect filterElement ?? MochiKit.Signal.disconnect(this.grid().filterElement(), 'updateFilter', this.filterController(), 'handleUpdateFilter'); } }, 'updateFilterElements': function (aSourceElement, aFilterString) { MochiKit.Iter.forEach(this.filterElements(), function (aFilterElement) { if (aFilterElement != aSourceElement) { aFilterElement.value = aFilterString; } } ); if (aSourceElement != null) { aSourceElement.focus(); } }, //----------------------------------------------------------------------------- 'run': function () { //Clipperz.log("=== FilterController.run"); }, //----------------------------------------------------------------------------- 'pendingSearchClicks': function () { return this._pendingSearchClicks; }, 'incrementPendingSearchClicks': function () { this._pendingSearchClicks++; }, 'decrementPendingSearchClicks': function () { this._pendingSearchClicks--; }, //----------------------------------------------------------------------------- 'searchClickHandler': function (anEvent) { if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ENTER')) { anEvent.preventDefault(); } else { var value; if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ESCAPE')) { value = "" } else if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ARROW_UP')) { } else if ((typeof(anEvent.key()) != 'undefined') && (anEvent.key().string == 'KEY_ARROW_DOWN')) { } else { value = null; } this.incrementPendingSearchClicks(); MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, "searchClickDeferredHandler", anEvent.src(), value)); } }, //......................................................................... 'searchClickDeferredHandler': function (aFilterElement, aValue) { if (aValue != null) { aFilterElement.value = aValue; } this.decrementPendingSearchClicks(); if (this.pendingSearchClicks()==0) { this._setFilter(aFilterElement, aFilterElement.value); } }, //----------------------------------------------------------------------------- 'syntaxFix': 'syntax fix' });
\ No newline at end of file diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js index 8bb3016..44fbdef 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/GridController.js @@ -1,371 +1,369 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.GridController = function(args) { args = args || {}; Clipperz.PM.UI.Web.Controllers.GridController.superclass.constructor.call(this, args); this._grid = null; this._user = null; this._sortedColumnManager = null; this._cachedObjects = null; this._filterController = args.filterController || null; this._deferredDisplaySelectedRowsInvocation = null; return this; }; Clipperz.Base.extend(Clipperz.PM.UI.Web.Controllers.GridController, Object, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.GridController"; }, //----------------------------------------------------------------------------- 'createGrid': function () { throw Clipperz.Base.exception.AbstractMethod; }, 'setupWithGrid': function (aGrid) { this._grid = aGrid; if (this._grid != null) { MochiKit.Iter.forEach(this.columnsManagers(), function (aColumnManager) { if (aColumnManager.isSortable()) { if (aColumnManager.isSorted()) { this.setSortedColumnManager(aColumnManager); } MochiKit.Signal.connect(aColumnManager, 'sort', this, 'handleColumnManagerSort'); } MochiKit.Signal.connect(aColumnManager, 'selectRow', this, 'handleColumnManagerSelectRow'); MochiKit.Signal.connect(aColumnManager, 'unselectRow', this, 'handleColumnManagerUnselectRow'); }, this); } }, 'grid': function() { if (this._grid == null) { this.setupWithGrid(this.createGrid()); } return this._grid; }, 'filterController': function () { //Clipperz.log('GridController.filterController >>>', this._filterController); if (this._filterController == null) { this._filterController = new Clipperz.PM.UI.Web.Controllers.FilterController(); } //Clipperz.log('GridController.filterController <<<', this._filterController); return this._filterController; }, //----------------------------------------------------------------------------- 'columnsManagers': function () { return this.grid().columnsManagers(); }, 'columnManagerWithName': function (aName) { var managers; var result; managers = MochiKit.Base.filter(function (aManager) { return aManager.name() == aName; } , this.columnsManagers()); if (managers.length == 1) { result = managers[0]; } else if (managers.length == 0) { result = null; } else { throw "WTF!!!"; } return result; }, 'sortedColumnManager': function () { return this._sortedColumnManager; }, 'setSortedColumnManager': function(aValue) { if (aValue.sorted() != 'UNSORTED') { this._sortedColumnManager = aValue; } else { this._sortedColumnManager = null; } }, //----------------------------------------------------------------------------- 'handleColumnManagerSort': function(aSelectedColumnManager) { MochiKit.Iter.forEach(this.columnsManagers(), function(aColumnManager) { if (aSelectedColumnManager != aColumnManager) { if (aColumnManager.isSortable()) { aColumnManager.setSorted('UNSORTED'); } } }); aSelectedColumnManager.toggleSorting(); this.setSortedColumnManager(aSelectedColumnManager); this.displaySelectedRows(this.filterController().getFilter()); }, 'handleColumnManagerSelectRow': function (aRowObject) { this.grid().selectRow(aRowObject); }, 'handleColumnManagerUnselectRow': function (aRowObject) { this.grid().unselectRow(aRowObject); }, //----------------------------------------------------------------------------- 'handleFilterUpdated': function (aFilter) { if (this.grid().isActive()) { this.displaySelectedRows(aFilter); } }, //----------------------------------------------------------------------------- // TODO: relying on user() in GridController, bad code smell :| // mhh: a controller should have access to business logic object too. Otherwise it will fail its controller role. [Giulio Cesare] 'setUser': function(anUser) { this._user = anUser; }, 'user': function() { return this._user; }, //----------------------------------------------------------------------------- 'run': function(args) { //Clipperz.log("=== GridController.run"); var deferredResult; this.setUser(args.user); args.slot.setContent(this.grid()); this.filterController().registerFilterElement(this.grid().filterElement()); MochiKit.Signal.connect(this.filterController(), 'filterUpdated', this, 'handleFilterUpdated'); return this.displaySelectedRows(); }, //----------------------------------------------------------------------------- 'handleGenericError': function(anError) { var result; if (anError instanceof MochiKit.Async.CancelledError) { result = anError; } else { Clipperz.log("## GridController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack); result = new MochiKit.Async.CancelledError(anError); } return result; }, //----------------------------------------------------------------------------- 'getRows': function () { throw Clipperz.Base.AbstractMethod; }, //----------------------------------------------------------------------------- 'setDeferredDisplaySelectedRowsInvocation': function (aDeferred) { if (this._deferredDisplaySelectedRowsInvocation != null) { this._deferredDisplaySelectedRowsInvocation.cancel(); } this._deferredDisplaySelectedRowsInvocation = aDeferred; }, //----------------------------------------------------------------------------- 'resetDeferredDisplaySelectedRowsInvocation': function () { if (this._deferredDisplaySelectedRowsInvocation != null) { this._deferredDisplaySelectedRowsInvocation.cancel(); } }, //----------------------------------------------------------------------------- '_displaySelectedRows': function (aFilter, someRows) { var result; var delay; if ((aFilter != null) && (aFilter != '')) { 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'])}, someRows); delay = 0.002*result.length; this.setDeferredDisplaySelectedRowsInvocation(MochiKit.Async.callLater(delay, MochiKit.Base.method(this, "deferredDisplaySelectedRows", result))); } else { result = someRows; this.resetDeferredDisplaySelectedRowsInvocation(); this.deferredDisplaySelectedRows(result); } }, //----------------------------------------------------------------------------- 'deferredDisplaySelectedRows': function (someRows) { if (this.sortedColumnManager() != null) { var comparator; var fieldName; fieldName = this.sortedColumnManager().name(); comparator = this.sortedColumnManager().comparator(); if (this.sortedColumnManager().sorted() == 'DESCENDING') { comparator = Clipperz.Base.reverseComparator(comparator); } someRows.sort(MochiKit.Base.partial(function(aKey, aComparator, aObject, bObject){ return comparator(aObject[aKey], bObject[aKey]); }, this.sortedColumnManager().name(), comparator)); } this.grid().update(someRows); this.grid().endSearch(); }, //----------------------------------------------------------------------------- 'getCachedValues': function () { var deferredResult; if (this._cachedObjects != null) { deferredResult = MochiKit.Async.succeed(this._cachedObjects); } else { var objectCollectResultsConfiguration; objectCollectResultsConfiguration = { '_rowObject': MochiKit.Async.succeed, '_reference': MochiKit.Base.methodcaller('reference'), '_searchableContent': MochiKit.Base.methodcaller('searchableContent') }; MochiKit.Base.map(function (aColumnManager) { objectCollectResultsConfiguration[aColumnManager.name()] = aColumnManager.selector(); }, this.columnsManagers()); deferredResult = new Clipperz.Async.Deferred("GridController.getCachedValues", {trace:false}); deferredResult.addMethod(this, 'getRows'); deferredResult.addCallback(MochiKit.Base.map, Clipperz.Async.collectResults("GridController.getCachedValues - collectResults", objectCollectResultsConfiguration, {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; }, //----------------------------------------------------------------------------- 'hasPendingChanges': function () { return this.user().hasPendingChanges(); }, 'saveChanges': function () { this._cachedObjects = null; return Clipperz.Async.callbacks("GridController.saveChanges", [ MochiKit.Base.method(this.user(), 'saveChanges'), MochiKit.Base.method(this, 'focus') ], {trace:false}); }, 'revertChanges': function () { return this.user().revertChanges(); }, //----------------------------------------------------------------------------- 'displayEmptyContent': function () { }, 'hideEmptyContent': function () { this.grid().removeNoRowsGridComponent(); }, 'displaySelectedRows': function (aFilter) { if ((aFilter != null) && (aFilter != '')){ this.grid().startSearch(); } return Clipperz.Async.callbacks("GridController.displaySelectedrows", [ MochiKit.Base.method(this, 'getCachedValues'), MochiKit.Base.itemgetter('length'), Clipperz.Async.deferredIf("There are some items to show in the grid", [ MochiKit.Base.method(this, 'hideEmptyContent'), MochiKit.Base.method(this, 'getCachedValues'), MochiKit.Base.method(this, '_displaySelectedRows', aFilter) ], [ MochiKit.Base.method(this, 'displayEmptyContent'), MochiKit.Base.method(this.grid(), 'endSearch') ]) ], {trace:false}); }, //----------------------------------------------------------------------------- 'focus': function () { return Clipperz.Async.callbacks("GridController.focus", [ MochiKit.Base.method(this, 'displaySelectedRows', this.filterController().getFilter()), MochiKit.Base.method(this.grid(), 'focus') ], {trace:false}) //*##*/ this.displaySelectedRows(this.filterController().getFilter()); // this.grid().focus(); }, //============================================================================= 'deleteAllCleanTextData': function () { this._cachedObjects = null; this.grid().drawEmpty(); }, //============================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js index a57152d..ac85d36 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js @@ -1,250 +1,246 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.LoginController = function(args) { this._args = args || {}; this._loginPage = null; this._newUserWizardController = null; this._newUserCreationComponent = null; return this; } MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.LoginController"; }, 'args': function () { return this._args; }, //----------------------------------------------------------------------------- 'loginPage': function() { if (this._loginPage == null) { this._loginPage = new Clipperz.PM.UI.Web.Components.LoginPage(); MochiKit.Signal.connect(this._loginPage, 'createNewAccountClick', this, 'handleCreateNewAccountClick') } return this._loginPage; }, //----------------------------------------------------------------------------- 'run': function(args) { var slot; var loginPage; var loginForm; slot = args.slot; loginForm = new Clipperz.PM.UI.Web.Components.LoginForm({'autocomplete': this.args()['autocomplete']}); slot.setContent(this.loginPage()); this.loginPage().slotNamed('loginForm').setContent(loginForm); MochiKit.Signal.connect(loginForm, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm)); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'doLogin', MochiKit.Base.method(this, 'doLogin', loginForm)); }, //----------------------------------------------------------------------------- 'doLogin': function(aLoginForm, anEvent) { var deferredResult; var parameters; var loginProgress; var user; var getPassphraseDelegate; parameters = anEvent; getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')}); loginProgress = new Clipperz.PM.UI.Web.Components.LoginProgress(); deferredResult = new Clipperz.Async.Deferred("LoginController.doLogin", {trace:false}); deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate); deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()}); deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); deferredResult.addMethod(user, 'login'); deferredResult.addCallback(function(aLoginProgress, res) { aLoginProgress.disableCancel(); return res; }, loginProgress); deferredResult.addCallback(function () { MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN', MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:MochiKit.DOM.currentDocument().body})); }) deferredResult.addMethod(this, 'userLoggedIn', user, loginProgress, aLoginForm); deferredResult.addErrback (MochiKit.Base.method(this, 'handleFailedLogin', loginProgress)); deferredResult.addErrback (MochiKit.Base.method(loginProgress, 'deferredHideModalAndRemove', {closeToElement:aLoginForm.submitButtonElement()})); deferredResult.addErrbackPass (MochiKit.Base.method(aLoginForm, 'focusOnPassphraseField')); deferredResult.addBoth(MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'removePassphraseDelegate', getPassphraseDelegate)); deferredResult.callback(); MochiKit.Signal.connect(loginProgress, 'cancelEvent', deferredResult, 'cancel'); return deferredResult; }, //----------------------------------------------------------------------------- 'userLoggedIn': function(aUser) { //Clipperz.log(">>> LoginController.userLoggedIn"); MochiKit.Signal.signal(this, 'userLoggedIn', {user: aUser}); //Clipperz.log("<<< LoginController.userLoggedIn"); }, //========================================================================= 'handleCreateNewAccountClick': function (aComponent) { // return Clipperz.PM.DataModel.User.registerNewAccount("new", "user"); return Clipperz.Async.callbacks("LoginController.handleCreateNewAccountClick", [ //' MochiKit.Base.method(this, 'newUserCreationComponent'), // MochiKit.Base.methodcaller('deferredShowModal', {openFromElement:aComponent}), // MochiKit.Base.method(this.newUserWizardController(), 'run') MochiKit.Base.method(this, 'newUserCreationComponent'), Clipperz.Async.forkAndJoin("Async.test succeedingForkedAndWaitDeferrer", [ MochiKit.Base.method(this.newUserCreationComponent(), 'deferredShowModal', {openFromElement:aComponent, duration:0.5}), MochiKit.Base.method(this.newUserWizardController(), 'run') ], {trace:false}), // MochiKit.Base.method(this.newUserCreationComponent(), 'enableCredentialsField') ], {trace:false}); }, //----------------------------------------------------------------------------- 'newUserWizardController': function () { if (this._newUserWizardController == null) { this._newUserWizardController = new Clipperz.PM.UI.Web.Controllers.NewUserWizardController({ 'newUserCreationComponent': this.newUserCreationComponent() }) // MochiKit.Signal.connect(this._newUserWizardController, 'exit', this, 'handleHideNewUserCreationComponent'); MochiKit.Signal.connect(this._newUserWizardController, 'done', this, 'handleCompleteNewUserCreationComponent'); } return this._newUserWizardController; }, //------------------------------------------------------------------------- 'newUserCreationComponent': function () { if (this._newUserCreationComponent == null) { this._newUserCreationComponent = new Clipperz.PM.UI.Web.Components.NewUserCreationComponent(); } return this._newUserCreationComponent; }, 'clearNewUserCreationComponent': function () { if (this._newUserCreationComponent != null) { this._newUserCreationComponent.clear(); } this._newUserCreationComponent = null; }, //------------------------------------------------------------------------- 'handleHideNewUserCreationComponent': function () { this.clearNewUserCreationComponent(); }, 'handleCompleteNewUserCreationComponent': function (someParameters) { var deferredResult; var user; var newUserCreationComponent; user = someParameters.user; newUserCreationComponent = this.newUserCreationComponent(); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'CARDS_CONTROLLER_DID_RUN', MochiKit.Base.method(newUserCreationComponent, 'deferredHideModal', {closeToElement:MochiKit.DOM.currentDocument().body})), deferredResult = new Clipperz.Async.Deferred("LoginController.handleCompleteNewUserCreationComponent", {trace:false}); deferredResult.addCallbackList([ MochiKit.Base.method(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'), MochiKit.Base.method(user, 'login'), MochiKit.Base.method(this, 'userLoggedIn', user), MochiKit.Base.method(this, 'clearNewUserCreationComponent') ]); deferredResult.addErrback(function (aValue) { Clipperz.log("WTF!! Error doing the login after creating a new user" + aValue)}); deferredResult.callback(); return deferredResult; }, //========================================================================= 'handleFailedLogin': function(aLoginProgress, anError) { var result; -//console.log("anError", anError); if (anError instanceof MochiKit.Async.CancelledError) { result = anError; } else { var deferredResult; -MochiKit.Logging.logError("## MainController - FAILED LOGIN: " + anError); +Clipperz.logError("## MainController - FAILED LOGIN: " + anError); deferredResult = new MochiKit.Async.Deferred(); aLoginProgress.showErrorMessage("failed login"); // Clipperz.NotificationCenter.register(loginProgress, 'cancelEvent', deferredResult, 'callback'); MochiKit.Signal.connect(aLoginProgress, 'cancelEvent', deferredResult, 'callback'); deferredResult.addCallback(MochiKit.Async.fail, anError) result = deferredResult; } return result; }, 'handleGenericError': function(anError) { var result; if (anError instanceof MochiKit.Async.CancelledError) { result = anError; } else { -MochiKit.Logging.logError("## MainController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack); -//console.log(anError); +Clipperz.logError("## MainController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack); result = new MochiKit.Async.CancelledError(anError); } return result; }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js index c83e3c0..9194125 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/MainController.js @@ -1,215 +1,207 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.MainController = function(args) { this._args = args; // controllers this._loginController = null; this._appController = null; // components this._headerComponent = null; this._pageComponent = null; this._footerComponent = null; this._passphraseDelegateLock = new MochiKit.Async.DeferredLock(); this._passphraseDelegateLock.acquire(); //Clipperz.log('MainController init _passphraseDelegateLock', this._passphraseDelegateLock); this._passphraseDelegate = null; MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'remoteRequestSent', this, 'handleRemoteRequestSent'); MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'remoteRequestReceived', this, 'handleRemoteRequestReceived'); return this; } MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.MainController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.MainController"; }, 'args': function () { return this._args; }, //----------------------------------------------------------------------------- 'headerComponent': function() { if (this._headerComponent == null) { this._headerComponent = new Clipperz.PM.UI.Web.Components.PageHeader(); } return this._headerComponent; }, 'footerComponent': function() { if (this._footerComponent == null) { this._footerComponent = new Clipperz.PM.UI.Web.Components.PageFooter(); } return this._footerComponent; }, //----------------------------------------------------------------------------- 'pageComponent': function() { if (this._pageComponent == null) { this._pageComponent = new Clipperz.PM.UI.Web.Components.Page({element:MochiKit.DOM.getElement('mainDiv')}); } return this._pageComponent; }, //----------------------------------------------------------------------------- 'loginController': function() { if (this._loginController == null) { this._loginController = new Clipperz.PM.UI.Web.Controllers.LoginController(this.args()); MochiKit.Signal.connect(this._loginController, 'userLoggedIn', this, 'loginControllerUserLoggedInCallback'); } return this._loginController; }, 'appController': function() { if (this._appController == null) { this._appController = new Clipperz.PM.UI.Web.Controllers.AppController(); MochiKit.Signal.connect(this._appController, 'logout', this, 'handleLogout'); } return this._appController; }, //----------------------------------------------------------------------------- 'run': function(shoudShowRegistrationForm) { this.pageComponent().slotNamed('header').setContent(this.headerComponent()); this.pageComponent().slotNamed('footer').setContent(this.footerComponent()); this.pageComponent().render(); this.loginController().run({slot:this.pageComponent().slotNamed('body')}); if (shoudShowRegistrationForm) { MochiKit.Signal.signal(this.loginController().loginPage(), 'createNewAccountClick'); // this.loginController().handleCreateNewAccountClick(); } }, //----------------------------------------------------------------------------- 'getPassphrase': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("MainController.getPassphrase", {trace:false}); deferredResult.acquireLock(this._passphraseDelegateLock); deferredResult.addMethod(this, 'invokePassphraseDelegate'); deferredResult.releaseLock(this._passphraseDelegateLock); deferredResult.callback(); return deferredResult; }, //......................................................................... 'invokePassphraseDelegate': function () { return this._passphraseDelegate(); }, 'passphraseDelegateLock': function () { return this._passphraseDelegateLock; }, //......................................................................... 'setPassphraseDelegate': function (aDelegate) { var shouldReleaseLock; shouldReleaseLock = (this._passphraseDelegate == null); this._passphraseDelegate = aDelegate; if (shouldReleaseLock) { this._passphraseDelegateLock.release(); } }, //......................................................................... 'removePassphraseDelegate': function (aDelegate) { if (this._passphraseDelegate == aDelegate) { this._passphraseDelegate = null; this._passphraseDelegateLock.acquire(); } }, //------------------------------------------------------------------------- 'loginControllerUserLoggedInCallback': function(anEvent) { -//Clipperz.log(">>> loginControllerUserLoggedInCallback", anEvent); -// this.setUser(anEvent.parameters()['user']); -//console.log("--- loginControllerUserLoggedInCallback - 1"); - -//console.log("--- loginControllerUserLoggedInCallback - 2"); this.headerComponent().switchToLoggedMode(); this.appController().run({slot:this.pageComponent().slotNamed('body'), user:anEvent['user']}); -//Clipperz.log("<<< loginControllerUserLoggedInCallback"); }, //----------------------------------------------------------------------------- 'handleRemoteRequestSent': function () { //Clipperz.log("REMOTE REQUEST sent >>>"); }, 'handleRemoteRequestReceived': function () { //Clipperz.log("REMOTE REQUEST received <<<"); }, //----------------------------------------------------------------------------- 'handleLogout': function(anEvent) { this.exit('logout.html'); }, //----------------------------------------------------------------------------- 'exit': function(aPageName) { //Clipperz.log("### exit " + aPageName); MochiKit.Async.wait(0).addCallback(function() { window.location.href = "./" + aPageName + "?ln=" + Clipperz.PM.Strings.selectedLanguage; }); }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js index 7db6888..b70aa17 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js @@ -1,466 +1,458 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ Clipperz.Base.module('Clipperz.PM.UI.Web.Controllers'); Clipperz.PM.UI.Web.Controllers.NewUserWizardController = function(args) { this._newUserCreationComponent = args.newUserCreationComponent || Clipperz.Base.exception.raise('MandatoryParameter'); MochiKit.Signal.connect(this._newUserCreationComponent, 'changedValue', this, 'handleChangedValue'); MochiKit.Signal.connect(this._newUserCreationComponent, 'moveForward', this, 'handleMoveForward'); MochiKit.Signal.connect(this._newUserCreationComponent, 'keyPressed', this, 'handleNewUserCreationComponentKeyPressed'); this._rulerComponent = null; this._steps = null; this._currentStepIndex = 0; this._isNextEnabled = false; this._userCreationState = 'IDLE'; // 'IN PROGRESS', 'DONE', 'FAILED' this._user = null; return this; } MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.NewUserWizardController.prototype, { 'toString': function() { return "Clipperz.PM.UI.Web.Controllers.NewUserWizardController"; }, //------------------------------------------------------------------------- 'newUserCreationComponent': function () { return this._newUserCreationComponent; }, //============================================================================= 'user': function () { return this._user; }, 'setUser': function (aValue) { this._user = aValue; }, //----------------------------------------------------------------------------- 'userCreationState': function () { return this._userCreationState; }, 'setUserCreationState': function (aValue) { -//console.log("+++ NewUserWizardController.setUserCreationState", aValue); this._userCreationState = aValue; this.checkState(); }, //============================================================================= 'resetCurrentStepIndex': function () { this._currentStepIndex = 0; this.rulerComponent().resetStatus({animateTransition:true}); }, //----------------------------------------------------------------------------- 'enableNext': function (aValue) { this.rulerComponent().enableNext(aValue); this._isNextEnabled = aValue; }, 'isNextEnabled': function () { return this._isNextEnabled; }, //----------------------------------------------------------------------------- 'enablePrevious': function (aValue) { this.rulerComponent().enablePrevious(aValue); }, //============================================================================= 'rulerComponent': function () { if (this._rulerComponent == null) { this._rulerComponent = new Clipperz.PM.UI.Web.Components.RulerComponent({ translationContext:'Wizards.NewUserWizard' }); this._rulerComponent.render(); MochiKit.Signal.connect(this._rulerComponent, 'exit', this, 'handleExit'); MochiKit.Signal.connect(this._rulerComponent, 'done', this, 'done'); MochiKit.Signal.connect(this._rulerComponent, 'moveForward', this, 'handleMoveForward'); MochiKit.Signal.connect(this._rulerComponent, 'moveBackward', this, 'handleMoveBackward'); MochiKit.Signal.connect(this._rulerComponent, 'cursorMoved', this, 'handleCursorMoved'); } return this._rulerComponent; }, 'resetRuler': function () { // if (this._rulerComponent != null) { // this._rulerComponent.clear(); // } // this._rulerComponent = null; }, //----------------------------------------------------------------------------- 'showRuler': function (someSteps) { var rulerElement; this.setSteps(someSteps); rulerElement = this.rulerComponent().element(); this.newUserCreationComponent().disableAllPanels(); MochiKit.Style.showElement(rulerElement); MochiKit.Style.setElementPosition(rulerElement, {x:-1000, y:this.newUserCreationComponent().bottomMargin()}); new MochiKit.Visual.Move(rulerElement, { x:0, y:this.newUserCreationComponent().bottomMargin(), mode:'absolute', duration:0.5, // afterFinish:MochiKit.Base.method(this, 'handleCursorMoved') afterFinish:MochiKit.Base.method(this, 'handleRulerShowed') }); }, //----------------------------------------------------------------------------- 'handleRulerShowed':function () { return Clipperz.Async.callbacks("NewUserWizardController.handlerRulerShowed", [ MochiKit.Base.method(this.newUserCreationComponent(), 'waitUntilFullyRendered'), MochiKit.Base.method(this, 'handleCursorMoved') ], {trace:false}); }, //----------------------------------------------------------------------------- 'hideRuler': function () { new MochiKit.Visual.Move(this.rulerComponent().element(), {x:-1000, mode:'relative', duration:0.5}); }, 'doneWithRuler': function () { var rulerComponentElement; rulerComponentElement = this.rulerComponent().element(); new MochiKit.Visual.Move(this.rulerComponent().element(), { x:1000, mode:'relative', duration:1, // afterFinish:MochiKit.Base.partial(MochiKit.Style.hideElement, rulerComponentElement) afterFinish:function () { MochiKit.Style.hideElement(rulerComponentElement); } }); }, //============================================================================= 'createNewUserRulerSteps': function () { return [ 'CREDENTIALS', 'CHECK_CREDENTIALS', 'TERMS_OF_SERVICE', 'CREATE_USER'/*, 'LOGIN' */]; }, //------------------------------------------------------------------------- 'run': function () { return Clipperz.Async.callbacks("NewUserWizardController.run", [ MochiKit.Base.method(this, 'createNewUserRulerSteps'), MochiKit.Base.method(this, 'showRuler') ], {trace:false}); }, //----------------------------------------------------------------------------- 'checkState': function () { var enablePrevious; var enableNext; enablePrevious = true; enableNext = false; this.newUserCreationComponent().disableAllPanels(); switch(this.currentStep()) { case 'CREDENTIALS': this.newUserCreationComponent().enableCredentialsPanel(); enableNext = ( (this.newUserCreationComponent().username() != '') && (this.newUserCreationComponent().passphrase() != '') ); // enablePrevious = false; break; case 'CHECK_CREDENTIALS': this.newUserCreationComponent().enableCheckCredentialsPanel(); enableNext = (this.newUserCreationComponent().passphrase() == this.newUserCreationComponent().rePassphrase()); // enablePrevious = true; break case 'TERMS_OF_SERVICE': this.newUserCreationComponent().enableTermsOfServicePanel(); -//console.log("awareOfUnrecoverablePassphrase", this.newUserCreationComponent().awareOfUnrecoverablePassphrase()); -//console.log("readTermsOfService", this.newUserCreationComponent().readTermsOfService()); enableNext = ( (this.newUserCreationComponent().awareOfUnrecoverablePassphrase() == 'on') && (this.newUserCreationComponent().readTermsOfService() == 'on') ) break; case 'CREATE_USER': -//console.log(">>> CREATE_USER", this.userCreationState()); this.newUserCreationComponent().enableCreateUserPanel(); switch (this.userCreationState()) { case 'IDLE': this.setUserCreationState('IN PROGRESS'); this.preformActualUserRegistration(); enablePrevious = false; enableNext = false; break; case 'IN PROGRESS': enablePrevious = false; enableNext = false; break; case 'DONE': enablePrevious = false; enableNext = true; break; case 'FAILED': enablePrevious = true; enableNext = false; break; }; break; // case 'LOGIN': // this.newUserCreationComponent().enableLoginPanel(); // break; } if (this.currentStepIndex() > 0) { this.enablePrevious(enablePrevious); } else { this.enablePrevious(false); } this.enableNext(enableNext); }, //----------------------------------------------------------------------------- 'setFocus': function () { switch(this.currentStep()) { case 'CREDENTIALS': this.newUserCreationComponent().focusOnUsernameElement(); break; case 'CHECK_CREDENTIALS': this.newUserCreationComponent().focusOnRePassphraseElement(); break case 'TERMS_OF_SERVICE': break; case 'CREATE_USER': break; // case 'LOGIN': // break; } }, //============================================================================= 'steps': function () { return this._steps; }, 'setSteps': function (aValue) { this._steps = aValue; this.rulerComponent().setSteps(aValue); this.resetCurrentStepIndex(); }, 'currentStepIndex': function () { return this._currentStepIndex; }, 'currentStep': function () { return this.steps()[this.currentStepIndex()]; }, //============================================================================= 'handleExit': function () { return Clipperz.Async.callbacks("NewUserWizardController.handleExit", [ // MochiKit.Base.method(this.newUserCreationComponent(), 'resetContent'), Clipperz.Async.forkAndJoin("NewUserWizardController.handleExit - fork and join", [ MochiKit.Base.method(this, 'hideRuler'), MochiKit.Base.method(this.newUserCreationComponent(), 'deferredHideModal') ], {trace:false}), MochiKit.Base.method(this, 'resetRuler'), // MochiKit.Base.method(this.newUserCreationComponent(), 'reset'), MochiKit.Base.partial(MochiKit.Signal.signal, this, 'exit') ], {trace:false}) }, 'done': function () { this.doneWithRuler(); MochiKit.Signal.signal(this, 'done', {'user': this.user()}); }, //============================================================================= 'handleMoveBackward': function () { if (this._currentStepIndex > 0) { var afterMoveAction; afterMoveAction = MochiKit.Base.noop; -//console.log("<-- backward", this.currentStep()); switch(this.currentStep()) { case 'CREDENTIALS': case 'CHECK_CREDENTIALS': case 'TERMS_OF_SERVICE': this._currentStepIndex --; this.rulerComponent().moveBackward(afterMoveAction); break; case 'CREATE_USER': this.setUser(null); this.newUserCreationComponent().hideAllProgeressStates(); this.resetCurrentStepIndex(); this.setUserCreationState('IDLE'); break; // case 'LOGIN': // break; }; } if (this._currentStepIndex == 0) { this.enablePrevious(false); } }, 'handleMoveForward': function () { if (this.isNextEnabled()) { var afterMoveAction; this._currentStepIndex ++; afterMoveAction = MochiKit.Base.noop; switch(this.currentStep()) { case 'CREDENTIALS': break; case 'CHECK_CREDENTIALS': break case 'TERMS_OF_SERVICE': break; case 'CREATE_USER': break; // case 'LOGIN': // break; }; this.rulerComponent().moveForward(afterMoveAction); }; }, 'handleCursorMoved': function () { // this.checkState(); // this.setFocus(); return Clipperz.Async.callbacks("NewUserWizardController.handleCursorMoved", [ MochiKit.Base.method(this.newUserCreationComponent(), 'waitUntilFullyRendered'), MochiKit.Base.method(this, 'checkState'), MochiKit.Base.method(this, 'setFocus') ], {trace:false}); }, //------------------------------------------------------------------------- 'handleChangedValue': function (anEvent) { this.checkState(); }, //------------------------------------------------------------------------- 'handleNewUserCreationComponentKeyPressed': function (anEvent) { -//console.log(">>> handleNewUserCreationComponentKeyPressed", anEvent.key().string); if (anEvent.key().string == 'KEY_ENTER') { if (anEvent.target().nodeName != 'TEXTAREA') { anEvent.preventDefault(); this.handleMoveForward(); } } else if (anEvent.key().string == 'KEY_TAB') { if (anEvent.target() == this.newUserCreationComponent().usernameElement()) { } else { this.handleMoveForward(); if ((anEvent.target().nodeName == 'INPUT') || (anEvent.target().nodeName == 'TEXTAREA')) { anEvent.preventDefault(); } } } else if ((anEvent.key().string == 'KEY_ARROW_RIGHT') && (anEvent.modifier().meta == true)) { this.handleMoveForward(); } else if ((anEvent.key().string == 'KEY_ARROW_LEFT') && (anEvent.modifier().meta == true)) { this.handleMoveBackward(); } else if (anEvent.key().string == 'KEY_ESCAPE') { anEvent.stop(); this.handleExit(); } else { MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, 'checkState')); } }, //============================================================================= 'preformActualUserRegistration': function () { var deferredResult; deferredResult = new Clipperz.Async.Deferred("NewUSerWizardController.preformActualUserRegistration", {trace:false}); deferredResult.addMethod(this.newUserCreationComponent(), 'showProgressOnUserCreation'); deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', MochiKit.Base.method(this.newUserCreationComponent(), 'passphrase')); deferredResult.addCallback(Clipperz.PM.DataModel.User.registerNewAccount, this.newUserCreationComponent().username(), MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase') ); deferredResult.addMethod(this, 'setUser'); deferredResult.addMethod(this.newUserCreationComponent(), 'showUserCreationDone'); deferredResult.addMethod(this, 'setUserCreationState', 'DONE'); // deferredResult.addErrback(MochiKit.Base.method(this.newUserCreationComponent(), 'showUserCreationFailed')); // deferredResult.addErrback(MochiKit.Base.method(this, 'setUser', null)); // deferredResult.addErrback(MochiKit.Base.method(this, 'setUserCreationState', 'FAILED')); deferredResult.addErrback(MochiKit.Base.bind(function (aValue) { this.newUserCreationComponent().showUserCreationFailed(); this.setUser(null); this.setUserCreationState('FAILED'); }, this)); deferredResult.callback(); return deferredResult; }, //============================================================================= __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Set.js b/frontend/gamma/js/Clipperz/Set.js index 7023888..b3831a4 100644 --- a/frontend/gamma/js/Clipperz/Set.js +++ b/frontend/gamma/js/Clipperz/Set.js @@ -1,164 +1,162 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } //############################################################################# Clipperz.Set = function(args) { args = args || {}; // MochiKit.Base.bindMethods(this); if (args.items != null) { this._items = args.items.slice(); } else { this._items = []; } return this; } //============================================================================= Clipperz.Set.prototype = MochiKit.Base.update(null, { //------------------------------------------------------------------------- 'toString': function() { return "Clipperz.Set"; }, //------------------------------------------------------------------------- 'items': function() { return this._items; }, //------------------------------------------------------------------------- 'popAnItem': function() { var result; if (this.size() > 0) { result = this.items().pop(); } else { result = null; } return result; }, //------------------------------------------------------------------------- 'allItems': function() { return this.items(); }, //------------------------------------------------------------------------- 'contains': function(anItem) { return (this.indexOf(anItem) != -1); }, //------------------------------------------------------------------------- 'indexOf': function(anItem) { var result; var i, c; result = -1; c = this.items().length; for (i=0; (i<c) && (result == -1); i++) { if (this.items()[i] === anItem) { result = i; } } return result; }, //------------------------------------------------------------------------- 'add': function(anItem) { if (anItem.constructor == Array) { MochiKit.Base.map(MochiKit.Base.bind(this,add, this), anItem); } else { if (! this.contains(anItem)) { this.items().push(anItem); } } }, //------------------------------------------------------------------------- 'debug': function() { var i, c; result = -1; c = this.items().length; for (i=0; i<c; i++) { alert("[" + i + "] " + this.items()[i].label); } }, //------------------------------------------------------------------------- 'remove': function(anItem) { if (anItem.constructor == Array) { MochiKit.Base.map(MochiKit.Base.bind(this.remove, this), anItem); } else { var itemIndex; itemIndex = this.indexOf(anItem); if (itemIndex != -1) { this.items().splice(itemIndex, 1); } } }, //------------------------------------------------------------------------- 'size': function() { return this.items().length; }, //------------------------------------------------------------------------- 'empty': function() { this.items().splice(0, this.items().length); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" //------------------------------------------------------------------------- }); diff --git a/frontend/gamma/js/Clipperz/Signal.js b/frontend/gamma/js/Clipperz/Signal.js index ca3e322..f9b74c9 100644 --- a/frontend/gamma/js/Clipperz/Signal.js +++ b/frontend/gamma/js/Clipperz/Signal.js @@ -1,68 +1,66 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Signal) == 'undefined') { Clipperz.Signal = {}; } Clipperz.Signal.VERSION = "0.1"; Clipperz.Signal.NAME = "Clipperz.Signal"; MochiKit.Base.update(Clipperz.Signal, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'fireNativeEvent': function(element, eventName) { if (element.fireEvent) { // MSIE element.fireEvent(eventName); } else { // W3C var event; event = document.createEvent("HTMLEvents"); event.initEvent(eventName.replace(/^on/, ""), true, true); element.dispatchEvent(event); } }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); Clipperz.Signal.NotificationCenter = {}; diff --git a/frontend/gamma/js/Clipperz/Style.js b/frontend/gamma/js/Clipperz/Style.js index d377893..acbe71b 100644 --- a/frontend/gamma/js/Clipperz/Style.js +++ b/frontend/gamma/js/Clipperz/Style.js @@ -1,91 +1,89 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Style) == 'undefined') { Clipperz.Style = {}; } Clipperz.Style.VERSION = "0.1"; Clipperz.Style.NAME = "Clipperz.DOM"; MochiKit.Base.update(Clipperz.Style, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'applyZebraStylesToTable': function(aTable) { var tbody; var tbodyRows; var i,c; tbody = MochiKit.DOM.getFirstElementByTagAndClassName('tbody', null, aTable); tbodyRows = tbody.childNodes; // tbodyRows = MochiKit.DOM.getElementsByTagAndClassName('tr', null, tbody) c = tbodyRows.length; for (i=0; i<c; i++) { var element; element = YAHOO.Element.get(tbodyRows[i]); element.addClass(((i%2 == 0) ? "zebra_odd": "zebra_even")); element.removeClass(((i%2 == 1) ? "zebra_odd": "zebra_even")); } }, //------------------------------------------------------------------------- 'getSizeAndPosition': function (anElement) { var result; if (anElement != null) { result = { dimensions:MochiKit.Style.getElementDimensions(anElement), position:MochiKit.Style.getElementPosition(anElement)}; } else { result = { dimensions:MochiKit.Style.getViewportDimensions(), position:MochiKit.Style.getViewportPosition()}; } return result; }, 'setBackgroundGradient': function (anElement, someParameters) { // background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ff9955), to(#ff6622), color-stop(1,#333333)); // background: -moz-linear-gradient(0% 100% 90deg,#ff6622, #ff9955); MochiKit.Style.setStyle(anElement, {'background': '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + someParameters['from'] + '), to(' + someParameters['to'] + '), color-stop(1,#333333))'}); MochiKit.Style.setStyle(anElement, {'background': '-moz-linear-gradient(0% 100% 90deg,' + someParameters['to'] + ', ' + someParameters['from'] + ')'}); }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); diff --git a/frontend/gamma/js/Clipperz/Visual.js b/frontend/gamma/js/Clipperz/Visual.js index c2da3b7..93ed725 100644 --- a/frontend/gamma/js/Clipperz/Visual.js +++ b/frontend/gamma/js/Clipperz/Visual.js @@ -1,365 +1,363 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Visual) == 'undefined') { Clipperz.Visual = {}; } Clipperz.Visual.VERSION = "0.1"; Clipperz.Visual.NAME = "Clipperz.Visual"; MochiKit.Base.update(Clipperz.Visual, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'deferredResize': function (anElement, someOptions) { var deferredResult; var moveTransition; var scaleTransition; var duration; duration = someOptions.duration || 0.5; deferredResult = new Clipperz.Async.Deferred("Visual.deferredResize", {trace:false}); deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); moveTransition = MochiKit.Visual.Transitions.linear; //MochiKit.Visual.Transitions.sinoidal; scaleTransition = MochiKit.Visual.Transitions.linear; //MochiKit.Visual.Transitions.sinoidal; MochiKit.Style.setElementPosition(anElement, {x:someOptions.from.position.x, y:someOptions.from.position.y }, 'px'); new MochiKit.Visual.Parallel([ new MochiKit.Visual.Move(anElement, {x:someOptions.to.position.x, y:someOptions.to.position.y, mode:'absolute', transition:moveTransition, sync:true}), new Clipperz.Visual.Resize(anElement, {fromSize:{h:someOptions.from.dimensions.h, w:someOptions.from.dimensions.w}, toSize:{h:someOptions.to.dimensions.h, w:someOptions.to.dimensions.w}, transition:scaleTransition, scaleContent:false, scaleFromCenter:false, restoreAfterFinish:true, sync:true}) ], {duration:duration, afterFinish:MochiKit.Base.method(deferredResult, 'callback')}) return deferredResult; }, //------------------------------------------------------------------------- 'deferredAnimation': function (anAnimation, someParameters, someOptions) { var deferredResult; var afterFinishCallback; var options; deferredResult = new Clipperz.Async.Deferred("Clipperz.Visual.deferredAnimation", {trace:false}); deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); if (MochiKit.Base.isUndefinedOrNull(someOptions)) { options = {} } else { options = someOptions; } if (MochiKit.Base.isUndefinedOrNull(someOptions['afterFinish'])) { options['afterFinish'] = MochiKit.Base.noop; } MochiKit.Base.update(options, { 'afterFinish': MochiKit.Base.compose(options['afterFinish'], MochiKit.Base.method(deferredResult, 'callback')) }); new anAnimation(someParameters, options); return deferredResult; }, //------------------------------------------------------------------------- 'deferredAnimations': function (aSinchronizationType, someAnimations, someOptions) { var deferredResult; var options; deferredResult = new Clipperz.Async.Deferred("Visual.deferredParallelAnimations", {trace:false}); deferredResult.addCallback(MochiKit.Async.succeed, arguments[arguments.length - 1]); options = someOptions; if (MochiKit.Base.isUndefinedOrNull(someOptions['afterFinish'])) { options['afterFinish'] = MochiKit.Base.noop; } MochiKit.Base.update(options, { 'afterFinish': MochiKit.Base.compose(options['afterFinish'], MochiKit.Base.method(deferredResult, 'callback')) }); new aSinchronizationType(someAnimations, options) return deferredResult; }, //------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# /** @id Clipperz.Visual.Resize */ Clipperz.Visual.Resize = function (element, percent, options) { var cls = arguments.callee; if (!(this instanceof cls)) { return new cls(element, percent, options); } this.__init__(element, percent, options); }; Clipperz.Visual.Resize.prototype = new MochiKit.Visual.Base(); MochiKit.Base.update(Clipperz.Visual.Resize.prototype, { __class__ : Clipperz.Visual.Resize, __init__: function (element, options) { this.element = MochiKit.DOM.getElement(element); options = MochiKit.Base.update({ scaleX: true, scaleY: true, scaleContent: true, scaleFromCenter: false, scaleMode: 'box', // 'box' or 'contents' or {} with provided values syntax_fix: 'syntax fix' }, options); this.start(options); }, setup: function () { this.restoreAfterFinish = this.options.restoreAfterFinish || false; this.elementPositioning = MochiKit.Style.getStyle(this.element, 'position'); var ma = MochiKit.Base.map; var b = MochiKit.Base.bind; this.originalStyle = {}; ma(b(function (k) { this.originalStyle[k] = this.element.style[k]; }, this), ['top', 'left', 'width', 'height', 'fontSize']); this.originalTop = this.element.offsetTop; this.originalLeft = this.element.offsetLeft; var fontSize = MochiKit.Style.getStyle(this.element, 'font-size') || '100%'; ma(b(function (fontSizeType) { if (fontSize.indexOf(fontSizeType) > 0) { this.fontSize = parseFloat(fontSize); this.fontSizeType = fontSizeType; } }, this), ['em', 'px', '%']); this.factor = 1; this.dims = [this.options.fromSize.h, this.options.fromSize.w]; }, update: function (position) { this.setDimensions( (this.options.toSize.h - this.options.fromSize.h) * position + this.options.fromSize.h, (this.options.toSize.w - this.options.fromSize.w) * position + this.options.fromSize.w); }, finish: function () { if (this.restoreAfterFinish) { MochiKit.Style.setStyle(this.element, this.originalStyle); } }, setDimensions: function (height, width) { var d = {}; var r = Math.round; if (/MSIE/.test(navigator.userAgent)) { r = Math.ceil; } if (this.options.scaleX) { d.width = r(width) + 'px'; } if (this.options.scaleY) { d.height = r(height) + 'px'; } if (this.options.scaleFromCenter) { var topd = (height - this.dims[0])/2; var leftd = (width - this.dims[1])/2; if (this.elementPositioning == 'absolute') { if (this.options.scaleY) { d.top = this.originalTop - topd + 'px'; } if (this.options.scaleX) { d.left = this.originalLeft - leftd + 'px'; } } else { if (this.options.scaleY) { d.top = -topd + 'px'; } if (this.options.scaleX) { d.left = -leftd + 'px'; } } } MochiKit.Style.setStyle(this.element, d); } }); //============================================================================= Clipperz.Visual.squize = function (element, /* optional */ options) { var d = MochiKit.DOM; var v = MochiKit.Visual; var s = MochiKit.Style; element = d.getElement(element); options = MochiKit.Base.update({ moveTransition: v.Transitions.sinoidal, scaleTransition: v.Transitions.sinoidal, opacityTransition: v.Transitions.none, scaleContent: true, scaleFromCenter: false, scaleX: true, scaleY: true }, options); var oldStyle = { top: element.style.top, left: element.style.left, height: element.style.height, width: element.style.width, opacity: s.getStyle(element, 'opacity') }; var dims = s.getElementDimensions(element, true); var moveX, moveY; moveX = options.scaleX ? dims.w/2 : 0; moveY = options.scaleY ? dims.h/2 : 0; var elemClip; var optionsParallel = MochiKit.Base.update({ beforeStartInternal: function (effect) { s.makePositioned(effect.effects[0].element); elemClip = s.makeClipping(effect.effects[0].element); }, afterFinishInternal: function (effect) { s.hideElement(effect.effects[0].element); s.undoClipping(effect.effects[0].element, elemClip); s.undoPositioned(effect.effects[0].element); s.setStyle(effect.effects[0].element, oldStyle); } }, options); return new v.Parallel( [new v.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), new v.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, { scaleMode: {originalHeight: dims.h, originalWidth: dims.w}, sync: true, transition: options.scaleTransition, scaleContent: options.scaleContent, scaleFromCenter: options.scaleFromCenter, restoreAfterFinish: true, scaleX: options.scaleX, scaleY: options.scaleY }), new v.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) ], optionsParallel ); }; //----------------------------------------------------------------------------- Clipperz.Visual.expand = function (element, /* optional */ options) { var d = MochiKit.DOM; var v = MochiKit.Visual; var s = MochiKit.Style; element = d.getElement(element); options = MochiKit.Base.update({ // direction: 'center', moveTransition: v.Transitions.sinoidal, scaleTransition: v.Transitions.sinoidal, opacityTransition: v.Transitions.none, scaleContent: true, scaleFromCenter: false, scaleX: true, scaleY: true }, options); var oldStyle = { top: element.style.top, left: element.style.left, height: element.style.height, width: element.style.width, opacity: s.getStyle(element, 'opacity') }; var dims = s.getElementDimensions(element, true); var moveX, moveY; moveX = options.scaleX ? dims.w/2 : 0; moveY = options.scaleY ? dims.h/2 : 0; var elemClip; var optionsParallel = MochiKit.Base.update({ beforeStartInternal: function (effect) { s.makePositioned(effect.effects[0].element); elemClip = s.makeClipping(effect.effects[0].element); }, afterFinishInternal: function (effect) { s.hideElement(effect.effects[0].element); s.undoClipping(effect.effects[0].element, elemClip); s.undoPositioned(effect.effects[0].element); s.setStyle(effect.effects[0].element, oldStyle); } }, options); return new v.Parallel( [new v.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), new v.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, { scaleMode: {originalHeight: dims.h, originalWidth: dims.w}, sync: true, transition: options.scaleTransition, scaleContent: options.scaleContent, scaleFromCenter: options.scaleFromCenter, restoreAfterFinish: true, scaleX: options.scaleX, scaleY: options.scaleY }), new v.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) ], optionsParallel ); }; //============================================================================= diff --git a/frontend/gamma/js/Clipperz/YUI/DomHelper.js b/frontend/gamma/js/Clipperz/YUI/DomHelper.js index 87c74f5..0a1f9fe 100644 --- a/frontend/gamma/js/Clipperz/YUI/DomHelper.js +++ b/frontend/gamma/js/Clipperz/YUI/DomHelper.js @@ -1,478 +1,471 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.YUI) == 'undefined') { Clipperz.YUI = {}; }
/**
* @class Clipperz.ext.DomHelper
* Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM.
* For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>.
* @singleton
*/
Clipperz.YUI.DomHelper = new function(){
/**@private*/
var d = document;
var tempTableEl = null;
/** True to force the use of DOM instead of html fragments @type Boolean */
this.useDom = false;
var emptyTags = /^(?:base|basefont|br|frame|hr|img|input|isindex|link|meta|nextid|range|spacer|wbr|audioscope|area|param|keygen|col|limittext|spot|tab|over|right|left|choose|atop|of)$/i;
/**
* Applies a style specification to an element
* @param {String/HTMLElement} el The element to apply styles to
* @param {String/Object/Function} styles A style specification string eg "width:100px", or object in the form {width:"100px"}, or
* a function which returns such a specification.
*/
this.applyStyles = function(el, styles){
if(styles){
var D = YAHOO.util.Dom;
if (typeof styles == "string"){
var re = /\s?([a-z\-]*)\:([^;]*);?/gi;
var matches;
while ((matches = re.exec(styles)) != null){
D.setStyle(el, matches[1], matches[2]);
}
}else if (typeof styles == "object"){
for (var style in styles){
D.setStyle(el, style, styles[style]);
}
}else if (typeof styles == "function"){
Clipperz.YUI.DomHelper.applyStyles(el, styles.call());
}
}
};
// build as innerHTML where available
/** @ignore */
var createHtml = function(o){
var b = '';
if(typeof(o['html']) != 'undefined') {
o['html'] = Clipperz.Base.sanitizeString(o['html']);
} else if (typeof(o['htmlString']) != 'undefined') {
o['html'] = o['htmlString'];
delete o.htmlString;
}
if (MochiKit.Base.isArrayLike(o)) {
for (var i = 0, l = o.length; i < l; i++) {
b += createHtml(o[i]);
}
return b;
}
b += '<' + o.tag;
for(var attr in o){
if(attr == 'tag' || attr == 'children' || attr == 'html' || typeof o[attr] == 'function') continue;
if(attr == 'style'){
var s = o['style'];
if(typeof s == 'function'){
s = s.call();
}
if(typeof s == 'string'){
b += ' style="' + s + '"';
}else if(typeof s == 'object'){
b += ' style="';
for(var key in s){
if(typeof s[key] != 'function'){
b += key + ':' + s[key] + ';';
}
}
b += '"';
}
}else{
if(attr == 'cls'){
b += ' class="' + o['cls'] + '"';
}else if(attr == 'htmlFor'){
b += ' for="' + o['htmlFor'] + '"';
}else{
b += ' ' + attr + '="' + o[attr] + '"';
}
}
}
if(emptyTags.test(o.tag)){
b += ' />';
}else{
b += '>';
if(o.children){
for(var i = 0, len = o.children.length; i < len; i++) {
b += createHtml(o.children[i], b);
}
}
if(o.html){
b += o.html;
}
b += '</' + o.tag + '>';
}
return b;
}
// build as dom
/** @ignore */
var createDom = function(o, parentNode){
var el = d.createElement(o.tag);
var useSet = el.setAttribute ? true : false; // In IE some elements don't have setAttribute
for(var attr in o){
if(attr == 'tag' || attr == 'children' || attr == 'html' || attr == 'style' || typeof o[attr] == 'function') continue;
if(attr=='cls'){
el.className = o['cls'];
}else{
if(useSet) el.setAttribute(attr, o[attr]);
else el[attr] = o[attr];
}
}
Clipperz.YUI.DomHelper.applyStyles(el, o.style);
if(o.children){
for(var i = 0, len = o.children.length; i < len; i++) {
createDom(o.children[i], el);
}
}
if(o.html){
el.innerHTML = o.html;
}
if(parentNode){
parentNode.appendChild(el);
}
return el;
};
/**
* @ignore
* Nasty code for IE's broken table implementation
*/
var insertIntoTable = function(tag, where, el, html){
if(!tempTableEl){
tempTableEl = document.createElement('div');
}
var nodes;
if(tag == 'table' || tag == 'tbody'){
tempTableEl.innerHTML = '<table><tbody>'+html+'</tbody></table>';
nodes = tempTableEl.firstChild.firstChild.childNodes;
}else{
tempTableEl.innerHTML = '<table><tbody><tr>'+html+'</tr></tbody></table>';
nodes = tempTableEl.firstChild.firstChild.firstChild.childNodes;
}
if (where == 'beforebegin') {
nodes.reverse();
// el.parentNode.insertBefore(node, el);
MochiKit.Base.map(function(aNode) {el.parentNode.insertBefore(aNode, el)}, nodes);
} else if (where == 'afterbegin') {
nodes.reverse();
// el.insertBefore(node, el.firstChild);
MochiKit.Base.map(function(aNode) {el.insertBefore(aNode, el.firstChild)}, nodes);
} else if (where == 'beforeend') {
// el.appendChild(node);
MochiKit.Base.map(function(aNode) {el.appendChild(aNode)}, nodes);
} else if (where == 'afterend') {
// el.parentNode.insertBefore(node, el.nextSibling);
MochiKit.Base.map(function(aNode) {el.parentNode.insertBefore(aNode, el.nextSibling)}, nodes);
}
return nodes;
}
/**
* Inserts an HTML fragment into the Dom
* @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.
* @param {HTMLElement} el The context element
* @param {String} html The HTML fragmenet
* @return {HTMLElement} The new node
*/
this.insertHtml = function(where, el, html){
where = where.toLowerCase();
// if(el.insertAdjacentHTML){
if(Clipperz_IEisBroken){
var tag = el.tagName.toLowerCase();
if(tag == 'table' || tag == 'tbody' || tag == 'tr'){
return insertIntoTable(tag, where, el, html);
}
switch(where){
case 'beforebegin':
el.insertAdjacentHTML(where, html);
return el.previousSibling;
case 'afterbegin':
el.insertAdjacentHTML(where, html);
return el.firstChild;
case 'beforeend':
el.insertAdjacentHTML(where, html);
return el.lastChild;
case 'afterend':
el.insertAdjacentHTML(where, html);
return el.nextSibling;
}
throw 'Illegal insertion point -> "' + where + '"';
}
var range = el.ownerDocument.createRange();
var frag;
switch(where){
case 'beforebegin':
range.setStartBefore(el);
frag = range.createContextualFragment(html);
el.parentNode.insertBefore(frag, el);
return el.previousSibling;
case 'afterbegin':
if(el.firstChild){ // faster
range.setStartBefore(el.firstChild);
}else{
range.selectNodeContents(el);
range.collapse(true);
}
frag = range.createContextualFragment(html);
el.insertBefore(frag, el.firstChild);
return el.firstChild;
case 'beforeend':
if(el.lastChild){
range.setStartAfter(el.lastChild); // faster
}else{
range.selectNodeContents(el);
range.collapse(false);
}
frag = range.createContextualFragment(html);
el.appendChild(frag);
return el.lastChild;
case 'afterend':
range.setStartAfter(el);
frag = range.createContextualFragment(html);
el.parentNode.insertBefore(frag, el.nextSibling);
return el.nextSibling;
}
throw 'Illegal insertion point -> "' + where + '"';
};
/**
* Creates new Dom element(s) and inserts them before el
* @param {String/HTMLElement/Element} el The context element
* @param {Object} o The Dom object spec (and children)
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
this.insertBefore = function(el, o, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
var newNode;
if(this.useDom){
newNode = createDom(o, null);
el.parentNode.insertBefore(newNode, el);
}else{
var html = createHtml(o);
newNode = this.insertHtml('beforeBegin', el, html);
}
return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
};
/**
* Creates new Dom element(s) and inserts them after el
* @param {String/HTMLElement/Element} el The context element
* @param {Object} o The Dom object spec (and children)
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
this.insertAfter = function(el, o, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
var newNode;
if(this.useDom){
newNode = createDom(o, null);
el.parentNode.insertBefore(newNode, el.nextSibling);
}else{
var html = createHtml(o);
newNode = this.insertHtml('afterEnd', el, html);
}
return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
};
/**
* Creates new Dom element(s) and appends them to el
* @param {String/HTMLElement/Element} el The context element
* @param {Object} o The Dom object spec (and children)
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
this.append = function(el, o, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
var newNode;
if(this.useDom){
newNode = createDom(o, null);
el.appendChild(newNode);
}else{
var html = createHtml(o);
newNode = this.insertHtml('beforeEnd', el, html);
}
return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
};
/**
* Creates new Dom element(s) and overwrites the contents of el with them
* @param {String/HTMLElement/Element} el The context element
* @param {Object} o The Dom object spec (and children)
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
this.overwrite = function(el, o, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
el.innerHTML = createHtml(o);
return returnElement ? YAHOO.Element.get(el.firstChild, true) : el.firstChild;
};
/**
* Creates a new Clipperz.YUI.DomHelper.Template from the Dom object spec
* @param {Object} o The Dom object spec (and children)
* @return {Clipperz.YUI.DomHelper.Template} The new template
*/
this.createTemplate = function(o){
var html = createHtml(o);
return new Clipperz.YUI.DomHelper.Template(html);
};
}();
/**
* @class Clipperz.YUI.DomHelper.Template
* Represents an HTML fragment template.
* For more information see <a href="http://www.jackslocum.com/yui/2006/10/06/domhelper-create-elements-using-dom-html-fragments-or-templates/">this blog post with examples</a>.
* <br>
* <b>This class is also available as Clipperz.YUI.Template</b>.
* @constructor
* @param {String/Array} html The HTML fragment or an array of fragments to join('') or multiple arguments to join('')
*/
Clipperz.YUI.DomHelper.Template = function(html){
if(html instanceof Array){
html = html.join('');
}else if(arguments.length > 1){
html = Array.prototype.join.call(arguments, '');
}
/**@private*/
this.html = html;
};
Clipperz.YUI.DomHelper.Template.prototype = {
/**
* Returns an HTML fragment of this template with the specified values applied
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @return {String}
*/
applyTemplate : function(values){
if(this.compiled){
return this.compiled(values);
}
var empty = '';
var fn = function(match, index){
if(typeof values[index] != 'undefined'){
return values[index];
}else{
return empty;
}
}
return this.html.replace(this.re, fn);
},
/**
* The regular expression used to match template variables
* @type RegExp
* @property
*/
re : /\{([\w|-]+)\}/g,
/**
* Compiles the template into an internal function, eliminating the RegEx overhead
*/
compile : function(){
var body = ["this.compiled = function(values){ return ['"];
body.push(this.html.replace(this.re, "', values['$1'], '"));
body.push("'].join('');};");
eval(body.join(''));
return this;
},
/**
* Applies the supplied values to the template and inserts the new node(s) before el
* @param {String/HTMLElement/Element} el The context element
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
insertBefore: function(el, values, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
var newNode = Clipperz.YUI.DomHelper.insertHtml('beforeBegin', el, this.applyTemplate(values));
return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
},
/**
* Applies the supplied values to the template and inserts the new node(s) after el
* @param {String/HTMLElement/Element} el The context element
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
insertAfter : function(el, values, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
var newNode = Clipperz.YUI.DomHelper.insertHtml('afterEnd', el, this.applyTemplate(values));
return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
},
/**
* Applies the supplied values to the template and append the new node(s) to el
* @param {String/HTMLElement/Element} el The context element
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
append : function(el, values, returnElement){
var sanitizedValues;
var key;
-// sanitizedValues = MochiKit.Base.map(sanitizedValues)
-//console.log("values", values);
sanitizedValues = {};
for (key in values) {
sanitizedValues[key] = Clipperz.Base.sanitizeString(values[key]);
}
-//console.log("sanitizedValues", sanitizedValues);
-// el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
el = (typeof el == 'string') ? YAHOO.util.Dom.get(el) : el;
-//Clipperz.log(this.applyTemplate(sanitizedValues));
var newNode = Clipperz.YUI.DomHelper.insertHtml('beforeEnd', el, this.applyTemplate(sanitizedValues));
-// return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
+
return newNode;
},
/**
* Applies the supplied values to the template and overwrites the content of el with the new node(s)
* @param {String/HTMLElement/Element} el The context element
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @param {<i>Boolean</i>} returnElement (optional) true to return a YAHOO.Element
* @return {HTMLElement} The new node
*/
overwrite : function(el, values, returnElement){
el = el.dom ? el.dom : YAHOO.util.Dom.get(el);
el.innerHTML = '';
var newNode = Clipperz.YUI.DomHelper.insertHtml('beforeEnd', el, this.applyTemplate(values));
return returnElement ? YAHOO.Element.get(newNode, true) : newNode;
}
};
/**
* Alias for applyTemplate
* @method
*/
Clipperz.YUI.DomHelper.Template.prototype.apply = Clipperz.YUI.DomHelper.Template.prototype.applyTemplate;
Clipperz.YUI.Template = Clipperz.YUI.DomHelper.Template;
diff --git a/frontend/gamma/js/Clipperz/YUI/DomQuery.js b/frontend/gamma/js/Clipperz/YUI/DomQuery.js index 76d0fae..c1af0ca 100644 --- a/frontend/gamma/js/Clipperz/YUI/DomQuery.js +++ b/frontend/gamma/js/Clipperz/YUI/DomQuery.js @@ -1,534 +1,532 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.YUI) == 'undefined') { Clipperz.YUI = {}; } /* * yui-ext 0.40 * Copyright(c) 2006, Jack Slocum. */ /** * @class Clipperz.YUI.DomQuery * Provides high performance selector/xpath processing by compiling queries into reusable functions. * New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in). * @singleton */ Clipperz.YUI.DomQuery = function(){ var cache = {}, simpleCache = {}, valueCache = {}; var nonSpace = /\S/; var trimRe = /^\s*(.*?)\s*$/; var tplRe = /\{(\d+)\}/g; var modeRe = /^(\s?[\/>]\s?|\s|$)/; var clsRes = {}; function child(p, index){ var i = 0; var n = p.firstChild; while(n){ if(n.nodeType == 1){ i++; if(i == index){ return n; } } n = n.nextSibling; } return null; }; function next(d){ var n = d.nextSibling; while(n && n.nodeType != 1){ n = n.nextSibling; } return n; }; function prev(d){ var n = d.previousSibling; while(n && n.nodeType != 1){ n = n.previousSibling; } return n; }; function clean(d){ var n = d.firstChild, ni = -1; while(n){ var nx = n.nextSibling; if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){ d.removeChild(n); }else{ n.nodeIndex = ++ni; } n = nx; } return this; }; function byClassName(c, a, v){ if(!v){ return c; } var re = clsRes[v]; if(!re){ re = new RegExp('(?:^|\\s)(?:' + v + ')(?:\\s|$)'); clsRes[v] = re; } var r = []; for(var i = 0, ci; ci = c[i]; i++){ if(re.test(ci.className)){ r[r.length] = ci; } } return r; }; function convert(c){ if(c.slice){ return c; } var r = []; for(var i = 0, l = c.length; i < l; i++){ r[r.length] = c[i]; } return r; }; function attrValue(n, attr){ if(!n.tagName && typeof n.length != 'undefined'){ n = n[0]; } if(!n){ return null; } if(attr == 'for'){ return n.htmlFor; } if(attr == 'class' || attr == 'className'){ return n.className; } return n.getAttribute(attr) || n[attr]; }; function getNodes(ns, mode, tagName){ var result = [], cs; if(!ns){ return result; } mode = mode ? mode.replace(trimRe, '$1') : ''; tagName = tagName || '*'; if(ns.tagName || ns == document){ ns = [ns]; } if(mode != '/' && mode != '>'){ for(var i = 0, ni; ni = ns[i]; i++){ cs = ni.getElementsByTagName(tagName); result = concat(result, cs); } }else{ for(var i = 0, ni; ni = ns[i]; i++){ var cn = ni.getElementsByTagName(tagName); for(var j = 0, cj; cj = cn[j]; j++){ if(cj.parentNode == ni){ result[result.length] = cj; } } } } return result; }; function concat(a, b){ if(b.slice){ return a.concat(b); } for(var i = 0, l = b.length; i < l; i++){ a[a.length] = b[i]; } return a; } function byTag(cs, tagName){ if(cs.tagName || cs == document){ cs = [cs]; } if(!tagName){ return cs; } var r = []; tagName = tagName.toLowerCase(); for(var i = 0, ci; ci = cs[i]; i++){ if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){ r[r.length] = ci; } } return r; }; function byId(cs, attr, id){ if(cs.tagName || cs == document){ cs = [cs]; } if(!id){ return cs; } var r = []; for(var i = 0, l = cs.length; i < l; i++){ var ci = cs[i]; if(ci && ci.id == id){ r[r.length] = ci; } } return r; }; function byAttribute(cs, attr, value, op, custom){ var r = [], st = custom=='{'; var f = Clipperz.YUI.DomQuery.operators[op]; for(var i = 0, l = cs.length; i < l; i++){ var a; if(st){ a = Clipperz.YUI.DomQuery.getStyle(cs[i], attr); } else if(attr == 'class' || attr == 'className'){ a = cs[i].className; }else if(attr == 'for'){ a = cs[i].htmlFor; }else{ a = cs[i].getAttribute(attr); } if((f && f(a, value)) || (!f && a)){ r[r.length] = cs[i]; } } return r; }; function byPseudo(cs, name, value){ return Clipperz.YUI.DomQuery.pseudos[name](cs, value); }; // This is for IE MSXML which does not support expandos. // IE runs the same speed using setAttribute, however FF slows way down // and Safari completely fails so they need to continue to use expandos. // Branched at load time for faster execution. var isIE = window.ActiveXObject; var addAttr = isIE ? function(n, a, v){ n.setAttribute(a, v); } : function(n, a, v){ n[a] = v; }; var getAttr = isIE ? function(n, a){ return n.getAttribute(a); } : function(n, a){ return n[a]; }; var clearAttr = isIE ? function(n, a){ n.removeAttribute(a); } : function(n, a, v){ delete n[a]; }; function nodup(cs){ if(!cs.length){ return cs; } addAttr(cs[0], '_nodup', true); var r = [cs[0]]; for(var i = 1, len = cs.length; i < len; i++){ var c = cs[i]; if(!getAttr(c, '_nodup')){ addAttr(c, '_nodup', true); r[r.length] = c; } } for(var i = 0, len = cs.length; i < len; i++){ clearAttr(cs[i], '_nodup'); } return r; } function quickDiff(c1, c2){ if(!c1.length){ return c2; } for(var i = 0, len = c1.length; i < len; i++){ addAttr(c1[i], '_qdiff', true); } var r = []; for(var i = 0, len = c2.length; i < len; i++){ if(!getAttr(c2[i], '_qdiff')){ r[r.length] = c2[i]; } } for(var i = 0, len = c1.length; i < len; i++){ clearAttr(c1[i], '_qdiff'); } return r; } function quickId(ns, mode, root, id){ if(ns == root){ var d = root.ownerDocument || root; return d.getElementById(id); } ns = getNodes(ns, mode, '*'); return byId(ns, null, id); } return { getStyle : function(el, name){ return YAHOO.util.Dom.getStyle(el, name); }, /** * Compiles a selector/xpath query into a reusable function. The returned function * takes one parameter "root" (optional), which is the context node from where the query should start. * @param {String} selector The selector/xpath query * @param {String} type (optional) Either 'select' (the default) or 'simple' for a simple selector match * @return {Function} */ compile : function(path, type){ // strip leading slashes while(path.substr(0, 1)=='/'){ path = path.substr(1); } type = type || 'select'; var fn = ['var f = function(root){\n var mode; var n = root || document;\n']; var q = path, mode, lq; var tk = Clipperz.YUI.DomQuery.matchers; var tklen = tk.length; var mm; while(q && lq != q){ lq = q; var tm = q.match(/^(#)?([\w-\*]+)/); if(type == 'select'){ if(tm){ if(tm[1] == '#'){ fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");'; }else{ fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");'; } q = q.replace(tm[0], ''); }else{ fn[fn.length] = 'n = getNodes(n, mode, "*");'; } }else{ if(tm){ if(tm[1] == '#'){ fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");'; }else{ fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");'; } q = q.replace(tm[0], ''); } } while(!(mm = q.match(modeRe))){ var matched = false; for(var j = 0; j < tklen; j++){ var t = tk[j]; var m = q.match(t.re); if(m){ fn[fn.length] = t.select.replace(tplRe, function(x, i){ return m[i]; }); q = q.replace(m[0], ''); matched = true; break; } } // prevent infinite loop on bad selector if(!matched){ throw 'Error parsing selector, parsing failed at "' + q + '"'; } } if(mm[1]){ fn[fn.length] = 'mode="'+mm[1]+'";'; q = q.replace(mm[1], ''); } } fn[fn.length] = 'return nodup(n);\n}'; eval(fn.join('')); return f; }, /** * Selects a group of elements. * @param {String} selector The selector/xpath query * @param {Node} root (optional) The start of the query (defaults to document). * @return {Array} */ select : function(path, root, type){ if(!root || root == document){ root = document; } if(typeof root == 'string'){ root = document.getElementById(root); } var paths = path.split(','); var results = []; for(var i = 0, len = paths.length; i < len; i++){ var p = paths[i].replace(trimRe, '$1'); if(!cache[p]){ cache[p] = Clipperz.YUI.DomQuery.compile(p); if(!cache[p]){ throw p + ' is not a valid selector'; } } var result = cache[p](root); if(result && result != document){ results = results.concat(result); } } return results; }, /** * Selects a single element. * @param {String} selector The selector/xpath query * @param {Node} root (optional) The start of the query (defaults to document). * @return {Element} */ selectNode : function(path, root){ return Clipperz.YUI.DomQuery.select(path, root)[0]; }, /** * Selects the value of a node, optionally replacing null with the defaultValue. * @param {String} selector The selector/xpath query * @param {Node} root (optional) The start of the query (defaults to document). * @param {String} defaultValue */ selectValue : function(path, root, defaultValue){ path = path.replace(trimRe, '$1'); if(!valueCache[path]){ valueCache[path] = Clipperz.YUI.DomQuery.compile(path, 'simple'); } var n = valueCache[path](root); n = n[0] ? n[0] : n; var v = (n && n.firstChild ? n.firstChild.nodeValue : null); return (v === null ? defaultValue : v); }, /** * Selects the value of a node, parsing integers and floats. * @param {String} selector The selector/xpath query * @param {Node} root (optional) The start of the query (defaults to document). * @param {Number} defaultValue * @return {Number} */ selectNumber : function(path, root, defaultValue){ var v = Clipperz.YUI.DomQuery.selectValue(path, root, defaultValue || 0); return parseFloat(v); }, /** * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child) * @param {String/HTMLElement/Array} el An element id, element or array of elements * @param {String} selector The simple selector to test * @return {Boolean} */ is : function(el, ss){ if(typeof el == 'string'){ el = document.getElementById(el); } var isArray = (el instanceof Array); var result = Clipperz.YUI.DomQuery.filter(isArray ? el : [el], ss); return isArray ? (result.length == el.length) : (result.length > 0); }, /** * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child) * @param {Array} el An array of elements to filter * @param {String} selector The simple selector to test * @param {Boolean} nonMatches If true, it returns the elements that DON'T match * the selector instead of the ones that match * @return {Array} */ filter : function(els, ss, nonMatches){ ss = ss.replace(trimRe, '$1'); if(!simpleCache[ss]){ simpleCache[ss] = Clipperz.YUI.DomQuery.compile(ss, 'simple'); } var result = simpleCache[ss](els); return nonMatches ? quickDiff(result, els) : result; }, /** * Collection of matching regular expressions and code snippets. */ matchers : [{ re: /^\.([\w-]+)/, select: 'n = byClassName(n, null, "{1}");' }, { re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/, select: 'n = byPseudo(n, "{1}", "{2}");' },{ re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/, select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");' }, { re: /^#([\w-]+)/, select: 'n = byId(n, null, "{1}");' },{ re: /^@([\w-]+)/, select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};' } ], /** * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *= and %=. * New operators can be added as long as the match the format <i>c</i>= where <i>c<i> is any character other than space, > <. */ operators : { '=' : function(a, v){ return a == v; }, '!=' : function(a, v){ return a != v; }, '^=' : function(a, v){ return a && a.substr(0, v.length) == v; }, '$=' : function(a, v){ return a && a.substr(a.length-v.length) == v; }, '*=' : function(a, v){ return a && a.indexOf(v) !== -1; }, '%=' : function(a, v){ return (a % v) == 0; } }, diff --git a/frontend/gamma/js/Clipperz/YUI/Utils.js b/frontend/gamma/js/Clipperz/YUI/Utils.js index e9929fc..4def842 100644 --- a/frontend/gamma/js/Clipperz/YUI/Utils.js +++ b/frontend/gamma/js/Clipperz/YUI/Utils.js @@ -1,95 +1,93 @@ /* -Copyright 2008-2011 Clipperz Srl +Copyright 2008-2013 Clipperz Srl -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. +This file is part of Clipperz, the 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 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. +* Clipperz 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 - <http://www.gnu.org/licenses/>. + License along with Clipperz. If not, see http://www.gnu.org/licenses/. */ if (typeof YAHOO == 'undefined') { YAHOO = {}; }; if (typeof YAHOO.util == 'undefined') { YAHOO.util = {}; }; if (typeof YAHOO.util.Dom == 'undefined') { YAHOO.util.Dom = {}; }; YAHOO.extend = function(subc, superc, overrides) { var F = function() {}; F.prototype=superc.prototype; subc.prototype=new F(); subc.prototype.constructor=subc; subc.superclass=superc.prototype; if (superc.prototype.constructor == Object.prototype.constructor) { superc.prototype.constructor=superc; } if (overrides) { for (var i in overrides) { subc.prototype[i]=overrides[i]; } } }; YAHOO.override = function(origclass, overrides){ if(overrides){ var p = origclass.prototype; for(var method in overrides){ p[method] = overrides[method]; } } }; YAHOO.extendX = function(subclass, superclass, overrides){ YAHOO.extend(subclass, superclass); subclass.override = function(o){ YAHOO.override(subclass, o); }; if(!subclass.prototype.override){ subclass.prototype.override = function(o){ for(var method in o){ this[method] = o[method]; } }; } if(overrides){ subclass.override(overrides); }; }; YAHOO.util.Dom.get = function(el) { if (!el) { return null; } // nothing to work with if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is return el; } if (typeof el == 'string') { // ID return document.getElementById(el); } else { // array of ID's and/or elements var collection = []; for (var i = 0, len = el.length; i < len; ++i) { collection[collection.length] = YAHOO.util.Dom.get(el[i]); } return collection; } return null; // safety, should never happen }; |