mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-25 14:36:15 -04:00
15 lines
397 B
TypeScript
15 lines
397 B
TypeScript
let div = document.createElement("div");
|
|
div.classList = "hidden toast";
|
|
document.body.appendChild(div);
|
|
let timeout: NodeJS.Timeout | undefined;
|
|
export function toast(html: string) {
|
|
div.classList = "toast visible";
|
|
div.innerHTML = html;
|
|
if (timeout) {
|
|
clearTimeout(timeout);
|
|
}
|
|
timeout = setTimeout(() => {
|
|
timeout = undefined;
|
|
div.classList = "hidden toast";
|
|
}, 1500);
|
|
}
|