Commit | Line | Data |
---|---|---|
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/. */ | |
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 | } | |
c7daa6aa RK |
20 | |
21 | function getParameterByName(aName) { | |
22 | // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript | |
23 | name = aName.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); | |
24 | var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | |
25 | results = regex.exec(location.search); | |
26 | return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | |
27 | } |