diff --git a/index.js b/index.js index 20627a0..89acd1b 100644 --- a/index.js +++ b/index.js @@ -622,6 +622,10 @@ io.on('connection', async (socket) => { } }); + socket.on('logout', () => { + session.destroy(); + }); + socket.on('disconnecting', () => { if (bships.isPlayerInRoom(socket)) { io.to(socket.rooms[1]).emit("player left"); diff --git a/public/assets/css/main.css b/public/assets/css/main.css index b406656..efc086e 100644 --- a/public/assets/css/main.css +++ b/public/assets/css/main.css @@ -337,4 +337,27 @@ nav span:hover { border-radius: 15px; outline: none; margin-left: 2rem; +} + +#settingsView a { + text-decoration: none; + color: var(--dynamic); + + transition: opacity 0.3s; +} + +#settingsView a:hover { + opacity: 0.6; + text-decoration: underline; +} + +#logout { + color: var(--danger); + cursor: pointer; + + transition: opacity 0.3s; +} + +#logout:hover { + opacity: 0.6; } \ No newline at end of file diff --git a/public/assets/js/landing.js b/public/assets/js/landing.js index 233d66c..15e0100 100644 --- a/public/assets/js/landing.js +++ b/public/assets/js/landing.js @@ -99,7 +99,11 @@ loginForm.addEventListener('submit', (e) => { if (response.next === "done") { console.log("No authorisation required."); - window.location.reload(); + $("body").addClass("closed"); + + setTimeout(() => { + window.location.reload(); + }, 700); return; } diff --git a/public/assets/js/socket.js b/public/assets/js/socket.js index 1dd5953..bf6d98b 100644 --- a/public/assets/js/socket.js +++ b/public/assets/js/socket.js @@ -144,6 +144,12 @@ $("#pvpMenuButton").on("click", function () { switchView('pvpMenuView'); }); +$("#logout").on("click", function() { + lockUI(true); + socket.emit("logout"); + window.location.reload(); +}); + const form = document.getElementById('pvpJoinForm'); const input = document.getElementById('pvpJoinCode'); diff --git a/public/assets/js/spa_lib.js b/public/assets/js/spa_lib.js index 614cf00..037c31e 100644 --- a/public/assets/js/spa_lib.js +++ b/public/assets/js/spa_lib.js @@ -23,10 +23,10 @@ function switchView(viewContainerId, useReplaceState=false) { function lockUI(doLock) { if (doLock) { $("body").css("pointer-events", "none"); - $("body").css("opacity", "0.4"); + $(".container").css("opacity", "0.4"); } else { $("body").css("pointer-events", "inherit"); - $("body").css("opacity", "1"); + $(".container").css("opacity", "1"); } } diff --git a/views/index.handlebars b/views/index.handlebars index 79701c6..514412a 100644 --- a/views/index.handlebars +++ b/views/index.handlebars @@ -100,6 +100,8 @@ +