summaryrefslogtreecommitdiffstats
path: root/dist/js/gsec.js
diff options
context:
space:
mode:
Diffstat (limited to 'dist/js/gsec.js')
-rw-r--r--dist/js/gsec.js7
1 files changed, 3 insertions, 4 deletions
diff --git a/dist/js/gsec.js b/dist/js/gsec.js
index 36d49a5..59d95bf 100644
--- a/dist/js/gsec.js
+++ b/dist/js/gsec.js
@@ -32,10 +32,9 @@ var dataToBeSent={"ctl00$ContentPlaceHolder1$edtDatZacetka":`${fromDate.getDay()
var absences=[];for(const izostanek of rowElements){var subFields=izostanek.getElementsByTagName("td");var date=subFields[0].innerHTML.trim().split(".");var dateObj=new Date(Date.parse(`${date[2]}-${date[1]}-${date[0]}`));var subjects=[];subFields[2].innerHTML.match(SUBJECT_LIST_REGEX).forEach((subject)=>{subjects.push(subject);});var absencesBySubject={};for(const subject of subjects){const matched_info=FIELDS_REGEX.exec(subject);var subjectName=matched_info[1];var status=Number(matched_info[2]);var period=matched_info[3];period=period.includes("P")?Number(period.replace("P",""))+7:Number(period);absencesBySubject[period]={status:status,subject:subjectName};}
absences.push({subjects:absencesBySubject,date:dateObj});}
resolve(absences);});});}
-fetchGrades(){var grades=[];return new Promise((resolve,reject)=>{$.ajax({xhrFields:{withCredentials:true},crossDomain:true,url:GSE_URL+"Page_Gim/Ucenec/OceneUcenec.aspx",cache:false,type:"GET",dataType:"html",processData:false,success:(data)=>{let parser=new DOMParser();let parsed=parser.parseFromString(data,"text/html");let gradeSpans=parsed.getElementsByClassName("txtVOcObd");for(const grade of gradeSpans){var ist=grade.getElementsByTagName("span")[0].getAttribute("title").split("\n");if(ist.length==1){var gradeToAdd={"gradeType":GSEC_ZAKLJUCNA_GRADE,"grade":Number(grade.getElementsByTagName("span")[0].innerHTML),"subject":grade.parentElement.parentElement.parentElement.parentElement.getElementsByTagName("th")[0].innerText}
-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())
+fetchGrades(){var grades=[];return new Promise((resolve,reject)=>{$.ajax({xhrFields:{withCredentials:true},crossDomain:true,url:GSE_URL+"Page_Gim/Ucenec/OceneUcenec.aspx",cache:false,type:"GET",dataType:"html",processData:false,success:(data)=>{let parser=new DOMParser();let parsed=parser.parseFromString(data,"text/html");let gradeSpans=parsed.getElementsByClassName("txtVOcObd");for(const grade of gradeSpans){var whatever_ist_meant_in_my_head_back_then_but_as_a_string=grade.getElementsByTagName("span")[0].getAttribute("title");var ist=whatever_ist_meant_in_my_head_back_then_but_as_a_string.split("\n");if(ist.length==1){var gradeToAdd={"gradeType":GSEC_ZAKLJUCNA_GRADE,"grade":Number(grade.getElementsByTagName("span")[0].innerHTML),"subject":grade.parentElement.parentElement.parentElement.parentElement.getElementsByTagName("th")[0].innerText}
+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(whatever_ist_meant_in_my_head_back_then_but_as_a_string.split("Ocenjevanje: ")[1].split("\nVrsta: ")[0].trim());name.push(whatever_ist_meant_in_my_head_back_then_but_as_a_string.split("Vrsta: ")[1].split("\nRok: ")[0].trim())
+name.push(whatever_ist_meant_in_my_head_back_then_but_as_a_string.split("Rok: ")[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,"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);}}