From 98688c884e754fcc239c0983fa373b37d067505f Mon Sep 17 00:00:00 2001 From: rstular Date: Thu, 30 Jan 2020 00:14:02 +0100 Subject: Temporary inclusion/exclusion option, fixed zoom --- js/grades.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/grades.js b/js/grades.js index 1768fb0..5c544fb 100644 --- a/js/grades.js +++ b/js/grades.js @@ -1,6 +1,8 @@ const API_ENDPOINT = "https://gimb.tk/test.php"; // const API_ENDPOINT = "http://localhost:5000/test.php"; +let checkbox_state = false; + async function checkLogin() { localforage.getItem("logged_in").then((value) => { // This code runs once the value has been loaded @@ -167,8 +169,8 @@ function displayGrades() { grade_node.appendChild(grade_node_div); - // Count the grade only if it's not temprary - if (!grade["temporary"]) { + // Count the grade only if it's not temporary or explicitly enabled + if (!grade["temporary"] || !checkbox_state) { grade_sum += grade["grade"]; grade_tot += 1; } @@ -205,9 +207,9 @@ function clearGrades() { } } -function refreshGrades() { +function refreshGrades(force) { clearGrades(); - loadGrades(true); + loadGrades(force); } function refreshClickHandlers() { @@ -252,9 +254,18 @@ document.addEventListener("DOMContentLoaded", async () => { // Setup refresh handler $("#refresh-icon").click(function () { - refreshGrades(); + refreshGrades(true); + }); + + // Setup checkbox handler + $("#permanent-grades-checkbox").change(function () { + checkbox_state = this.checked; + refreshGrades(false); }); + let elems = document.querySelectorAll('.modal'); + let instances = M.Modal.init(elems, {}); + // Setup side menu const menus = document.querySelectorAll('.side-menu'); M.Sidenav.init(menus, { edge: 'right', draggable: true }); -- cgit v1.2.3 From e32fb47304ab8b4aa21f11ec42f454077276dfcc Mon Sep 17 00:00:00 2001 From: rstular Date: Thu, 30 Jan 2020 00:14:29 +0100 Subject: Added changelog --- js/changelog.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 js/changelog.js (limited to 'js') diff --git a/js/changelog.js b/js/changelog.js new file mode 100644 index 0000000..9fb9a84 --- /dev/null +++ b/js/changelog.js @@ -0,0 +1,24 @@ +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); + }); +} + +document.addEventListener("DOMContentLoaded", () => { + checkLogin(); + + // Setup back button + $("#nav-back-button").click(function () { + window.location.replace("/pages/about.html"); + }); + + var elems = document.querySelectorAll(".collapsible"); + var instances = M.Collapsible.init(elems, {}); +}); \ No newline at end of file -- cgit v1.2.3