mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
connection/reconnection logic
This commit is contained in:
@@ -30,6 +30,10 @@ export class GameStateRenderer {
|
||||
}
|
||||
|
||||
renderLobbyHeader() {
|
||||
let existingTitle = document.querySelector('#game-link h1');
|
||||
if (existingTitle) {
|
||||
existingTitle.remove();
|
||||
}
|
||||
let title = document.createElement("h1");
|
||||
title.innerText = "Lobby";
|
||||
document.getElementById("game-title").appendChild(title);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
export const toast = (message, type, positionAtTop = true) => {
|
||||
export const toast = (message, type, positionAtTop = true, dispelAutomatically=true) => {
|
||||
if (message && type) {
|
||||
buildAndInsertMessageElement(message, type, positionAtTop);
|
||||
buildAndInsertMessageElement(message, type, positionAtTop, dispelAutomatically);
|
||||
}
|
||||
};
|
||||
|
||||
function buildAndInsertMessageElement (message, type, positionAtTop) {
|
||||
function buildAndInsertMessageElement (message, type, positionAtTop, dispelAutomatically) {
|
||||
cancelCurrentToast();
|
||||
let backgroundColor;
|
||||
const position = positionAtTop ? 'top:3rem;' : 'bottom: 35px;';
|
||||
@@ -19,9 +19,16 @@ function buildAndInsertMessageElement (message, type, positionAtTop) {
|
||||
backgroundColor = '#bef5cb';
|
||||
break;
|
||||
}
|
||||
|
||||
let animation = '';
|
||||
if (dispelAutomatically) {
|
||||
animation = 'animation:fade-in-slide-down-then-exit 6s ease normal forwards';
|
||||
} else {
|
||||
animation = 'animation:fade-in-slide-down 6s ease normal forwards';
|
||||
}
|
||||
const messageEl = document.createElement("div");
|
||||
messageEl.setAttribute("id", "current-info-message");
|
||||
messageEl.setAttribute("style", 'background-color:' + backgroundColor + ';' + position)
|
||||
messageEl.setAttribute("style", 'background-color:' + backgroundColor + ';' + position + animation);
|
||||
messageEl.setAttribute("class", 'info-message');
|
||||
messageEl.innerText = message;
|
||||
document.body.prepend(messageEl);
|
||||
|
||||
Reference in New Issue
Block a user