2022-01-10 19:34:58 +01:00
|
|
|
|
export default class NotificationMessage {
|
|
|
|
|
private static _notificationArea: HTMLElement = document.getElementById("notification") as HTMLElement;
|
2022-01-31 19:29:33 +01:00
|
|
|
|
private static _notificationPanelArea: HTMLElement = document.getElementById("panel-fenetre-notification") as HTMLElement;
|
2022-01-10 19:34:58 +01:00
|
|
|
|
private static _currentTimeout: NodeJS.Timeout | undefined;
|
|
|
|
|
public static ajouterNotification(message: string): void {
|
2022-01-31 19:29:33 +01:00
|
|
|
|
this.ajouterNotificationDiv(this._notificationArea, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ajouterNotificationPanel(message: string): void {
|
|
|
|
|
this.ajouterNotificationDiv(this._notificationPanelArea, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static ajouterNotificationDiv(div: HTMLElement, message: string): void {
|
2022-01-10 19:34:58 +01:00
|
|
|
|
if (this._currentTimeout) {
|
|
|
|
|
clearTimeout(this._currentTimeout);
|
|
|
|
|
this._currentTimeout = undefined;
|
|
|
|
|
}
|
2022-01-31 19:29:33 +01:00
|
|
|
|
div.innerHTML = message;
|
|
|
|
|
div.style.opacity = "1";
|
2022-01-10 19:34:58 +01:00
|
|
|
|
this._currentTimeout = setTimeout(
|
|
|
|
|
(() => {
|
2022-01-31 19:29:33 +01:00
|
|
|
|
div.style.opacity = "0";
|
2022-01-12 08:36:43 +01:00
|
|
|
|
this._currentTimeout = setTimeout(
|
|
|
|
|
(() => {
|
2022-01-31 19:29:33 +01:00
|
|
|
|
div.innerHTML = " ";
|
2022-01-12 08:36:43 +01:00
|
|
|
|
this._currentTimeout = undefined;
|
|
|
|
|
}).bind(this),
|
|
|
|
|
1000
|
|
|
|
|
);
|
2022-01-10 19:34:58 +01:00
|
|
|
|
}).bind(this),
|
|
|
|
|
5000
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|