mirror of
https://framagit.org/JonathanMM/sutom.git
synced 2025-01-09 04:41:30 +01:00
25 lines
851 B
TypeScript
25 lines
851 B
TypeScript
export default class NotificationMessage {
|
||
private static _notificationArea: HTMLElement = document.getElementById("notification") as HTMLElement;
|
||
private static _currentTimeout: NodeJS.Timeout | undefined;
|
||
public static ajouterNotification(message: string): void {
|
||
if (this._currentTimeout) {
|
||
clearTimeout(this._currentTimeout);
|
||
this._currentTimeout = undefined;
|
||
}
|
||
this._notificationArea.innerHTML = message;
|
||
this._notificationArea.style.opacity = "1";
|
||
this._currentTimeout = setTimeout(
|
||
(() => {
|
||
this._notificationArea.style.opacity = "0";
|
||
this._currentTimeout = setTimeout(
|
||
(() => {
|
||
this._notificationArea.innerHTML = " ";
|
||
this._currentTimeout = undefined;
|
||
}).bind(this),
|
||
1000
|
||
);
|
||
}).bind(this),
|
||
5000
|
||
);
|
||
}
|
||
}
|