author | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
commit | 07d0357beef5d9328a2dd8d07ad7b39c87ac55e4 (patch) (unidiff) | |
tree | f7a4aed8848302db153c2a211f8e58b944eb4c5b /frontend/gamma/js/Clipperz/KeyValueObjectStore.js | |
parent | 767a3dcf48b6ac911c088af5dd7738a728eb6b99 (diff) | |
download | clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.zip clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.gz clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.bz2 |
Updated Copyright claims
- updated reference dates;
- removed reference to Community Edition;
- normalized logging using Clipperz.log[Warn|Error|Debug]
Diffstat (limited to 'frontend/gamma/js/Clipperz/KeyValueObjectStore.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/KeyValueObjectStore.js | 27 |
1 files changed, 10 insertions, 17 deletions
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,161 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | 25 | ||
28 | //############################################################################# | 26 | //############################################################################# |
29 | 27 | ||
30 | Clipperz.KeyValueObjectStore = function(args) { | 28 | Clipperz.KeyValueObjectStore = function(args) { |
31 | args = args || {}; | 29 | args = args || {}; |
32 | 30 | ||
33 | //this._name = args['name'] || "unnamed KeyValueObjectStore"; | 31 | //this._name = args['name'] || "unnamed KeyValueObjectStore"; |
34 | this._values = args['values'] || {}; | 32 | this._values = args['values'] || {}; |
35 | //this._referenceObjectStore = null; | 33 | //this._referenceObjectStore = null; |
36 | //console.log("new KeyValueObjectStore", args, this._values); | ||
37 | 34 | ||
38 | return this; | 35 | return this; |
39 | } | 36 | } |
40 | 37 | ||
41 | Clipperz.KeyValueObjectStore.prototype = MochiKit.Base.update(null, { | 38 | Clipperz.KeyValueObjectStore.prototype = MochiKit.Base.update(null, { |
42 | 39 | ||
43 | 'values': function() { | 40 | 'values': function() { |
44 | return this._values; | 41 | return this._values; |
45 | }, | 42 | }, |
46 | 43 | ||
47 | 'initWithValues': function (someValues) { | 44 | 'initWithValues': function (someValues) { |
48 | this._values = Clipperz.Base.deepClone(someValues) || {}; | 45 | this._values = Clipperz.Base.deepClone(someValues) || {}; |
49 | return this; | 46 | return this; |
50 | }, | 47 | }, |
51 | 48 | ||
52 | 'setValues': function (someValues) { | 49 | 'setValues': function (someValues) { |
53 | //console.log("KeyValueObjectStore.setValues", someValues); | ||
54 | this._values = someValues; | 50 | this._values = someValues; |
55 | return this; | 51 | return this; |
56 | }, | 52 | }, |
57 | 53 | ||
58 | //'initWithObjectStore': function (anObjectStore) { | 54 | //'initWithObjectStore': function (anObjectStore) { |
59 | // this._referenceObjectStore = anObjectStore; | 55 | // this._referenceObjectStore = anObjectStore; |
60 | //}, | 56 | //}, |
61 | 57 | ||
62 | 'removeAllData': function () { | 58 | 'removeAllData': function () { |
63 | this._values = {}; | 59 | this._values = {}; |
64 | }, | 60 | }, |
65 | 61 | ||
66 | //------------------------------------------------------------------------- | 62 | //------------------------------------------------------------------------- |
67 | 63 | ||
68 | 'getValue': function(aKeyPath) { | 64 | 'getValue': function(aKeyPath) { |
69 | var result; | 65 | var result; |
70 | var keys; | 66 | var keys; |
71 | var i,c; | 67 | var i,c; |
72 | 68 | ||
73 | result = this.values(); | 69 | result = this.values(); |
74 | 70 | ||
75 | keys = (aKeyPath + '').split('.'); | 71 | keys = (aKeyPath + '').split('.'); |
76 | c = keys.length; | 72 | c = keys.length; |
77 | i = 0; | 73 | i = 0; |
78 | 74 | ||
79 | while ((i<c) && (result != null)) { | 75 | while ((i<c) && (result != null)) { |
80 | if (typeof result[keys[i]] != 'undefined') { | 76 | if (typeof result[keys[i]] != 'undefined') { |
81 | result = result[keys[i]]; | 77 | result = result[keys[i]]; |
82 | } else { | 78 | } else { |
83 | result = null; | 79 | result = null; |
84 | } | 80 | } |
85 | 81 | ||
86 | i++; | 82 | i++; |
87 | } | 83 | } |
88 | 84 | ||
89 | return result; | 85 | return result; |
90 | }, | 86 | }, |
91 | 87 | ||
92 | //------------------------------------------------------------------------- | 88 | //------------------------------------------------------------------------- |
93 | 89 | ||
94 | 'setValue': function(aKeyPath, aValue) { | 90 | 'setValue': function(aKeyPath, aValue) { |
95 | var targetObject; | 91 | var targetObject; |
96 | var keys; | 92 | var keys; |
97 | var i,c; | 93 | var i,c; |
98 | 94 | ||
99 | //console.log(">>> KeyValueObjectStore.setValue", this, this.values(), aKeyPath, aValue); | ||
100 | targetObject = this.values(); | 95 | targetObject = this.values(); |
101 | keys = (aKeyPath + '').split('.'); | 96 | keys = (aKeyPath + '').split('.'); |
102 | c = keys.length - 1; | 97 | c = keys.length - 1; |
103 | for (i=0; i<c; i++) { | 98 | for (i=0; i<c; i++) { |
104 | //console.log("--- KeyValueObjectStore.setValue", i, targetObject, keys[i]); | ||
105 | if (typeof targetObject[keys[i]] == 'undefined') { | 99 | if (typeof targetObject[keys[i]] == 'undefined') { |
106 | targetObject[keys[i]] = {} | 100 | targetObject[keys[i]] = {} |
107 | } | 101 | } |
108 | 102 | ||
109 | targetObject = targetObject[keys[i]]; | 103 | targetObject = targetObject[keys[i]]; |
110 | } | 104 | } |
111 | 105 | ||
112 | targetObject[keys[c]] = aValue; | 106 | targetObject[keys[c]] = aValue; |
113 | //console.log("<<< KeyValueObjectStore.setValue"); | ||
114 | 107 | ||
115 | return aValue; | 108 | return aValue; |
116 | }, | 109 | }, |
117 | 110 | ||
118 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
119 | 112 | ||
120 | 'removeValue': function (aKeyPath) { | 113 | 'removeValue': function (aKeyPath) { |
121 | // this.setValue(aKeyPath, null); | 114 | // this.setValue(aKeyPath, null); |
122 | 115 | ||
123 | var targetObject; | 116 | var targetObject; |
124 | var keys; | 117 | var keys; |
125 | var i,c; | 118 | var i,c; |
126 | 119 | ||
127 | targetObject = this.values(); | 120 | targetObject = this.values(); |
128 | keys = ('' + aKeyPath).split('.'); | 121 | keys = ('' + aKeyPath).split('.'); |
129 | c = keys.length - 1; | 122 | c = keys.length - 1; |
130 | for (i=0; i<c; i++) { | 123 | for (i=0; i<c; i++) { |
131 | if (typeof targetObject[keys[i]] == 'undefined') { | 124 | if (typeof targetObject[keys[i]] == 'undefined') { |
132 | targetObject[keys[i]] = {} | 125 | targetObject[keys[i]] = {} |
133 | } | 126 | } |
134 | 127 | ||
135 | targetObject = targetObject[keys[i]]; | 128 | targetObject = targetObject[keys[i]]; |
136 | } | 129 | } |
137 | 130 | ||
138 | delete targetObject[keys[c]]; | 131 | delete targetObject[keys[c]]; |
139 | }, | 132 | }, |
140 | 133 | ||
141 | //------------------------------------------------------------------------- | 134 | //------------------------------------------------------------------------- |
142 | 135 | ||
143 | 'deferredGetOrSet': function(aKeyPath, aGetterFunction) { | 136 | 'deferredGetOrSet': function(aKeyPath, aGetterFunction) { |
144 | var deferredResult; | 137 | var deferredResult; |
145 | 138 | ||
146 | if (this.getValue(aKeyPath) != null) { | 139 | if (this.getValue(aKeyPath) != null) { |
147 | deferredResult = MochiKit.Async.succeed(this.getValue(aKeyPath)); | 140 | deferredResult = MochiKit.Async.succeed(this.getValue(aKeyPath)); |
148 | } else { | 141 | } else { |
149 | deferredResult = new Clipperz.Async.Deferred("KeyValueObjectStore.deferredGetOrSet [" + aKeyPath + "]", {trace:false}); | 142 | deferredResult = new Clipperz.Async.Deferred("KeyValueObjectStore.deferredGetOrSet [" + aKeyPath + "]", {trace:false}); |
150 | 143 | ||
151 | deferredResult.addCallback(aGetterFunction); | 144 | deferredResult.addCallback(aGetterFunction); |
152 | deferredResult.addMethod(this, 'setValue', aKeyPath); | 145 | deferredResult.addMethod(this, 'setValue', aKeyPath); |
153 | deferredResult.callback(); | 146 | deferredResult.callback(); |
154 | } | 147 | } |
155 | 148 | ||
156 | return deferredResult; | 149 | return deferredResult; |
157 | }, | 150 | }, |
158 | 151 | ||
159 | //------------------------------------------------------------------------- | 152 | //------------------------------------------------------------------------- |
160 | 153 | ||
161 | 'isEmpty': function () { | 154 | 'isEmpty': function () { |