make onload fallback actually work, and comment on piwik brokenness with IE10 or...
[authserver.git] / app / authsystem.js
... / ...
CommitLineData
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
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() {
10 var jsWarning = document.getElementById("jswarning");
11 if (jsWarning) {
12 if (jsWarning.classList) {
13 jsWarning.classList.add("hidden");
14 }
15 else {
16 // IE9 or older (sigh)
17 jsWarning.setAttribute("class", "warn hidden");
18 }
19 }
20 var loginForm = document.getElementById("loginform");
21 if (loginForm) {
22 if (loginForm.classList) {
23 loginForm.classList.remove("hidden");
24 }
25 else {
26 // IE9 or older (sigh)
27 loginForm.setAttribute("class", "loginarea");
28 }
29 }
30 var cancelAuth = document.getElementById("cancelauth");
31 if (cancelAuth) {
32 cancelAuth.onclick = function() {
33 document.getElementById("isauthorized").value = "no";
34 document.getElementById("authform").submit();
35 }
36 }
37 var addAnotherEmail = document.getElementById("addanotheremail");
38 if (addAnotherEmail) {
39 addAnotherEmail.onclick = function() {
40 location.href = "./?addemail";
41 }
42 }
43 var isNotMe = document.getElementById("isnotme");
44 if (isNotMe) {
45 isNotMe.onclick = function() {
46 location.href = location.href + "&logout=1";
47 }
48 }
49}