partey_workadventure/front/src/Logger/MessageUI.ts

27 lines
786 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");
body.insertAdjacentHTML('afterbegin', `
<div id="message-reconnect" class="message-info warning">
${text}
</div>
`);
}
static removeMessage(id : string = null) {
if(!id){
let messages = document.getElementsByClassName("message-info");
for (let i = 0; i < messages.length; i++){
messages.item(i).remove();
}
return;
}
let previousElement = document.getElementById(id);
if (!previousElement) {
return;
}
previousElement.remove();
}
}