1
0
Fork 0

Setup Time Schedule on home page

This commit is contained in:
Ethanell 2021-01-20 22:40:40 +01:00
parent e4535a9c7e
commit c8e156dc72
2 changed files with 46 additions and 16 deletions

View file

@ -0,0 +1,35 @@
const socket = io.connect();
socket.on("agendaGet", data => {
document.querySelectorAll(".eventName, .eventLocation").forEach(p => p.innerHTML = "");
data.forEach(event => {
let day = new Date(event.startDate);
let y = day.getHours();
if (y >= 8 && y < 10)
y = 0;
else if (y >= 10 && y < 12)
y = 1;
else if (y >= 12 && y < 14)
y = 2;
else if (y >= 14 && y < 16)
y = 3;
else if (y >= 16 && y < 18)
y = 4;
else
y = null;
if (y != null) {
let el = document.getElementById(`${y}`);
el.dataset.id = event.id;
el.querySelector(".eventName").innerHTML = event.name;
el.querySelector(".eventLocation").innerHTML = event.locations;
}
});
});
document.addEventListener("DOMContentLoaded", () => {
let startDate = new Date();
let endDate = new Date();
startDate.setHours(0, 0, 0, 0);
endDate.setHours(23, 0, 0, 0);
socket.emit("agendaGet", { groups: groups.map(g => g.id), startDate: startDate, endDate: endDate});
});

View file

@ -21,20 +21,15 @@ block content
div
p Maths
p S26
div(class="col s12 m6" id="edtjour")
div(class="col s10 offset-s1 edtflex")
div(class="edthead")
div#edtjour(class="col s12 m6")
div.edtflex(class="col s10 offset-s1")
div.edthead
p Time Schedule
div
p Maths
p S26
div
p Maths
p S26
div(class="edtmidi")
div
p Maths
p S26
div
p Maths
p S26
- for (let i = 0; i < 5; i++)
div(style="min-height: 10vh" id=i)
p.eventName
p.eventLocation
script#removeMe.
let groups = !{JSON.stringify(session.user.Groups)};
document.getElementById("removeMe").remove();
script(src="/javascripts/home.js")