KaiRo bug 415 - Consolidate some more setup code into the utilities class
[authserver.git] / app / authsystem.js
CommitLineData
d26d08a1
RK
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
7be13777
RK
5// Call initElements at the earliest possible stage after parsing the document.
6if (window.addEventListener) { window.addEventListener("DOMContentLoaded", initElements, false); }
7else { window.onload = initElements(); }
8
9function initElements() {
409b55f4
RK
10 var jsWarning = document.getElementById("jswarning");
11 if (jsWarning) {
46f7aeda
RK
12 if (jsWarning.classList) {
13 jsWarning.classList.add("hidden");
14 }
15 else {
16 // IE9 or older (sigh)
17 jsWarning.setAttribute("class", "warn hidden");
18 }
409b55f4 19 }
d26d08a1
RK
20 var loginForm = document.getElementById("loginform");
21 if (loginForm) {
46f7aeda
RK
22 if (loginForm.classList) {
23 loginForm.classList.remove("hidden");
24 }
25 else {
26 // IE9 or older (sigh)
27 loginForm.setAttribute("class", "loginarea");
28 }
d26d08a1 29 }
b217e836
RK
30 var cancelAuth = document.getElementById("cancelauth");
31 if (cancelAuth) {
32 cancelAuth.onclick = function() {
33 document.getElementById("isauthorized").value = "no";
9cab985c 34 document.getElementById("authform").submit();
b217e836
RK
35 }
36 }
37 var addAnotherEmail = document.getElementById("addanotheremail");
38 if (addAnotherEmail) {
39 addAnotherEmail.onclick = function() {
60e46184 40 location.href = "./?addemail";
b217e836
RK
41 }
42 }
43 var isNotMe = document.getElementById("isnotme");
44 if (isNotMe) {
45 isNotMe.onclick = function() {
46 location.href = location.href + "&logout=1";
47 }
48 }
d26d08a1 49}