Widget:ClubStatus: Unterschied zwischen den Versionen

aus dem Wiki des Entropia e.V., CCC Karlsruhe
(Die Seite wurde neu angelegt: „<noinclude>__NOTOC__ {{#widget:ClubStatus}} </noinclude> <includeonly><span class="club-status"></span> <script> (() => { const OPENED_CLASS = 'club-status-opened'; const CLOSED_CLASS = 'club-status-closed'; const clubStatusMarker = document.querySelector('.club-status'); function setClubStatus(isOpen, lastChange) { if (isOpen) { clubStatusMarker.classList.remove(CLOSED_CLASS); clubStatusMarker.classList.add(OPENED_CLASS);…“)
 
Keine Bearbeitungszusammenfassung
 
(9 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
<noinclude>__NOTOC__
<noinclude>
 
__NOTOC__
{{#widget:ClubStatus}}
{{#widget:ClubStatus}}
 
</noinclude><includeonly><script>
</noinclude>
 
<includeonly><span class="club-status"></span>
<script>
(() => {
(() => {
   const OPENED_CLASS = 'club-status-opened';
   const OPENED_CLASS = 'widget-clubstatus__type--opened';
   const CLOSED_CLASS = 'club-status-closed';
   const CLOSED_CLASS = 'widget-clubstatus__type--closed';


   const clubStatusMarker = document.querySelector('.club-status');
   const clubStatusMarker = document.querySelector('#widget-clubstatus');


   function setClubStatus(isOpen, lastChange) {
   function setClubStatus(isOpen, lastChange) {
Zeile 17: Zeile 13:
       clubStatusMarker.classList.remove(CLOSED_CLASS);
       clubStatusMarker.classList.remove(CLOSED_CLASS);
       clubStatusMarker.classList.add(OPENED_CLASS);
       clubStatusMarker.classList.add(OPENED_CLASS);
       clubStatusMarker.innerHTML = 'geöffnet';
       clubStatusMarker.innerHTML = 'geöffnet';
     } else {
     } else {
       clubStatusMarker.classList.remove(OPENED_CLASS);
       clubStatusMarker.classList.remove(OPENED_CLASS);
Zeile 26: Zeile 22:
     const lastChangeDateTimeString = (new Date(lastChange).toLocaleString('de-DE'));
     const lastChangeDateTimeString = (new Date(lastChange).toLocaleString('de-DE'));


     clubStatusMarker.setAttribute('title', 'letzte Änderung: ' + lastChangeDateTimeString);
     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 39: Zeile 35:
   updateClubStatus();
   updateClubStatus();
})();
})();
</script>
</script></includeonly>
</includeonly>

Aktuelle Version vom 14. März 2024, 12:10 Uhr