Fix WebSocket, add auto refresh on frontend update
This commit is contained in:
20
ejs/footer.ejs
Normal file
20
ejs/footer.ejs
Normal file
@@ -0,0 +1,20 @@
|
||||
<script>
|
||||
let ws;
|
||||
|
||||
function connectWebSocket() {
|
||||
const ws = new WebSocket((window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + window.location.pathname);
|
||||
|
||||
|
||||
ws.onmessage = async (event) => {
|
||||
if (event.data === 'update') {
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
setTimeout(connectWebSocket, 5000);
|
||||
};
|
||||
}
|
||||
|
||||
connectWebSocket();
|
||||
</script>
|
||||
57
ejs/home.ejs
Normal file
57
ejs/home.ejs
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||
<title>XernoBomb</title>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #111;
|
||||
color: white;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.home {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
a {
|
||||
background-color: #505050;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="home">
|
||||
<h1>XernoBomb</h1>
|
||||
<a href="/create">Create lobby</a>
|
||||
<a href="/lobbies">Search Lobbies</a>
|
||||
</div>
|
||||
</body>
|
||||
<%- include('footer') %>
|
||||
</html>
|
||||
Reference in New Issue
Block a user