diff options
author | rstular <rok@stular.eu> | 2020-05-16 19:13:09 +0200 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-05-16 19:30:20 +0200 |
commit | 4f0ec02153703d7ae845efb3830a5d065b393dd2 (patch) | |
tree | 79fa2e5f48cfc04da1d787fdec1697a77f17294c /js | |
parent | bvr (upstream) fixes, added support for nested commands (diff) | |
download | beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.tar beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.tar.gz beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.tar.bz2 beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.tar.lz beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.tar.xz beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.tar.zst beziapp-4f0ec02153703d7ae845efb3830a5d065b393dd2.zip |
Diffstat (limited to 'js')
-rw-r--r-- | js/gsec.js | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -362,10 +362,13 @@ class gsec { } fetchAbsences(fromDate = null, tillDate = null) { // navedba datumov je deprecated. Internet je dovolj hiter za poslat maksimalno 4160 ur (16 ur/dan, 5 dni/ted, 52 ted/leto) + + const FIELDS_REGEX = /^(.+) \(<span class="opr(\d)">(\dP?)<\/span>/; + return new Promise((resolve, reject)=>{ if (!(fromDate instanceof Date) || !(tillDate instanceof Date)) { tillDate = new Date(Date.UTC(9999, 11, 30)); // overkill? Of course not, cez 8000 let bo ta app se vedno top shit - fromDate = new Date(Date.UTC(1, 1, 1)); // i don't thunk so + fromDate = new Date(Date.UTC(1, 1, 1)); // i don't think so } var dataToBeSent = { @@ -390,10 +393,14 @@ class gsec { var subjects = {}; for (const subject of subFields[2].innerHTML.split(", ")) { - var subjectName = subject.split(" (")[0]; - var status = Number(subject.split('(<span class="opr').pop().split('">')[0]); - // statusi so: 0: ni obdelano, 1: opravičeno, 2: neopravičeno, 3: ne šteje, uporabi S(gseAbsenceTypes[num]) za i18n pre3vod - var period = Number(subject.split('">').pop().split('</span>')[0]); + const matched_info = FIELDS_REGEX.exec(subject); + + var subjectName = matched_info[1]; + var status = Number(matched_info[2]); + // statusi so: 0: ni obdelano, 1: opravičeno, 2: neopravičeno, 3: ne šteje, uporabi S(gseAbsenceTypes[num]) za i18n prevod + // Ce je v "stevilki" P, gre za popoldansko uro -> +7 ur + var period = matched_info[3]; + period = period.includes("P") ? Number(period.replace("P", "")) + 7 : Number(period); subjects[period] = {status: status, subject: subjectName}; } absences.push({subjects: subjects, date: dateObj}); |