MediaWiki:Common.js: Unterschied zwischen den Versionen
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1.050: | Zeile 1.050: | ||
navigator.serviceWorker.register('/app/labelscan/sw.js').catch(function(){}); | navigator.serviceWorker.register('/app/labelscan/sw.js').catch(function(){}); | ||
} | } | ||
// ------------------------------------------------------------ | |||
// ADOS: Countdown zur nächsten Messe (Bottle Market Bremen) | |||
// ------------------------------------------------------------ | |||
(function () { | |||
// Zieldatum: 12.12.2025, 9:00 Uhr, Bremen (MEZ = +01:00) | |||
// Wenn Uhrzeit ändern: einfach die 10:00:00 anpassen. | |||
var adosTimerTarget = new Date('2025-12-12T10:00:00+01:00'); | |||
// Nur im Haupt-Namespace anzeigen (Abfüllungs-/Artikel-Seiten) | |||
if (typeof mw !== 'undefined' && mw.config.get('wgNamespaceNumber') !== 0) { | |||
return; | |||
} | |||
// Falls Datum kaputt -> nichts tun | |||
if (isNaN(adosTimerTarget.getTime())) { | |||
return; | |||
} | |||
function domReady(fn) { | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', fn); | |||
} else { | |||
fn(); | |||
} | |||
} | |||
domReady(function () { | |||
// Timer-Bar einbauen | |||
var bar = document.createElement('div'); | |||
bar.id = 'ados-timer-bar'; | |||
bar.innerHTML = | |||
'<div id="ados-timer-inner">' + | |||
'<span id="ados-timer-message">Nächste Messe: Bottle Market Bremen (Brühler Whiskyhaus) in </span>' + | |||
'<span id="ados-timer-countdown">–:–:–:–</span>' + | |||
'<button id="ados-timer-close" type="button" title="Ausblenden">×</button>' + | |||
'</div>'; | |||
document.body.appendChild(bar); | |||
document.body.className += ' has-ados-timer'; | |||
var countdownEl = document.getElementById('ados-timer-countdown'); | |||
var closeBtn = document.getElementById('ados-timer-close'); | |||
bar.style.display = 'block'; | |||
if (closeBtn) { | |||
closeBtn.onclick = function () { | |||
bar.style.display = 'none'; | |||
document.body.className = document.body.className.replace(/\bhas-ados-timer\b/g, ''); | |||
}; | |||
} | |||
function pad(num) { | |||
return num < 10 ? '0' + num : '' + num; | |||
} | |||
function updateTimer() { | |||
var now = new Date(); | |||
var diff = adosTimerTarget.getTime() - now.getTime(); | |||
if (diff <= 0) { | |||
countdownEl.innerHTML = '🔔 Jetzt auf dem Bottle Market!'; | |||
clearInterval(intervalId); | |||
return; | |||
} | |||
var secTotal = Math.floor(diff / 1000); | |||
var days = Math.floor(secTotal / 86400); | |||
var hours = Math.floor((secTotal % 86400) / 3600); | |||
var mins = Math.floor((secTotal % 3600) / 60); | |||
var secs = secTotal % 60; | |||
var text; | |||
if (days > 0) { | |||
text = days + 'T ' + pad(hours) + ':' + pad(mins) + ':' + pad(secs); | |||
} else { | |||
text = pad(hours) + ':' + pad(mins) + ':' + pad(secs); | |||
} | |||
countdownEl.textContent = text; | |||
} | |||
// Direkt initialisieren & dann jede Sekunde aktualisieren | |||
updateTimer(); | |||
var intervalId = window.setInterval(updateTimer, 1000); | |||
}); | |||
})(); | |||