2025-04-15 21:28:00 +02:00
|
|
|
let div = document.createElement("div");
|
|
|
|
div.classList = "hidden toast";
|
|
|
|
document.body.appendChild(div);
|
|
|
|
let timeout: NodeJS.Timeout | undefined;
|
2025-05-03 18:29:54 +02:00
|
|
|
export function toast(html: string, className = "") {
|
2025-05-03 20:22:25 +02:00
|
|
|
clearToasts();
|
2025-05-03 18:29:54 +02:00
|
|
|
div.classList = "toast visible " + className;
|
2025-04-15 16:47:04 +02:00
|
|
|
div.innerHTML = html;
|
2025-05-03 19:41:45 +02:00
|
|
|
timeout = setTimeout(clearToasts, 1500);
|
|
|
|
}
|
|
|
|
|
2025-05-03 20:22:25 +02:00
|
|
|
export function clearToasts() {
|
2025-04-15 21:28:00 +02:00
|
|
|
if (timeout) {
|
|
|
|
clearTimeout(timeout);
|
2025-05-03 20:22:25 +02:00
|
|
|
timeout = undefined;
|
2025-04-15 16:47:04 +02:00
|
|
|
}
|
2025-05-03 20:22:25 +02:00
|
|
|
div.classList = "hidden toast";
|
|
|
|
}
|