Browse Source

styling and basic substitution support

master
Baltazár Radics 5 months ago
parent
commit
e8ad8b4607
Signed by: baltazar GPG Key ID: 9440F591E4397C3E
  1. 22
      11.IB.json
  2. 13
      index.html
  3. 51
      index.js

22
11.IB.json

@ -351,99 +351,119 @@
"classes": {
"MAT": {
"pretty": "Maths HL",
"substSubject": "matematika",
"gc": "MjA5ODI0NDY5NDcy",
"color": "#c26401"
},
"mat": {
"pretty": "Maths SL",
"substSubject": "matematika",
"gc": "MjA5OTYyOTUyNDIx",
"color": ""
},
"fra": {
"pretty": "Francia",
"substSubject": "francia",
"gc": "idk",
"color": ""
},
"ném": {
"pretty": "Német",
"substSubject": "német",
"gc": "MjEwMzQzODEyMzE0",
"color": ""
},
"oro": {
"pretty": "Orosz",
"substSubject": "orosz",
"gc": "MjM3NzY4MDAyOTUz",
"color": ""
},
"spa": {
"pretty": "Spanyol",
"substSubject": "spanyol",
"gc": "MjA5NzM0NzE3NjMx",
"color": ""
},
"mag": {
"pretty": "Magyar",
"substSubject": "magyar",
"gc": "MTcyNjUzNjM0NzE3",
"color": "#202124"
},
"inf": {
"pretty": "CompSci",
"substSubject": "informatika",
"gc": "MjA5ODk1Mjg1Njg1",
"color": "#1967d2"
},
"bio": {
"pretty": "Biology",
"substSubject": "biológia",
"gc": "MjA5ODM3MjU2OTIx",
"color": ""
},
"fiz": {
"pretty": "Physics",
"substSubject": "fizika",
"gc": "MjA5ODg1MzQ0MTcw",
"color": "#174ea6"
},
"tör": {
"pretty": "History",
"substSubject": "történelem",
"gc": "MjEwMzEzODM5Mzgy",
"color": "#c26401"
},
"köz": {
"pretty": "Economics",
"substSubject": "közgáz",
"gc": "MTcyNjYwNDY1NDk1",
"color": "#007b83"
},
"pszi": {
"pretty": "Psychology",
"substSubject": "pszichológia",
"gc": "MjExNTEyNDIxODE0",
"color": ""
},
"ang": {
"pretty": "English B",
"substSubject": "angol",
"gc": "MjEwMDgyNDU2ODMz",
"color": "#1967d2"
},
"ANG": {
"pretty": "English A",
"substSubject": "angol",
"gc": "MjA5ODEyOTA5NTQx",
"color": "#5f6368"
},
"tok": {
"pretty": "TOK",
"substSubject": "tok",
"gc": "MjA5ODQ3ODc0ODQx",
"color": "#1967d2"
},
"ofo": {
"pretty": "Ofő",
"substSubject": "osztályfőnöki",
"gc": "MzQ2NTY2MzQ0NTla",
"color": "#1967d2"
},
"kém": {
"pretty": "Kémia",
"substSubject": "kémia",
"gc": "MjA4OTMxNzQ3OTc5",
"color": ""
},
"KÉM": {
"pretty": "Kémia fakt",
"substSubject": "kémia",
"gc": "MjA2MzQ4MTMyMTM2",
"color": ""
}
},
"lunch": [ 7, 5, 6, 7, 5 ]
"lunch": [ 7, 5, 6, 7, 5 ],
"substClass": [ "11.IB" ]
}

13
index.html

@ -4,7 +4,7 @@
<meta charset='UTF-8'>
<title>Timetable</title>
<link rel="manifest" href="timetable.webmanifest">
<script src='index.js'></script>
<script src='index.js?x'></script>
<style>
html {
background-color: black;
@ -15,17 +15,14 @@ body {
}
#timetable, .tile {
border: 1px solid #333;
border-collapse: collapse;
border-spacing: 0px;
}
#timetable th {
width: 120px;
}
#timetable th, #timetable td {
text-align: center;
border: 3px solid black;
}
#timetable {
empty-cells: hide;
border: 2px solid black;
}
.startt::after {
content: ' - ';
@ -100,4 +97,8 @@ a {
</tr>
</table>
<h3>Substitutions:</h3>
<div id='substDiv'>
</div>
</body></html>

51
index.js

@ -59,6 +59,21 @@ function dur_fmt(dur) {
let timetable = [];
let classes;
let substClass;
async function fill_subst() {
substDiv.replaceChildren();
let now = new Date();
const start = now.toISOString().slice(0,10)
now.setDate(now.getDate() + 7);
const end = now.toISOString().slice(0,10)
const substs = (await (await fetch(`https://balti.desnull.hu/subst_api?startDay=${start}&endDay=${end}&orderBy=day&orderDirection=asc`)).json()).substitutions;
for (const subst of substs) {
if (!substClass.has(subst.class))
continue;
substDiv.appendChild(document.createElement('div')).innerText = `${new Date(subst.day).toDateString()}${subst.subject}#${subst.lesson}: ${subst.missingTeacher}${subst.substitutingTeacher} (${subst.comment})`;
}
}
function cur_lesson(time) {
let count = timetable.length;
@ -113,28 +128,34 @@ window.onload = async function() {
const thing = await (await fetch(localStorage.cls+'.json', {cache: 'no-cache'})).json();
const table = thing.table;
const lunch = thing.lunch;
substClass = new Set(thing.substClass);
classes = thing.classes;
for (let i = 0; i < table.length; ++i) {
let row = tbody.appendChild(document.createElement('tr'));
let lastEnd = pmd(7,0) + (i + 1) * day
let num = 0;
row.appendChild(document.createElement('td')).innerText = wdays[i];
function insertEmpty(nextStart) {
if (num < lunch[i] && lunch[i] < nextStart) {
let y = row.appendChild(document.createElement('td'));
y.colSpan = lunch[i] - num;
num = lunch[i];
y.style.borderRightColor = 'red';
}
let x = row.appendChild(document.createElement('td'));
x.colSpan = nextStart - num;
if (nextStart == lunch[i])
x.style.borderRightColor = 'red';
if (num == lunch[i])
x.style.borderLeftColor = 'red';
}
for (let lesson of table[i]) {
if (lesson.start < num)
continue;
if (!filter.includes(lesson.name))
continue;
if (lesson.start > num) {
if (num < lunch[i] && lunch[i] < lesson.start) {
let y = row.appendChild(document.createElement('td'));
y.colSpan = lunch[i] - num;
num = lunch[i];
y.style.borderRight = '3px solid red'
}
let x = row.appendChild(document.createElement('td'));
x.colSpan = lesson.start - num;
if (lesson.start == lunch[i])
x.style.borderRight = '3px solid red'
insertEmpty(lesson.start)
}
let cell = row.appendChild(document.createElement('td'));
cell.colSpan = lesson.len;
@ -145,7 +166,9 @@ window.onload = async function() {
cell.firstChild.style.backgroundColor = classes[lesson.name].color;
cell.style.backgroundColor = classes[lesson.name].color;
if (lesson.start + lesson.len == lunch[i])
cell.style.borderRight = '3px solid red'
cell.style.borderRightColor = 'red';
if (lesson.start == lunch[i])
cell.style.borderLeftColor = 'red';
timetable.push({
name: lesson.name,
cell: cell,
@ -155,7 +178,11 @@ window.onload = async function() {
num = lesson.start + lesson.len;
lastEnd = end
}
if (num < starttimes.length)
insertEmpty(starttimes.length)
}
update_times();
setInterval(update_times, 1000);
setInterval(update_times, 1000); // update times every second
fill_subst();
setInterval(fill_subst, 1000*60*10); // check substitutions every ten minutes
}
Loading…
Cancel
Save