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