guarantee non-reentrant drawing, clean up variables, make sure we do not skip multipl...
[lantea.git] / js / loginwindow.js
CommitLineData
6ba597ed
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/. */
6ba597ed
RK
4
5window.onload = function() {
6 // Complete the login process by calling the main window.
6ba597ed 7 if (window.opener) {
6ba597ed 8 window.opener.finishLogin(getParameterByName("code"), getParameterByName("state"));
6ba597ed
RK
9 window.close();
10 }
11 else {
6ba597ed
RK
12 document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported.";
13 }
14}
c7daa6aa
RK
15
16function getParameterByName(aName) {
17 // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
18 name = aName.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
19 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
20 results = regex.exec(location.search);
21 return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
22}