adjust styling and bump dates etc
This commit is contained in:
parent
476bf0d6d9
commit
a584a5252f
40 changed files with 678 additions and 294 deletions
|
|
@ -1,25 +1,21 @@
|
|||
const spaceapiUrl = "https://spaceapi.hamburg.ccc.de"
|
||||
const interval_ms = 60000
|
||||
|
||||
console.log("clubstatus.js geladen!"); /* TODO: ENTFERNEN */
|
||||
|
||||
function timeDistanceDE(pastDate) {
|
||||
const seconds = Math.floor((Date.now() - pastDate.getTime()) / 1000)
|
||||
const minutes = Math.floor(seconds / 60)
|
||||
const hours = Math.floor(minutes / 60)
|
||||
const days = Math.floor(hours / 24)
|
||||
|
||||
if (days = 1) return `since ${days}d`
|
||||
if (days > 1) return `since ${days}d`
|
||||
if (hours = 1) return `since ${hours}h`
|
||||
if (hours > 1) return `since ${hours}h`
|
||||
if (minutes = 1) return `since ${minutes}min`
|
||||
if (minutes > 1) return `since ${minutes}min`
|
||||
if (days >= 1) return `seit ${days}d`
|
||||
if (hours >= 1) return `seit ${hours}h`
|
||||
if (minutes >= 1) return `seit ${minutes}min`
|
||||
return `gerade eben`
|
||||
}
|
||||
|
||||
function updateRoomState(openState, lastChangeTimestamp) {
|
||||
const roomstate = document.querySelector('#clubstatus-badge')
|
||||
if (!roomstate) return
|
||||
const statusItem = roomstate.querySelector(".state")
|
||||
const durationItem = roomstate.querySelector(".duration")
|
||||
|
||||
|
|
@ -30,17 +26,20 @@ function updateRoomState(openState, lastChangeTimestamp) {
|
|||
|
||||
if (openState === null || lastChangeTimestamp === null) {
|
||||
statusItem.textContent = "unbekannt"
|
||||
roomstate.classList.add("unknown")
|
||||
statusItem.classList.add("unknown")
|
||||
durationItem.textContent = "(since unbekannt)"
|
||||
durationItem.textContent = "(seit unbekannt)"
|
||||
} else {
|
||||
const changeDate = new Date(lastChangeTimestamp * 1000)
|
||||
const sinceText = timeDistanceDE(changeDate)
|
||||
|
||||
if (openState) {
|
||||
statusItem.textContent = "open"
|
||||
roomstate.classList.add("open")
|
||||
statusItem.classList.add("open")
|
||||
} else {
|
||||
statusItem.textContent = "closed"
|
||||
roomstate.classList.add("closed")
|
||||
statusItem.classList.add("closed")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue