|
@@ -7,7 +7,7 @@ window.addEventListener("load", function()
|
|
|
const gridSlots = occupancyGrid.getElementsByClassName("slot")
|
|
|
|
|
|
const endpoint = `${window.location.href}/slots`
|
|
|
- setTimeout(updateSlots, 1000)
|
|
|
+ updateSlots()
|
|
|
|
|
|
function updateSlots()
|
|
|
{
|
|
@@ -18,20 +18,37 @@ window.addEventListener("load", function()
|
|
|
function setCheckboxes(data)
|
|
|
{
|
|
|
let maxParticipants = 0
|
|
|
+ const username = document.getElementById("username")
|
|
|
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')
|
|
|
+ if(data[participant][i] === '1')
|
|
|
+ {
|
|
|
participants.push(participant)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(username && data[username.value])
|
|
|
+ {
|
|
|
+ if(data[username.value][i] === '1')
|
|
|
+ {
|
|
|
+ slot.classList.add("my-slot")
|
|
|
+ document.getElementsByName(`slot_${i}`)[0].checked = true
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ slot.classList.remove("my-slot")
|
|
|
+ document.getElementsByName(`slot_${i}`)[0].checked = false
|
|
|
+ }
|
|
|
}
|
|
|
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)
|
|
|
+ this.document.getElementById("update-button").style.display = "none"
|
|
|
}
|
|
|
|
|
|
onCheckedChanged = function(checkables) {
|
|
@@ -45,6 +62,4 @@ window.addEventListener("load", function()
|
|
|
body: data,
|
|
|
}).then(response => response.json()).then(setCheckboxes)
|
|
|
}
|
|
|
-
|
|
|
- //this.document.getElementById("update-button").style.display = "none"
|
|
|
})
|