summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/css/styles.css4
-rw-r--r--assets/js/grades.js16
-rw-r--r--assets/js/gsec.js74
3 files changed, 60 insertions, 34 deletions
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);
},