author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-03 16:04:12 (UTC) |
commit | 541bb378ddece2eab135a8066a16994e94436dea (patch) (unidiff) | |
tree | ff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js | |
parent | 1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff) | |
parent | ecad5e895831337216544e81f1a467e0c68c4a6a (diff) | |
download | clipperz-541bb378ddece2eab135a8066a16994e94436dea.zip clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2 |
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js | 1114 |
1 files changed, 1114 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js b/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js new file mode 100644 index 0000000..84b2475 --- a/dev/null +++ b/frontend/beta/js/Clipperz/PM/Components/Panels/LoginPanel.js | |||
@@ -0,0 +1,1114 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
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 | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | 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 | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | */ | ||
28 | |||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | ||
30 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | ||
31 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | ||
32 | if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } | ||
33 | |||
34 | |||
35 | Clipperz.PM.Components.Panels.LoginPanel = function(anElement, args) { | ||
36 | args = args || {}; | ||
37 | |||
38 | Clipperz.PM.Components.Panels.LoginPanel.superclass.constructor.call(this, anElement, args); | ||
39 | |||
40 | this._showLoginFormAnimator = null; | ||
41 | this._showRegistrationFormAnimator = null; | ||
42 | this._shouldShowRegistrationAlert = true; | ||
43 | |||
44 | this._visibleForm = null; | ||
45 | //this._isPassphraseVisible = true; | ||
46 | |||
47 | Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); | ||
48 | |||
49 | this.render(); | ||
50 | |||
51 | return this; | ||
52 | } | ||
53 | |||
54 | //============================================================================= | ||
55 | |||
56 | //MochiKit.Base.update(Clipperz.PM.Components.Panels.LoginPanel.prototype, { | ||
57 | YAHOO.extendX(Clipperz.PM.Components.Panels.LoginPanel, Clipperz.PM.Components.Panels.BasePanel, { | ||
58 | |||
59 | 'toString': function() { | ||
60 | return "Clipperz.PM.Components.LoginPanel component"; | ||
61 | }, | ||
62 | |||
63 | //------------------------------------------------------------------------- | ||
64 | |||
65 | 'render': function() { | ||
66 | var result; | ||
67 | varlayout; | ||
68 | var registerButton; | ||
69 | |||
70 | MochiKit.Signal.disconnectAllTo(this); | ||
71 | this.element().update(""); | ||
72 | |||
73 | //MochiKit.Logging.logDebug(">>> LoginPanel.initPanel"); | ||
74 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ | ||
75 | {tag:'table', children:[ | ||
76 | {tag:'thead'}, | ||
77 | {tag:'tbody', children:[ | ||
78 | {tag:'tr', children:[ | ||
79 | {tag:'td', valign:'top', children:[ | ||
80 | {tag:'div', cls:'clipperzServiceDescription', htmlString:Clipperz.PM.Strings['clipperzServiceDescription']} | ||
81 | ]}, | ||
82 | {tag:'td', valign:'top', align:'right', children:[ | ||
83 | {tag:'div', id:this.getId('forms'), cls:'clipperzLoginForm', children:[ | ||
84 | {tag:'div', id:this.getId('loginForm'), cls:'loginForm', children:[ | ||
85 | {tag:'div', cls:'loginFormHeaderBox', children:[{tag:'h3', htmlString:Clipperz.PM.Strings['loginFormTitle']}]}, | ||
86 | {tag:'form', id:this.getId('loginForm_form'), autocomplete:'off', children:[ | ||
87 | |||
88 | {tag:'table', cls:'formLayout', children:[ | ||
89 | {tag:'thead'}, | ||
90 | {tag:'tbody', children:[ | ||
91 | {tag:'tr', cls:'formFieldTR', children:[ | ||
92 | {tag:'td', width:'90', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, | ||
93 | {tag:'td', children:[ | ||
94 | {tag:'input', id:this.getId('login_username'), cls:'loginFormField', type:'text', name:'username'} | ||
95 | ]} | ||
96 | ]}, | ||
97 | {tag:'tr', cls:'formFieldTR', children:[ | ||
98 | {tag:'td', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, | ||
99 | {tag:'td', children:[ | ||
100 | {tag:'div', id:this.getId('passphraseDIV'), children:[ | ||
101 | {tag:'input', id:this.getId('login_passphrase'), cls:'loginFormField', type:'password', name:'passphrase'} | ||
102 | ]}, | ||
103 | {tag:'div', cls:'oneTimePassword', id:this.getId('oneTimePasswordDIV'), children:[ | ||
104 | {tag:'input', type:'text', id:this.getId('oneTimePassword_1'), name:'passphrase'}, | ||
105 | {tag:'span', html:'-'}, | ||
106 | {tag:'input', type:'text', id:this.getId('oneTimePassword_2'), name:'passphrase'}, | ||
107 | {tag:'span', html:'-'}, | ||
108 | {tag:'input', type:'text', id:this.getId('oneTimePassword_3'), name:'passphrase'}, | ||
109 | {tag:'span', html:'-'}, | ||
110 | {tag:'input', type:'text', id:this.getId('oneTimePassword_4'), name:'passphrase'} | ||
111 | ]} | ||
112 | ]} | ||
113 | ]}, | ||
114 | {tag:'tr', cls:'formFieldTR', id:this.getId('passwordTypeChooserTR'), children:[ | ||
115 | {tag:'td', valign:'top', align:'right', children:[ | ||
116 | {tag:'input', type:'checkbox', cls:'passwordTypeCheckbox', id:this.getId('useOneTimePasswordCheckbox')} | ||
117 | ]}, | ||
118 | {tag:'td', children:[ | ||
119 | {tag:'div', cls:'passwordTypeChooser', children:[ | ||
120 | {tag:'h4', htmlString:Clipperz.PM.Strings['loginFormOneTimePasswordCheckboxLabel']}, | ||
121 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormOneTimePasswordCheckboxDescription']} | ||
122 | ]} | ||
123 | ]} | ||
124 | ]}, | ||
125 | {tag:'tr', children:[ | ||
126 | {tag:'td'}, | ||
127 | {tag:'td', children:[ | ||
128 | {tag:'div', id:this.getId('login_submit')} | ||
129 | ]} | ||
130 | ]} | ||
131 | ]}, | ||
132 | {tag:'tfoot'} | ||
133 | ]} | ||
134 | ]}, | ||
135 | |||
136 | {tag:'div', cls:'loginFormFooterBox', children:[ | ||
137 | {tag:'ul', children:[ | ||
138 | {tag:'li', id:this.getId('showRegistrationLI'), children:[ | ||
139 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormDontHaveAnAccountLabel']}, | ||
140 | {tag:'a', href:'.', id:this.getId('showRegistration'), cls:'clipperzActionLink', htmlString:Clipperz.PM.Strings['loginFormCreateOneLabel']} | ||
141 | ]}, | ||
142 | {tag:'li', children:[ | ||
143 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormForgotYourCredentialsLabel']}, | ||
144 | {tag:'a', href:Clipperz.PM.Strings['loginFormAarghThatsBadUrl'], target:'Clipperz_Help', htmlString:Clipperz.PM.Strings['loginFormAarghThatsBadLabel']} | ||
145 | ]}, | ||
146 | {tag:'li', children:[ | ||
147 | {tag:'span', htmlString:Clipperz.PM.Strings['loginFormAfraidOfMaliciousScriptsLabel']}, | ||
148 | {tag:'a', href:Clipperz.PM.Strings['loginFormVerifyTheCodeUrl'], target:'Clipperz_Help', htmlString:Clipperz.PM.Strings['loginFormVerifyTheCodeLabel']} | ||
149 | ]} | ||
150 | ]} | ||
151 | ]} | ||
152 | ]}, | ||
153 | |||
154 | |||
155 | |||
156 | {tag:'div', id:this.getId('registrationForm'), cls:'registrationForm', children:[ | ||
157 | {tag:'div', cls:'loginFormHeaderBox', children:[{tag:'h3', htmlString:Clipperz.PM.Strings['registrationFormTitle']}]}, | ||
158 | {tag:'form', id:this.getId('registrationForm_form'), children:[ | ||
159 | {tag:'h5', cls:'errorMessage', id:this.getId('registration_errorMessage')}, | ||
160 | {tag:'table', cls:'formLayout', children:[ | ||
161 | {tag:'thead'}, | ||
162 | {tag:'tbody', children:[ | ||
163 | {tag:'tr', cls:'formFieldTR', children:[ | ||
164 | {tag:'td', width:'90', htmlString:Clipperz.PM.Strings['registrationFormUsernameLabel']}, | ||
165 | {tag:'td', children:[ | ||
166 | {tag:'input', id:this.getId('registration_username'), cls:'loginFormField', type:'text', name:'username'} | ||
167 | ]} | ||
168 | ]}, | ||
169 | {tag:'tr', cls:'formFieldTR', children:[ | ||
170 | {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormPassphraseLabel']}, | ||
171 | {tag:'td', children:[ | ||
172 | {tag:'input', id:this.getId('registration_passphrase'), cls:'loginFormField', type:'password', name:'passphrase'} | ||
173 | ]} | ||
174 | ]}, | ||
175 | {tag:'tr', cls:'formFieldTR', children:[ | ||
176 | {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormRetypePassphraseLabel']}, | ||
177 | {tag:'td', children:[ | ||
178 | {tag:'input', id:this.getId('registration_repassphrase'), cls:'loginFormField', type:'password', name:'repeat-passphrase'} | ||
179 | ]} | ||
180 | ]}, | ||
181 | {tag:'tr', cls:'formFieldTR', children:[ | ||
182 | {tag:'td', align:'right', valign:'top', children:[ | ||
183 | {tag:'input', id:this.getId('registration_check'), type:'checkbox', name:'safetyCheck'} | ||
184 | ]}, | ||
185 | {tag:'td', children:[ | ||
186 | {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormSafetyCheckLabel']} | ||
187 | ]} | ||
188 | ]}, | ||
189 | {tag:'tr', cls:'formFieldTR', children:[ | ||
190 | {tag:'td', align:'right', valign:'top', children:[ | ||
191 | {tag:'input', id:this.getId('registration_termsOfServiceCheck'), type:'checkbox', name:'termsOfServiceCheck'} | ||
192 | ]}, | ||
193 | {tag:'td', children:[ | ||
194 | {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormTermsOfServiceCheckLabel']} | ||
195 | ]} | ||
196 | ]}, | ||
197 | // {tag:'tr', cls:'formFieldTR', children:[ | ||
198 | // {tag:'td', htmlString:Clipperz.PM.Strings['registrationFormInvitationCodeLabel']}, | ||
199 | // {tag:'td', children:[ | ||
200 | // {tag:'input', id:this.getId('registration_invitationCode'), type:'text', size:'30', name:'invitationCode'} | ||
201 | // ]} | ||
202 | // ]}, | ||
203 | {tag:'tr', children:[ | ||
204 | {tag:'td'}, | ||
205 | {tag:'td', children:[ | ||
206 | {tag:'div', id:this.getId('registration_submit')} | ||
207 | ]} | ||
208 | ]} | ||
209 | ]}, | ||
210 | {tag:'tfoot'} | ||
211 | ]} | ||
212 | ]}, | ||
213 | {tag:'div', cls:'loginFormFooterBox', children:[ | ||
214 | {tag:'ul', children:[ | ||
215 | {tag:'li', children:[ | ||
216 | {tag:'span', htmlString:Clipperz.PM.Strings['registrationFormDoYouAlreadyHaveAnAccountLabel']}, | ||
217 | {tag:'a', href:'.', id:this.getId('showLogin'), cls:'clipperzActionLink', htmlString:Clipperz.PM.Strings['registrationFormSimplyLoginLabel']} | ||
218 | ]} | ||
219 | ]} | ||
220 | ]} | ||
221 | ]} | ||
222 | ]}, | ||
223 | {tag:'div', cls:'loginPanelSwitchLanguageBox', children:[ | ||
224 | {tag:'div', cls:'loginPanelSwitchLanguageDescription', htmlString:Clipperz.PM.Strings['loginPanelSwithLanguageDescription']}, | ||
225 | {tag:'div', cls:'loginPanelSwitchLanguageSelect', children:[ | ||
226 | {tag:'select', id:this.getId('languageSelector'), children:Clipperz.PM.Strings['loginPanelSwitchLanguageSelectOptions']} | ||
227 | ]} | ||
228 | ]}, | ||
229 | {tag:'div', cls:'browserCompatibilityBox', htmlString:Clipperz.PM.Strings['browserCompatibilityDescription']} | ||
230 | ]} | ||
231 | ]} | ||
232 | ]} | ||
233 | ]} | ||
234 | ]}); | ||
235 | |||
236 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', function(e){e.stop();}); | ||
237 | MochiKit.Signal.connect(this.getId('registrationForm_form'), 'onsubmit', function(e){e.stop();}); | ||
238 | |||
239 | MochiKit.Signal.connect(this.getId('showRegistration'), 'onclick', this, 'showRegistrationFormEventHandler'); | ||
240 | MochiKit.Signal.connect(this.getId('showLogin'), 'onclick', this, 'showLoginFormEventHandler'); | ||
241 | |||
242 | new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); | ||
243 | registerButton = new YAHOO.ext.Button(this.getId('registration_submit'), {text:Clipperz.PM.Strings['registrationFormButtonLabel'], handler:this.doRegister, scope:this, minWidth:0}) | ||
244 | |||
245 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | ||
246 | // this.getElement('showRegistrationLI').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
247 | this.getElement('registrationForm_form').addClass('read-only'); | ||
248 | registerButton.disable(); | ||
249 | this.getElement('passwordTypeChooserTR').addClass('read-only'); | ||
250 | this.getDom('useOneTimePasswordCheckbox').disabled = true; | ||
251 | } | ||
252 | |||
253 | MochiKit.Signal.connect(this.getId('loginForm'), 'onkeydown', this, 'onkeydown'); | ||
254 | MochiKit.Signal.connect(this.getId('registrationForm'), 'onkeydown', this, 'onkeydown'); | ||
255 | // MochiKit.Signal.connect(this.getId('useOneTimePasswordCheckbox'), 'onchange', this, 'renderPasswordField'); | ||
256 | MochiKit.Signal.connect(this.getId('useOneTimePasswordCheckbox'), 'onclick', this, 'renderPasswordField'); | ||
257 | this.renderPasswordField(); | ||
258 | |||
259 | this.selectSelectedLanguageOption(); | ||
260 | MochiKit.Signal.connect(this.getId('languageSelector'), 'onchange', this, 'switchLanguage'); | ||
261 | |||
262 | MochiKit.Signal.connect(this.getId('oneTimePassword_1'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
263 | MochiKit.Signal.connect(this.getId('oneTimePassword_2'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
264 | MochiKit.Signal.connect(this.getId('oneTimePassword_3'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
265 | MochiKit.Signal.connect(this.getId('oneTimePassword_4'), 'onkeypress', this, 'handleOneTimePasswordFieldKeyPress'); | ||
266 | |||
267 | MochiKit.Signal.connect(this.getId('oneTimePassword_1'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
268 | MochiKit.Signal.connect(this.getId('oneTimePassword_2'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
269 | MochiKit.Signal.connect(this.getId('oneTimePassword_3'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
270 | MochiKit.Signal.connect(this.getId('oneTimePassword_4'), 'onkeyup', this, 'handleOneTimePasswordFieldKeyUp'); | ||
271 | |||
272 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); | ||
273 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('registration_passphrase')); | ||
274 | //MochiKit.Logging.logDebug("<<< LoginPanel.initPanel"); | ||
275 | |||
276 | return result; | ||
277 | }, | ||
278 | |||
279 | //------------------------------------------------------------------------- | ||
280 | |||
281 | 'renderPasswordField': function() { | ||
282 | if (this.getDom('useOneTimePasswordCheckbox').checked == false) { | ||
283 | this.getElement('oneTimePasswordDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(false); | ||
284 | this.getElement('passphraseDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(false); | ||
285 | this.getElement('login_passphrase').focus(); | ||
286 | } else { | ||
287 | this.getElement('passphraseDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); | ||
288 | this.getElement('oneTimePasswordDIV').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | ||
289 | this.getElement('oneTimePassword_1').focus(); | ||
290 | } | ||
291 | |||
292 | }, | ||
293 | |||
294 | //......................................................................... | ||
295 | |||
296 | 'handleOneTimePasswordFieldKeyPress': function(anEvent) { | ||
297 | if (anEvent.key().string == '-') { | ||
298 | switch (anEvent.src().id) { | ||
299 | case this.getId('oneTimePassword_1'): | ||
300 | this.getElement('oneTimePassword_2').focus(); | ||
301 | break; | ||
302 | case this.getId('oneTimePassword_2'): | ||
303 | this.getElement('oneTimePassword_3').focus(); | ||
304 | break; | ||
305 | case this.getId('oneTimePassword_3'): | ||
306 | this.getElement('oneTimePassword_4').focus(); | ||
307 | break; | ||
308 | } | ||
309 | |||
310 | anEvent.stop(); | ||
311 | } | ||
312 | }, | ||
313 | |||
314 | /* | ||
315 | var ctrl = document.getElementById("txtTargetText"); | ||
316 | var saveText = ctrl.value; | ||
317 | ctrl.focus(); | ||
318 | |||
319 | var range = document.selection.createRange(); | ||
320 | var specialchar = String.fromCharCode(1); | ||
321 | range.text = specialchar; | ||
322 | var pos = ctrl.value.indexOf(specialchar); | ||
323 | ctrl.value = saveText; | ||
324 | range = ctrl.createTextRange(); | ||
325 | range.move('character', pos); | ||
326 | range.select(); | ||
327 | range.text = | ||
328 | document.getElementById("txtSourceText").value; | ||
329 | document.getElementById("txtTargetText").focus(); | ||
330 | window.event.returnValue = false; | ||
331 | */ | ||
332 | |||
333 | 'handleOneTimePasswordFieldKeyUp': function(anEvent) { | ||
334 | varfield; | ||
335 | varfieldValue; | ||
336 | var key; | ||
337 | |||
338 | //console.log("keyUp", anEvent); | ||
339 | field = anEvent.src(); | ||
340 | fieldValue = field.value; | ||
341 | key = anEvent.key(); | ||
342 | |||
343 | // &&(key.string != 'KEY_TAB') | ||
344 | // &&(key.string != 'KEY_SHIFT') | ||
345 | // &&(key.string != 'KEY_BACKSPACE') | ||
346 | // &&(key.string != 'KEY_DELETE') | ||
347 | // &&(key.string.indexOf('KEY_ARROW') != 0) | ||
348 | |||
349 | |||
350 | if ((fieldValue.replace(/\s/g, '').length == 8) && (key.string == 'KEY_SPACEBAR')) { | ||
351 | // field.value = Clipperz.Base.trim(fieldValue).replace(/.{4}/g, '$&' + ' '); | ||
352 | |||
353 | switch (field.id) { | ||
354 | case this.getId('oneTimePassword_1'): | ||
355 | this.getElement('oneTimePassword_2').focus(); | ||
356 | break; | ||
357 | case this.getId('oneTimePassword_2'): | ||
358 | this.getElement('oneTimePassword_3').focus(); | ||
359 | break; | ||
360 | case this.getId('oneTimePassword_3'): | ||
361 | this.getElement('oneTimePassword_4').focus(); | ||
362 | break; | ||
363 | } | ||
364 | // } else if (fieldValue.replace(/\s/g, '').length > 8) { | ||
365 | } | ||
366 | |||
367 | //MochiKit.Logging.logDebug("-- fieldValue: " + fieldValue); | ||
368 | }, | ||
369 | |||
370 | //......................................................................... | ||
371 | |||
372 | 'doLogin': function() { | ||
373 | //MochiKit.Logging.logDebug(">>> LoginPanel.doLogin"); | ||
374 | if (this.checkLoginForm()) { | ||
375 | if (this.getDom('useOneTimePasswordCheckbox').checked == false) { | ||
376 | this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); | ||
377 | } else { | ||
378 | varoneTimePasswordValue; | ||
379 | |||
380 | oneTimePasswordValue = this.getDom('oneTimePassword_1').value + this.getDom('oneTimePassword_2').value + this.getDom('oneTimePassword_3').value + this.getDom('oneTimePassword_4').value; | ||
381 | this.doLoginWithUsernameAndOneTimePassword(this.getDom('login_username').value, oneTimePasswordValue); | ||
382 | } | ||
383 | } | ||
384 | //MochiKit.Logging.logDebug("<<< LoginPanel.doLogin"); | ||
385 | }, | ||
386 | |||
387 | //......................................................................... | ||
388 | |||
389 | 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | ||
390 | var deferredResult; | ||
391 | var user; | ||
392 | var loginPanel; | ||
393 | |||
394 | //MochiKit.Logging.logDebug(">>> LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
395 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | ||
396 | loginPanel = this; | ||
397 | |||
398 | deferredResult = new MochiKit.Async.Deferred(); | ||
399 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("0 - LoginPanel.doLogin - 0: "/* + res*/); return res;}); | ||
400 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
401 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
402 | { | ||
403 | title: "", | ||
404 | text: "", | ||
405 | width:240, | ||
406 | showProgressBar:true, | ||
407 | showCloseButton:false, | ||
408 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
409 | scope:this | ||
410 | }, | ||
411 | this.getDom('login_submit') | ||
412 | ); | ||
413 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1 - LoginPanel.doLogin - 1: "/* + res*/); return res;}); | ||
414 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
415 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'login_start'); | ||
416 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("2 - LoginPanel.doLogin - 2: "/* + res*/); return res;}); | ||
417 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
418 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | ||
419 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("3 - LoginPanel.doLogin - 3: "/* + res*/); return res;}); | ||
420 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
421 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_done'); | ||
422 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("4 - LoginPanel.doLogin - 4: "/* + res*/); return res;}); | ||
423 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
424 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loadingUserData'); | ||
425 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("5 - LoginPanel.doLogin - 5: "/* + res*/); return res;}); | ||
426 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
427 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadPreferences')); | ||
428 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("6 - LoginPanel.doLogin - 6: "/* + res*/); return res;}); | ||
429 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
430 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadRecords')); | ||
431 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("7 - LoginPanel.doLogin - 7: "/* + res*/); return res;}); | ||
432 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
433 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadDirectLogins')); | ||
434 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("8 - LoginPanel.doLogin - 8: "/* + res*/); return res;}); | ||
435 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
436 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'login_connected'); | ||
437 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("9 - LoginPanel.doLogin - 9: "/* + res*/); return res;}); | ||
438 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
439 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, user, 'setupDone', null); | ||
440 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("10 - LoginPanel.doLogin - 10: "/* + res*/); return res;}); | ||
441 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
442 | |||
443 | deferredResult.addCallback(MochiKit.Async.wait, 0.5); | ||
444 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("11 - LoginPanel.doLogin - 11: "/* + res*/); return res;}); | ||
445 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
446 | |||
447 | deferredResult.addCallback(function(res) { | ||
448 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
449 | return res; | ||
450 | }); | ||
451 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("12 - LoginPanel.doLogin - 12: "/* + res*/); return res;}); | ||
452 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
453 | |||
454 | deferredResult.addErrback(MochiKit.Base.bind(function() { | ||
455 | Clipperz.PM.Components.MessageBox().update({ | ||
456 | title:Clipperz.PM.Strings['loginMessagePanelFailureTitle'], | ||
457 | text:Clipperz.PM.Strings['loginMessagePanelFailureText'], | ||
458 | showProgressBar:false, | ||
459 | buttons:{'ok':Clipperz.PM.Strings['loginMessagePanelFailureButtonLabel']}, | ||
460 | fn:MochiKit.Base.bind(function() { | ||
461 | this.getElement('login_passphrase').focus(); | ||
462 | this.getElement('login_passphrase').dom.select(); | ||
463 | }, this), | ||
464 | scope:this | ||
465 | }); | ||
466 | }, this)); | ||
467 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("13 - LoginPanel.doLogin - 13: "/* + res*/); return res;}); | ||
468 | //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); | ||
469 | |||
470 | deferredResult.callback("token"); | ||
471 | //MochiKit.Logging.logDebug("<<< LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
472 | |||
473 | return deferredResult; | ||
474 | }, | ||
475 | |||
476 | //......................................................................... | ||
477 | |||
478 | 'doLoginWithUsernameAndOneTimePassword': function(anUsername, aOneTimePassword) { | ||
479 | var deferredResult; | ||
480 | var loginPanel; | ||
481 | var oneTimePassword; | ||
482 | |||
483 | oneTimePassword = Clipperz.PM.DataModel.OneTimePassword.normalizedOneTimePassword(aOneTimePassword); | ||
484 | |||
485 | //MochiKit.Logging.logDebug(">>> LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
486 | deferredResult = new MochiKit.Async.Deferred(); | ||
487 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
488 | { | ||
489 | title: "", | ||
490 | text: "", | ||
491 | width:240, | ||
492 | showProgressBar:true, | ||
493 | showCloseButton:false, | ||
494 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
495 | scope:this, | ||
496 | steps:7, | ||
497 | buttons:{ | ||
498 | //'ok':Clipperz.PM.Strings['loginMessagePanelInitialButtonLabel'] | ||
499 | } | ||
500 | }, | ||
501 | this.getDom('login_submit') | ||
502 | ); | ||
503 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_start'); | ||
504 | deferredResult.addCallback(function(anUsername, aOneTimePassword) { | ||
505 | var args; | ||
506 | |||
507 | args = { | ||
508 | 'message': 'oneTimePassword', | ||
509 | 'version': Clipperz.PM.Crypto.communicationProtocol.currentVersion, | ||
510 | 'parameters': { | ||
511 | 'oneTimePasswordKey': Clipperz.PM.DataModel.OneTimePassword.computeKeyWithUsernameAndPassword(anUsername, aOneTimePassword), | ||
512 | 'oneTimePasswordKeyChecksum': Clipperz.PM.DataModel.OneTimePassword.computeKeyChecksumWithUsernameAndPassword(anUsername, aOneTimePassword) | ||
513 | } | ||
514 | } | ||
515 | |||
516 | return args; | ||
517 | }, anUsername, oneTimePassword); | ||
518 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_loadingOTP'); | ||
519 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'handshake')); | ||
520 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'OTP_login_extractingPassphrase'); | ||
521 | deferredResult.addCallback(function(aResult) { | ||
522 | return Clipperz.PM.Crypto.deferredDecrypt(oneTimePassword, aResult['data'], aResult['version']); | ||
523 | }); | ||
524 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.otpLogin - 4: " + res); return res;}); | ||
525 | deferredResult.addCallback(function(aResult) { | ||
526 | //MochiKit.Logging.logDebug("aResult") | ||
527 | return (new Clipperz.ByteArray().appendBase64String(aResult['passphrase'])).asString(); | ||
528 | }); | ||
529 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.otpLogin - 5: " + res); return res;}); | ||
530 | deferredResult.addCallbacks( | ||
531 | MochiKit.Base.method(this, 'doLoginWithUsernameAndPassphrase', anUsername), | ||
532 | MochiKit.Base.bind(function(aLoginPanel) { | ||
533 | Clipperz.PM.Components.MessageBox().update({ | ||
534 | title:Clipperz.PM.Strings['loginMessagePanelFailureTitle'], | ||
535 | text:Clipperz.PM.Strings['loginMessagePanelFailureText'], | ||
536 | showProgressBar:false, | ||
537 | buttons:{'ok':Clipperz.PM.Strings['loginMessagePanelFailureButtonLabel']}, | ||
538 | fn:MochiKit.Base.bind(function() { | ||
539 | this.getElement('oneTimePassword_1').focus(); | ||
540 | }, this), | ||
541 | scope:aLoginPanel | ||
542 | }); | ||
543 | }, this) | ||
544 | ); | ||
545 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.otpLogin - 6: " + res); return res;}); | ||
546 | deferredResult.callback("token"); | ||
547 | //MochiKit.Logging.logDebug("<<< LoginPanel.doLoginWithUsernameAndPassphrase"); | ||
548 | |||
549 | return deferredResult; | ||
550 | }, | ||
551 | |||
552 | //......................................................................... | ||
553 | |||
554 | 'checkLoginForm': function() { | ||
555 | var result; | ||
556 | var username | ||
557 | |||
558 | result = true; | ||
559 | |||
560 | //MochiKit.Logging.logDebug(">>> checkLoginForm"); | ||
561 | username = Clipperz.Base.trim(this.getDom('login_username').value); | ||
562 | if (username == "") { | ||
563 | this.getElement('login_username').focus(); | ||
564 | result = false; | ||
565 | } else { | ||
566 | if (this.getDom('useOneTimePasswordCheckbox').checked == false) { | ||
567 | varpassphrase; | ||
568 | |||
569 | passphrase = Clipperz.Base.trim(this.getDom('login_passphrase').value); | ||
570 | |||
571 | if (passphrase == "") { | ||
572 | this.getElement('login_passphrase').focus(); | ||
573 | result = false; | ||
574 | } | ||
575 | } else { | ||
576 | if (Clipperz.Base.trim(this.getDom('oneTimePassword_1').value) == "") { | ||
577 | this.getElement('oneTimePassword_1').focus(); | ||
578 | result = false; | ||
579 | } else if (Clipperz.Base.trim(this.getDom('oneTimePassword_2').value) == "") { | ||
580 | this.getElement('oneTimePassword_2').focus(); | ||
581 | result = false; | ||
582 | } else if (Clipperz.Base.trim(this.getDom('oneTimePassword_3').value) == "") { | ||
583 | this.getElement('oneTimePassword_3').focus(); | ||
584 | result = false; | ||
585 | } else if (Clipperz.Base.trim(this.getDom('oneTimePassword_4').value) == "") { | ||
586 | this.getElement('oneTimePassword_4').focus(); | ||
587 | result = false; | ||
588 | } | ||
589 | } | ||
590 | } | ||
591 | //MochiKit.Logging.logDebug("<<< checkLoginForm - " + result); | ||
592 | |||
593 | return result; | ||
594 | }, | ||
595 | |||
596 | //......................................................................... | ||
597 | |||
598 | 'doRegister': function(anEvent) { | ||
599 | if ((Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false) && (this.checkRegistrationForm())) { | ||
600 | this.doRegistrationWithUsernameAndPassphrase(this.getDom('registration_username').value, this.getDom('registration_passphrase').value /*, this.getDom('registration_invitationCode').value*/); | ||
601 | } | ||
602 | }, | ||
603 | |||
604 | //......................................................................... | ||
605 | |||
606 | 'checkRegistrationForm': function() { | ||
607 | var result; | ||
608 | var username | ||
609 | varpassphrase; | ||
610 | varrePassphrase; | ||
611 | varsafetyCheck; | ||
612 | vartermsOfServiceCheck; | ||
613 | // varinvitationCode; | ||
614 | |||
615 | username = this.getDom('registration_username').value; | ||
616 | passphrase = this.getDom('registration_passphrase').value; | ||
617 | rePassphrase = this.getDom('registration_repassphrase').value; | ||
618 | safetyCheck = this.getDom('registration_check').checked; | ||
619 | termsOfServiceCheck = this.getDom('registration_termsOfServiceCheck').checked; | ||
620 | // invitationCode = this.getDom('registration_invitationCode').value; | ||
621 | |||
622 | if ((username != "") && (passphrase != "") && (rePassphrase != "") /*&& (invitationCode != "")*/) { | ||
623 | if (passphrase != rePassphrase) { | ||
624 | //show alert that the passphrase and rePassphrase should be equal | ||
625 | //MochiKit.Logging.logDebug("WARNING: passphrase != rePassphrase"); | ||
626 | this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageNotMatchingPassphrases']); | ||
627 | this.getElement('registration_repassphrase').focus().dom.select(); | ||
628 | // this.getElement('registration_repassphrase').select(); | ||
629 | result = false; | ||
630 | } else if (safetyCheck != true) { | ||
631 | //show alert that the safetyCheck should be checed | ||
632 | //MochiKit.Logging.logDebug("WARNING: safetyCheck not checked"); | ||
633 | this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageSafetyCheckNotSelected']); | ||
634 | this.getElement('registration_check').focus(); | ||
635 | result = false; | ||
636 | } else if (termsOfServiceCheck != true) { | ||
637 | this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageTermsOfServiceCheckNotSelected']); | ||
638 | this.getElement('registration_termsOfServiceCheck').focus(); | ||
639 | } else { | ||
640 | result = true; | ||
641 | } | ||
642 | } else { | ||
643 | if (username == "") { | ||
644 | this.getElement('registration_username').focus(); | ||
645 | } else if (passphrase == "") { | ||
646 | this.getElement('registration_passphrase').focus(); | ||
647 | } else if (rePassphrase == "") { | ||
648 | this.getElement('registration_repassphrase').focus(); | ||
649 | // } else if (invitationCode == "") { | ||
650 | // this.showRegistrationFormErrorMessageAnimation(Clipperz.PM.Strings['registrationFormWarningMessageInvitationCodeMissing']); | ||
651 | // this.getElement('registration_invitationCode').focus(); | ||
652 | } | ||
653 | |||
654 | result = false; | ||
655 | } | ||
656 | |||
657 | if (result === true) { | ||
658 | this.getActor('registration_errorMessage').hide(); | ||
659 | } | ||
660 | |||
661 | return result; | ||
662 | }, | ||
663 | |||
664 | //......................................................................... | ||
665 | |||
666 | 'showRegistrationFormErrorMessageAnimation': function(anErrorMessage, aCallback) { | ||
667 | varerrorMessageActor; | ||
668 | |||
669 | errorMessageActor = this.getActor('registration_errorMessage'); | ||
670 | errorMessageActor.update(anErrorMessage); | ||
671 | errorMessageActor.show(true); | ||
672 | errorMessageActor.play(aCallback); | ||
673 | }, | ||
674 | |||
675 | //......................................................................... | ||
676 | |||
677 | 'doRegistrationWithUsernameAndPassphrase': function(anUsername, aPassphrase /*, anInvitationCode */) { | ||
678 | var deferredResult; | ||
679 | var user; | ||
680 | var loginPanel; | ||
681 | |||
682 | //MochiKit.Logging.logDebug(">>> LoginPanel.doRegistrationWithUsernameAndPassphrase"); | ||
683 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | ||
684 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 1"); | ||
685 | loginPanel = this; | ||
686 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 2"); | ||
687 | |||
688 | deferredResult = new MochiKit.Async.Deferred(); | ||
689 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 3"); | ||
690 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 1: " + res); return res;}); | ||
691 | deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'), | ||
692 | { | ||
693 | title:Clipperz.PM.Strings['registrationMessagePanelInitialTitle'], | ||
694 | text: Clipperz.PM.Strings['registrationMessagePanelInitialText'], | ||
695 | width:240, | ||
696 | showProgressBar:true, | ||
697 | showCloseButton:false, | ||
698 | fn:MochiKit.Base.method(deferredResult, 'cancel'), | ||
699 | scope:this, | ||
700 | steps:9, | ||
701 | buttons:{ | ||
702 | 'ok':Clipperz.PM.Strings['registrationMessagePanelInitialButtonLabel'] | ||
703 | } | ||
704 | }, | ||
705 | this.getDom('registration_submit') | ||
706 | ); | ||
707 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 4"); | ||
708 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 2: " + res); return res;}); | ||
709 | deferredResult.addCallback(MochiKit.Base.method(user, 'register'), /*anInvitationCode*/ "VeryBraveBetaTester"); | ||
710 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 5"); | ||
711 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 3: " + res); return res;}); | ||
712 | deferredResult.addCallback(function(res) { | ||
713 | Clipperz.PM.Components.MessageBox().update({ | ||
714 | title:Clipperz.PM.Strings['registrationMessagePanelRegistrationDoneTitle'], | ||
715 | text:Clipperz.PM.Strings['registrationMessagePanelRegistrationDoneText'], | ||
716 | step:'next' | ||
717 | }); | ||
718 | return res; | ||
719 | }); | ||
720 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 6"); | ||
721 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 5: " + res); return res;}); | ||
722 | deferredResult.addCallback(MochiKit.Async.wait, 1); | ||
723 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 7"); | ||
724 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 6: " + res); return res;}); | ||
725 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | ||
726 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 8"); | ||
727 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 7: " + res); return res;}); | ||
728 | deferredResult.addCallback(MochiKit.Async.wait, 1); | ||
729 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 9"); | ||
730 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 8: " + res); return res;}); | ||
731 | deferredResult.addCallback(function(res) { | ||
732 | Clipperz.PM.Components.MessageBox().hide(YAHOO.ext.Element.get('main')); | ||
733 | return res; | ||
734 | }); | ||
735 | deferredResult.addCallback(MochiKit.Base.method(this, 'showRegistrationSplashScreen'), user); | ||
736 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 10"); | ||
737 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 9: " + res); return res;}); | ||
738 | deferredResult.addErrback(function(anError) { | ||
739 | Clipperz.PM.Components.MessageBox().update({ | ||
740 | title:Clipperz.PM.Strings['registrationMessagePanelFailureTitle'], | ||
741 | text:anError.message, | ||
742 | showProgressBar:false, | ||
743 | buttons:{'ok':Clipperz.PM.Strings['registrationMessagePanelFailureButtonLabel']}}); | ||
744 | return anError; | ||
745 | }); | ||
746 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 11"); | ||
747 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("LoginPanel.doRegistrationWithUsernameAndPassphrase - 10: " + res); return res;}); | ||
748 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, user, 'setupDone', null); | ||
749 | deferredResult.callback("token"); | ||
750 | //MochiKit.Logging.logDebug("--- LoginPanel.doRegistrationWithUsernameAndPassphrase - 12"); | ||
751 | |||
752 | return deferredResult; | ||
753 | }, | ||
754 | |||
755 | //------------------------------------------------------------------------- | ||
756 | |||
757 | 'showRegistrationSplashScreen': function(anUser) { | ||
758 | var deferredResult; | ||
759 | var alertElement; | ||
760 | varalertDialog; | ||
761 | var closeButton; | ||
762 | var closeFunction; | ||
763 | |||
764 | deferredResult = new MochiKit.Async.Deferred(); | ||
765 | |||
766 | //MochiKit.Logging.logDebug(">>> Main.showRegistrationSplashScreen"); | ||
767 | alertElement = Clipperz.YUI.DomHelper.append(document.body, {tag:'div', id:'registrationSplash', children:[ | ||
768 | {tag:'div', cls:'ydlg-hd', htmlString:Clipperz.PM.Strings['registrationSplashPanelTitle']}, | ||
769 | {tag:'div', cls:'ydlg-bd', children:[ | ||
770 | {tag:'div', cls:'alert-message', id:'splashMessage', children:[ | ||
771 | {tag:'div', htmlString:Clipperz.PM.Strings['registrationSplashPanelDescription']}, | ||
772 | {tag:'table', border:'0', cellpadding:'5', children:[ | ||
773 | {tag:'tbody', children:[ | ||
774 | {tag:'tr', children:[ | ||
775 | {tag:'td', valign:'top', children:[ | ||
776 | {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['registrationSplashPanelUsernameLabel']} | ||
777 | ]}, | ||
778 | {tag:'td', valign:'top', children:[ | ||
779 | {tag:'span', cls:'value', html:Clipperz.Base.escapeHTML(anUser.username())} | ||
780 | ]} | ||
781 | ]}, | ||
782 | {tag:'tr', children:[ | ||
783 | {tag:'td', valign:'top', children:[ | ||
784 | {tag:'span', cls:'label', htmlString:Clipperz.PM.Strings['registrationSplashPanelPassphraseLabel']} | ||
785 | ]}, | ||
786 | {tag:'td', valign:'top', children:[ | ||
787 | {tag:'div', id:this.getId('showPassphraseDiv'), children:[ | ||
788 | {tag:'span', cls:'value', html:Clipperz.Base.escapeHTML(anUser.passphrase())} | ||
789 | ]}, | ||
790 | {tag:'div', id:this.getId('hidePassphraseDiv'), cls:'Clipperz_recordFieldData', children:[ | ||
791 | {tag:'input', id:this.getId('passwordField'), type:'text', cls:'scrambledField', title:Clipperz.PM.Strings['recordDetailPasswordFieldTooltipLabel'], value:"anUser.passphrase()"} | ||
792 | ]} | ||
793 | ]} | ||
794 | ]}, | ||
795 | {tag:'tr', children:[ | ||
796 | {tag:'td'}, | ||
797 | {tag:'td', valign:'top', children:[ | ||
798 | // {tag:'a', href:"#", id:this.getId('togglePassphraseVisibility'), htmlString:Clipperz.PM.Strings['registrationSplashPanelShowPassphraseButtonLabel']} | ||
799 | {tag:'input', type:'checkbox', id:this.getId('showPassphraseCheckbox')}, | ||
800 | {tag:'span', cls:'activeText', id:this.getId('showPassphraseText'), htmlString:Clipperz.PM.Strings['registrationSplashPanelShowPassphraseButtonLabel']} | ||
801 | ]} | ||
802 | ]} | ||
803 | ]} | ||
804 | ]} | ||
805 | ]} | ||
806 | ]}, | ||
807 | {tag:'div', cls:'ydlg-ft'} | ||
808 | ]}, true); | ||
809 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1"); | ||
810 | |||
811 | this.getElement('passwordField').dom.value = anUser.passphrase(); | ||
812 | this.getElement('passwordField').wrap({tag:'div', cls:'passwordBackground'}).setStyle('background-position', "0px -" + Math.min(128, Clipperz.PM.Crypto.passwordEntropy(anUser.passphrase())) + "px").setStyle('width', '71px'); | ||
813 | MochiKit.Signal.connect(this.getId('showPassphraseCheckbox'), 'onclick', this, 'togglePassphraseVisibility'); | ||
814 | MochiKit.Signal.connect(this.getId('showPassphraseText'), 'onclick', this, 'togglePassphraseCheckbox'); | ||
815 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1.1"); | ||
816 | |||
817 | this.getElement('showPassphraseDiv').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
818 | this.getElement('hidePassphraseDiv').setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
819 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1.1.1"); | ||
820 | this.togglePassphraseVisibility(); | ||
821 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 1.2"); | ||
822 | |||
823 | alertDialog = new YAHOO.ext.BasicDialog( | ||
824 | alertElement, { | ||
825 | closable:false, | ||
826 | modal:true, | ||
827 | autoTabs:false, | ||
828 | resizable:false, | ||
829 | fixedcenter:true, | ||
830 | constraintoviewport:false, | ||
831 | width:450, | ||
832 | height:220, | ||
833 | shadow:true, | ||
834 | minWidth:300, | ||
835 | minHeight:300 | ||
836 | } | ||
837 | ); | ||
838 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 2"); | ||
839 | |||
840 | closeFunction = deferredResult.callback; | ||
841 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 3"); | ||
842 | alertDialog.addKeyListener(27, closeFunction); | ||
843 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 4"); | ||
844 | closeButton = alertDialog.addButton(Clipperz.PM.Strings['splashAlertCloseButtonLabel'], closeFunction, deferredResult); | ||
845 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 5"); | ||
846 | alertDialog.setDefaultButton(closeButton); | ||
847 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 6"); | ||
848 | alertDialog.show('main'); | ||
849 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 7"); | ||
850 | |||
851 | deferredResult.addBoth(MochiKit.Base.method(alertDialog, 'hide')); | ||
852 | deferredResult.addCallback(MochiKit.Signal.disconnectAllTo, this) | ||
853 | //MochiKit.Logging.logDebug("--- Main.showRegistrationSplashScreen - 8"); | ||
854 | deferredResult.addCallback(MochiKit.Async.succeed); | ||
855 | //MochiKit.Logging.logDebug("<<< Main.showRegistrationSplashScreen"); | ||
856 | |||
857 | return deferredResult; | ||
858 | }, | ||
859 | |||
860 | //------------------------------------------------------------------------- | ||
861 | |||
862 | 'showLoginFormEventHandler': function(anEvent) { | ||
863 | anEvent.stop(); | ||
864 | this.showLoginForm(true); | ||
865 | }, | ||
866 | |||
867 | 'showLoginForm': function(shouldAnimate) { | ||
868 | if (shouldAnimate) { | ||
869 | this.showLoginFormAnimator().play(); | ||
870 | } else { | ||
871 | this.hideRegistrationForm(false); | ||
872 | this.getActor('loginForm').show(false); | ||
873 | this.getElement('login_username').focus(); | ||
874 | } | ||
875 | this.setVisibleForm('login'); | ||
876 | }, | ||
877 | |||
878 | 'showLoginFormAnimator': function() { | ||
879 | if (this._showLoginFormAnimator == null) { | ||
880 | var animator; | ||
881 | varloginFormActor; | ||
882 | var registrationFormActor; | ||
883 | var usernameFieldActor; | ||
884 | |||
885 | animator = new YAHOO.ext.Animator(); | ||
886 | loginFormActor = this.getActor('loginForm', animator); | ||
887 | loginFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
888 | registrationFormActor = this.getActor('registrationForm', animator); | ||
889 | registrationFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
890 | usernameFieldActor = this.getActor('login_username', animator); | ||
891 | |||
892 | animator.startCapture(); | ||
893 | registrationFormActor.hide(true); | ||
894 | loginFormActor.show(true); | ||
895 | usernameFieldActor.focus(); | ||
896 | animator.stopCapture(); | ||
897 | |||
898 | this._showLoginFormAnimator = animator; | ||
899 | } | ||
900 | |||
901 | return this._showLoginFormAnimator; | ||
902 | }, | ||
903 | |||
904 | |||
905 | 'hideLoginForm': function(shouldAnimate) { | ||
906 | var loginFormActor; | ||
907 | |||
908 | loginFormActor = this.getActor('loginForm'); | ||
909 | loginFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
910 | loginFormActor.hide(shouldAnimate); | ||
911 | }, | ||
912 | |||
913 | //------------------------------------------------------------------------- | ||
914 | |||
915 | 'showRegistrationFormEventHandler': function(anEvent) { | ||
916 | anEvent.stop(); | ||
917 | this.showRegistrationForm(true); | ||
918 | }, | ||
919 | |||
920 | 'showRegistrationForm': function(shouldAnimate) { | ||
921 | if (shouldAnimate) { | ||
922 | this.showRegistrationFormAnimator().play(MochiKit.Base.bind(this.showRegistrationAlert, this)); | ||
923 | } else { | ||
924 | varerrorMessageActor; | ||
925 | |||
926 | this.hideLoginForm(shouldAnimate) | ||
927 | this.getActor('registrationForm').show(false); | ||
928 | this.getElement('registration_username').focus(); | ||
929 | |||
930 | errorMessageActor = this.getActor('registration_errorMessage'); | ||
931 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
932 | errorMessageActor.update("---"); | ||
933 | errorMessageActor.hide(); | ||
934 | |||
935 | this.showRegistrationAlert(); | ||
936 | } | ||
937 | this.setVisibleForm('registration'); | ||
938 | }, | ||
939 | |||
940 | 'showRegistrationFormAnimator': function() { | ||
941 | if (this._showRegistrationFormAnimator == null) { | ||
942 | var animator; | ||
943 | varloginFormActor; | ||
944 | var registrationFormActor; | ||
945 | var usernameFieldActor; | ||
946 | varerrorMessageActor; | ||
947 | |||
948 | animator = new YAHOO.ext.Animator(); | ||
949 | loginFormActor = this.getActor('loginForm', animator); | ||
950 | loginFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
951 | registrationFormActor = this.getActor('registrationForm', animator); | ||
952 | registrationFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
953 | usernameFieldActor = this.getActor('registration_username', animator); | ||
954 | errorMessageActor = this.getActor('registration_errorMessage', animator); | ||
955 | errorMessageActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
956 | |||
957 | animator.startCapture(); | ||
958 | loginFormActor.hide(true); | ||
959 | errorMessageActor.update("---"); | ||
960 | errorMessageActor.hide(); | ||
961 | registrationFormActor.show(true); | ||
962 | usernameFieldActor.focus(); | ||
963 | animator.stopCapture(); | ||
964 | |||
965 | this._showRegistrationFormAnimator = animator; | ||
966 | } | ||
967 | |||
968 | return this._showRegistrationFormAnimator; | ||
969 | }, | ||
970 | |||
971 | 'hideRegistrationForm': function(shouldAnimate) { | ||
972 | var registrationFormActor; | ||
973 | |||
974 | registrationFormActor = this.getActor('registrationForm'); | ||
975 | registrationFormActor.setVisibilityMode(YAHOO.ext.Element.DISPLAY); | ||
976 | registrationFormActor.hide(shouldAnimate); | ||
977 | }, | ||
978 | |||
979 | //------------------------------------------------------------------------- | ||
980 | |||
981 | 'shouldShowRegistrationAlert': function() { | ||
982 | return this._shouldShowRegistrationAlert; | ||
983 | }, | ||
984 | |||
985 | 'showRegistrationAlert': function() { | ||
986 | if ((this.shouldShowRegistrationAlert()) && (Clipperz.PM.Proxy.defaultProxy.isReadOnly() == false)) { | ||
987 | var alertElement; | ||
988 | varalertDialog; | ||
989 | var closeButton; | ||
990 | var closeFunction; | ||
991 | |||
992 | alertElement = Clipperz.YUI.DomHelper.append(document.body, {tag:'div', id:'alert', children:[ | ||
993 | {tag:'div', cls:'ydlg-hd', htmlString:Clipperz.PM.Strings['splashAlertTitle']}, | ||
994 | {tag:'div', cls:'ydlg-bd', children:[ | ||
995 | {tag:'div', cls:'alert-message', id:'splashMessage', htmlString:Clipperz.PM.Strings['splashAlertText']} | ||
996 | ]}, | ||
997 | {tag:'div', cls:'ydlg-ft'} | ||
998 | ]}, true); | ||
999 | |||
1000 | alertDialog = new YAHOO.ext.BasicDialog( | ||
1001 | alertElement, { | ||
1002 | closable:false, | ||
1003 | modal:true, | ||
1004 | autoTabs:false, | ||
1005 | resizable:false, | ||
1006 | fixedcenter:true, | ||
1007 | constraintoviewport:false, | ||
1008 | width:450, | ||
1009 | height:320, | ||
1010 | shadow:true, | ||
1011 | minWidth:300, | ||
1012 | minHeight:300 | ||
1013 | } | ||
1014 | ); | ||
1015 | |||
1016 | closeFunction = MochiKit.Base.partial(MochiKit.Base.bind(this.closeResigrationAlert, this), alertDialog); | ||
1017 | alertDialog.addKeyListener(27, closeFunction); | ||
1018 | closeButton = alertDialog.addButton(Clipperz.PM.Strings['splashAlertCloseButtonLabel'], closeFunction, this); | ||
1019 | alertDialog.setDefaultButton(closeButton); | ||
1020 | alertDialog.show('main'); | ||
1021 | |||
1022 | this._shouldShowRegistrationAlert = false; | ||
1023 | } | ||
1024 | }, | ||
1025 | |||
1026 | 'closeResigrationAlert': function(anAlertDialog) { | ||
1027 | anAlertDialog.hide(MochiKit.Base.bind(function() {anAlertDialog.destroy(true); this.focusOnVisibleForm();}, this)); | ||
1028 | }, | ||
1029 | |||
1030 | //------------------------------------------------------------------------- | ||
1031 | |||
1032 | 'onkeydown': function(anEvent) { | ||
1033 | //MochiKit.Logging.logDebug(">>> onkeydown - " + anEvent.src().id); | ||
1034 | if (anEvent.key().code == 13) { | ||
1035 | if (anEvent.src() == this.getDom('loginForm')) { | ||
1036 | this.doLogin(); | ||
1037 | } else if (anEvent.src() == this.getDom('registrationForm')) { | ||
1038 | this.doRegister(); | ||
1039 | } else { | ||
1040 | } | ||
1041 | |||
1042 | anEvent.stop(); | ||
1043 | } | ||
1044 | }, | ||
1045 | |||
1046 | //------------------------------------------------------------------------- | ||
1047 | |||
1048 | 'visibleForm': function() { | ||
1049 | return this._visibleForm; | ||
1050 | }, | ||
1051 | |||
1052 | 'setVisibleForm': function(aValue) { | ||
1053 | this._visibleForm = aValue; | ||
1054 | }, | ||
1055 | |||
1056 | //------------------------------------------------------------------------- | ||
1057 | |||
1058 | 'focusOnVisibleForm': function() { | ||
1059 | if (this.visibleForm() == 'registration') { | ||
1060 | this.getElement('registration_username').focus(); | ||
1061 | } else { | ||
1062 | this.getElement('login_username').focus(); | ||
1063 | } | ||
1064 | }, | ||
1065 | |||
1066 | //------------------------------------------------------------------------- | ||
1067 | |||
1068 | 'show': function() { | ||
1069 | if (this.visibleForm() == 'registration') { | ||
1070 | this.showRegistrationForm(false); | ||
1071 | } else { | ||
1072 | this.showLoginForm(false); | ||
1073 | } | ||
1074 | }, | ||
1075 | |||
1076 | //------------------------------------------------------------------------- | ||
1077 | |||
1078 | 'switchLanguage': function(anEvent) { | ||
1079 | Clipperz.PM.Strings.Languages.setSelectedLanguage(anEvent.src().value); | ||
1080 | }, | ||
1081 | |||
1082 | //------------------------------------------------------------------------- | ||
1083 | |||
1084 | 'selectSelectedLanguageOption': function() { | ||
1085 | Clipperz.DOM.selectOptionMatchingValue(this.getDom('languageSelector'), Clipperz.PM.Strings.selectedLanguage, true); | ||
1086 | }, | ||
1087 | |||
1088 | //------------------------------------------------------------------------- | ||
1089 | |||
1090 | 'switchLanguageHandler': function() { | ||
1091 | this.render(); | ||
1092 | this.show(); | ||
1093 | }, | ||
1094 | |||
1095 | //------------------------------------------------------------------------- | ||
1096 | |||
1097 | 'togglePassphraseCheckbox': function(anEvent) { | ||
1098 | this.getDom('showPassphraseCheckbox').click(); | ||
1099 | }, | ||
1100 | |||
1101 | 'togglePassphraseVisibility': function(anEvent) { | ||
1102 | if (this.getDom('showPassphraseCheckbox').checked == true) { | ||
1103 | this.getElement('showPassphraseDiv').show(); | ||
1104 | this.getElement('hidePassphraseDiv').hide(); | ||
1105 | } else { | ||
1106 | this.getElement('showPassphraseDiv').hide(); | ||
1107 | this.getElement('hidePassphraseDiv').show(); | ||
1108 | } | ||
1109 | }, | ||
1110 | |||
1111 | //------------------------------------------------------------------------- | ||
1112 | __syntaxFix__: "syntax fix" | ||
1113 | |||
1114 | }); | ||