COVID-19 INF regulations update

This commit is contained in:
Claudio Maggioni 2020-09-22 16:58:15 +02:00
parent 86f43a4b43
commit 95c7d93d76
4 changed files with 60 additions and 11 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*~

48
app.js
View File

@ -30,12 +30,37 @@ function roomStatus(room, callback) {
end.setSeconds(0);
parsed.push({
title: lesson.getAttribute('title'),
title: lesson.getAttribute('title').trim(),
start: start,
end: end
});
}
let start = new Date();
start.setHours(0);
start.setMinutes(0);
start.setSeconds(0);
let s = start;
let end = new Date();
end.setHours(23);
end.setMinutes(59);
end.setSeconds(0);
const holes = [];
for (let i = 0; i <= parsed.length; i++) {
const time = i == parsed.length ? end : parsed[i].start;
if (time > s) {
holes.push({title: "Unassigned", start: s, end: time});
}
if (time != end) {
s = parsed[i].end;
}
}
parsed.push(...holes);
resolve(parsed);
});
xhr.open('GET', URL + room);
@ -77,16 +102,22 @@ function colorRoom(roomTitle, node, time = NOW /* QuantumLeap */) {
return
}
const currentLecture = data.filter(d => d.start < time && d.end > time)[0];
const isFree = currentLecture === void(0);
const currentLecture = data.filter(d => d.start < time && d.end > time)[0] || null;
const isFree = !!currentLecture && !!currentLecture.title &&
currentLecture.title === "Overflow";
console.log(roomTitle, isFree);
const block = document.getElementById(roomTitle);
block.className = block.className.replace(" room-in-use", "")
.replace(" room-free", "");
block.className += isFree ? " room-free" : " room-in-use";
block.className = block.className
.replace(" room-in-use", "")
.replace(" room-free", "")
.replace(" room-unassigned", "");
block.className += isFree ? " room-free" :
currentLecture.title === "Unassigned" ? " room-unassigned" : " room-in-use";
block.querySelector('p').innerHTML = isFree ? 'Free' :
currentLecture.title + "<br> (" + formatTime(currentLecture.start) + " - " +
block.querySelector('p').innerHTML = isFree ? 'Free (overflow)' :
(currentLecture ? currentLecture.title : "Unassigned") +
"<br> (" + formatTime(currentLecture.start) + " - " +
formatTime(currentLecture.end) + ")";
}
@ -99,6 +130,7 @@ async function buildRoomMarkup(roomTitle) {
const list = room.querySelector('.list');
for (const d of data) {
if (d.title === "Unassigned" || d.title === "Overflow") continue;
const slot = document.importNode(SLOT_TEMPLATE.content, true);
const title = slot.querySelector('.title');
title.innerHTML = d.title;

View File

@ -169,7 +169,7 @@ input[type="range"]::-moz-range-progress {
/* Schedule */
.schedule {
.schedule, .warning {
border: #00000033 solid 1px;
border-radius: 6px;
box-shadow: 0 1px 3px #0000001a;
@ -229,13 +229,21 @@ input[type="range"]::-moz-range-progress {
.room-free {
background-color: #3FE1B0;
background-color: #3fe1b0;
}
.room-free:hover {
box-shadow: 0 4px 8px #b3ffe333;
}
.room-unassigned {
background-color: #fe8a4f;
}
.room-unassigned:hover {
box-shadow: 0 4px 8px #b3fe8a4f;
}
.room-in-use {
background-color: #ff6a75;
}
@ -250,7 +258,7 @@ input[type="range"]::-moz-range-progress {
box-shadow: 0 0 0 #00000000;
}
.schedule {
.schedule, .warning {
border: #384047 solid 1px;
background-color: #2d3339;
box-shadow: 0 0 0 #00000000;

View File

@ -90,6 +90,14 @@
</template>
</div>
<div class="warning">
<h3>Updated to latest Decanato rules about room usage according to
COVID-19 regulations.</h3> Rooms that are marked with "Free (overflow)"
(here in
green) can be used for unbooked activities (e.g. studying or working on
homework)
</div>
<script src='app.js'></script>
</body>
</html>