Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/RecordField.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/RecordField.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js b/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js index bca664d..a5d7980 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/RecordField.js | |||
@@ -1,214 +1,212 @@ | |||
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 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | //############################################################################# | 28 | //############################################################################# |
31 | 29 | ||
32 | Clipperz.PM.DataModel.RecordField = function(args) { | 30 | Clipperz.PM.DataModel.RecordField = function(args) { |
33 | args = args || {}; | 31 | args = args || {}; |
34 | 32 | ||
35 | this._recordVersion = args.recordVersion || null; | 33 | this._recordVersion = args.recordVersion || null; |
36 | this._key = args.key || Clipperz.PM.Crypto.randomKey(); | 34 | this._key = args.key || Clipperz.PM.Crypto.randomKey(); |
37 | this.setLabel(args.label || ''); | 35 | this.setLabel(args.label || ''); |
38 | this.setValue(args.value || ''); | 36 | this.setValue(args.value || ''); |
39 | this.setType(args.type || 'TXT'); //valid types: 'TXT', 'PWD', 'URL', 'DATE', 'ADDR', 'CHECK', 'RADIO', ('NOTE' probably not), ... | 37 | this.setType(args.type || 'TXT'); //valid types: 'TXT', 'PWD', 'URL', 'DATE', 'ADDR', 'CHECK', 'RADIO', ('NOTE' probably not), ... |
40 | this._hidden = args.hidden || (args.type == 'PWD') || false; | 38 | this._hidden = args.hidden || (args.type == 'PWD') || false; |
41 | 39 | ||
42 | return this; | 40 | return this; |
43 | } | 41 | } |
44 | 42 | ||
45 | Clipperz.PM.DataModel.RecordField.prototype = MochiKit.Base.update(null, { | 43 | Clipperz.PM.DataModel.RecordField.prototype = MochiKit.Base.update(null, { |
46 | 44 | ||
47 | 'toString': function() { | 45 | 'toString': function() { |
48 | return "Clipperz.PM.DataModel.RecordField - " + this.label() + " (" + this.key() + ")"; | 46 | return "Clipperz.PM.DataModel.RecordField - " + this.label() + " (" + this.key() + ")"; |
49 | }, | 47 | }, |
50 | 48 | ||
51 | //------------------------------------------------------------------------- | 49 | //------------------------------------------------------------------------- |
52 | 50 | ||
53 | 'recordVersion': function() { | 51 | 'recordVersion': function() { |
54 | return this._recordVersion; | 52 | return this._recordVersion; |
55 | }, | 53 | }, |
56 | 54 | ||
57 | //------------------------------------------------------------------------- | 55 | //------------------------------------------------------------------------- |
58 | 56 | ||
59 | 'key': function() { | 57 | 'key': function() { |
60 | return this._key; | 58 | return this._key; |
61 | }, | 59 | }, |
62 | 60 | ||
63 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
64 | 62 | ||
65 | 'label': function() { | 63 | 'label': function() { |
66 | return this._label; | 64 | return this._label; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | 'setLabel': function(aValue) { | 67 | 'setLabel': function(aValue) { |
70 | this._label = aValue; | 68 | this._label = aValue; |
71 | }, | 69 | }, |
72 | 70 | ||
73 | //------------------------------------------------------------------------- | 71 | //------------------------------------------------------------------------- |
74 | 72 | ||
75 | 'value': function() { | 73 | 'value': function() { |
76 | return this._value; | 74 | return this._value; |
77 | }, | 75 | }, |
78 | 76 | ||
79 | 'setValue': function(aValue) { | 77 | 'setValue': function(aValue) { |
80 | this._value = aValue; | 78 | this._value = aValue; |
81 | }, | 79 | }, |
82 | 80 | ||
83 | //------------------------------------------------------------------------- | 81 | //------------------------------------------------------------------------- |
84 | 82 | ||
85 | 'type': function() { | 83 | 'type': function() { |
86 | return this._type; | 84 | return this._type; |
87 | }, | 85 | }, |
88 | 86 | ||
89 | 'setType': function(aValue) { | 87 | 'setType': function(aValue) { |
90 | this._type = aValue; | 88 | this._type = aValue; |
91 | 89 | ||
92 | if (aValue == 'PWD') { | 90 | if (aValue == 'PWD') { |
93 | this.setHidden(true); | 91 | this.setHidden(true); |
94 | } else { | 92 | } else { |
95 | this.setHidden(false); | 93 | this.setHidden(false); |
96 | } | 94 | } |
97 | }, | 95 | }, |
98 | 96 | ||
99 | //------------------------------------------------------------------------- | 97 | //------------------------------------------------------------------------- |
100 | 98 | ||
101 | 'serializeData': function() { | 99 | 'serializeData': function() { |
102 | var result; | 100 | var result; |
103 | 101 | ||
104 | //MochiKit.Logging.logDebug(">>> RecordField.serializeData - " + this); | 102 | //MochiKit.Logging.logDebug(">>> RecordField.serializeData - " + this); |
105 | result = { | 103 | result = { |
106 | label: this.label(), | 104 | label: this.label(), |
107 | value:this.value(), | 105 | value:this.value(), |
108 | type: this.type(), | 106 | type: this.type(), |
109 | hidden: this.hidden() | 107 | hidden: this.hidden() |
110 | }; | 108 | }; |
111 | //MochiKit.Logging.logDebug("<<< RecordField.serializeData"); | 109 | //MochiKit.Logging.logDebug("<<< RecordField.serializeData"); |
112 | 110 | ||
113 | return result; | 111 | return result; |
114 | }, | 112 | }, |
115 | 113 | ||
116 | //------------------------------------------------------------------------- | 114 | //------------------------------------------------------------------------- |
117 | 115 | ||
118 | 'typeShortDescription': function() { | 116 | 'typeShortDescription': function() { |
119 | // return Clipperz.PM.DataModel.RecordField.TypeDescriptions[this.type()]['shortDescription']; | 117 | // return Clipperz.PM.DataModel.RecordField.TypeDescriptions[this.type()]['shortDescription']; |
120 | return Clipperz.PM.Strings['recordFieldTypologies'][this.type()]['shortDescription']; | 118 | return Clipperz.PM.Strings['recordFieldTypologies'][this.type()]['shortDescription']; |
121 | }, | 119 | }, |
122 | 120 | ||
123 | //------------------------------------------------------------------------- | 121 | //------------------------------------------------------------------------- |
124 | 122 | ||
125 | 'hidden': function() { | 123 | 'hidden': function() { |
126 | return this._hidden; | 124 | return this._hidden; |
127 | }, | 125 | }, |
128 | 126 | ||
129 | 'setHidden': function(aValue) { | 127 | 'setHidden': function(aValue) { |
130 | this._hidden = aValue; | 128 | this._hidden = aValue; |
131 | }, | 129 | }, |
132 | 130 | ||
133 | //------------------------------------------------------------------------- | 131 | //------------------------------------------------------------------------- |
134 | 132 | ||
135 | 'clone': function(aRecordVersion) { | 133 | 'clone': function(aRecordVersion) { |
136 | var result; | 134 | var result; |
137 | 135 | ||
138 | result = new Clipperz.PM.DataModel.RecordField({ | 136 | result = new Clipperz.PM.DataModel.RecordField({ |
139 | recordVersion:aRecordVersion, | 137 | recordVersion:aRecordVersion, |
140 | label:this.label(), | 138 | label:this.label(), |
141 | value:this.value(), | 139 | value:this.value(), |
142 | type:this.type(), | 140 | type:this.type(), |
143 | hidden:this.hidden() | 141 | hidden:this.hidden() |
144 | }); | 142 | }); |
145 | 143 | ||
146 | return result; | 144 | return result; |
147 | }, | 145 | }, |
148 | 146 | ||
149 | //------------------------------------------------------------------------- | 147 | //------------------------------------------------------------------------- |
150 | 148 | ||
151 | 'isEmpty': function() { | 149 | 'isEmpty': function() { |
152 | var result; | 150 | var result; |
153 | 151 | ||
154 | if ((this.label() == "") && (this.value() == "") && (this.type() == 'TXT')) { | 152 | if ((this.label() == "") && (this.value() == "") && (this.type() == 'TXT')) { |
155 | result = true; | 153 | result = true; |
156 | } else { | 154 | } else { |
157 | result = false; | 155 | result = false; |
158 | } | 156 | } |
159 | 157 | ||
160 | return result; | 158 | return result; |
161 | }, | 159 | }, |
162 | 160 | ||
163 | //------------------------------------------------------------------------- | 161 | //------------------------------------------------------------------------- |
164 | __syntaxFix__: "syntax fix" | 162 | __syntaxFix__: "syntax fix" |
165 | 163 | ||
166 | }); | 164 | }); |
167 | 165 | ||
168 | //############################################################################# | 166 | //############################################################################# |
169 | /* | 167 | /* |
170 | Clipperz.PM.DataModel.RecordField.TypeDescriptions = { | 168 | Clipperz.PM.DataModel.RecordField.TypeDescriptions = { |
171 | 'TXT': { | 169 | 'TXT': { |
172 | description: 'simple text field', | 170 | description: 'simple text field', |
173 | shortDescription: 'txt' | 171 | shortDescription: 'txt' |
174 | }, | 172 | }, |
175 | 'PWD': { | 173 | 'PWD': { |
176 | description: 'simple text field, with default status set to hidden', | 174 | description: 'simple text field, with default status set to hidden', |
177 | shortDescription: 'pwd' | 175 | shortDescription: 'pwd' |
178 | }, | 176 | }, |
179 | 'URL': { | 177 | 'URL': { |
180 | description: 'simple text field in edit mode, that became an active url in view mode', | 178 | description: 'simple text field in edit mode, that became an active url in view mode', |
181 | shortDescription: 'url' | 179 | shortDescription: 'url' |
182 | }, | 180 | }, |
183 | 'DATE': { | 181 | 'DATE': { |
184 | description: 'a value set with a calendar helper', | 182 | description: 'a value set with a calendar helper', |
185 | shortDescription: 'date' | 183 | shortDescription: 'date' |
186 | }, | 184 | }, |
187 | 'ADDR': { | 185 | 'ADDR': { |
188 | description: 'just like the URL, but the active link points to Google Maps (or similar service) passing the address value as argument', | 186 | description: 'just like the URL, but the active link points to Google Maps (or similar service) passing the address value as argument', |
189 | shortDescription: 'addr' | 187 | shortDescription: 'addr' |
190 | }, | 188 | }, |
191 | 'CHECK': { | 189 | 'CHECK': { |
192 | description: 'check description', | 190 | description: 'check description', |
193 | shortDescription: 'check' | 191 | shortDescription: 'check' |
194 | }, | 192 | }, |
195 | 'RADIO': { | 193 | 'RADIO': { |
196 | description: 'radio description', | 194 | description: 'radio description', |
197 | shortDescription: 'radio' | 195 | shortDescription: 'radio' |
198 | }, | 196 | }, |
199 | 'SELECT': { | 197 | 'SELECT': { |
200 | description: 'select description', | 198 | description: 'select description', |
201 | shortDescription: 'select' | 199 | shortDescription: 'select' |
202 | } | 200 | } |
203 | 201 | ||
204 | //'NOTE': { | 202 | //'NOTE': { |
205 | // description: 'a simple text field, but with a bigger component dimension; possibly with "smart edit components"', | 203 | // description: 'a simple text field, but with a bigger component dimension; possibly with "smart edit components"', |
206 | // shortDescription: 'note' | 204 | // shortDescription: 'note' |
207 | //} | 205 | //} |
208 | }; | 206 | }; |
209 | 207 | ||
210 | Clipperz.PM.DataModel.RecordField.InputTypeToRecordFieldType = { | 208 | Clipperz.PM.DataModel.RecordField.InputTypeToRecordFieldType = { |
211 | 'text': 'TXT', | 209 | 'text': 'TXT', |
212 | 'password': 'PWD', | 210 | 'password': 'PWD', |
213 | 'checkbox': 'CHECK', | 211 | 'checkbox': 'CHECK', |
214 | 'radio': 'RADIO', | 212 | 'radio': 'RADIO', |