Diffstat (limited to 'frontend/gamma/js/Clipperz/KeyValueObjectStore.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/KeyValueObjectStore.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/KeyValueObjectStore.js b/frontend/gamma/js/Clipperz/KeyValueObjectStore.js index 04beb85..36cda88 100644 --- a/frontend/gamma/js/Clipperz/KeyValueObjectStore.js +++ b/frontend/gamma/js/Clipperz/KeyValueObjectStore.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 | 27 | ||
31 | //############################################################################# | 28 | //############################################################################# |
32 | 29 | ||
33 | Clipperz.KeyValueObjectStore = function(args) { | 30 | Clipperz.KeyValueObjectStore = function(args) { |
34 | args = args || {}; | 31 | args = args || {}; |
35 | 32 | ||
36 | //this._name = args['name'] || "unnamed KeyValueObjectStore"; | 33 | //this._name = args['name'] || "unnamed KeyValueObjectStore"; |
37 | this._values = args['values'] || {}; | 34 | this._values = args['values'] || {}; |
38 | //this._referenceObjectStore = null; | 35 | //this._referenceObjectStore = null; |
39 | //console.log("new KeyValueObjectStore", args, this._values); | 36 | //console.log("new KeyValueObjectStore", args, this._values); |
40 | 37 | ||
41 | return this; | 38 | return this; |
42 | } | 39 | } |
43 | 40 | ||
44 | Clipperz.KeyValueObjectStore.prototype = MochiKit.Base.update(null, { | 41 | Clipperz.KeyValueObjectStore.prototype = MochiKit.Base.update(null, { |
45 | 42 | ||
46 | 'values': function() { | 43 | 'values': function() { |
47 | return this._values; | 44 | return this._values; |
48 | }, | 45 | }, |
49 | 46 | ||
50 | 'initWithValues': function (someValues) { | 47 | 'initWithValues': function (someValues) { |
51 | this._values = Clipperz.Base.deepClone(someValues) || {}; | 48 | this._values = Clipperz.Base.deepClone(someValues) || {}; |
52 | return this; | 49 | return this; |
53 | }, | 50 | }, |
54 | 51 | ||
55 | 'setValues': function (someValues) { | 52 | 'setValues': function (someValues) { |
56 | //console.log("KeyValueObjectStore.setValues", someValues); | 53 | //console.log("KeyValueObjectStore.setValues", someValues); |
57 | this._values = someValues; | 54 | this._values = someValues; |
58 | return this; | 55 | return this; |
59 | }, | 56 | }, |
60 | 57 | ||
61 | //'initWithObjectStore': function (anObjectStore) { | 58 | //'initWithObjectStore': function (anObjectStore) { |
62 | // this._referenceObjectStore = anObjectStore; | 59 | // this._referenceObjectStore = anObjectStore; |
63 | //}, | 60 | //}, |
64 | 61 | ||
65 | 'removeAllData': function () { | 62 | 'removeAllData': function () { |
66 | this._values = {}; | 63 | this._values = {}; |
67 | }, | 64 | }, |
68 | 65 | ||
69 | //------------------------------------------------------------------------- | 66 | //------------------------------------------------------------------------- |
70 | 67 | ||
71 | 'getValue': function(aKeyPath) { | 68 | 'getValue': function(aKeyPath) { |
72 | var result; | 69 | var result; |
73 | var keys; | 70 | var keys; |
74 | var i,c; | 71 | var i,c; |
75 | 72 | ||
76 | result = this.values(); | 73 | result = this.values(); |
77 | 74 | ||
78 | keys = (aKeyPath + '').split('.'); | 75 | keys = (aKeyPath + '').split('.'); |
79 | c = keys.length; | 76 | c = keys.length; |
80 | i = 0; | 77 | i = 0; |
81 | 78 | ||
82 | while ((i<c) && (result != null)) { | 79 | while ((i<c) && (result != null)) { |
83 | if (typeof result[keys[i]] != 'undefined') { | 80 | if (typeof result[keys[i]] != 'undefined') { |
84 | result = result[keys[i]]; | 81 | result = result[keys[i]]; |
85 | } else { | 82 | } else { |
86 | result = null; | 83 | result = null; |
87 | } | 84 | } |
88 | 85 | ||
89 | i++; | 86 | i++; |
90 | } | 87 | } |
91 | 88 | ||
92 | return result; | 89 | return result; |
93 | }, | 90 | }, |
94 | 91 | ||
95 | //------------------------------------------------------------------------- | 92 | //------------------------------------------------------------------------- |
96 | 93 | ||
97 | 'setValue': function(aKeyPath, aValue) { | 94 | 'setValue': function(aKeyPath, aValue) { |
98 | var targetObject; | 95 | var targetObject; |
99 | var keys; | 96 | var keys; |
100 | var i,c; | 97 | var i,c; |
101 | 98 | ||
102 | //console.log(">>> KeyValueObjectStore.setValue", this, this.values(), aKeyPath, aValue); | 99 | //console.log(">>> KeyValueObjectStore.setValue", this, this.values(), aKeyPath, aValue); |
103 | targetObject = this.values(); | 100 | targetObject = this.values(); |
104 | keys = (aKeyPath + '').split('.'); | 101 | keys = (aKeyPath + '').split('.'); |
105 | c = keys.length - 1; | 102 | c = keys.length - 1; |
106 | for (i=0; i<c; i++) { | 103 | for (i=0; i<c; i++) { |
107 | //console.log("--- KeyValueObjectStore.setValue", i, targetObject, keys[i]); | 104 | //console.log("--- KeyValueObjectStore.setValue", i, targetObject, keys[i]); |
108 | if (typeof targetObject[keys[i]] == 'undefined') { | 105 | if (typeof targetObject[keys[i]] == 'undefined') { |
109 | targetObject[keys[i]] = {} | 106 | targetObject[keys[i]] = {} |
110 | } | 107 | } |
111 | 108 | ||
112 | targetObject = targetObject[keys[i]]; | 109 | targetObject = targetObject[keys[i]]; |
113 | } | 110 | } |
114 | 111 | ||
115 | targetObject[keys[c]] = aValue; | 112 | targetObject[keys[c]] = aValue; |
116 | //console.log("<<< KeyValueObjectStore.setValue"); | 113 | //console.log("<<< KeyValueObjectStore.setValue"); |
117 | 114 | ||
118 | return aValue; | 115 | return aValue; |
119 | }, | 116 | }, |
120 | 117 | ||