Baltazár Radics 5 months ago
parent
commit
812118d617
Signed by: baltazar GPG Key ID: 9440F591E4397C3E
  1. 121
      11.IB.json
  2. BIN
      TalosEye.png
  3. 18
      index.html
  4. 74
      index.js
  5. 15
      timetable.webmanifest

121
11.IB.json

@ -4,230 +4,346 @@
{
"start": 1,
"len": 1,
"offset": 0,
"room": 106,
"name": "mat"
}, {
"start": 1,
"len": 1,
"offset": 0,
"room": 43,
"name": "MAT"
}, {
"start": 2,
"len": 1,
"offset": 0,
"room": 110,
"name": "fra"
}, {
"start": 2,
"len": 1,
"offset": 0,
"room": 30,
"name": "ném"
}, {
"start": 2,
"len": 1,
"offset": 0,
"room": 225,
"name": "oro"
}, {
"start": 2,
"len": 1,
"offset": 0,
"room": 120,
"name": "spa"
}, {
"start": 3,
"len": 2,
"offset": 0,
"room": 102,
"name": "mag"
}, {
"start": 5,
"len": 1,
"offset": 0,
"room": 228,
"name": "ang"
}, {
"start": 5,
"len": 1,
"offset": 0,
"room": 224,
"name": "ANG"
}, {
"start": 6,
"len": 1,
"offset": -5,
"room": 124,
"name": "fra"
}, {
"start": 6,
"len": 3,
"len": 1,
"offset": -5,
"room": 42,
"name": "fiz"
}, {
"start": 7,
"len": 2,
"offset": 5,
"room": 42,
"name": "fiz"
}
], [
{
"start": 0,
"len": 2,
"offset": 5,
"room": 109,
"name": "tör"
}, {
"start": 0,
"len": 2,
"offset": 0,
"room": 45,
"name": "KÉM"
}, {
"start": 2,
"len": 2,
"offset": 0,
"room": 224,
"name": "köz"
}, {
"start": 2,
"len": 2,
"offset": 0,
"room": 101,
"name": "pszi"
}, {
"start": 4,
"len": 1,
"offset": -5,
"room": 112,
"name": "inf"
}, {
"start": 4,
"len": 1,
"offset": -5,
"room": 48,
"name": "bio"
}, {
"start": 5,
"len": 1,
"offset": 5,
"room": 106,
"name": "mat"
}, {
"start": 5,
"len": 1,
"offset": 5,
"room": 118,
"name": "MAT"
}, {
"start": 6,
"len": 1,
"offset": 0,
"room": 102,
"name": "fra"
}, {
"start": 6,
"len": 1,
"offset": 0,
"room": 30,
"name": "ném"
}, {
"start": 6,
"len": 1,
"offset": 0,
"room": 225,
"name": "oro"
}, {
"start": 6,
"len": 1,
"offset": 0,
"room": 111,
"name": "spa"
}, {
"start": 7,
"len": 1,
"offset": 0,
"room": 48,
"name": "kém"
}
], [
{
"start": 0,
"len": 2,
"offset": 20,
"room": 43,
"name": "fiz"
}, {
"start": 2,
"len": 1,
"offset": 0,
"room": 228,
"name": "mag"
}, {
"start": 3,
"len": 1,
"offset": 0,
"room": 114,
"name": "tör"
}, {
"start": 3,
"len": 1,
"offset": 0,
"room": 43,
"name": "kém"
}, {
"start": 4,
"len": 2,
"offset": 0,
"room": 225,
"name": "ang"
}, {
"start": 4,
"len": 2,
"offset": 0,
"room": 208,
"name": "ANG"
}, {
"start": 6,
"len": 2,
"offset": 5,
"room": 35,
"name": "inf"
}, {
"start": 6,
"len": 2,
"offset": 5,
"room": 48,
"name": "bio"
}
], [
{
"start": 0,
"len": 2,
"offset": 20,
"room": 106,
"name": "mat"
}, {
"start": 0,
"len": 2,
"offset": 10,
"room": 42,
"name": "MAT"
}, {
"start": 2,
"len": 2,
"offset": 0,
"room": 207,
"name": "tok"
}, {
"start": 4,
"len": 1,
"offset": 0,
"room": 116,
"name": "fra"
}, {
"start": 4,
"len": 1,
"offset": 0,
"room": 30,
"name": "ném"
}, {
"start": 4,
"len": 1,
"offset": 0,
"room": 225,
"name": "oro"
}, {
"start": 4,
"len": 1,
"offset": 0,
"room": 111,
"name": "spa"
}, {
"start": 5,
"len": 2,
"offset": 0,
"room": 35,
"name": "inf"
}, {
"start": 5,
"len": 2,
"offset": 0,
"room": 47,
"name": "bio"
}, {
"start": 7,
"len": 2,
"offset": 5,
"room": 111,
"name": "tör"
}, {
"start": 7,
"len": 2,
"offset": 5,
"room": 45,
"name": "KÉM"
}
], [
{
"start": 0,
"len": 2,
"offset": 10,
"room": 43,
"name": "MAT"
}, {
"start": 0,
"len": 2,
"offset": 10,
"room": 224,
"name": "mag"
}, {
"start": 2,
"len": 1,
"offset": 0,
"room": 103,
"name": "tör"
}, {
"start": 3,
"len": 2,
"offset": 0,
"room": 208,
"name": "ang"
}, {
"start": 3,
"len": 2,
"offset": 0,
"room": 211,
"name": "ANG"
}, {
"start": 5,
"len": 1,
"offset": 5,
"room": 114,
"name": "köz"
}, {
"start": 5,
"len": 1,
"offset": 5,
"room": 110,
"name": "pszi"
}, {
"start": 6,
"len": 1,
"offset": 0,
"room": 228,
"name": "ofo"
}, {
"start": 7,
"len": 2,
"offset": 0,
"room": 104,
"name": "fra"
}, {
"start": 7,
"len": 2,
"offset": 0,
"room": 30,
"name": "ném"
}, {
"start": 7,
"len": 2,
"offset": 0,
"room": 225,
"name": "oro"
}, {
"start": 7,
"len": 2,
"offset": 0,
"room": 118,
"name": "spa"
}
]
@ -328,5 +444,6 @@
"gc": "MjA2MzQ4MTMyMTM2",
"color": ""
}
}
},
"lunch": [ 7, 5, 6, 7, 5 ]
}

BIN
TalosEye.png

After

Width: 590  |  Height: 590  |  Size: 21 KiB

18
index.html

@ -3,6 +3,7 @@
<meta charset='UTF-8'>
<title>Timetable</title>
<link rel="manifest" href="timetable.webmanifest">
<script src='index.js'></script>
<style>
html {
@ -14,15 +15,14 @@ body {
}
#timetable, .tile {
border: 1px solid #333;
}
.tile {
cursor: pointer;
border-collapse: collapse;
}
#timetable th {
width: 120px;
}
#timetable th, td {
#timetable th, #timetable td {
text-align: center;
border: 3px solid black;
}
#timetable {
empty-cells: hide;
@ -43,10 +43,12 @@ a {
color: inherit;
display: block;
}
.room::before {
content: 'Room ';
}
#bot {
margin: 10px;
}
#bot td>a,
#bot th {
padding: 10px;
}
@ -54,11 +56,13 @@ a {
position: relative;
padding: 0;
width: 160px;
text-align: center;
}
#progressbar {
position: absolute;
height: 100%;
z-index: -1;
top: 0;
}
</style>
@ -90,9 +94,9 @@ a {
<th>Next lesson</th>
</tr>
<tr>
<td><a id='cur'></a></td>
<td id='cur'></td>
<td><div id='progressbar'></div><a id='left'></a></td>
<td><a id='next'></a></td>
<td id='next'></td>
</tr>
</table>

74
index.js

@ -25,17 +25,29 @@ function cur_pmd() {
}
const starttimes = [
pmd( 7,20),
pmd( 7,10),
pmd( 8, 0),
pmd( 8,50),
pmd( 9, 0),
pmd(10, 0),
pmd(10,50),
pmd(11,40),
pmd(13,10),
pmd(11, 0),
pmd(12, 0),
pmd(13, 0),
pmd(14, 0),
pmd(14,50),
pmd(15, 0),
];
//const starttimes = [
// pmd( 7,20),
// pmd( 8, 0),
// pmd( 8,50),
// pmd(10, 0),
// pmd(10,50),
// pmd(11,40),
// pmd(13,10),
// pmd(14, 0),
// pmd(14,50),
//];
function dur_fmt(dur) {
dur = Math.floor(dur/1000);
const sec = ('0' + dur % 60).slice(-2);
@ -47,7 +59,6 @@ function dur_fmt(dur) {
let timetable = [];
let classes;
let guser;
function cur_lesson(time) {
let count = timetable.length;
@ -75,39 +86,37 @@ function update_times() {
const nexts = c > n && time > timetable[c].end ? 7*day : 0;
if (time < curc.end+curs) {
cur.innerText = classes[curc.name].pretty;
cur.href = `https://classroom.google.com/u/${guser}/c/${classes[curc.name].gc}`
cur.style.backgroundColor = classes[curc.name].color;
cur.replaceChildren(curc.cell.firstChild.cloneNode(true))
left.innerText = dur_fmt(curc.end+curs - time);
progressbar.style.width = 100*(curc.end+curs - time)/(curc.end - curc.start) + '%';
progressbar.style.backgroundColor = classes[curc.name].color;
progressbar.style.right = null;
} else {
cur.innerText = '-';
cur.removeAttribute('href');
cur.style.backgroundColor = null;
left.innerText = dur_fmt(nextc.start+nexts - time);
progressbar.style.width = 100*(1 - (nextc.start+nexts - time)/((nextc.start+nexts) - (curc.end+curs))) + '%';
progressbar.style.backgroundColor = classes[nextc.name].color;
progressbar.style.right = 0;
}
next.innerText = classes[nextc.name].pretty;
next.href = `https://classroom.google.com/u/${guser}/c/${classes[nextc.name].gc}`
next.style.backgroundColor = classes[nextc.name].color;
next.replaceChildren(nextc.cell.firstChild.cloneNode(true))
}
window.onload = async function() {
const formatter = new Intl.DateTimeFormat('default', { timeStyle: 'short', hourCycle: 'h23', timeZone: 'UTC' });
const params = new URLSearchParams(window.location.search);
const cls = params.get('class');
const filter = params.get('filter').split(',');
guser = params.get('authuser') ?? '1';
const usecolor = +(params.get('color') ?? '0');
const thing = await (await fetch(cls+'.json')).json();
localStorage.cls = params.get('class') ?? localStorage.cls;
localStorage.filter = params.get('filter') ?? localStorage.filter;
const filter = localStorage.filter.split(',');
localStorage.guser = params.get('authuser') ?? localStorage.guser ?? '1';
localStorage.usecolor = params.get('color') ?? localStorage.usecolor ?? '0'
const usecolor = +localStorage.usecolor;
const thing = await (await fetch(localStorage.cls+'.json', {cache: 'no-cache'})).json();
const table = thing.table;
const lunch = thing.lunch;
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];
for (let lesson of table[i]) {
@ -115,16 +124,28 @@ window.onload = async function() {
continue;
if (!filter.includes(lesson.name))
continue;
if (lesson.start > num)
row.appendChild(document.createElement('td')).colSpan = lesson.start - num;
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'
}
let cell = row.appendChild(document.createElement('td'));
cell.colSpan = lesson.len;
const start = starttimes[lesson.start] + mins(lesson.offset) + (i + 1) * day;
const end = start + mins(45*lesson.len);
cell.innerHTML = `<a href='https://classroom.google.com/u/${localStorage.guser}/c/${classes[lesson.name].gc}'><div class='lesson'>${classes[lesson.name].pretty}</div><span class='startt'>${formatter.format(start)}</span><span class='endt'>${formatter.format(end)}</span><div class='room'>${lesson.room}</div></a>`;
if (usecolor && classes[lesson.name].color)
cell.firstChild.style.backgroundColor = classes[lesson.name].color;
cell.style.backgroundColor = classes[lesson.name].color;
const start = starttimes[lesson.start] + (i + 1) * day;
const end = start + mins(40*lesson.len);
cell.innerHTML = `<a href='https://classroom.google.com/u/${guser}/c/${classes[lesson.name].gc}'><div class='lesson'>${classes[lesson.name].pretty}</div><span class='startt'>${formatter.format(start)}</span><span class='endt'>${formatter.format(end)}</span></a>`;
cell.className = 'tile';
if (lesson.start + lesson.len == lunch[i])
cell.style.borderRight = '3px solid red'
timetable.push({
name: lesson.name,
cell: cell,
@ -132,6 +153,7 @@ window.onload = async function() {
end: end,
});
num = lesson.start + lesson.len;
lastEnd = end
}
}
update_times();

15
timetable.webmanifest

@ -0,0 +1,15 @@
{
"name": "Timetable",
"short_name": "Timetable",
"description": "Timetable",
"background_color": "black",
"display": "standalone",
"icons": [
{
"src": "/timetable/TalosEye.png",
"sizes": "590x590",
"type": "image/png"
}
],
"start_url": "/timetable/index.html"
}
Loading…
Cancel
Save