Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
(8 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
<noinclude>__NOTOC__ | <noinclude> | ||
__NOTOC__ | |||
{{#widget:ClubStatus}} | {{#widget:ClubStatus}} | ||
</noinclude><includeonly><script> | |||
</noinclude> | |||
<includeonly> | |||
<script> | |||
(() => { | (() => { | ||
const OPENED_CLASS = ' | const OPENED_CLASS = 'widget-clubstatus__type--opened'; | ||
const CLOSED_CLASS = ' | const CLOSED_CLASS = 'widget-clubstatus__type--closed'; | ||
const clubStatusMarker = document.querySelector(' | const clubStatusMarker = document.querySelector('#widget-clubstatus'); | ||
function setClubStatus(isOpen, lastChange) { | function setClubStatus(isOpen, lastChange) { | ||
Zeile 18: | Zeile 13: | ||
clubStatusMarker.classList.remove(CLOSED_CLASS); | clubStatusMarker.classList.remove(CLOSED_CLASS); | ||
clubStatusMarker.classList.add(OPENED_CLASS); | clubStatusMarker.classList.add(OPENED_CLASS); | ||
clubStatusMarker.innerHTML = ' | clubStatusMarker.innerHTML = 'geöffnet'; | ||
} else { | } else { | ||
clubStatusMarker.classList.remove(OPENED_CLASS); | clubStatusMarker.classList.remove(OPENED_CLASS); | ||
Zeile 27: | Zeile 22: | ||
const lastChangeDateTimeString = (new Date(lastChange).toLocaleString('de-DE')); | const lastChangeDateTimeString = (new Date(lastChange).toLocaleString('de-DE')); | ||
clubStatusMarker.setAttribute('title', 'letzte | clubStatusMarker.setAttribute('title', 'letzte Änderung: ' + lastChangeDateTimeString); | ||
} | } | ||
function updateClubStatus() { | function updateClubStatus() { | ||
fetch('api/entropia-club-status-json-api.php') | fetch('/api/entropia-club-status-json-api.php') | ||
.then(response => response.json()) | .then(response => response.json()) | ||
.then(data => setClubStatus(data["isOpen"], data["lastChange"])); | .then(data => setClubStatus(data["isOpen"], data["lastChange"])); | ||
Zeile 40: | Zeile 35: | ||
updateClubStatus(); | updateClubStatus(); | ||
})(); | })(); | ||
</script> | </script></includeonly> | ||
</includeonly> |
Aktuelle Version vom 14. März 2024, 12:10 Uhr