summaryrefslogtreecommitdiffstats
path: root/dist
diff options
context:
space:
mode:
authorrstular <rok@stular.eu>2020-06-01 20:27:31 +0200
committerrstular <rok@stular.eu>2020-06-01 20:27:31 +0200
commit578e093077032d6f17abb619a2471c9a4490db79 (patch)
tree695efc6ad02c4bd667661f149ae5189ee0786a9f /dist
parentgsec bug fix - regex may return null (diff)
downloadbeziapp-578e093077032d6f17abb619a2471c9a4490db79.tar
beziapp-578e093077032d6f17abb619a2471c9a4490db79.tar.gz
beziapp-578e093077032d6f17abb619a2471c9a4490db79.tar.bz2
beziapp-578e093077032d6f17abb619a2471c9a4490db79.tar.lz
beziapp-578e093077032d6f17abb619a2471c9a4490db79.tar.xz
beziapp-578e093077032d6f17abb619a2471c9a4490db79.tar.zst
beziapp-578e093077032d6f17abb619a2471c9a4490db79.zip
Diffstat (limited to 'dist')
-rwxr-xr-xdist/js/app.js2
-rw-r--r--dist/js/gradings.js4
-rw-r--r--dist/js/gsec.js6
-rwxr-xr-xdist/pages/about.html2
-rwxr-xr-xdist/sw.js4
5 files changed, 10 insertions, 8 deletions
diff --git a/dist/js/app.js b/dist/js/app.js
index d551d22..6daa06c 100755
--- a/dist/js/app.js
+++ b/dist/js/app.js
@@ -3,7 +3,7 @@
const app_version = "1.0.14-beta";
-const previous_commit = "a8cffc9c334e02ca962f615cc28c66634bea06aa";
+const previous_commit = "aebac8bcd0e946f1e7283d8e280e301d52b8d64b";
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js")
diff --git a/dist/js/gradings.js b/dist/js/gradings.js
index 172858c..017e4e6 100644
--- a/dist/js/gradings.js
+++ b/dist/js/gradings.js
@@ -11,4 +11,6 @@ month_str=month_str.toString().padStart(2,"0");let day_str=date.getDate();day_st
async function loadGradings(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("gradings").then((value)=>{gradings=value;})];await Promise.all(promises_to_run);if(gradings==null||gradings==[]||gradings==-1||force_refresh){try{let gsecInstance=new gsec();await gsecInstance.login(username,password);gsecInstance.fetchGradings().then((value)=>{gradings=value;localforage.setItem("gradings",value).then(()=>{displayData();setLoading(false);});setLoading(false);}).catch((err)=>{gsecErrorHandlerUI(err);setLoading(false);});}catch(err){gsecErrorHandlerUI(err);setLoading(false);}}else{displayData();setLoading(false);}}
function displayData(){let transformed_gradings=[];gradings.forEach((element,index)=>{let bg_color=getHexColorFromString(element["acronym"]);let fg_color=getForegroundFromBackground(bg_color);let grading_object={start:element["date"].toISOString().substring(0,10),title:element["acronym"],id:index.toString(),backgroundColor:bg_color,textColor:fg_color};transformed_gradings.push(grading_object);});calendar_obj.removeAllEvents();calendar_obj.addEventSource(transformed_gradings);}
function gradingClickHandler(eventClickInfo){let grading_id=parseInt(eventClickInfo.event.id);let grading_subject=gradings[grading_id]["subject"];let grading_date_obj=gradings[grading_id]["date"];let grading_date=dateString.longFormatted(grading_date_obj);let grading_description=gradings[grading_id]["description"];$("#grading-subject").text(grading_subject);$("#grading-date").text(grading_date);$("#grading-description").text(grading_description);const modal=document.querySelectorAll(".side-modal")[0];M.Sidenav.getInstance(modal).open();}
-document.addEventListener("DOMContentLoaded",()=>{checkLogin();var calendarEl=document.getElementById("calendar");calendar_obj=new FullCalendar.Calendar(calendarEl,{firstDay:1,plugins:["dayGrid"],defaultDate:getDateString(),navLinks:false,editable:false,events:[],eventClick:gradingClickHandler,height:"parent"});calendar_obj.render();loadGradings(true);$("#refresh-icon").click(()=>{loadGradings(true);});const menus=document.querySelectorAll(".side-menu");M.Sidenav.init(menus,{edge:"right",draggable:true});const modals=document.querySelectorAll('.side-modal');M.Sidenav.init(modals,{edge:'left',draggable:false});}); \ No newline at end of file
+function setupPickers(){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",()=>{checkLogin();var calendarEl=document.getElementById("calendar");calendar_obj=new FullCalendar.Calendar(calendarEl,{firstDay:1,plugins:["dayGrid"],defaultDate:getDateString(),navLinks:false,editable:false,events:[],eventClick:gradingClickHandler,height:"parent"});calendar_obj.render();setupPickers();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);$("#refresh-icon").click(()=>{loadGradings(true);});const menus=document.querySelectorAll(".side-menu");M.Sidenav.init(menus,{edge:"right",draggable:true});const modals=document.querySelectorAll('.side-modal');M.Sidenav.init(modals,{edge:'left',draggable:false});}); \ No newline at end of file
diff --git a/dist/js/gsec.js b/dist/js/gsec.js
index 8736eaf..7925d00 100644
--- a/dist/js/gsec.js
+++ b/dist/js/gsec.js
@@ -18,8 +18,8 @@ $.ajax({xhrFields:{withCredentials:true},crossDomain:true,url:GSE_URL+"Page_Gim/
fetchTimetable(datum=null){const SUBJECT_REGEX=/\((.+?)\)/;const ABKURZUNG_REGEX=/^(.+?) \(/;var dataToSend=datum==null?{}:{"ctl00$ContentPlaceHolder1$wkgDnevnik_edtGridSelectDate":`${datum.getDate()}.${Number(datum.getMonth()+1)}.${datum.getFullYear()}`};return new Promise((resolve)=>{var urnik={0:{},1:{},2:{},3:{},4:{},5:{},6:{}};this.postback(GSE_URL+"Page_Gim/Ucenec/DnevnikUcenec.aspx",dataToSend,null,true).then((response)=>{let parser=new DOMParser();let parsed=parser.parseFromString(response.data,"text/html");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("\n");var subject=SUBJECT_REGEX.exec(desc[1])[1];var abkurzung=ABKURZUNG_REGEX.exec(desc[1])[1];var razred=desc[2];var teacher=desc[3];var place=desc[4];urnik[day][period]={"subject":subject,"acronym":abkurzung,"class":razred,"teacher":teacher,"place":place};}
resolve(urnik);});});}
fetchGradings(){const DESC_REGEX=/\((.+?)\)/m;const SUBJECT_REGEX=/^(.+?) \(/m;return new Promise((resolve)=>{var gradings=[];this.postback(GSE_URL+"Page_Gim/Ucenec/IzpitiUcenec.aspx",{},null,true).then((response)=>{let parser=new DOMParser();let parsed=parser.parseFromString(response.data,"text/html");var rowElements=parsed.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr");for(const row of rowElements){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")[0];var abkurzung="";if(rowSpan){abkurzung=rowSpan.innerHTML.trim();}
-rowSpan.remove();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,"acronym":abkurzung,"subject":subject,"description":desc});}
+rowSpan.remove();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];gradings.push({"date":dateObj,"acronym":abkurzung,"subject":subject,"description":desc});}
resolve(gradings);});});}
fetchTeachers(){const SUBJECT_REGEX=/^(.+?(?= \()|.+(?! \())/;const ABKURZUNG_REGEX=/\((.+)\)/;const DAY_REGEX=/^(.+?), /m;const PERIOD_REGEX=/, (\d+?)\. ura/;const TIME_RANGE_REGEX=/\((.+?) - (.+?)\)/;return new Promise((resolve)=>{var Teachers={};this.postback(GSE_URL+"Page_Gim/Ucenec/UciteljskiZbor.aspx",{},null,true).then((response)=>{let parser=new DOMParser();let parsed=parser.parseFromString(response.data,"text/html");var rowElements=parsed.getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].getElementsByTagName("tr");for(const row of rowElements){var subFields=row.getElementsByTagName("td");var name=stripHtml(subFields[0].innerHTML);var subjectStrings=subFields[2].innerHTML.split("<br>");var subjects={};for(const subjectString of subjectStrings){var subjectName=SUBJECT_REGEX.exec(stripHtml(subjectString))[1];var abkurzung=ABKURZUNG_REGEX.exec(stripHtml(subjectString));abkurzung=abkurzung==null?subjectName:abkurzung[1];subjects[abkurzung]=subjectName;}
try{var TP={};TP.day=slDayToInt(DAY_REGEX.exec(subFields[3].innerHTML)[1]);TP.period=Number(PERIOD_REGEX.exec(subFields[3].innerHTML)[1]);var time_range_matches=TIME_RANGE_REGEX.exec(subFields[3].innerHTML);TP.from=time_range_matches[1];TP.till=time_range_matches[2];if(TP.day<0){TP=false;}}catch(error){var TP={};TP.day=slDayToInt(subFields[3].innerHTML.split(", ")[0]);TP.period=Number(subFields[3].innerHTML.split(", ").pop().split(". ura")[0]);TP.from=subFields[3].innerHTML.split("(").pop().split(")")[0].split(" - ")[0];TP.till=subFields[3].innerHTML.split("(").pop().split(")")[0].split(" - ")[1];if(TP.day<0){TP=false;}}
@@ -45,7 +45,7 @@ resolve(currentPage);});});}
fetchMessagesList(category=GSEC_MSGTYPE_RECEIVED,pageNumber=1,outputResponse=false){const DATE_REGEX=/(\d+?).(\d+?).(\d+?) /;var msgCategory=GSEC_MSGTYPES[category];var messages=[];var requestURI=GSE_URL+"Page_Gim/Uporabnik/Sporocila.aspx";return new Promise((resolve)=>{var dataToBeSent={"ctl00$ContentPlaceHolder1$ddlPrikaz":msgCategory,"__EVENTARGUMENT":"Page$"+pageNumber,"__EVENTTARGET":"ctl00$ContentPlaceHolder1$gvwSporocila"};this.postback(requestURI,dataToBeSent,null,true).then((response)=>{if(outputResponse===true){response.url=requestURI;resolve(response);}
let parser=new DOMParser();let parsed=parser.parseFromString(response.data,"text/html");let messageElements=parsed.getElementById("ctl00_ContentPlaceHolder1_gvwSporocila").getElementsByTagName("tbody")[0].getElementsByTagName("td");for(const messageElement of messageElements){let msgId=messageElement.getElementsByTagName("input")[0].value;var date=DATE_REGEX.exec(messageElement.getElementsByClassName("msgSubDate")[0].innerHTML);var today=new Date();if(date[3]==undefined||date[2].length<1){date[3]=today.getFullYear();}
if(date[2]==undefined||date[2].length<1){date[2]=today.getMonth()+1;date[1]=today.getDate();}
-var tume=messageElement.getElementsByClassName("msgSubDate")[0].innerHTML.split(" ")[1];if(tume==null||tume.length<1){tume=messageElement.getElementsByClassName("msgSubDate")[0].innerHTML;}
+var tume=messageElement.getElementsByClassName("msgSubDate")[0].innerHTML.split(" ")[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));var person=messageElement.getElementsByClassName("msgDir")[0].innerHTML;var subject=messageElement.getElementsByClassName("msgSubject")[0].innerHTML;messages.push({"date":dateObj,"sender":person,"subject":subject,"msgId":msgId});}
resolve(messages);});});}
fetchMessage(category=GSEC_MSGTYPE_RECEIVED,pageNumber=1,messageNumberOnPage=0){const TIME_REGEX=/ \(.+ (.+?)\)/;const DATE_REGEX=/ \((\d+?).(\d+?).(\d+?) /;const SENDER_REGEX=/^(.+?) \(/;return new Promise((resolve)=>{this.fetchMessagesList(category,pageNumber,true).then((value)=>{this.parseAndPost(value.data,{"__EVENTTARGET":"ctl00$ContentPlaceHolder1$gvwSporocila","__EVENTARGUMENT":"Select$"+messageNumberOnPage},null,value.url).then((response)=>{let parser=new DOMParser();let parsed=parser.parseFromString(response.data,"text/html");let subject=parsed.getElementsByClassName("msgSubjectS")[0].innerHTML.trim();let body=parsed.getElementsByClassName("gCursorAuto")[0].innerHTML.trim();let sender=SENDER_REGEX.exec(parsed.querySelectorAll("[id$=Label7]")[0].innerHTML)[1];let recipient=parsed.querySelectorAll("[id$=Label8]")[0].innerHTML;var date=DATE_REGEX.exec(parsed.querySelectorAll("[id$=Label7]")[0].innerHTML);var tume=TIME_REGEX.exec(parsed.querySelectorAll("[id$=Label7]")[0].innerHTML)[1];var dateObj=new Date(Date.parse(`${date[3]}-${date[2]}-${date[1]} ${tume}`));var msgId=parsed.getElementById("ctl00_ContentPlaceHolder1_hfIdSporocilo").getAttribute("value");var message={"subject":subject,"body":body,"sender":sender,"recipient":recipient,"date":dateObj,"msgId":msgId};resolve(message);});});});}} \ No newline at end of file
diff --git a/dist/pages/about.html b/dist/pages/about.html
index b8788ee..af98a69 100755
--- a/dist/pages/about.html
+++ b/dist/pages/about.html
@@ -142,7 +142,7 @@
<div class="row">
<p>
<small>
- ^HEAD a8cffc9c334e02ca962f615cc28c66634bea06aa
+ ^HEAD aebac8bcd0e946f1e7283d8e280e301d52b8d64b
</small>
</p>
</div>
diff --git a/dist/sw.js b/dist/sw.js
index 99f2269..bcbefa9 100755
--- a/dist/sw.js
+++ b/dist/sw.js
@@ -3,8 +3,8 @@
// Change version to cause cache refresh
-const static_cache_name = "site-static-1.0.14-beta-a8cffc9";
-// commit before the latest is a8cffc9c334e02ca962f615cc28c66634bea06aa
+const static_cache_name = "site-static-1.0.14-beta-aebac8b";
+// commit before the latest is aebac8bcd0e946f1e7283d8e280e301d52b8d64b
// Got them with find . -not -path '*/\.*' | sed "s/.*/\"&\",/" | grep -v sw.js
// sw.js NE SME BITI CACHAN, ker vsebuje verzijo!