From: Robert Kaiser Date: Mon, 20 Nov 2017 18:26:17 +0000 (+0100) Subject: Merge branch 'master' of linz:/srv/git/lantea X-Git-Tag: production~22 X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=commitdiff_plain;h=c53a1969fd519687ca4d581077c8dc3792169bb8;hp=5e9f4a24c890ea34a762380ac01d76648a8547e5 Merge branch 'master' of linz:/srv/git/lantea --- diff --git a/js/loginwindow.js b/js/loginwindow.js new file mode 100644 index 0000000..94cd6c2 --- /dev/null +++ b/js/loginwindow.js @@ -0,0 +1,22 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +window.onload = function() { + // Complete the login process by calling the main window. + if (window.opener) { + window.opener.finishLogin(getParameterByName("code"), getParameterByName("state")); + window.close(); + } + else { + document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported."; + } +} + +function getParameterByName(aName) { + // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript + name = aName.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); +} diff --git a/js/ui.js b/js/ui.js index 263a139..60abf40 100644 --- a/js/ui.js +++ b/js/ui.js @@ -17,11 +17,6 @@ var gBackendURL = "https://backend.lantea.kairo.at"; var gAuthClientID = "lantea"; window.onload = function() { - if (/\/login\.html/.test(window.location)) { - // If we are in the login window, call a function to complete the process and don't do anything else here. - completeLoginWindow(); - return; - } gAction = document.getElementById("action"); gActionLabel = document.getElementById("actionlabel"); @@ -175,16 +170,6 @@ function prepareLoginButton(aCallback) { ); } -function completeLoginWindow() { - if (window.opener) { - window.opener.finishLogin(getParameterByName("code"), getParameterByName("state")); - window.close(); - } - else { - document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported."; - } -} - function finishLogin(aCode, aState) { if (aState == authData["state"]) { fetchBackend("login?code=" + aCode + "&state=" + aState + "&redirect_uri=" + encodeURIComponent(getRedirectURI()), "GET", null, @@ -729,11 +714,3 @@ function fetchBackend(aEndpoint, aMethod, aSendData, aCallback, aCallbackForward aCallback(e, 500, aCallbackForwards); } } - -function getParameterByName(aName) { - // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript - name = aName.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); -} diff --git a/login.html b/login.html index aa4656e..b406349 100644 --- a/login.html +++ b/login.html @@ -10,7 +10,7 @@ https://developer.mozilla.org/en/Mobile/Viewport_meta_tag --> Lantea Login - + diff --git a/manifest.appcache b/manifest.appcache index 67b8bc1..9ead495 100644 --- a/manifest.appcache +++ b/manifest.appcache @@ -1,12 +1,13 @@ CACHE MANIFEST -# 2017-10-23 +# 2017-11-10 index.html login.html manifest.webapp js/map.js js/ui.js js/library.js +js/loginwindow.js style/lantea.css style/loading.png style/loading_action.png