summaryrefslogtreecommitdiff
path: root/assets/index.html
diff options
context:
space:
mode:
authorstale <redkugelblitzin@gmail.com>2022-07-03 04:24:51 -0300
committerstale <redkugelblitzin@gmail.com>2022-07-03 04:24:51 -0300
commitf8735f5b539b991f8da9ec1b3e64966566d77477 (patch)
tree6a5a87bcabbff808a200bddc372ebca7ae420f83 /assets/index.html
parente933ae3795a27a0fad1f37189670c993d8b65f47 (diff)
sounds!
Diffstat (limited to 'assets/index.html')
-rw-r--r--assets/index.html23
1 files changed, 16 insertions, 7 deletions
diff --git a/assets/index.html b/assets/index.html
index 9729132..7961bde 100644
--- a/assets/index.html
+++ b/assets/index.html
@@ -40,6 +40,7 @@
elem: document.getElementById('rlist'),
map: new Map(),
};
+ let active_rids = [];
let rspace = {
elem: document.getElementById('rspace'),
num: NaN,
@@ -50,7 +51,8 @@
fetch('rlist').then(r => r.json()).then(info => {
let rooms = info[0];
let pcounts = info[1];
- Object.keys(rooms).forEach(id => {
+ active_rids = Object.keys(rooms);
+ active_rids.forEach(id => {
let room = rlist.map.get(id);
if (!room) { room = { init: false }; }
let rinfo = JSON.parse(rooms[id]);
@@ -60,6 +62,13 @@
room.board_conf = rinfo.board_conf;
rlist.map.set(id, room);
});
+ for (id of rlist.map.keys()) {
+ if (!active_rids.includes(id)) {
+ let r = rlist.map.get(id);
+ r.entry.remove();
+ rlist.map.delete(id);
+ }
+ }
callback();
});
fetch("rspace").then(resp => resp.text()).then(roomspace => {
@@ -72,7 +81,7 @@
rlist.map.forEach((room, id) => {
let full = room.pcount == room.pcapacity;
if (!room.init) {
- let entry = (full)? document.createElement('span') : document.createElement('a');
+ room.entry = (full)? document.createElement('span') : document.createElement('a');
room.h1 = document.createElement("h1");
room.h1_txt = document.createTextNode("");
room.h1.appendChild(room.h1_txt);
@@ -81,11 +90,11 @@
`${room.board_conf.w} by ${room.board_conf.h} with
${room.board_conf.mine_ratio[0]} in every ${room.board_conf.mine_ratio[1]} tiles mined`
));
- entry.append(room.h1);
- entry.append(room.h4);
- entry.href = 'room/' + id;
- rlist.elem.append(entry);
- rlist.elem.append(document.createElement('br'));
+ room.entry.append(room.h1);
+ room.entry.append(room.h4);
+ room.entry.append(document.createElement('br'));
+ room.entry.href = 'room/' + id;
+ rlist.elem.append(room.entry);
room.init = true;
}
let ptxt = `${room.pcount}/${room.pcapacity} players` + ((full)? " (full)" : "");