summaryrefslogtreecommitdiffstats
path: root/js/grades.js
diff options
context:
space:
mode:
authorbeziapp <60441126+beziapp@users.noreply.github.com>2020-01-30 00:32:00 +0100
committerGitHub <noreply@github.com>2020-01-30 00:32:00 +0100
commit32a43c2ce04fd9b594cea615552d5181c9a72e44 (patch)
tree2dfd68b1701c8abbbcf1510a118389f84538ef97 /js/grades.js
parentMerge pull request #3 from beziapp/dev (diff)
parentWeekly calendar accent color (diff)
downloadbeziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.tar
beziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.tar.gz
beziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.tar.bz2
beziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.tar.lz
beziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.tar.xz
beziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.tar.zst
beziapp-32a43c2ce04fd9b594cea615552d5181c9a72e44.zip
Diffstat (limited to 'js/grades.js')
-rw-r--r--js/grades.js21
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 });