partey_workadventure/front/src/Logger/MessageUI.ts

28 lines
794 B
TypeScript
Raw Normal View History

2020-05-13 20:22:42 +02:00
export class MessageUI {
static warningMessage(text: string){
this.removeMessage();
let body = document.getElementById("body");
2020-06-03 11:55:31 +02:00
body?.insertAdjacentHTML('afterbegin', `
2020-05-13 20:22:42 +02:00
<div id="message-reconnect" class="message-info warning">
${text}
</div>
`);
}
2020-06-03 11:55:31 +02:00
static removeMessage(id : string|null = null) {
2020-05-13 20:22:42 +02:00
if(!id){
let messages = document.getElementsByClassName("message-info");
for (let i = 0; i < messages.length; i++){
2020-06-03 11:55:31 +02:00
messages.item(i)?.remove();
2020-05-13 20:22:42 +02:00
}
return;
}
let previousElement = document.getElementById(id);
if (!previousElement) {
return;
}
previousElement.remove();
}
2020-06-03 11:55:31 +02:00
}