move login window functions into a separate JS file and add debug statements
[lantea.git] / js / loginwindow.js
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 console.log("JS-load");
5
6 window.onload = function() {
7   // Complete the login process by calling the main window.
8   console.log("onload");
9   if (window.opener) {
10     console.log("opener");
11     window.opener.finishLogin(getParameterByName("code"), getParameterByName("state"));
12     console.log("finished");
13     window.close();
14   }
15   else {
16     console.log("no-opener");
17     document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported.";
18   }
19 }