diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-06-26 00:34:40 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-06-26 00:34:40 +0200 |
commit | c479b34bc340aaec7df8926321b47cdb5497f2dc (patch) | |
tree | 07104071b73b3eecccab5b2ef2907264c926fd96 /public/join.js | |
parent | ad4a4ea757cce61cde102be2aea2d07fe55aaa2c (diff) | |
download | server-c479b34bc340aaec7df8926321b47cdb5497f2dc.tar.gz |
Handle deleted games in new join page.
Diffstat (limited to 'public/join.js')
-rw-r--r-- | public/join.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/public/join.js b/public/join.js index 96ca321..31d2bcc 100644 --- a/public/join.js +++ b/public/join.js @@ -1,11 +1,12 @@ "use strict"; let evtsrc = null; +let timer = 0; function confirm_delete(status) { let warning = "Are you sure you want to DELETE this game?"; if (window.confirm(warning)) - window.open("/delete/" + game.game_id); + window.location.href = "/delete/" + game.game_id; } function send(url) { @@ -34,10 +35,16 @@ function start_event_source() { evtsrc.addEventListener("game", function (evt) { console.log("GAME:", evt.data); game = JSON.parse(evt.data); - if (game.status > 1) + if (game.status > 1) { + clearInterval(timer); evtsrc.close(); + } update(); }); + evtsrc.addEventListener("deleted", function (evt) { + console.log("DELETED"); + window.location.href = '/info/' + game.title_id; + }); evtsrc.onerror = function (err) { window.message.innerHTML = "Disconnected from server..."; }; @@ -104,6 +111,6 @@ window.onload = function () { update(); if (game.status < 2) { start_event_source(); - setInterval(start_event_source, 15000); + timer = setInterval(start_event_source, 15000); } } |