39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
/* ================================
|
|
Globale Notification Funktion
|
|
Wird von allen Modulen genutzt
|
|
================================ */
|
|
|
|
export function showNotification(message, title = "Hinweis", icon = "⚔️") {
|
|
const overlay = document.getElementById("game-notification-overlay");
|
|
const popup = document.getElementById("game-notification");
|
|
const msgEl = document.getElementById("notification-message");
|
|
const titleEl = document.getElementById("notification-title");
|
|
const iconEl = document.getElementById("notification-icon");
|
|
const okBtn = document.getElementById("notification-ok");
|
|
|
|
if (!overlay || !popup || !msgEl) return;
|
|
|
|
msgEl.innerText = message;
|
|
titleEl.innerText = title;
|
|
iconEl.innerText = icon;
|
|
|
|
overlay.classList.add("show");
|
|
popup.style.display = "block";
|
|
|
|
requestAnimationFrame(() => {
|
|
popup.classList.add("show");
|
|
});
|
|
|
|
// Alten Listener entfernen um Mehrfach-Klicks zu vermeiden
|
|
const newBtn = okBtn.cloneNode(true);
|
|
okBtn.parentNode.replaceChild(newBtn, okBtn);
|
|
|
|
newBtn.onclick = () => {
|
|
popup.classList.remove("show");
|
|
overlay.classList.remove("show");
|
|
setTimeout(() => {
|
|
popup.style.display = "none";
|
|
}, 200);
|
|
};
|
|
}
|