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

View File

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

View File

@ -90,6 +90,14 @@
</template> </template>
</div> </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> <script src='app.js'></script>
</body> </body>
</html> </html>