From a8cffc9c334e02ca962f615cc28c66634bea06aa Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 1 Jun 2020 20:05:54 +0200 Subject: Added UI for user-defined gradings --- assets/js/lang/bundle.js | 2 ++ assets/pages-src/gradings.bvr | 38 ++++++--------------------- assets/pages-src/misc/grading-add-modal.bvr | 40 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 assets/pages-src/misc/grading-add-modal.bvr (limited to 'assets') diff --git a/assets/js/lang/bundle.js b/assets/js/lang/bundle.js index 8270527..2cd78bc 100644 --- a/assets/js/lang/bundle.js +++ b/assets/js/lang/bundle.js @@ -159,6 +159,7 @@ var langstrings = { noPeriods: "no periods in selected week", // gradings requestFailed: "request failed", + addGrading: "add grading", noInternetConnection: "no internet connection", // grades temporary: "temporary", @@ -360,6 +361,7 @@ var langstrings = { settings: "nastavitve", // gradings requestFailed: "zahteva spodletela", + addGrading: "dodaj ocenjevanje", noInternetConnection: "ni povezave s spletom", // grades temporary: "začasno", diff --git a/assets/pages-src/gradings.bvr b/assets/pages-src/gradings.bvr index 672b8a2..109296b 100644 --- a/assets/pages-src/gradings.bvr +++ b/assets/pages-src/gradings.bvr @@ -75,37 +75,15 @@
- + +
+ + add + +
+ <@?i grading-add-modal@> + diff --git a/assets/pages-src/misc/grading-add-modal.bvr b/assets/pages-src/misc/grading-add-modal.bvr new file mode 100644 index 0000000..eb5f3b7 --- /dev/null +++ b/assets/pages-src/misc/grading-add-modal.bvr @@ -0,0 +1,40 @@ + + + -- cgit v1.2.3 From aebac8bcd0e946f1e7283d8e280e301d52b8d64b Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 1 Jun 2020 20:14:59 +0200 Subject: gsec bug fix - regex may return null --- assets/js/gsec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'assets') diff --git a/assets/js/gsec.js b/assets/js/gsec.js index 19e190f..5632949 100644 --- a/assets/js/gsec.js +++ b/assets/js/gsec.js @@ -273,8 +273,10 @@ class gsec { } rowSpan.remove(); // magic - var subject = SUBJECT_REGEX.exec(subFields[1].innerHTML)[1].trim(); - var desc = DESC_REGEX.exec(subFields[1].innerHTML)[1]; + var subject = SUBJECT_REGEX.exec(subFields[1].innerHTML) + subject = subject == null ? "" : subject[1].trim(); + var desc = DESC_REGEX.exec(subFields[1].innerHTML); + desc = desc == null ? "" : desc[1]; gradings.push({ "date": dateObj, @@ -529,7 +531,7 @@ class gsec { "__EVENTARGUMENT": "Select$" + selectId }; - this.postback(GSE_URL+"Page_Gim/Uporabnik/Sporocila.aspx", dataToBeSent, null, true).then((response) => { + this.postback(GSE_URL + "Page_Gim/Uporabnik/Sporocila.aspx", dataToBeSent, null, true).then((response) => { let parser = new DOMParser(); let parsed = parser.parseFromString(response.data, "text/html"); let subject = parsed.getElementsByClassName("msgSubjectS")[0].innerHTML.trim(); -- cgit v1.2.3 From 578e093077032d6f17abb619a2471c9a4490db79 Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 1 Jun 2020 20:27:31 +0200 Subject: gsec bug fix (subject must not be null), UI fix --- assets/js/gradings.js | 18 ++++++++++++++---- assets/js/gsec.js | 13 +++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'assets') diff --git a/assets/js/gradings.js b/assets/js/gradings.js index b5bf7b5..a852337 100644 --- a/assets/js/gradings.js +++ b/assets/js/gradings.js @@ -143,7 +143,7 @@ function gradingClickHandler(eventClickInfo) { const modal = document.querySelectorAll(".side-modal")[0]; M.Sidenav.getInstance(modal).open(); } -/* + function setupPickers() { // Setup pickers, todo (adding an event), to be stored in messages var date_object = new Date(); @@ -155,10 +155,9 @@ function gradingClickHandler(eventClickInfo) { setDefaultDate: true, firstDay: 1 } - let instances = M.Datepicker.init(elems, options); instances = M.Datepicker.init(elems, options); } -*/ + document.addEventListener("DOMContentLoaded", () => { checkLogin(); @@ -175,7 +174,18 @@ document.addEventListener("DOMContentLoaded", () => { height: "parent" }); calendar_obj.render(); - // setupPickers(); // todo (adding an event), to be stored in messages + + // Modal for adding gradings + setupPickers(); // todo (adding an event), to be stored in messages + // Setup modals + const modal_elems = document.querySelectorAll('.modal'); + const modal_options = { + onOpenStart: () => { $("#fab-new").hide() }, + onCloseEnd: () => { $("#fab-new").show() }, + dismissible: false + }; + M.Modal.init(modal_elems, modal_options); + loadGradings(true); // Setup refresh handler $("#refresh-icon").click(() => { diff --git a/assets/js/gsec.js b/assets/js/gsec.js index 5632949..96ea624 100644 --- a/assets/js/gsec.js +++ b/assets/js/gsec.js @@ -273,8 +273,13 @@ class gsec { } rowSpan.remove(); // magic - var subject = SUBJECT_REGEX.exec(subFields[1].innerHTML) - subject = subject == null ? "" : subject[1].trim(); + + var subject = SUBJECT_REGEX.exec(subFields[1].innerHTML); + if (subject == null) { + continue; + } + subject = subject[1].trim(); + var desc = DESC_REGEX.exec(subFields[1].innerHTML); desc = desc == null ? "" : desc[1]; @@ -614,9 +619,9 @@ class gsec { } var tume = messageElement.getElementsByClassName("msgSubDate")[0].innerHTML.split(" ")[1]; - if(tume == null || tume.length < 1) { + if (tume == null || tume.length === 0) { tume = messageElement.getElementsByClassName("msgSubDate")[0].innerHTML; - } + } var dateStringToParse = `${date[2]}-${date[1]}-${date[0]} ${tume}`; var dateObj = new Date(Date.parse(dateStringToParse)); // "tume"! var person = messageElement.getElementsByClassName("msgDir")[0].innerHTML; -- cgit v1.2.3 From 35b595f806f99ca18365d511ab820ab818da348d Mon Sep 17 00:00:00 2001 From: rstular Date: Mon, 1 Jun 2020 20:49:56 +0200 Subject: WIP - Grading UI changes, minor translation changes --- assets/js/gradings.js | 42 +++++++++++++++++++---------- assets/js/lang/bundle.js | 16 ++++++++--- assets/pages-src/misc/grading-add-modal.bvr | 23 +++++++--------- assets/pages-src/misc/msg-compose-modal.bvr | 4 +-- 4 files changed, 51 insertions(+), 34 deletions(-) (limited to 'assets') diff --git a/assets/js/gradings.js b/assets/js/gradings.js index a852337..bd664bb 100644 --- a/assets/js/gradings.js +++ b/assets/js/gradings.js @@ -131,6 +131,18 @@ function displayData() { calendar_obj.addEventSource(transformed_gradings); } +async function validateInputs() { + if ($("#input-grading-name").val() != null && $("#input-grading-name").val().length > 0) { + $("#btn-add-grading").removeAttr("disabled"); + $("#input-grading-name").addClass("valid"); + $("#input-grading-name").removeClass("invalid"); + } else { + $("#btn-add-grading").attr("disabled", "disabled"); + $("#input-grading-name").addClass("invalid"); + $("#input-grading-name").removeClass("valid"); + } +} + function gradingClickHandler(eventClickInfo) { let grading_id = parseInt(eventClickInfo.event.id); let grading_subject = gradings[grading_id]["subject"]; @@ -144,19 +156,19 @@ function gradingClickHandler(eventClickInfo) { M.Sidenav.getInstance(modal).open(); } - function setupPickers() { - // Setup pickers, todo (adding an event), to be stored in messages - var date_object = new Date(); - let elems = document.querySelectorAll('#datepicker-add'); - let options = { - autoClose: true, - format: "dd.mm.yyyy", - defaultDate: date_object, - setDefaultDate: true, - firstDay: 1 - } - instances = M.Datepicker.init(elems, options); +function setupPickers() { + // Setup pickers, todo (adding an event), to be stored in messages + var date_object = new Date(); + let elems = document.querySelectorAll('#datepicker-add'); + let options = { + autoClose: true, + format: "dd.mm.yyyy", + defaultDate: date_object, + setDefaultDate: true, + firstDay: 1 } + instances = M.Datepicker.init(elems, options); +} document.addEventListener("DOMContentLoaded", () => { @@ -176,14 +188,16 @@ document.addEventListener("DOMContentLoaded", () => { calendar_obj.render(); // Modal for adding gradings - setupPickers(); // todo (adding an event), to be stored in messages + setupPickers(); // TODO: Hook up submit logic // Setup modals const modal_elems = document.querySelectorAll('.modal'); const modal_options = { onOpenStart: () => { $("#fab-new").hide() }, onCloseEnd: () => { $("#fab-new").show() }, dismissible: false - }; + }; + $("#input-grading-name").on("blur", validateInputs); + $("#input-grading-description").on("blur", validateInputs); M.Modal.init(modal_elems, modal_options); loadGradings(true); diff --git a/assets/js/lang/bundle.js b/assets/js/lang/bundle.js index 2cd78bc..49e64ac 100644 --- a/assets/js/lang/bundle.js +++ b/assets/js/lang/bundle.js @@ -10,7 +10,7 @@ var dateString = { return mesecileta[mesl]; }, longFormatted: (dateObject) => { - return dateString.day(dateObject.getDay())+", "+(dateObject.getDate())+". "+dateString.month(dateObject.getMonth())+" "+dateObject.getFullYear(); + return `${dateString.day(dateObject.getDay())}, ${(dateObject.getDate())}. ${dateString.month(dateObject.getMonth())} ${dateObject.getFullYear()}`; } }; async function refreshLangDOM() { @@ -143,7 +143,7 @@ var langstrings = { and: "and", thePrivacyPolicy: "the privacy policy", loginFailed: "login failed", - browserNotSupported: "bežiapp won't work on your device, unless you update your Internet browser", + browserNotSupported: "bežiapp won't work on your device, unless you update your Internet browser", // index timetable: "timetable", gradings: "gradings", @@ -158,6 +158,9 @@ var langstrings = { // timetable noPeriods: "no periods in selected week", // gradings + date: "date", + description: "description", + add: "add", requestFailed: "request failed", addGrading: "add grading", noInternetConnection: "no internet connection", @@ -187,6 +190,7 @@ var langstrings = { // messaging loadingMessages: "Loading messages...", sendAMessage: "send a message", + send: "send", recipient: "recipient", messageSubject: "subject", messageBody: "message body", @@ -227,7 +231,7 @@ var langstrings = { recipientNotInDirectory: "recipient is not in directory.", chatExternalInfo: "you have just received a chat. Chats are not supported by GimSIS, so you must reply by changing the subject to something else. Chat body: ", // meals - loginError: "login error", + loginError: "login error", loginToLopolis: "login to Lopolis", loginToLopolisNote: "it seems like you're not currently logged in to eRestavracija, so this form has been presented to you. You have a different username and password combination used for applying and opting out of of menus. In order to use this feature, you have to log in with your Lopolis account.", logInToLopolis: "log in to Lopolis", @@ -360,6 +364,9 @@ var langstrings = { logout: "odjava", settings: "nastavitve", // gradings + date: "datum", + description: "opis", + add: "dodaj", requestFailed: "zahteva spodletela", addGrading: "dodaj ocenjevanje", noInternetConnection: "ni povezave s spletom", @@ -378,7 +385,7 @@ var langstrings = { // absences from: "od", to: "do", - cancel: "preklic", + cancel: "prekliči", ok: "v redu", noAbsences: "ni izostankov v izbranem časovnem obdobju", lesson: "ura", @@ -389,6 +396,7 @@ var langstrings = { // messaging loadingMessages: "Nalagam sporočila...", sendAMessage: "pošlji sporočilo", + send: "pošlji", recipient: "prejemnik", messageSubject: "zadeva", messageBody: "telo", diff --git a/assets/pages-src/misc/grading-add-modal.bvr b/assets/pages-src/misc/grading-add-modal.bvr index eb5f3b7..0b7189d 100644 --- a/assets/pages-src/misc/grading-add-modal.bvr +++ b/assets/pages-src/misc/grading-add-modal.bvr @@ -6,25 +6,20 @@

addGrading

-
+
- +
-
- - -
-
- +
+ +
- - + +
@@ -32,8 +27,8 @@
diff --git a/assets/pages-src/misc/msg-compose-modal.bvr b/assets/pages-src/misc/msg-compose-modal.bvr index 5889214..48afaaf 100644 --- a/assets/pages-src/misc/msg-compose-modal.bvr +++ b/assets/pages-src/misc/msg-compose-modal.bvr @@ -57,8 +57,8 @@
-- cgit v1.2.3 From 569d9d8e239e76dcf961855ce6d8ced3b1175d56 Mon Sep 17 00:00:00 2001 From: rstular Date: Tue, 2 Jun 2020 17:05:09 +0200 Subject: Add .well-known to GH pages --- assets/root/_config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 assets/root/_config.yml (limited to 'assets') diff --git a/assets/root/_config.yml b/assets/root/_config.yml new file mode 100644 index 0000000..68730c9 --- /dev/null +++ b/assets/root/_config.yml @@ -0,0 +1 @@ +include: [".well-known"] -- cgit v1.2.3 From 2d3512096eafba380a7d4ad8498e839f35c45717 Mon Sep 17 00:00:00 2001 From: sijanec Date: Wed, 3 Jun 2020 20:26:36 +0200 Subject: =?UTF-8?q?slovni=C4=8Dna=20napaka,=20datatype=20messages=20storag?= =?UTF-8?q?e=20fix,=20message=20card=20css=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/css/styles.css | 4 ++++ assets/js/lang/bundle.js | 2 +- assets/js/setup-storage.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'assets') diff --git a/assets/css/styles.css b/assets/css/styles.css index 4e6050b..ba3d5cb 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -417,3 +417,7 @@ p { h1, h2, h3, h4, h5, h6 { color: var(--color-text) !important; } + +.card { + background-color: var(--background-accent) !important; +} diff --git a/assets/js/lang/bundle.js b/assets/js/lang/bundle.js index 49e64ac..eeee695 100644 --- a/assets/js/lang/bundle.js +++ b/assets/js/lang/bundle.js @@ -509,7 +509,7 @@ var langstrings = { on: "vklopljeno", off: "izklopljeno", selectErrorReporting: "ali naj so napake v aplikaciji posredovane razvijalcem?", - triggerWarning: "spodnji gumb omogoči dodatne možnosti, ki lahko razburijo/vznevoljijo nekatere uporabnike. Če omogočite stikalo se strinjate, da avtorjev in/ali njihovih osebnih prepričanj ne boste povezovali s katerokoli od dodatnih omogočenih možnosti.", + triggerWarning: "spodnji gumb omogoči dodatne možnosti, ki lahko razburijo/vznevoljijo nekatere uporabnike. Če omogočite stikalo, se strinjate, da avtorjev in/ali njihovih osebnih prepričanj ne boste povezovali s katerokoli od dodatnih omogočenih možnosti", triggerAgreement: "strinjam se z zgoraj navedenimi pogoji", triggerWarningSet: "spremenili ste stanje dodatnih nastavitev", additionalOptions: "dodatne nastavitve", diff --git a/assets/js/setup-storage.js b/assets/js/setup-storage.js index 0d2552a..c862d5f 100644 --- a/assets/js/setup-storage.js +++ b/assets/js/setup-storage.js @@ -15,7 +15,7 @@ async function setupStorage(force = false) { localforage.setItem("gradings", []), localforage.setItem("grades", []), localforage.setItem("absences", {}), - localforage.setItem("messages", { "0": [], "1": [], "2": []}), // see messages.js:129, commit 8eb9ca9caca30fbbe023243657535ab4088be377 + localforage.setItem("messages", [[], [], []]), // see messages.js:129, commit 8eb9ca9caca30fbbe023243657535ab4088be377 localforage.setItem("directory", {}), //\\ well I could remember my own code but I didn't. localforage.setItem("meals", {}), localforage.setItem("chosenLang", "en"), -- cgit v1.2.3 From 4501c407bab73552c846df236a6c361a2e1b88a8 Mon Sep 17 00:00:00 2001 From: sijanec Date: Thu, 4 Jun 2020 14:42:13 +0200 Subject: this MAY fix the grades problem; not tested yet, DNM --- assets/css/styles.css | 4 +++ assets/js/grades.js | 16 ++++++++--- assets/js/gsec.js | 74 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 60 insertions(+), 34 deletions(-) (limited to 'assets') diff --git a/assets/css/styles.css b/assets/css/styles.css index ba3d5cb..3f403e7 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -421,3 +421,7 @@ h1, h2, h3, h4, h5, h6 { .card { background-color: var(--background-accent) !important; } + +.zakljucna-grade { + color: red; +} \ No newline at end of file diff --git a/assets/js/grades.js b/assets/js/grades.js index aff62e4..480a82a 100644 --- a/assets/js/grades.js +++ b/assets/js/grades.js @@ -68,8 +68,13 @@ async function loadGrades(force_refresh = false) { } function displayGrades() { - let grades_by_subject = {}; + let grades_by_subject = {}; + let zakljucne_grades_by_subject = {}; grades.forEach((grade, index) => { + if(grade["gradeType"] != GSEC_NORMAL_GRADE) { + zakljucne_grades_by_subject[grade["subject"]] = grade["grade"]; + break; // gfuck + } if (!(grade["subject"] in grades_by_subject)) { grades_by_subject[grade["subject"]] = []; } @@ -149,8 +154,13 @@ function displayGrades() { }); let grade_average = (grade_tot === 0) ? "N/A" : (Math.round(((grade_sum / grade_tot) + Number.EPSILON) * 100) / 100); let subject_header_average = document.createElement("div"); - subject_header_average.className = "collapsible-header-right"; - subject_header_average.innerText = grade_average.toString(); + subject_header_average.className = "collapsible-header-right"; + if(subject in zakljucne_grades_by_subject) { + subject_header_average.innerText = zakljucne_grades_by_subject[subject]; + subject_header_average.classList.add = "zakljucna-grade"; + } else { + subject_header_average.innerText = grade_average.toString(); + } subject_header.appendChild(subject_header_text); subject_header.appendChild(subject_header_average); subject_body.append(subject_body_root); diff --git a/assets/js/gsec.js b/assets/js/gsec.js index 96ea624..6cef90e 100644 --- a/assets/js/gsec.js +++ b/assets/js/gsec.js @@ -28,6 +28,8 @@ const GSEC_MSGTYPE_DELETED = 2; const GSEC_ERR_LOGIN = "GSEC LOGIN ERROR"; const GSEC_NO_ABSENCES = "noAbsences"; const GSEC_MSGTYPES = ["msgReceived", "msgSent", "msgDeleted"]; +const GSEC_NORMAL_GRADE = "GSEC NORMAL GRADE"; +const GSEC_ZAKLJUCNA_GRADE = "GSEC ZAKLJUCNA GRADE"; class gsec { @@ -480,39 +482,49 @@ class gsec { let gradeSpans = parsed.getElementsByClassName("txtVOcObd"); for (const grade of gradeSpans) { var ist = grade.getElementsByTagName("span")[0].getAttribute("title").split("\n"); - var date = ist[0].split(": ")[1].trim().split("."); - var dateObj = new Date(Date.parse(`${date[2]}-${date[1]}-${date[0]}`)); - var teacher = ist[1].split(": ")[1].trim(); - var subject = ist[2].split(": ")[1].trim(); - var name = []; - - name.push(ist[3].split(": ")[1].trim()) - name.push(ist[4].split(": ")[1].trim()) - name.push(ist[5].split(": ")[1].trim()) - - var gradeNumber = Number(grade.getElementsByTagName("span")[0].innerHTML); - var temporary = grade.getElementsByTagName("span")[0].classList.contains("ocVmesna"); - - var gradeToAdd = { - "date": dateObj, - "teacher": teacher, - "subject": subject, - "name": name, - "temporary": temporary, - "grade": gradeNumber - }; - - if (grade.getElementsByTagName("span").length > 1) { - if(grade.getElementsByTagName("span")[1].classList.contains("ocVmesna")) { - gradeToAdd["temporary"] = true; - } else { - gradeToAdd["temporary"] = false; + if (ist.length == 1) { // that means the txtVOcObd defines a zaključno oceno // gimsis is just utter crap + var gradeToAdd = { + "gradeType": GSEC_ZAKLJUCNA_GRADE, + "grade": Number(grade.getElementsByTagName("span")[0].innerHTML), + "subject": grade.parentElement.parentElement.parentElement.parentElement. + getElementsByTagName("th")[0].innerText // I fucking hope this works } - gradeToAdd["grade"] = Number(grade.getElementsByTagName("span")[1].innerHTML); - gradeToAdd["oldgrade"] = Number(grade.getElementsByTagName("span")[0].innerHTML); + grades.push(gradeToAdd); + } else { + var date = ist[0].split(": ")[1].trim().split("."); + var dateObj = new Date(Date.parse(`${date[2]}-${date[1]}-${date[0]}`)); + var teacher = ist[1].split(": ")[1].trim(); + var subject = ist[2].split(": ")[1].trim(); + var name = []; + + name.push(ist[3].split(": ")[1].trim()) + name.push(ist[4].split(": ")[1].trim()) + name.push(ist[5].split(": ")[1].trim()) + + var gradeNumber = Number(grade.getElementsByTagName("span")[0].innerHTML); + var temporary = grade.getElementsByTagName("span")[0].classList.contains("ocVmesna"); + + var gradeToAdd = { + "gradeType": GSEC_NORMAL_GRADE, // well said I must say + "date": dateObj, + "teacher": teacher, + "subject": subject, + "name": name, + "temporary": temporary, + "grade": gradeNumber + }; + + if (grade.getElementsByTagName("span").length > 1) { + if(grade.getElementsByTagName("span")[1].classList.contains("ocVmesna")) { + gradeToAdd["temporary"] = true; + } else { + gradeToAdd["temporary"] = false; + } + gradeToAdd["grade"] = Number(grade.getElementsByTagName("span")[1].innerHTML); + gradeToAdd["oldgrade"] = Number(grade.getElementsByTagName("span")[0].innerHTML); + } + grades.push(gradeToAdd); } - grades.push(gradeToAdd); - } resolve(grades); }, -- cgit v1.2.3 From 17094323e955995d18341d572636c959609280ac Mon Sep 17 00:00:00 2001 From: sijanec Date: Thu, 4 Jun 2020 14:51:19 +0200 Subject: appareantly some fucking js engineer figured out it'd be a good idea not to have breaks in forEach --- assets/js/grades.js | 433 ++++++++++++++++++++++++++-------------------------- 1 file changed, 216 insertions(+), 217 deletions(-) (limited to 'assets') diff --git a/assets/js/grades.js b/assets/js/grades.js index 480a82a..8e04c2b 100644 --- a/assets/js/grades.js +++ b/assets/js/grades.js @@ -2,244 +2,243 @@ let checkbox_state = false; var grades; async function checkLogin() { - localforage.getItem("logged_in").then((value) => { - // This code runs once the value has been loaded - // from the offline store. - if (value !== true) { - window.location.replace("/index.html"); - } - }).catch((err) => { - // This code runs if there were any errors - console.log(err); - }); + localforage.getItem("logged_in").then((value) => { + // This code runs once the value has been loaded + // from the offline store. + if (value !== true) { + window.location.replace("/index.html"); + } + }).catch((err) => { + // This code runs if there were any errors + console.log(err); + }); } // Set loading bar visibility function setLoading(state) { - if (state) { - $("#loading-bar").removeClass("hidden"); - } else { - $("#loading-bar").addClass("hidden"); - } + if (state) { + $("#loading-bar").removeClass("hidden"); + } else { + $("#loading-bar").addClass("hidden"); + } } async function loadGrades(force_refresh = false) { - setLoading(true); - let promises_to_run = [ - localforage.getItem("username").then((value) => { - username = value; - }), - localforage.getItem("password").then((value) => { - password = value; - }), - localforage.getItem("grades").then((value) => { - grades = value; - }) - ]; - await Promise.all(promises_to_run); - // If we don't have a list of grades, fetch it - if (grades == null || grades == [] || force_refresh) { - try { - - let gsecInstance = new gsec(); - await gsecInstance.login(username, password); - - gsecInstance.fetchGrades().then( (value) => { - grades = value; - localforage.setItem("grades", value).then(() => { - displayGrades(); - setLoading(false); - }); - setLoading(false); - }).catch( (err) => { - gsecErrorHandlerUI(err); - setLoading(false); - }); - - } catch (err) { - gsecErrorHandlerUI(err); - setLoading(false); - } - - } else { - displayGrades(); - setLoading(false); - } + setLoading(true); + let promises_to_run = [ + localforage.getItem("username").then((value) => { + username = value; + }), + localforage.getItem("password").then((value) => { + password = value; + }), + localforage.getItem("grades").then((value) => { + grades = value; + }) + ]; + await Promise.all(promises_to_run); + // If we don't have a list of grades, fetch it + if (grades == null || grades == [] || force_refresh) { + try { + + let gsecInstance = new gsec(); + await gsecInstance.login(username, password); + + gsecInstance.fetchGrades().then((value) => { + grades = value; + localforage.setItem("grades", value).then(() => { + displayGrades(); + setLoading(false); + }); + setLoading(false); + }).catch((err) => { + gsecErrorHandlerUI(err); + setLoading(false); + }); + + } catch (err) { + gsecErrorHandlerUI(err); + setLoading(false); + } + + } else { + displayGrades(); + setLoading(false); + } } function displayGrades() { - let grades_by_subject = {}; - let zakljucne_grades_by_subject = {}; - grades.forEach((grade, index) => { - if(grade["gradeType"] != GSEC_NORMAL_GRADE) { - zakljucne_grades_by_subject[grade["subject"]] = grade["grade"]; - break; // gfuck - } - if (!(grade["subject"] in grades_by_subject)) { - grades_by_subject[grade["subject"]] = []; - } - - let grade_object = { - date: dateString.longFormatted(grade["date"]), - teacher: grade["teacher"], - subject: grade["subject"], - title: grade["name"][0], - type: grade["name"][1], - term: grade["name"][2], - grade: grade["grade"], - temporary: grade["temporary"], - index: index - } - grades_by_subject[grade["subject"]].push(grade_object); - - }); - - let root_element = document.getElementById("grades-collapsible"); - Object.keys(grades_by_subject).forEach((subject) => { - // Create root element for a subject entry - let subject_entry = document.createElement("li"); - // Create subject collapsible header - let subject_header = document.createElement("div"); - subject_header.classList.add("collapsible-header"); - subject_header.classList.add("collapsible-header-root"); - // Create header text element - let subject_header_text = document.createElement("span"); - subject_header_text.innerText = subject; - // Create collection for displaying individuals grades - let subject_body = document.createElement("div"); - subject_body.className = "collapsible-body"; - let subject_body_root = document.createElement("ul"); - subject_body_root.className = "collection"; - // Setup variables for calculating average - let grade_sum = 0; - let grade_tot = 0; - grades_by_subject[subject].forEach((grade) => { - // Create element for individual grade - let grade_node = document.createElement("li"); - grade_node.className = "collection-item"; - grade_node.classList.add("collection-item") - grade_node.classList.add("grade-node"); - grade_node.dataset["index"] = grade["index"]; - let grade_node_div = document.createElement("div"); - // Node for date and subject text - let grade_text = document.createElement("span"); - // Node for the actual number - let grade_number = document.createElement("div"); - grade_number.className = "secondary-content"; - // Apply different style, if the grade is temporary - if (grade["temporary"]) { - // Styling for text - let grade_text_italic = document.createElement("i"); - grade_text_italic.innerText = grade["date"] + " - " + grade["title"]; - grade_text.appendChild(grade_text_italic); - // Styling for number - let grade_number_italic = document.createElement("i"); - grade_number_italic.innerText = grade["grade"].toString(); - grade_number.appendChild(grade_number_italic); - } else { - // Text - grade_text.innerText = grade["date"] + " - " + grade["title"]; - // Number - grade_number.innerText = grade["grade"].toString(); - } - grade_node_div.appendChild(grade_text); - grade_node_div.appendChild(grade_number); - grade_node.appendChild(grade_node_div); - // Count the grade only if it's not temporary or explicitly enabled - if (!grade["temporary"] || !checkbox_state) { - grade_sum += grade["grade"]; - grade_tot += 1; - } - subject_body_root.appendChild(grade_node); - }); - let grade_average = (grade_tot === 0) ? "N/A" : (Math.round(((grade_sum / grade_tot) + Number.EPSILON) * 100) / 100); - let subject_header_average = document.createElement("div"); - subject_header_average.className = "collapsible-header-right"; - if(subject in zakljucne_grades_by_subject) { - subject_header_average.innerText = zakljucne_grades_by_subject[subject]; - subject_header_average.classList.add = "zakljucna-grade"; - } else { - subject_header_average.innerText = grade_average.toString(); - } - subject_header.appendChild(subject_header_text); - subject_header.appendChild(subject_header_average); - subject_body.append(subject_body_root); - subject_entry.append(subject_header); - subject_entry.append(subject_body); - root_element.append(subject_entry); - }); - $("#grades-collapsible").append(root_element); - refreshClickHandlers(); + let grades_by_subject = {}; + let zakljucne_grades_by_subject = {}; + grades.forEach((grade, index) => { + if (grade["gradeType"] != GSEC_NORMAL_GRADE) { + zakljucne_grades_by_subject[grade["subject"]] = grade["grade"]; + } else { + if (!(grade["subject"] in grades_by_subject)) { + grades_by_subject[grade["subject"]] = []; + } + + let grade_object = { + date: dateString.longFormatted(grade["date"]), + teacher: grade["teacher"], + subject: grade["subject"], + title: grade["name"][0], + type: grade["name"][1], + term: grade["name"][2], + grade: grade["grade"], + temporary: grade["temporary"], + index: index + } + grades_by_subject[grade["subject"]].push(grade_object); + } + }); + + let root_element = document.getElementById("grades-collapsible"); + Object.keys(grades_by_subject).forEach((subject) => { + // Create root element for a subject entry + let subject_entry = document.createElement("li"); + // Create subject collapsible header + let subject_header = document.createElement("div"); + subject_header.classList.add("collapsible-header"); + subject_header.classList.add("collapsible-header-root"); + // Create header text element + let subject_header_text = document.createElement("span"); + subject_header_text.innerText = subject; + // Create collection for displaying individuals grades + let subject_body = document.createElement("div"); + subject_body.className = "collapsible-body"; + let subject_body_root = document.createElement("ul"); + subject_body_root.className = "collection"; + // Setup variables for calculating average + let grade_sum = 0; + let grade_tot = 0; + grades_by_subject[subject].forEach((grade) => { + // Create element for individual grade + let grade_node = document.createElement("li"); + grade_node.className = "collection-item"; + grade_node.classList.add("collection-item") + grade_node.classList.add("grade-node"); + grade_node.dataset["index"] = grade["index"]; + let grade_node_div = document.createElement("div"); + // Node for date and subject text + let grade_text = document.createElement("span"); + // Node for the actual number + let grade_number = document.createElement("div"); + grade_number.className = "secondary-content"; + // Apply different style, if the grade is temporary + if (grade["temporary"]) { + // Styling for text + let grade_text_italic = document.createElement("i"); + grade_text_italic.innerText = grade["date"] + " - " + grade["title"]; + grade_text.appendChild(grade_text_italic); + // Styling for number + let grade_number_italic = document.createElement("i"); + grade_number_italic.innerText = grade["grade"].toString(); + grade_number.appendChild(grade_number_italic); + } else { + // Text + grade_text.innerText = grade["date"] + " - " + grade["title"]; + // Number + grade_number.innerText = grade["grade"].toString(); + } + grade_node_div.appendChild(grade_text); + grade_node_div.appendChild(grade_number); + grade_node.appendChild(grade_node_div); + // Count the grade only if it's not temporary or explicitly enabled + if (!grade["temporary"] || !checkbox_state) { + grade_sum += grade["grade"]; + grade_tot += 1; + } + subject_body_root.appendChild(grade_node); + }); + let grade_average = (grade_tot === 0) ? "N/A" : (Math.round(((grade_sum / grade_tot) + Number.EPSILON) * 100) / 100); + let subject_header_average = document.createElement("div"); + subject_header_average.className = "collapsible-header-right"; + if (subject in zakljucne_grades_by_subject) { + subject_header_average.innerText = zakljucne_grades_by_subject[subject]; + subject_header_average.classList.add = "zakljucna-grade"; + } else { + subject_header_average.innerText = grade_average.toString(); + } + subject_header.appendChild(subject_header_text); + subject_header.appendChild(subject_header_average); + subject_body.append(subject_body_root); + subject_entry.append(subject_header); + subject_entry.append(subject_body); + root_element.append(subject_entry); + }); + $("#grades-collapsible").append(root_element); + refreshClickHandlers(); } function clearGrades() { - const table = document.getElementById("grades-collapsible"); - while (table.firstChild) { - table.removeChild(table.firstChild); - } + const table = document.getElementById("grades-collapsible"); + while (table.firstChild) { + table.removeChild(table.firstChild); + } } function refreshGrades(force) { - clearGrades(); - loadGrades(force); + clearGrades(); + loadGrades(force); } function refreshClickHandlers() { - $("#grades-collapsible").find(".collection-item.grade-node").click(function () { - let grade_obj = grades[parseInt(this.dataset["index"])]; - document.getElementById("grade-header").innerText = grade_obj["subject"] + ": " + grade_obj["grade"]; - document.getElementById("grade-date").innerText = dateString.longFormatted(grade_obj["date"]); - document.getElementById("grade-title").innerText = grade_obj["name"][0]; - document.getElementById("grade-type").innerText = S("type") + ": " + grade_obj["name"][1]; - let term_element = document.getElementById("grade-term"); - if (grade_obj["name"][2] !== "") { - term_element.innerText = S("term") + ": " + grade_obj["name"][2]; - term_element.style["display"] = ""; - } else { - term_element.style["display"] = "none"; - } - document.getElementById("grade-teacher").innerText = S("teacher") + ": " + grade_obj["teacher"]; - let temporary_object = document.getElementById("grade-temporary"); - let temporary_object_root = document.getElementById("grade-temporary-root"); - if (grade_obj["temporary"]) { - temporary_object.innerText = "(" + S("temporary") + ")"; - temporary_object_root.style["display"] = ""; - } else { - temporary_object_root.style["display"] = "none"; - } - const modal = document.querySelectorAll('.side-modal')[0]; - M.Sidenav.getInstance(modal).open(); - }); + $("#grades-collapsible").find(".collection-item.grade-node").click(function () { + let grade_obj = grades[parseInt(this.dataset["index"])]; + document.getElementById("grade-header").innerText = grade_obj["subject"] + ": " + grade_obj["grade"]; + document.getElementById("grade-date").innerText = dateString.longFormatted(grade_obj["date"]); + document.getElementById("grade-title").innerText = grade_obj["name"][0]; + document.getElementById("grade-type").innerText = S("type") + ": " + grade_obj["name"][1]; + let term_element = document.getElementById("grade-term"); + if (grade_obj["name"][2] !== "") { + term_element.innerText = S("term") + ": " + grade_obj["name"][2]; + term_element.style["display"] = ""; + } else { + term_element.style["display"] = "none"; + } + document.getElementById("grade-teacher").innerText = S("teacher") + ": " + grade_obj["teacher"]; + let temporary_object = document.getElementById("grade-temporary"); + let temporary_object_root = document.getElementById("grade-temporary-root"); + if (grade_obj["temporary"]) { + temporary_object.innerText = "(" + S("temporary") + ")"; + temporary_object_root.style["display"] = ""; + } else { + temporary_object_root.style["display"] = "none"; + } + const modal = document.querySelectorAll('.side-modal')[0]; + M.Sidenav.getInstance(modal).open(); + }); } // Initialization code document.addEventListener("DOMContentLoaded", async () => { - checkLogin(); - - let coll_elem = document.querySelectorAll('.collapsible'); - M.Collapsible.init(coll_elem, {}); - - // Setup refresh handler - $("#refresh-icon").click(function () { - refreshGrades(true); - }); - - // Setup checkbox handler - $("#permanent-grades-checkbox").change(function () { - checkbox_state = this.checked; - refreshGrades(false); - }); - let elems = document.querySelectorAll('.modal'); - M.Modal.init(elems, {}); - - // Setup side menu - const menus = document.querySelectorAll('.side-menu'); - M.Sidenav.init(menus, { edge: 'right', draggable: true }); - - // Setup side modal - const modals = document.querySelectorAll('.side-modal'); - M.Sidenav.init(modals, { edge: 'left', draggable: false }); - - clearGrades(); - await loadGrades(); + checkLogin(); + + let coll_elem = document.querySelectorAll('.collapsible'); + M.Collapsible.init(coll_elem, {}); + + // Setup refresh handler + $("#refresh-icon").click(function () { + refreshGrades(true); + }); + + // Setup checkbox handler + $("#permanent-grades-checkbox").change(function () { + checkbox_state = this.checked; + refreshGrades(false); + }); + let elems = document.querySelectorAll('.modal'); + M.Modal.init(elems, {}); + + // Setup side menu + const menus = document.querySelectorAll('.side-menu'); + M.Sidenav.init(menus, { edge: 'right', draggable: true }); + + // Setup side modal + const modals = document.querySelectorAll('.side-modal'); + M.Sidenav.init(modals, { edge: 'left', draggable: false }); + + clearGrades(); + await loadGrades(); }); -- cgit v1.2.3 From cb700f0e69588dd5cac218ad5fe50f022e141674 Mon Sep 17 00:00:00 2001 From: sijanec Date: Thu, 4 Jun 2020 15:06:21 +0200 Subject: fixed final grade styling --- assets/js/grades.js | 2 +- assets/js/lang/bundle.js | 2 ++ assets/pages-src/grades.bvr | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'assets') diff --git a/assets/js/grades.js b/assets/js/grades.js index 8e04c2b..91a5587 100644 --- a/assets/js/grades.js +++ b/assets/js/grades.js @@ -156,7 +156,7 @@ function displayGrades() { subject_header_average.className = "collapsible-header-right"; if (subject in zakljucne_grades_by_subject) { subject_header_average.innerText = zakljucne_grades_by_subject[subject]; - subject_header_average.classList.add = "zakljucna-grade"; + subject_header_average.classList.add("zakljucna-grade"); } else { subject_header_average.innerText = grade_average.toString(); } diff --git a/assets/js/lang/bundle.js b/assets/js/lang/bundle.js index eeee695..b311bf4 100644 --- a/assets/js/lang/bundle.js +++ b/assets/js/lang/bundle.js @@ -172,6 +172,7 @@ var langstrings = { type: "type", term: "term", teacher: "teacher", + zakljucneGradess: "grades in red are final grades that appear on your end-of-year certificate and are decided by your teacher. They are not averages like grades in black. Should you have any questions or complaints about them, contact your teacher", // teachers name: "name", schoolSubject: "subject", @@ -378,6 +379,7 @@ var langstrings = { type: "tip", term: "rok", teacher: "profesor", + zakljucneGradess: "zaključne ocene, ki bodo na spričevalu, so označene z rdečo, povprečja ocen pa so v črni barvi. V kolikor imate kakršnekoli pritožbe ali vprašanja glede zaključnih ocen, povprašajte profesorja", // teachers name: "ime", schoolSubject: "predmet", diff --git a/assets/pages-src/grades.bvr b/assets/pages-src/grades.bvr index f47d462..5d05c3e 100644 --- a/assets/pages-src/grades.bvr +++ b/assets/pages-src/grades.bvr @@ -91,7 +91,8 @@

-
    +
      +

      zakljucneGradess

      -- cgit v1.2.3 From cc82f7c592a75efaa57292e27f0596ce1ab1b6a6 Mon Sep 17 00:00:00 2001 From: sijanec Date: Thu, 4 Jun 2020 15:13:04 +0200 Subject: version bump to 1.0.14.1-beta --- assets/js/grades.js | 1 + 1 file changed, 1 insertion(+) (limited to 'assets') diff --git a/assets/js/grades.js b/assets/js/grades.js index 91a5587..549ac7c 100644 --- a/assets/js/grades.js +++ b/assets/js/grades.js @@ -241,4 +241,5 @@ document.addEventListener("DOMContentLoaded", async () => { clearGrades(); await loadGrades(); + }); -- cgit v1.2.3 From a55ce514441b2dee1e0e8d2fdbcc1447fa56ad12 Mon Sep 17 00:00:00 2001 From: rstular Date: Thu, 4 Jun 2020 15:58:49 +0200 Subject: Code-style fixes --- assets/js/messaging.js | 2 +- assets/pages-src/gradings.bvr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'assets') diff --git a/assets/js/messaging.js b/assets/js/messaging.js index 890da18..0f55e1a 100644 --- a/assets/js/messaging.js +++ b/assets/js/messaging.js @@ -587,7 +587,7 @@ function setupEventListeners() { function getUrlParameter(sParam) { const url_params = new URLSearchParams(window.location.search); const found_param = url_params.get(sParam); - return found_param + return found_param; } var additionalstufftoaddtomessage = ""; diff --git a/assets/pages-src/gradings.bvr b/assets/pages-src/gradings.bvr index 109296b..20a2d39 100644 --- a/assets/pages-src/gradings.bvr +++ b/assets/pages-src/gradings.bvr @@ -77,11 +77,11 @@ -
      + <@?i grading-add-modal@> -- cgit v1.2.3 From 7e1a97e4f1943e458c806bf19cac556174a51319 Mon Sep 17 00:00:00 2001 From: rstular Date: Thu, 4 Jun 2020 16:20:22 +0200 Subject: Minor styling fixes --- assets/js/login.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'assets') diff --git a/assets/js/login.js b/assets/js/login.js index ab59058..fc6dfcd 100644 --- a/assets/js/login.js +++ b/assets/js/login.js @@ -33,7 +33,7 @@ function login() { dataType: "script", }); try { - gsecInstance = new gsec(); + gsecInstance = new gsec(); } catch (error) { alert(D("browserNotSupported")); } @@ -45,6 +45,7 @@ function login() { localforage.setItem("username", username), localforage.setItem("password", password) ]; + read_val(0); Promise.all(promises_to_run).then(function () { window.location.replace("/pages/timetable.html"); }); -- cgit v1.2.3