summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js
index a30992a..8621397 100644
--- a/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js
+++ b/frontend/beta/js/Clipperz/PM/Components/RecordDetail/FieldValueComponent.js
@@ -1,275 +1,272 @@
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.Components) == 'undefined') { Clipperz.PM.Components = {}; } 28if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; } 29if (typeof(Clipperz.PM.Components.RecordDetail) == 'undefined') { Clipperz.PM.Components.RecordDetail = {}; }
33 30
34//############################################################################# 31//#############################################################################
35 32
36Clipperz.PM.Components.RecordDetail.FieldValueComponent = function(anElement, args) { 33Clipperz.PM.Components.RecordDetail.FieldValueComponent = function(anElement, args) {
37 args = args || {}; 34 args = args || {};
38 35
39 Clipperz.PM.Components.RecordDetail.FieldValueComponent.superclass.constructor.call(this, anElement, args); 36 Clipperz.PM.Components.RecordDetail.FieldValueComponent.superclass.constructor.call(this, anElement, args);
40 37
41 this._inputElement = null; 38 this._inputElement = null;
42 this._scrambledStatus = 'SCRAMBLED'; //'UNSCRAMBLED' 39 this._scrambledStatus = 'SCRAMBLED'; //'UNSCRAMBLED'
43 40
44 this.render(); 41 this.render();
45 42
46 return this; 43 return this;
47} 44}
48 45
49//============================================================================= 46//=============================================================================
50 47
51YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldValueComponent, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, { 48YAHOO.extendX(Clipperz.PM.Components.RecordDetail.FieldValueComponent, Clipperz.PM.Components.RecordDetail.AbstractFieldSubComponent, {
52 49
53 'toString': function() { 50 'toString': function() {
54 return "Clipperz.PM.Components.RecordDetail.FieldValueComponent component"; 51 return "Clipperz.PM.Components.RecordDetail.FieldValueComponent component";
55 }, 52 },
56 53
57 //------------------------------------------------------------------------- 54 //-------------------------------------------------------------------------
58 55
59 'value': function() { 56 'value': function() {
60 return this.recordField().value(); 57 return this.recordField().value();
61 }, 58 },
62 59
63 'setValue': function(aValue) { 60 'setValue': function(aValue) {
64 this.recordField().setValue(aValue); 61 this.recordField().setValue(aValue);
65 }, 62 },
66 63
67 //------------------------------------------------------------------------- 64 //-------------------------------------------------------------------------
68 65
69 'inputElement': function() { 66 'inputElement': function() {
70 return this._inputElement; 67 return this._inputElement;
71 }, 68 },
72 69
73 'setInputElement': function(aValue) { 70 'setInputElement': function(aValue) {
74 this._inputElement = aValue; 71 this._inputElement = aValue;
75 }, 72 },
76 73
77 //------------------------------------------------------------------------- 74 //-------------------------------------------------------------------------
78 75
79 'scrambledStatus': function() { 76 'scrambledStatus': function() {
80 return this._scrambledStatus; 77 return this._scrambledStatus;
81 }, 78 },
82 79
83 'setScrambledStatus': function(aValue) { 80 'setScrambledStatus': function(aValue) {
84 this._scrambledStatus = aValue; 81 this._scrambledStatus = aValue;
85 }, 82 },
86 83
87 //------------------------------------------------------------------------- 84 //-------------------------------------------------------------------------
88 85
89 'handleTypeChange': function() { 86 'handleTypeChange': function() {
90//MochiKit.Logging.logDebug(">>> handling type change - " + this.recordField().type()); 87//MochiKit.Logging.logDebug(">>> handling type change - " + this.recordField().type());
91 this.synchronizeComponentValues(); 88 this.synchronizeComponentValues();
92 this.update(); 89 this.update();
93 }, 90 },
94 91
95 //------------------------------------------------------------------------- 92 //-------------------------------------------------------------------------
96 93
97 'addrUrl': function() { 94 'addrUrl': function() {
98 var result; 95 var result;
99 96
100 result = "http://maps.google.com/maps?q=" + this.value().split(' ').join('+'); 97 result = "http://maps.google.com/maps?q=" + this.value().split(' ').join('+');
101 98
102 return result; 99 return result;
103 }, 100 },
104 101
105 //------------------------------------------------------------------------- 102 //-------------------------------------------------------------------------
106 103
107 'updateViewMode': function() { 104 'updateViewMode': function() {
108 var scarmbledStatus; 105 var scarmbledStatus;
109 106
110 scrambledStatus = this.scrambledStatus() || 'SCRAMBLED'; 107 scrambledStatus = this.scrambledStatus() || 'SCRAMBLED';
111 108
112 this.element().update(""); 109 this.element().update("");
113 if (this.recordField().hidden() == false) { 110 if (this.recordField().hidden() == false) {
114 switch(this.recordField().type()) { 111 switch(this.recordField().type()) {
115 case 'TXT': 112 case 'TXT':
116 case 'PWD': 113 case 'PWD':
117 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.value()}); 114 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.value()});
118 break; 115 break;
119 case 'URL': 116 case 'URL':
120 varurlLocation; 117 varurlLocation;
121 118
122 urlLocation = Clipperz.Base.sanitizeString(this.value()); 119 urlLocation = Clipperz.Base.sanitizeString(this.value());
123 if (! (/^(https?|ftp|svn):\/\//.test(urlLocation))) { 120 if (! (/^(https?|ftp|svn):\/\//.test(urlLocation))) {
124 urlLocation = 'http://' + urlLocation; 121 urlLocation = 'http://' + urlLocation;
125 } 122 }
126 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'a', href:urlLocation, html:this.value(), target:'_blank'}); 123 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'a', href:urlLocation, html:this.value(), target:'_blank'});
127 break; 124 break;
128 case 'DATE': 125 case 'DATE':
129 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.value()}); 126 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'span', html:this.value()});
130 break; 127 break;
131 case 'ADDR': 128 case 'ADDR':
132 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'a', href:this.addrUrl(), html:this.value(), target:'_blank'}); 129 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'a', href:this.addrUrl(), html:this.value(), target:'_blank'});
133 break; 130 break;
134 } 131 }
135 } else { 132 } else {
136 var tableElement; 133 var tableElement;
137 var tdElement; 134 var tdElement;
138 var inputElement; 135 var inputElement;
139 var passwordElementConfiguration; 136 var passwordElementConfiguration;
140 137
141 if (scrambledStatus == 'SCRAMBLED') { 138 if (scrambledStatus == 'SCRAMBLED') {
142 varscrambledInputElement; 139 varscrambledInputElement;
143 140
144 if ((Clipperz_IEisBroken === true) && (Clipperz.PM.Proxy.defaultProxy.isReadOnly())) { 141 if ((Clipperz_IEisBroken === true) && (Clipperz.PM.Proxy.defaultProxy.isReadOnly())) {
145 scrambledInputElement = {tag:'input', type:'password', value:"this.value()"}; 142 scrambledInputElement = {tag:'input', type:'password', value:"this.value()"};
146 } else { 143 } else {
147 scrambledInputElement = {tag:'input', type:'text', cls:'scrambledField', title:Clipperz.PM.Strings['recordDetailPasswordFieldTooltipLabel'], value:"this.value()"}; 144 scrambledInputElement = {tag:'input', type:'text', cls:'scrambledField', title:Clipperz.PM.Strings['recordDetailPasswordFieldTooltipLabel'], value:"this.value()"};
148 } 145 }
149 146
150 passwordElementConfiguration = 147 passwordElementConfiguration =
151 {tag:'table', border:'0', cellspacing:'2', cellpadding:'0', children:[ 148 {tag:'table', border:'0', cellspacing:'2', cellpadding:'0', children:[
152 {tag:'tbody', children:[ 149 {tag:'tbody', children:[
153 {tag:'tr', children:[ 150 {tag:'tr', children:[
154 {tag:'td', valign:'top', children:[ 151 {tag:'td', valign:'top', children:[
155 scrambledInputElement, 152 scrambledInputElement,
156 {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldUnscrambleLabel']} 153 {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldUnscrambleLabel']}
157 ]}, 154 ]},
158 {tag:'td', valign:'top', children:[ 155 {tag:'td', valign:'top', children:[
159 {tag:'span', cls:'scrambledFieldLabel', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldHelpLabel']} 156 {tag:'span', cls:'scrambledFieldLabel', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldHelpLabel']}
160 ]} 157 ]}
161 ]} 158 ]}
162 ]} 159 ]}
163 ]}; 160 ]};
164 } else { 161 } else {
165 passwordElementConfiguration = 162 passwordElementConfiguration =
166 {tag:'div', children:[ 163 {tag:'div', children:[
167 {tag:'input', type:'text', cls:'unscrambledField', value:"this.value()"}, 164 {tag:'input', type:'text', cls:'unscrambledField', value:"this.value()"},
168 {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldScrambleLabel']} 165 {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', htmlString:Clipperz.PM.Strings['recordDetailPasswordFieldScrambleLabel']}
169 ]}; 166 ]};
170 } 167 }
171 168
172 tableElement = Clipperz.YUI.DomHelper.append(this.element().dom, passwordElementConfiguration, true); 169 tableElement = Clipperz.YUI.DomHelper.append(this.element().dom, passwordElementConfiguration, true);
173 170
174 inputElement = tableElement.getChildrenByTagName('input')[0]; 171 inputElement = tableElement.getChildrenByTagName('input')[0];
175 inputElement.dom.value = this.value(); 172 inputElement.dom.value = this.value();
176 inputElement.wrap({tag:'div', cls:'passwordBackground'}).setStyle('background-position', "0px -" + Math.min(128, Clipperz.PM.Crypto.passwordEntropy(this.value())) + "px"); 173 inputElement.wrap({tag:'div', cls:'passwordBackground'}).setStyle('background-position', "0px -" + Math.min(128, Clipperz.PM.Crypto.passwordEntropy(this.value())) + "px");
177 174
178 MochiKit.Signal.connect(inputElement.dom, 'onfocus', this, 'selectHiddenFieldOnFocus'); 175 MochiKit.Signal.connect(inputElement.dom, 'onfocus', this, 'selectHiddenFieldOnFocus');
179 MochiKit.Signal.connect(this.getDom('scrambleLink'), 'onclick', this, 'toggleScramble'); 176 MochiKit.Signal.connect(this.getDom('scrambleLink'), 'onclick', this, 'toggleScramble');
180 } 177 }
181 }, 178 },
182 179
183 //------------------------------------------------------------------------- 180 //-------------------------------------------------------------------------
184 181
185 'updateEditMode': function() { 182 'updateEditMode': function() {
186 var inputElement; 183 var inputElement;
187 var scarmbledStatus; 184 var scarmbledStatus;
188 185
189 scrambledStatus = this.scrambledStatus() || 'SCRAMBLED'; 186 scrambledStatus = this.scrambledStatus() || 'SCRAMBLED';
190 187
191 this.element().update(""); 188 this.element().update("");
192 switch(this.recordField().type()) { 189 switch(this.recordField().type()) {
193 case 'TXT': 190 case 'TXT':
194 case 'URL': 191 case 'URL':
195 case 'ADDR': 192 case 'ADDR':
196 inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:"this.value()"}, true); 193 inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:"this.value()"}, true);
197 inputElement.dom.value = this.value(); 194 inputElement.dom.value = this.value();
198 break; 195 break;
199 case 'PWD': 196 case 'PWD':
200 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', width:'100%', cellpadding:'0', cellspacing:'0', children:[ 197 Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', width:'100%', cellpadding:'0', cellspacing:'0', children:[
201 {tag:'tbody', children:[ 198 {tag:'tbody', children:[
202 {tag:'tr', children:[ 199 {tag:'tr', children:[
203 {tag:'td', valign:'top', children:[ 200 {tag:'td', valign:'top', children:[
204 {tag:'input', type:((scrambledStatus == 'SCRAMBLED') ? 'password' : 'text'), id:this.getId('passwordInputElement'), value:"this.value()"}, 201 {tag:'input', type:((scrambledStatus == 'SCRAMBLED') ? 'password' : 'text'), id:this.getId('passwordInputElement'), value:"this.value()"},
205 {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', html:(scrambledStatus == 'SCRAMBLED' ? Clipperz.PM.Strings['recordDetailPasswordFieldUnscrambleLabel'] : Clipperz.PM.Strings['recordDetailPasswordFieldScrambleLabel'])} 202 {tag:'a', cls:'scrambleLink', id:this.getId('scrambleLink'), href:'#', html:(scrambledStatus == 'SCRAMBLED' ? Clipperz.PM.Strings['recordDetailPasswordFieldUnscrambleLabel'] : Clipperz.PM.Strings['recordDetailPasswordFieldScrambleLabel'])}
206 ]}, 203 ]},
207 {tag:'td', valign:'top', children:[ 204 {tag:'td', valign:'top', children:[
208 {tag:'div', id:this.getId('passwordGenerator'), cls:'Clipperz_PasswordGenerator_button', html:'&nbsp;'} 205 {tag:'div', id:this.getId('passwordGenerator'), cls:'Clipperz_PasswordGenerator_button', html:'&nbsp;'}
209 ]} 206 ]}
210 ]} 207 ]}
211 ]} 208 ]}
212 ]}) 209 ]})
213 inputElement = this.getElement('passwordInputElement'); 210 inputElement = this.getElement('passwordInputElement');
214 inputElement.dom.value = this.value(); 211 inputElement.dom.value = this.value();
215 new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('passwordInputElement')); 212 new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('passwordInputElement'));
216 new Clipperz.PM.Components.PasswordGenerator(this.getElement('passwordGenerator'), this); 213 new Clipperz.PM.Components.PasswordGenerator(this.getElement('passwordGenerator'), this);
217 MochiKit.Signal.connect(this.getDom('scrambleLink'), 'onclick', this, 'toggleScramble'); 214 MochiKit.Signal.connect(this.getDom('scrambleLink'), 'onclick', this, 'toggleScramble');
218 break; 215 break;
219 // case 'NOTE': 216 // case 'NOTE':
220 // inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'textarea', rows:'5', html:this.value()}, true); 217 // inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'textarea', rows:'5', html:this.value()}, true);
221 // break 218 // break
222 case 'DATE': 219 case 'DATE':
223 inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:"this.value()"}, true); 220 inputElement = Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'input', type:'text', value:"this.value()"}, true);
224 inputElement.dom.value = this.value(); 221 inputElement.dom.value = this.value();
225 break; 222 break;
226 } 223 }
227 224
228 this.setInputElement(inputElement); 225 this.setInputElement(inputElement);
229 }, 226 },
230 227
231 //------------------------------------------------------------------------- 228 //-------------------------------------------------------------------------
232 229
233 'synchronizeComponentValues': function() { 230 'synchronizeComponentValues': function() {
234//MochiKit.Logging.logDebug(">>> FieldValueComponent.synchronizeComponentValues"); 231//MochiKit.Logging.logDebug(">>> FieldValueComponent.synchronizeComponentValues");
235 if (this.inputElement() != null) { 232 if (this.inputElement() != null) {
236 var value; 233 var value;
237 234
238 switch(this.recordField().type()) { 235 switch(this.recordField().type()) {
239 case 'TXT': 236 case 'TXT':
240 case 'URL': 237 case 'URL':
241 case 'ADDR': 238 case 'ADDR':
242 case 'PWD': 239 case 'PWD':
243 case 'DATE': 240 case 'DATE':
244 value = this.inputElement().dom.value; 241 value = this.inputElement().dom.value;
245 break; 242 break;
246 } 243 }
247 this.setValue(value); 244 this.setValue(value);
248 } 245 }
249//MochiKit.Logging.logDebug("<<< FieldValueComponent.synchronizeComponentValues"); 246//MochiKit.Logging.logDebug("<<< FieldValueComponent.synchronizeComponentValues");
250 }, 247 },
251 248
252 //------------------------------------------------------------------------- 249 //-------------------------------------------------------------------------
253 250
254 'selectHiddenFieldOnFocus': function(anEvent) { 251 'selectHiddenFieldOnFocus': function(anEvent) {
255 anEvent.src().select(); 252 anEvent.src().select();
256 }, 253 },
257 254
258 //------------------------------------------------------------------------- 255 //-------------------------------------------------------------------------
259 256
260 'toggleScramble': function(anEvent) { 257 'toggleScramble': function(anEvent) {
261 this.synchronizeComponentValues(); 258 this.synchronizeComponentValues();
262 259
263 if (this.scrambledStatus() == 'SCRAMBLED') { 260 if (this.scrambledStatus() == 'SCRAMBLED') {
264 this.setScrambledStatus('UNSCRAMBLED'); 261 this.setScrambledStatus('UNSCRAMBLED');
265 } else { 262 } else {
266 this.setScrambledStatus('SCRAMBLED'); 263 this.setScrambledStatus('SCRAMBLED');
267 }; 264 };
268 265
269 this.update(); 266 this.update();
270 }, 267 },
271 268
272 //------------------------------------------------------------------------- 269 //-------------------------------------------------------------------------
273 __syntaxFix__: "syntax fix" 270 __syntaxFix__: "syntax fix"
274}); 271});
275 272