Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/Record.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/Record.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js index 85dd06b..b816f80 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/Record.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
31 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
32 | 29 | ||
33 | 30 | ||
34 | Clipperz.PM.DataModel.Record = function(args) { | 31 | Clipperz.PM.DataModel.Record = function(args) { |
35 | //console.log(">>> new Clipperz.PM.DataModel.Record", args); | 32 | //console.log(">>> new Clipperz.PM.DataModel.Record", args); |
36 | Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); | 33 | Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); |
37 | 34 | ||
38 | this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); | 35 | this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); |
39 | 36 | ||
40 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); | 37 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction|| Clipperz.Base.exception.raise('MandatoryParameter'); |
41 | this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); | 38 | this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); |
42 | 39 | ||
43 | this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction|| null; | 40 | this._retrieveDirectLoginIndexDataFunction = args.retrieveDirectLoginIndexDataFunction|| null; |
44 | this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; | 41 | this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null; |
45 | this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction|| null; | 42 | this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction|| null; |
46 | 43 | ||
47 | this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; | 44 | this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null; |
48 | 45 | ||
49 | this._directLogins = {}; | 46 | this._directLogins = {}; |
50 | 47 | ||
51 | this._versions = {}; | 48 | this._versions = {}; |
52 | 49 | ||
53 | this._currentRecordVersion = null; | 50 | this._currentRecordVersion = null; |
54 | if (this.isBrandNew()) { | 51 | if (this.isBrandNew()) { |
55 | var newVersion; | 52 | var newVersion; |
56 | 53 | ||
57 | this.setNotes(''); | 54 | this.setNotes(''); |
58 | newVersion = new Clipperz.PM.DataModel.Record.Version({ | 55 | newVersion = new Clipperz.PM.DataModel.Record.Version({ |
59 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), | 56 | 'retrieveKeyFunction':MochiKit.Base.method(this, 'getVersionKey'), |
60 | 'getVersion': MochiKit.Base.method(this, 'getVersion') | 57 | 'getVersion': MochiKit.Base.method(this, 'getVersion') |
61 | 58 | ||
62 | }); | 59 | }); |
63 | this._versions[newVersion.reference()] = newVersion; | 60 | this._versions[newVersion.reference()] = newVersion; |
64 | this._currentVersionReference = newVersion.reference(); | 61 | this._currentVersionReference = newVersion.reference(); |
65 | // this.setLabel(''); | 62 | // this.setLabel(''); |
66 | } | 63 | } |
67 | 64 | ||
68 | //console.log("<<< new Clipperz.PM.DataModel.Record", args); | 65 | //console.log("<<< new Clipperz.PM.DataModel.Record", args); |
69 | 66 | ||
70 | return this; | 67 | return this; |
71 | } | 68 | } |
72 | 69 | ||
73 | 70 | ||
74 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { | 71 | Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.EncryptedRemoteObject, { |
75 | 72 | ||
76 | 'toString': function() { | 73 | 'toString': function() { |
77 | return "Record (" + this.reference() + ")"; | 74 | return "Record (" + this.reference() + ")"; |
78 | }, | 75 | }, |
79 | 76 | ||
80 | //------------------------------------------------------------------------- | 77 | //------------------------------------------------------------------------- |
81 | 78 | ||
82 | 'reference': function () { | 79 | 'reference': function () { |
83 | return this._reference; | 80 | return this._reference; |
84 | }, | 81 | }, |
85 | 82 | ||
86 | //========================================================================= | 83 | //========================================================================= |
87 | 84 | ||
88 | 'getIndexData': function () { | 85 | 'getIndexData': function () { |
89 | return this._retrieveIndexDataFunction(this.reference()); | 86 | return this._retrieveIndexDataFunction(this.reference()); |
90 | }, | 87 | }, |
91 | 88 | ||
92 | //......................................................................... | 89 | //......................................................................... |
93 | 90 | ||
94 | 'getIndexDataForKey': function (aKey) { | 91 | 'getIndexDataForKey': function (aKey) { |
95 | return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ | 92 | return Clipperz.Async.callbacks("Record.getIndexDataForKey", [ |
96 | MochiKit.Base.method(this, 'getIndexData'), | 93 | MochiKit.Base.method(this, 'getIndexData'), |
97 | MochiKit.Base.itemgetter(aKey) | 94 | MochiKit.Base.itemgetter(aKey) |
98 | ], {trace:false}); | 95 | ], {trace:false}); |
99 | }, | 96 | }, |
100 | 97 | ||
101 | //------------------------------------------------------------------------- | 98 | //------------------------------------------------------------------------- |
102 | 99 | ||
103 | 'setIndexDataForKey': function (aKey, aValue) { | 100 | 'setIndexDataForKey': function (aKey, aValue) { |
104 | // return this._updateIndexDataFunction(this.reference(), aKey, aValue); | 101 | // return this._updateIndexDataFunction(this.reference(), aKey, aValue); |
105 | 102 | ||
106 | var deferredResult; | 103 | var deferredResult; |
107 | 104 | ||
108 | deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); | 105 | deferredResult = new Clipperz.Async.Deferred("Record.setIndexDataForKey", {trace:false}); |
109 | deferredResult.addMethod(this, 'getIndexDataForKey', aKey); | 106 | deferredResult.addMethod(this, 'getIndexDataForKey', aKey); |
110 | deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { | 107 | deferredResult.addCallback(MochiKit.Base.bind(function (aCurrentValue) { |
111 | var result; | 108 | var result; |
112 | var originalValue; | 109 | var originalValue; |
113 | 110 | ||
114 | originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); | 111 | originalValue = this.transientState().getValue('originalValues.indexData.' + aKey); |
115 | if (originalValue == null) { | 112 | if (originalValue == null) { |
116 | originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); | 113 | originalValue = this.transientState().setValue('originalValues.indexData.' + aKey, aCurrentValue); |
117 | } | 114 | } |
118 | 115 | ||
119 | if (aCurrentValue != aValue) { | 116 | if (aCurrentValue != aValue) { |
120 | if (originalValue != aValue) { | 117 | if (originalValue != aValue) { |