From fefeee7ccf1b6fb6a133c8b9c5eb07b1760c2d94 Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 17 Feb 2020 15:15:55 +0100 Subject: Reformatting --- css/styles.css | 48 +++++ directory.json | 4 + index.html | 6 +- js/app.js | 12 +- js/initialize.js | 36 ++-- js/lib/xss.js | 1 - js/login.js | 19 +- js/messaging.js | 462 ++++++++++++++++++++++++++--------------------- js/timetable.js | 2 +- login.html | 5 +- logout.html | 6 +- pages/about.html | 11 +- pages/absences.html | 11 +- pages/changelog.html | 9 +- pages/grades.html | 11 +- pages/gradings.html | 11 +- pages/messaging.html | 101 ++++++----- pages/privacypolicy.html | 2 +- pages/teachers.html | 11 +- pages/timetable.html | 11 +- pages/tos.html | 2 +- sw.js | 194 ++++++++++---------- 22 files changed, 556 insertions(+), 419 deletions(-) create mode 100644 directory.json diff --git a/css/styles.css b/css/styles.css index 73c6be6..8ad12a0 100644 --- a/css/styles.css +++ b/css/styles.css @@ -3,6 +3,12 @@ --color-secondary: rgba(0, 77, 50, 1); --color-accent: rgba(0, 156, 101, 1); --color-primary-light: rgba(230, 250, 231, 1); + --color-invalid: rgba(192, 0, 0, 1); + --background-color: rgba(255, 255, 255, 1); +} + +body { + background: var(--background-color); } .title-primary { @@ -99,4 +105,46 @@ a.collection-item { -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; +} + +/* label focus color */ + +.input-field input[type=text]:focus+label { + color: var(--color-primary); +} + +/* label underline focus color */ + +.input-field input[type=text]:focus { + border-bottom: 1px solid var(--color-primary) !important; + box-shadow: 0 1px 0 0 var(--color-primary) !important; +} + +/* valid color */ + +.input-field input[type=text].valid { + border-bottom: 1px solid var(--color-secondary); + box-shadow: 0 1px 0 0 var(--color-secondary); +} + +/* invalid color */ + +.input-field input[type=text].invalid { + border-bottom: 1px solid var(--color-invalid); + box-shadow: 0 1px 0 0 var(--color-invalid); +} + +/* icon prefix focus color */ + +.input-field .prefix.active { + color: var(--color-primary); +} + +.input-field textarea:not([readonly]):focus+label { + color: var(--color-primary) !important; +} + +.input-field textarea:not([readonly]):focus { + border-bottom: 1px solid var(--color-primary) !important; + box-shadow: 0 1px 0 0 var(--color-primary) !important; } \ No newline at end of file diff --git a/directory.json b/directory.json new file mode 100644 index 0000000..6a50675 --- /dev/null +++ b/directory.json @@ -0,0 +1,4 @@ +{ + "Anton Luka Šijanec": 6326, + "Rok Štular": 5313 +} \ No newline at end of file diff --git a/index.html b/index.html index 5bf50e2..8b10888 100644 --- a/index.html +++ b/index.html @@ -9,10 +9,10 @@ - + - + @@ -23,4 +23,4 @@ - + \ No newline at end of file diff --git a/js/app.js b/js/app.js index eebb62d..98da025 100644 --- a/js/app.js +++ b/js/app.js @@ -5,12 +5,12 @@ if ("serviceWorker" in navigator) { } // Listen to messages from service workers. -if(navigator.serviceWorker) { -navigator.serviceWorker.addEventListener('message', (event) => { - if (event.data.msg === "install") { - window.location.replace("/index.html"); - } -}); +if (navigator.serviceWorker) { + navigator.serviceWorker.addEventListener('message', (event) => { + if (event.data.msg === "install") { + window.location.replace("/index.html"); + } + }); } if (location.protocol != 'https:') { diff --git a/js/initialize.js b/js/initialize.js index 2023921..ca29e2f 100644 --- a/js/initialize.js +++ b/js/initialize.js @@ -1,15 +1,13 @@ function getUrlParameter(sParam) { - var sPageURL = window.location.search.substring(1), - sURLVariables = sPageURL.split('&'), - sParameterName, - i; - for (i = 0; i < sURLVariables.length; i++) { - sParameterName = sURLVariables[i].split('='); - if (sParameterName[0] === sParam) { - return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); - } + const url_params = new URLSearchParams(window.location.search); + const found_param = url_params.get(sParam); + if (found_param === null) { + return "" + } else { + return found_param } -}; +} + function setupStorage() { promises_to_run = [ localforage.setItem("logged_in", false), @@ -21,7 +19,8 @@ function setupStorage() { localforage.setItem("gradings", []), localforage.setItem("grades", []), localforage.setItem("absences", {}), - localforage.setItem("messages", {}) + localforage.setItem("messages", {}), + localforage.setItem("directory", {}) ]; Promise.all(promises_to_run) @@ -36,15 +35,20 @@ localforage.getItem("logged_in") // This code runs once the value has been loaded // from the offline store. if (value === null) { + // Setup the storage if it doesn't exist setupStorage(); } else if (value === false) { + // If storage exists, but user isn't logged in, redirect to login window.location.replace("/login.html"); } else { - if(getUrlParameter("m")) { - window.location.replace("pages/messaging.html?"+getUrlParameter("m")); - } else { - window.location.replace("/pages/timetable.html"); - } + // User is logged in, execute appropriate action + + if (getUrlParameter("m") !== "") { + window.location.replace("/pages/messaging.html?m=" + getUrlParameter("m")); + } else { + window.location.replace("/pages/timetable.html"); + } + } } ).catch( diff --git a/js/lib/xss.js b/js/lib/xss.js index bddbdd8..e0a6ba0 100644 --- a/js/lib/xss.js +++ b/js/lib/xss.js @@ -1611,4 +1611,3 @@ module.exports = { }; },{}]},{},[2]); - diff --git a/js/login.js b/js/login.js index 6a68d98..aba0fa3 100644 --- a/js/login.js +++ b/js/login.js @@ -7,17 +7,18 @@ document.addEventListener("DOMContentLoaded", () => { function setupEventListeners() { // Setup login button listener - $("#login-button").click(function () { + $("#login-button").click(() => { login(); }); - window.addEventListener("keyup", function(event) { - // Number 13 is the "Enter" key on the keyboard - if (event.keyCode === 13) { - // Cancel the default action, if needed - event.preventDefault(); - login(); - } - }); + + window.addEventListener("keyup", (event) => { + // Number 13 is the "Enter" key on the keyboard + if (event.keyCode === 13) { + // Cancel the default action, if needed + event.preventDefault(); + login(); + } + }); } // Handle login button click diff --git a/js/messaging.js b/js/messaging.js index 42bbd0b..4004147 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -1,3 +1,10 @@ +const API_ENDPOINT = "https://gimb.tk/test.php"; +const DIRECTORY_URL = "/directory.json"; +// const API_ENDPOINT = "http://localhost:5000/test.php"; + +// "Global" object for name directory +var directory = null; + async function checkLogin() { localforage.getItem("logged_in").then(function (value) { // This code runs once the value has been loaded @@ -11,31 +18,72 @@ async function checkLogin() { }); } -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. - return $(' + + +
+ +
- -
-
- mode_edit - - -
-
- -
-
-
- +
+

Messages

- - - -
+ + + +
- - + \ No newline at end of file diff --git a/pages/privacypolicy.html b/pages/privacypolicy.html index 6ff7f56..d5a4b0c 100644 --- a/pages/privacypolicy.html +++ b/pages/privacypolicy.html @@ -67,4 +67,4 @@ - + \ No newline at end of file diff --git a/pages/teachers.html b/pages/teachers.html index 5f7fa8f..ee4f49c 100644 --- a/pages/teachers.html +++ b/pages/teachers.html @@ -50,11 +50,14 @@

BežiApp

-
  • view_moduleTimetable
  • +
  • view_moduleTimetable +
  • eventGradings
  • receiptGrades
  • -
  • supervisor_accountTeachers
  • -
  • query_builderAbsences
  • +
  • supervisor_accountTeachers
  • +
  • query_builderAbsences +
  • messageMessaging
  • fastfoodMeals
  • @@ -102,4 +105,4 @@ - + \ No newline at end of file diff --git a/pages/timetable.html b/pages/timetable.html index 19b5fa4..98110c1 100644 --- a/pages/timetable.html +++ b/pages/timetable.html @@ -59,11 +59,14 @@

    BežiApp

  • -
  • view_moduleTimetable
  • +
  • view_moduleTimetable +
  • eventGradings
  • receiptGrades
  • -
  • supervisor_accountTeachers
  • -
  • query_builderAbsences
  • +
  • supervisor_accountTeachers
  • +
  • query_builderAbsences +
  • messageMessaging
  • fastfoodMeals
  • @@ -106,4 +109,4 @@ - + \ No newline at end of file diff --git a/pages/tos.html b/pages/tos.html index 622fd1d..ed37acb 100644 --- a/pages/tos.html +++ b/pages/tos.html @@ -119,4 +119,4 @@ - + \ No newline at end of file diff --git a/sw.js b/sw.js index 027615f..7d64a88 100644 --- a/sw.js +++ b/sw.js @@ -1,85 +1,82 @@ // Change version to cause cache refresh const static_cache_name = "site-static-v1.0.9"; + +// Tukej ne met notr directory namov, samo imena fajlov, +// ker v primeru index.html to prpele do double-cachinga, oz. do velik 404 + // Got them with find . -not -path '*/\.*' | sed "s/.*/\"&\",/" | grep -v sw.js // sw.js NE SME BITI CACHAN, ker vsebuje verzijo! const assets = [ -".", -"./login.html", -"./logout.html", -"./css", -"./css/materialize.min.css", -"./css/fontawesome.min.css", -"./css/materialicons.css", -"./css/styles.css", -"./css/fullcalendar", -"./css/fullcalendar/custom.css", -"./css/fullcalendar/daygrid", -"./css/fullcalendar/daygrid/main.min.css", -"./css/fullcalendar/core", -"./css/fullcalendar/core/main.min.css", -"./css/fullcalendar/timegrid", -"./css/fullcalendar/timegrid/main.min.css", -"./favicon.png", -"./fonts", -"./fonts/fa-solid-900.eot", -"./fonts/fa-solid-900.woff2", -"./fonts/fa-brands-400.woff2", -"./fonts/fa-regular-400.eot", -"./fonts/fa-regular-400.woff2", -"./fonts/fa-brands-400.eot", -"./fonts/materialicons.woff2", -"./index.html", -"./img", -"./img/avatars", -"./img/avatars/asijanec.png", -"./img/avatars/rstular.png", -"./img/icons", -"./img/icons/icon_384.png", -"./img/icons/icon_192.png", -"./img/icons/icon_72.png", -"./img/icons/icon_144.png", -"./img/icons/icon_512.png", -"./img/icons/icon_96.png", -"./img/icons/icon_48.png", -"./js", -"./js/timetable.js", -"./js/gradings.js", -"./js/messaging.js", -"./js/privacypolicy.js", -"./js/teachers.js", -"./js/tos.js", -"./js/login.js", -"./js/app.js", -"./js/lib", -"./js/lib/materialize.min.js", -"./js/lib/jquery.min.js", -"./js/lib/localforage.min.js", -"./js/lib/xss.js", -"./js/lib/fullcalendar", -"./js/lib/fullcalendar/daygrid", -"./js/lib/fullcalendar/daygrid/main.min.js", -"./js/lib/fullcalendar/core", -"./js/lib/fullcalendar/core/main.min.js", -"./js/lib/fullcalendar/timegrid", -"./js/lib/fullcalendar/timegrid/main.min.js", -"./js/grades.js", -"./js/about.js", -"./js/logout.js", -"./js/initialize.js", -"./js/absences.js", -"./js/changelog.js", -"./manifest.json", -"./pages", -"./pages/timetable.html", -"./pages/teachers.html", -"./pages/absences.html", -"./pages/about.html", -"./pages/changelog.html", -"./pages/messaging.html", -"./pages/gradings.html", -"./pages/grades.html", -"./pages/privacypolicy.html", -"./pages/tos.html" + + + + "/css/materialize.min.css", + "/css/fontawesome.min.css", + "/css/materialicons.css", + "/css/styles.css", + "/css/fullcalendar/custom.css", + "/css/fullcalendar/daygrid/main.min.css", + "/css/fullcalendar/core/main.min.css", + "/css/fullcalendar/timegrid/main.min.css", + + "/fonts/fa-solid-900.eot", + "/fonts/fa-solid-900.woff2", + "/fonts/fa-brands-400.woff2", + "/fonts/fa-regular-400.eot", + "/fonts/fa-regular-400.woff2", + "/fonts/fa-brands-400.eot", + "/fonts/materialicons.woff2", + + "/img/avatars/asijanec.png", + "/img/avatars/rstular.png", + "/img/icons/icon_384.png", + "/img/icons/icon_192.png", + "/img/icons/icon_72.png", + "/img/icons/icon_144.png", + "/img/icons/icon_512.png", + "/img/icons/icon_96.png", + "/img/icons/icon_48.png", + + "/js/timetable.js", + "/js/gradings.js", + "/js/messaging.js", + "/js/privacypolicy.js", + "/js/teachers.js", + "/js/tos.js", + "/js/login.js", + "/js/app.js", + + "/js/lib/materialize.min.js", + "/js/lib/jquery.min.js", + "/js/lib/localforage.min.js", + "/js/lib/xss.js", + + "/js/lib/fullcalendar/daygrid/main.min.js", + "/js/lib/fullcalendar/core/main.min.js", + "/js/lib/fullcalendar/timegrid/main.min.js", + "/js/grades.js", + "/js/about.js", + "/js/logout.js", + "/js/initialize.js", + "/js/absences.js", + "/js/changelog.js", + + "/pages/timetable.html", + "/pages/teachers.html", + "/pages/absences.html", + "/pages/about.html", + "/pages/changelog.html", + "/pages/messaging.html", + "/pages/gradings.html", + "/pages/grades.html", + "/pages/privacypolicy.html", + "/pages/tos.html", + + "/manifest.json", + "/index.html", + "/login.html", + "/logout.html", + "/favicon.png" ]; importScripts("/js/lib/localforage.min.js"); @@ -109,28 +106,29 @@ self.addEventListener("activate", evt => { ); }); -self.addEventListener('message', event => { - if (event.data) { - let data = JSON.parse(event.data); // parse the message back to JSON - if (data.action == "addtocache") { // check the action - event.waitUntil( - caches.open(static_cache_name).then(function(cache) { - try { - return cache.add([data.url]); - } - catch(error) { - console.error("[sw.js] error: "+error); - } - }) - ); - } else if (data.action == "deletecaches") { - caches.keys().then(function(names) { - for (let name of names) - console.log("[sw.js] deleting cache named "+name); - caches.delete(name); - }); +self.addEventListener("message", event => { + + if (event.data) { + let data = JSON.parse(event.data); // parse the message back to JSON + if (data.action == "addtocache") { // check the action + event.waitUntil( + caches.open(static_cache_name).then(function (cache) { + try { + return cache.add([data.url]); + } + catch (error) { + console.error("[sw.js] error: " + error); + } + }) + ); + } else if (data.action == "deletecaches") { + caches.keys().then(function (names) { + for (let name of names) + console.log("[sw.js] deleting cache named " + name); + caches.delete(name); + }); + } } - } }); self.addEventListener("fetch", (evt) => { -- cgit v1.2.3