partey_workadventure/front/src/Logger/MessageUI.ts
2020-06-19 14:30:34 +02:00

28 lines
800 B
TypeScript

export class MessageUI {
static warningMessage(text: string){
this.removeMessage();
const body = document.getElementById("body");
body?.insertAdjacentHTML('afterbegin', `
<div id="message-reconnect" class="message-info warning">
${text}
</div>
`);
}
static removeMessage(id : string|null = null) {
if(!id){
const messages = document.getElementsByClassName("message-info");
for (let i = 0; i < messages.length; i++){
messages.item(i)?.remove();
}
return;
}
const previousElement = document.getElementById(id);
if (!previousElement) {
return;
}
previousElement.remove();
}
}