diff --git a/public/javascripts/home.js b/public/javascripts/home.js new file mode 100644 index 0000000..fdea4e3 --- /dev/null +++ b/public/javascripts/home.js @@ -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}); +}); diff --git a/views/pages/home.pug b/views/pages/home.pug index 4088a8a..d84dc29 100644 --- a/views/pages/home.pug +++ b/views/pages/home.pug @@ -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 \ No newline at end of file + - 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") \ No newline at end of file