Merge branch 'master' of linz:/srv/git/lantea
authorRobert Kaiser <kairo@kairo.at>
Mon, 20 Nov 2017 18:26:17 +0000 (19:26 +0100)
committerRobert Kaiser <kairo@kairo.at>
Mon, 20 Nov 2017 18:26:17 +0000 (19:26 +0100)
js/loginwindow.js [new file with mode: 0644]
js/ui.js
login.html
manifest.appcache

diff --git a/js/loginwindow.js b/js/loginwindow.js
new file mode 100644 (file)
index 0000000..94cd6c2
--- /dev/null
@@ -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, " "));
+}
index 263a139387e3ff37a45b43e290cca2cbced159e0..60abf40a4b42793f331645f98e9adbc04a6193c0 100644 (file)
--- 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, " "));
-}
index aa4656e593c469d80766795ba4fee70df9a56ea8..b4063494af8c3424497491f250f9377de3f8ee9b 100644 (file)
@@ -10,7 +10,7 @@
        https://developer.mozilla.org/en/Mobile/Viewport_meta_tag -->
   <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, user-scalable=no">
   <title>Lantea Login</title>
-  <script src="js/ui.js"></script>
+  <script src="js/loginwindow.js"></script>
   <script src="js/piwik.js" async="" defer=""></script>
   <link rel="stylesheet" href="style/lantea.css">
   <link rel="shortcut icon" href="style/lanteaIcon16.png" type="image/png">
index 67b8bc195f8b1b3e55ef01bf742b164e8abac139..9ead49518d98aff31502e1830085eb5cf7fd119e 100644 (file)
@@ -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