summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-03-12 23:21:38 +0100
committerAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-03-12 23:21:38 +0100
commite00ba090eecf5f3b1d43ba079854c52b858d5b5e (patch)
treea56be291285c62ce6d154152e10fdc2e1da5aae5
parentadd server config for cors, fix gsec.js/postback (diff)
downloadbeziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.tar
beziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.tar.gz
beziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.tar.bz2
beziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.tar.lz
beziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.tar.xz
beziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.tar.zst
beziapp-e00ba090eecf5f3b1d43ba079854c52b858d5b5e.zip
-rw-r--r--js/gsec.js26
-rw-r--r--sw.js2
2 files changed, 17 insertions, 11 deletions
diff --git a/js/gsec.js b/js/gsec.js
index 02362ba..6e59db7 100644
--- a/js/gsec.js
+++ b/js/gsec.js
@@ -73,7 +73,7 @@ class gsec {
if( simpleResponse = "Napaka pri prijavi.") {
reject(new Error(false));
} else {
- resolve(true);
+ resolve(new Error(false)); // tudi false, ker da pokaže form in ne redirecta je slabo
}
} catch (e) {
resolve(null);
@@ -127,7 +127,13 @@ class gsec {
// note about the nulls, "null"s and ""s: this is actually how zgimsisext2016 javascripts sends it.
processData: false,
success: (data, textStatus, xhr) => {
- resolve({"data": data.d, "textStatus": textStatus, "code": xhr.status});
+ var teachersDirectory = data.d.split(";"); // data.d je "12434=Ime Primek (učitelj);75353=Ime Drugega Priimek (učitelj)";
+ teachersDirectory.pop(); // pop, ker se string konča z ;
+ var formatted = {};
+ teachersDirectory.forEach((v) => {
+ formatted[v.split("=")[1].split(" (")[0]] = v.split("=")[0];
+ });
+ resolve(formatted);
},
error: () => {
reject(new Error(false));
@@ -139,18 +145,18 @@ class gsec {
if(datum == null) {
var dataToSend = {};
} else {
- var dataToSend = {"ctl00$ContentPlaceHolder1$wkgDnevnik_edtGridSelectDate": inputDate.getDate()+"."+Number(inputDate.getMonth()+1)+"."+inputDate.getFullYear()};
+ var dataToSend = {"ctl00$ContentPlaceHolder1$wkgDnevnik_edtGridSelectDate": datum.getDate()+"."+Number(datum.getMonth()+1)+"."+datum.getFullYear()};
}
return new Promise((resolve, reject) => {
- var urnik = {};
- this.postback(GSE_URL+"Page_Gim/Ucenec/DnevnikUcenec.aspx", dataToSend).then( (response) => {
+ var urnik = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6:{} } ;
+ this.postback(GSE_URL+"Page_Gim/Ucenec/DnevnikUcenec.aspx", dataToSend, null, true).then( (response) => {
var parsed = document.createElement("html");
parsed.innerHTML = response.data;
- for(const urnikElement of $('[id^="ctl00_ContentPlaceHolder1_wkgDnevnik_btnCell_"]')) {
+ for(const urnikElement of parsed.querySelectorAll('*[id^="ctl00_ContentPlaceHolder1_wkgDnevnik_btnCell_"]')) {
var subFields = urnikElement.id.split("_");
var period = subFields[4];
var day = subFields[5];
- var desc = $(urnikElement).attr("title").split("/\r?\n/");
+ var desc = $(urnikElement).attr("title").split("\n");
var subject = desc[1].split('(').pop().split(')')[0]; // https://stackoverflow.com/a/27522597/11293716
var abkurzung = desc[0].split(" (")[0];
var razred = desc[2];
@@ -165,7 +171,7 @@ class gsec {
fetchGradings() {
return new Promise((resolve, reject) => {
var gradings = [];
- this.postback(GSE_URL+"Page_Gim/Ucenec/IzpitiUcenec.aspx").then( (response) => {
+ this.postback(GSE_URL+"Page_Gim/Ucenec/IzpitiUcenec.aspx", {}, null, true).then( (response) => {
var parsed = document.createElement("html");
parsed.innerHTML = response.data;
var rowElements = parsed.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr");
@@ -173,7 +179,7 @@ class gsec {
var subFields = row.getElementsByTagName("td");
var date = subFields[0].innerHTML.trim().split(".");
var dateObj = new Date(date[2]+"-"+date[1]+"-"+date[0]);
- var rowSpan = subFields[1].getElementsByTagName("span");
+ var rowSpan = subFields[1].getElementsByTagName("span")[0];
var abkurzung = "";
if(rowSpan) {
abkurzung = rowSpan.innerHTML.trim();
@@ -190,7 +196,7 @@ class gsec {
fetchTeachers() {
return new Promise((resolve, reject) => {
var Teachers = {};
- this.postback(GSE_URL+"Page_Gim/Ucenec/UciteljskiZbor.aspx").then((response)=>{
+ this.postback(GSE_URL+"Page_Gim/Ucenec/UciteljskiZbor.aspx", {}, null, true).then((response)=>{
var parsed = document.createElement("html");
parsed.innerHTML = response.data;
var rowElements = parsed.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr");
diff --git a/sw.js b/sw.js
index a4ffa9c..091edd5 100644
--- a/sw.js
+++ b/sw.js
@@ -1,5 +1,5 @@
// Change version to cause cache refresh
-const static_cache_name = "site-static-v1.0.12.43";
+const static_cache_name = "site-static-v1.0.12.54";
// Got them with find . -not -path '*/\.*' | sed "s/.*/\"&\",/" | grep -v sw.js
// sw.js NE SME BITI CACHAN, ker vsebuje verzijo!