1 // Copyright (c) 2012 The Chromium 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.
6 * @fileoverview Offline login implementation.
10 var params = getUrlSearchParams(location.search);
12 // Setup localized strings.
13 $('sign-in-title').textContent = decodeURIComponent(params['stringSignIn']);
14 $('email-label').textContent = decodeURIComponent(params['stringEmail']);
15 $('password-label').textContent =
16 decodeURIComponent(params['stringPassword']);
17 $('submit-button').value = decodeURIComponent(params['stringSignIn']);
18 $('empty-email-alert').textContent =
19 decodeURIComponent(params['stringEmptyEmail']);
20 $('empty-password-alert').textContent =
21 decodeURIComponent(params['stringEmptyPassword']);
22 $('errormsg-alert').textContent = decodeURIComponent(params['stringError']);
25 var form = $('offline-login-form');
26 form.addEventListener('submit', function(e) {
27 // Clear all previous errors.
28 form.email.classList.remove('field-error');
29 form.password.classList.remove('field-error');
30 form.password.classList.remove('form-error');
32 if (form.email.value == '') {
33 form.email.classList.add('field-error');
35 } else if (form.password.value == '') {
36 form.password.classList.add('field-error');
37 form.password.focus();
40 'method': 'offlineLogin',
41 'email': form.email.value,
42 'password': form.password.value
44 window.parent.postMessage(msg, 'chrome://oobe/');
49 var email = params['email'];
51 // Email is present, which means that unsuccessful login attempt has been
52 // made. Try to mimic Gaia's behaviour.
53 form.email.value = email;
54 form.password.classList.add('form-error');
55 form.password.focus();
59 window.parent.postMessage({'method': 'loginUILoaded'}, 'chrome://oobe/');
62 document.addEventListener('DOMContentLoaded', load);