diff options
-rw-r--r-- | js/about.js | 2 | ||||
-rw-r--r-- | js/messaging.js | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/js/about.js b/js/about.js index 836ffaf..8dd55ab 100644 --- a/js/about.js +++ b/js/about.js @@ -17,4 +17,4 @@ document.addEventListener("DOMContentLoaded", () => { // Setup side menu const menus = document.querySelectorAll(".side-menu"); M.Sidenav.init(menus, { edge: "right", draggable: true }); -});
\ No newline at end of file +}); diff --git a/js/messaging.js b/js/messaging.js index 0578a1a..44e027a 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -1,3 +1,16 @@ +async function checkLogin() { + localforage.getItem("logged_in").then(function (value) { + // This code runs once the value has been loaded + // from the offline store. + if (value !== true) { + window.location.replace("/index.html"); + } + }).catch(function (err) { + // This code runs if there were any errors + console.log(err); + }); +} + function htmlEncode(value){ // Create a in-memory element, set its inner text (which is automatically encoded) // Then grab the encoded contents back out. The element never exists on the DOM. @@ -263,8 +276,9 @@ function validateName() { console.log(err); }); } -var additionalstufftoaddtomessage; +var additionalstufftoaddtomessage = ""; document.addEventListener('DOMContentLoaded', function() { + checkLogin(); var elems = document.querySelectorAll('.autocomplete-fullname'); localforage.getItem('directory').then(function(value) { // vse editam v nanotu @@ -325,6 +339,4 @@ var additionalstufftoaddtomessage; } input.click(); }); - - }); |