OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Offline login implementation. |
| 7 */ |
| 8 |
| 9 function load() { |
| 10 var params = getUrlSearchParams(location.search); |
| 11 |
| 12 // Setup localized strings. |
| 13 var signInTitle = $('sign-in-title'); |
| 14 var emailLabel = $('email-label'); |
| 15 var passwordLabel = $('password-label'); |
| 16 var submitButton = $('submit-button'); |
| 17 var errorSpan = $('errormsg-alert'); |
| 18 |
| 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 |
| 25 // Setup actions. |
| 26 var form = $('offline-login-form'); |
| 27 form.addEventListener('submit', function(e) { |
| 28 var msg = { |
| 29 'method': 'offlineLogin', |
| 30 'email': form.email.value, |
| 31 'password': form.password.value |
| 32 }; |
| 33 window.parent.postMessage(msg, 'chrome://oobe/'); |
| 34 e.preventDefault(); |
| 35 }); |
| 36 |
| 37 var email = params['email']; |
| 38 if (email) { |
| 39 // Email is present, which means that unsuccessful login attempt has been |
| 40 // made. Try to mimic Gaia's behaviour. |
| 41 form.email.value = email; |
| 42 form.password.classList.add('form-error'); |
| 43 form.password.focus(); |
| 44 } else { |
| 45 form.email.focus(); |
| 46 } |
| 47 window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/'); |
| 48 } |
| 49 |
| 50 document.addEventListener('DOMContentLoaded', load); |
OLD | NEW |