| 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 | window.onload = function() { |
| 6 | // Complete the login process by calling the main window. |
| 7 | if (window.opener) { |
| 8 | window.opener.finishLogin(getParameterByName("code"), getParameterByName("state")); |
| 9 | window.close(); |
| 10 | } |
| 11 | else { |
| 12 | document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported."; |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | function 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 | } |