summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-06-26 00:34:40 +0200
committerTor Andersson <tor@ccxvii.net>2021-06-26 00:34:40 +0200
commitc479b34bc340aaec7df8926321b47cdb5497f2dc (patch)
tree07104071b73b3eecccab5b2ef2907264c926fd96 /public
parentad4a4ea757cce61cde102be2aea2d07fe55aaa2c (diff)
downloadserver-c479b34bc340aaec7df8926321b47cdb5497f2dc.tar.gz
Handle deleted games in new join page.
Diffstat (limited to 'public')
-rw-r--r--public/join.js13
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);
}
}