From b5e17275d72bd5cc692d8ecfafd5726c2b5867b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sun, 9 Feb 2020 00:48:40 +0100 Subject: some messaging fixes --- js/about.js | 2 +- 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(); }); - - }); -- cgit v1.2.3