OLD | NEW |
1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Offline login implementation. | 6 * @fileoverview Offline login implementation. |
7 */ | 7 */ |
8 | 8 |
9 function load() { | 9 function load() { |
10 var params = getUrlSearchParams(location.search); | 10 var params = getUrlSearchParams(location.search); |
11 | 11 |
12 // Setup localized strings. | 12 // Setup localized strings. |
13 var signInTitle = $('sign-in-title'); | 13 $('sign-in-title').textContent = decodeURIComponent(params['stringSignIn']); |
14 var emailLabel = $('email-label'); | 14 $('email-label').textContent = decodeURIComponent(params['stringEmail']); |
15 var passwordLabel = $('password-label'); | 15 $('password-label').textContent = |
16 var submitButton = $('submit-button'); | 16 decodeURIComponent(params['stringPassword']); |
17 var errorSpan = $('errormsg-alert'); | 17 $('submit-button').value = decodeURIComponent(params['stringSignIn']); |
18 | 18 $('errormsg-alert').textContent = decodeURIComponent(params['stringError']); |
19 signInTitle.textContent = decodeURIComponent(params['stringSignIn']); | |
20 emailLabel.textContent = decodeURIComponent(params['stringEmail']); | |
21 passwordLabel.textContent = decodeURIComponent(params['stringPassword']); | |
22 submitButton.value = decodeURIComponent(params['stringSignIn']); | |
23 errorSpan.textContent = decodeURIComponent(params['stringError']); | |
24 | 19 |
25 // Setup actions. | 20 // Setup actions. |
26 var form = $('offline-login-form'); | 21 var form = $('offline-login-form'); |
27 form.addEventListener('submit', function(e) { | 22 form.addEventListener('submit', function(e) { |
28 var msg = { | 23 var msg = { |
29 'method': 'offlineLogin', | 24 'method': 'offlineLogin', |
30 'email': form.email.value, | 25 'email': form.email.value, |
31 'password': form.password.value | 26 'password': form.password.value |
32 }; | 27 }; |
33 window.parent.postMessage(msg, 'chrome://oobe/'); | 28 window.parent.postMessage(msg, 'chrome://oobe/'); |
34 e.preventDefault(); | 29 e.preventDefault(); |
35 }); | 30 }); |
36 | 31 |
37 var email = params['email']; | 32 var email = params['email']; |
38 if (email) { | 33 if (email) { |
39 // Email is present, which means that unsuccessful login attempt has been | 34 // Email is present, which means that unsuccessful login attempt has been |
40 // made. Try to mimic Gaia's behaviour. | 35 // made. Try to mimic Gaia's behaviour. |
41 form.email.value = email; | 36 form.email.value = email; |
42 form.password.classList.add('form-error'); | 37 form.password.classList.add('form-error'); |
43 form.password.focus(); | 38 form.password.focus(); |
44 } else { | 39 } else { |
45 form.email.focus(); | 40 form.email.focus(); |
46 } | 41 } |
47 window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/'); | 42 window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/'); |
48 } | 43 } |
49 | 44 |
50 document.addEventListener('DOMContentLoaded', load); | 45 document.addEventListener('DOMContentLoaded', load); |
OLD | NEW |