summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js
index d2b3e12..fc4a45c 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/RecordVersion.js
@@ -1,216 +1,213 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer 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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } 28if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
32 29
33 30
34//############################################################################# 31//#############################################################################
35 32
36Clipperz.PM.DataModel.RecordVersion = function(aRecord, args) { 33Clipperz.PM.DataModel.RecordVersion = function(aRecord, args) {
37 args = args || {}; 34 args = args || {};
38 35
39 this._record = aRecord; 36 this._record = aRecord;
40 37
41 this._reference = args.reference || Clipperz.PM.Crypto.randomKey(); 38 this._reference = args.reference || Clipperz.PM.Crypto.randomKey();
42 this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion; 39 this._version = args.version || Clipperz.PM.Crypto.encryptingFunctions.currentVersion;
43 this._key = args.key || Clipperz.PM.Crypto.randomKey();; 40 this._key = args.key || Clipperz.PM.Crypto.randomKey();;
44 41
45 this._previousVersion = args.previousVersion || null; 42 this._previousVersion = args.previousVersion || null;
46 this._previousVersionKey = args.previousVersionKey || null; 43 this._previousVersionKey = args.previousVersionKey || null;
47 44
48 this.setIsBrandNew(args.reference == null); 45 this.setIsBrandNew(args.reference == null);
49 46
50 if (this.isBrandNew()) { 47 if (this.isBrandNew()) {
51 this._fields = {}; 48 this._fields = {};
52 49
53 this.setShouldLoadData(false); 50 this.setShouldLoadData(false);
54 this.setShouldDecryptData(false); 51 this.setShouldDecryptData(false);
55 this.setShouldProcessData(false); 52 this.setShouldProcessData(false);
56 } else { 53 } else {
57 if (typeof(args.fields) != 'undefined') { 54 if (typeof(args.fields) != 'undefined') {
58 this.processFieldData(args.fields); 55 this.processFieldData(args.fields);
59 56
60 this.setShouldLoadData(false); 57 this.setShouldLoadData(false);
61 this.setShouldDecryptData(false); 58 this.setShouldDecryptData(false);
62 this.setShouldProcessData(false); 59 this.setShouldProcessData(false);
63 } else { 60 } else {
64 if (typeof(args.data) != 'undefined') { 61 if (typeof(args.data) != 'undefined') {
65 this.setShouldLoadData(false); 62 this.setShouldLoadData(false);
66 } else { 63 } else {
67 this.setShouldLoadData(true); 64 this.setShouldLoadData(true);
68 } 65 }
69 this.setShouldDecryptData(true); 66 this.setShouldDecryptData(true);
70 this.setShouldProcessData(true); 67 this.setShouldProcessData(true);
71 } 68 }
72 } 69 }
73 70
74 this._serverData = args.data; 71 this._serverData = args.data;
75 this._decryptedData = null; 72 this._decryptedData = null;
76 73
77 return this; 74 return this;
78} 75}
79 76
80Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, { 77Clipperz.PM.DataModel.RecordVersion.prototype = MochiKit.Base.update(null, {
81 78
82 'toString': function() { 79 'toString': function() {
83 return "RecordVersion"; 80 return "RecordVersion";
84 }, 81 },
85 82
86 //------------------------------------------------------------------------- 83 //-------------------------------------------------------------------------
87 84
88 'record': function() { 85 'record': function() {
89 return this._record; 86 return this._record;
90 }, 87 },
91 88
92 //------------------------------------------------------------------------- 89 //-------------------------------------------------------------------------
93 90
94 'reference': function() { 91 'reference': function() {
95 return this._reference; 92 return this._reference;
96 }, 93 },
97 94
98 'setReference': function(aValue) { 95 'setReference': function(aValue) {
99 this._reference = aValue; 96 this._reference = aValue;
100 }, 97 },
101 98
102 //------------------------------------------------------------------------- 99 //-------------------------------------------------------------------------
103 100
104 'key': function() { 101 'key': function() {
105//MochiKit.Logging.logDebug(">>> RecordVersion.key"); 102//MochiKit.Logging.logDebug(">>> RecordVersion.key");
106//MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key); 103//MochiKit.Logging.logDebug("--- RecordVersion.key - " + this._key);
107 return this._key; 104 return this._key;
108 }, 105 },
109 106
110 'setKey': function(aValue) { 107 'setKey': function(aValue) {
111 this._key = aValue; 108 this._key = aValue;
112 }, 109 },
113 110
114 //------------------------------------------------------------------------- 111 //-------------------------------------------------------------------------
115 112
116 'serverData': function() { 113 'serverData': function() {
117 return this._serverData; 114 return this._serverData;
118 }, 115 },
119 116
120 'setServerData': function(aValue) { 117 'setServerData': function(aValue) {
121 this._serverData = aValue; 118 this._serverData = aValue;
122 this.setShouldLoadData(false); 119 this.setShouldLoadData(false);
123 return aValue; 120 return aValue;
124 }, 121 },
125 122
126 //------------------------------------------------------------------------- 123 //-------------------------------------------------------------------------
127 124
128 'decryptedData': function() { 125 'decryptedData': function() {
129//MochiKit.Logging.logDebug(">>> RecordVersion.decryptedData: " + (this._decryptedData ? Clipperz.Base.serializeJSON(aValue) : "null")); 126//MochiKit.Logging.logDebug(">>> RecordVersion.decryptedData: " + (this._decryptedData ? Clipperz.Base.serializeJSON(aValue) : "null"));
130 return this._decryptedData; 127 return this._decryptedData;
131 }, 128 },
132 129
133 'setDecryptedData': function(aValue) { 130 'setDecryptedData': function(aValue) {
134//MochiKit.Logging.logDebug(">>> RecordVersion.setDecryptedData: " + Clipperz.Base.serializeJSON(aValue)); 131//MochiKit.Logging.logDebug(">>> RecordVersion.setDecryptedData: " + Clipperz.Base.serializeJSON(aValue));
135 this._decryptedData = aValue; 132 this._decryptedData = aValue;
136 this.setShouldDecryptData(false); 133 this.setShouldDecryptData(false);
137 return aValue; 134 return aValue;
138 }, 135 },
139 136
140 //------------------------------------------------------------------------- 137 //-------------------------------------------------------------------------
141 138
142 'version': function() { 139 'version': function() {
143 return this._version; 140 return this._version;
144 }, 141 },
145 142
146 //------------------------------------------------------------------------- 143 //-------------------------------------------------------------------------
147 144
148 'isBrandNew': function() { 145 'isBrandNew': function() {
149 return this._isBrandNew; 146 return this._isBrandNew;
150 }, 147 },
151 148
152 'setIsBrandNew': function(aValue) { 149 'setIsBrandNew': function(aValue) {
153 this._isBrandNew = aValue; 150 this._isBrandNew = aValue;
154 }, 151 },
155 152
156 //------------------------------------------------------------------------- 153 //-------------------------------------------------------------------------
157 154
158 'fields': function() { 155 'fields': function() {
159 return this._fields; 156 return this._fields;
160 }, 157 },
161 158
162 'addField': function(aField) { 159 'addField': function(aField) {
163 this.fields()[aField.key()] = aField; 160 this.fields()[aField.key()] = aField;
164 }, 161 },
165 162
166 'addNewField': function() { 163 'addNewField': function() {
167 varnewRecordField; 164 varnewRecordField;
168 165
169 newRecordField = new Clipperz.PM.DataModel.RecordField({recordVersion:this}); 166 newRecordField = new Clipperz.PM.DataModel.RecordField({recordVersion:this});
170 this.addField(newRecordField); 167 this.addField(newRecordField);
171 168
172 return newRecordField; 169 return newRecordField;
173 }, 170 },
174 171
175 'fieldWithName': function(aValue) { 172 'fieldWithName': function(aValue) {
176 varresult; 173 varresult;
177 var fieldValues; 174 var fieldValues;
178 var i,c; 175 var i,c;
179 176
180 result = null; 177 result = null;
181 fieldValues = MochiKit.Base.values(this.fields()); 178 fieldValues = MochiKit.Base.values(this.fields());
182 c = fieldValues.length; 179 c = fieldValues.length;
183 for (i=0; (i<c) && (result == null); i++) { 180 for (i=0; (i<c) && (result == null); i++) {
184 varcurrentField; 181 varcurrentField;
185 182
186 currentField = fieldValues[i]; 183 currentField = fieldValues[i];
187 if (currentField.label() == aValue) { 184 if (currentField.label() == aValue) {
188 result = currentField; 185 result = currentField;
189 } 186 }
190 } 187 }
191 188
192 return result; 189 return result;
193 }, 190 },
194 191
195 //------------------------------------------------------------------------- 192 //-------------------------------------------------------------------------
196 193
197 'shouldLoadData': function() { 194 'shouldLoadData': function() {
198 return this._shouldLoadData; 195 return this._shouldLoadData;
199 }, 196 },
200 197
201 'setShouldLoadData': function(aValue) { 198 'setShouldLoadData': function(aValue) {
202 this._shouldLoadData = aValue; 199 this._shouldLoadData = aValue;
203 }, 200 },
204 201
205 //------------------------------------------------------------------------- 202 //-------------------------------------------------------------------------
206 203
207 'shouldDecryptData': function() { 204 'shouldDecryptData': function() {
208 return this._shouldDecryptData; 205 return this._shouldDecryptData;
209 }, 206 },
210 207
211 'setShouldDecryptData': function(aValue) { 208 'setShouldDecryptData': function(aValue) {
212 this._shouldDecryptData = aValue; 209 this._shouldDecryptData = aValue;
213 }, 210 },
214 211
215 //------------------------------------------------------------------------- 212 //-------------------------------------------------------------------------
216 213