diff options
author | rstular <rok@stular.eu> | 2020-01-30 00:14:02 +0100 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-01-30 00:14:02 +0100 |
commit | 98688c884e754fcc239c0983fa373b37d067505f (patch) | |
tree | 0dbe257830cdb91de4c6ec785157af15627bdc09 /js | |
parent | Removed woff fonts (diff) | |
download | beziapp-98688c884e754fcc239c0983fa373b37d067505f.tar beziapp-98688c884e754fcc239c0983fa373b37d067505f.tar.gz beziapp-98688c884e754fcc239c0983fa373b37d067505f.tar.bz2 beziapp-98688c884e754fcc239c0983fa373b37d067505f.tar.lz beziapp-98688c884e754fcc239c0983fa373b37d067505f.tar.xz beziapp-98688c884e754fcc239c0983fa373b37d067505f.tar.zst beziapp-98688c884e754fcc239c0983fa373b37d067505f.zip |
Diffstat (limited to 'js')
-rw-r--r-- | js/grades.js | 21 |
1 files changed, 16 insertions, 5 deletions
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 }); |