|
@@ -0,0 +1,33 @@
|
|
|
+window.addEventListener("load", function()
|
|
|
+{
|
|
|
+ const slotPicker = document.getElementsByClassName("slot-picker")[0]
|
|
|
+ const inputs = slotPicker.getElementsByTagName("input")
|
|
|
+
|
|
|
+ const occupancyGrid = document.getElementsByClassName("occupancy-grid")[0]
|
|
|
+ const gridSlots = occupancyGrid.getElementsByClassName("slot")
|
|
|
+
|
|
|
+ const endpoint = `${window.location.href}/slots`
|
|
|
+ setTimeout(updateSlots, 1000)
|
|
|
+
|
|
|
+ function updateSlots()
|
|
|
+ {
|
|
|
+ setTimeout(updateSlots, 5000)
|
|
|
+ fetch(endpoint).then(response => response.json()).then(data => {
|
|
|
+ let maxParticipants = 0
|
|
|
+ for(let i=0; i<gridSlots.length; i++)
|
|
|
+ {
|
|
|
+ const slot = document.getElementById(`grid_slot_${i}`)
|
|
|
+ let participants = []
|
|
|
+ for(let participant in data)
|
|
|
+ {
|
|
|
+ if(data[participant][i] == '1')
|
|
|
+ participants.push(participant)
|
|
|
+ }
|
|
|
+ slot.style.setProperty("--color-index", participants.length)
|
|
|
+ slot.title = `${slot.title.split('\n')[0]}\n${participants.join(", ")}`
|
|
|
+ maxParticipants = Math.max(participants.length, maxParticipants)
|
|
|
+ }
|
|
|
+ occupancyGrid.style.setProperty("--color-count", maxParticipants)
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|