summaryrefslogtreecommitdiff
path: root/assets/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'assets/index.html')
-rw-r--r--assets/index.html23
1 files changed, 20 insertions, 3 deletions
diff --git a/assets/index.html b/assets/index.html
index 9517529..f85b733 100644
--- a/assets/index.html
+++ b/assets/index.html
@@ -7,16 +7,23 @@
<link rel="stylesheet" type="text/css" href="./s.css">
</head>
<body>
- <div id="rlist" class="cent"></div>
+ <div class="cent">
+ <div id="rlist"></div>
+ <span id="rspace"></span>
+ </div>
<script>
let rlist = document.getElementById('rlist');
- fetch('rlist').then(r => r.json()).then(rooms => {
+ fetch('rlist').then(r => r.json()).then(info => {
+ let rooms = info[0];
+ let pcounts = info[1];
Object.keys(rooms).forEach(x => {
let roominfo = JSON.parse(rooms[x]);
+ let pc = Number(pcounts[x]);
let bc = roominfo.board_conf;
let a = document.createElement('a');
let h1 = document.createElement('h1');
- h1.appendChild(document.createTextNode(`> ${roominfo.name}`));
+ let ptxt = (pc > 0)? ((pc > 1)? `${pc} players`: `${pc} player`) : "no players";
+ h1.appendChild(document.createTextNode(`> ${roominfo.name} — ${ptxt}`));
let h4 = document.createElement('h4');
h4.appendChild(document.createTextNode(`${bc.w} by ${bc.h} with ${bc.mine_ratio[0]} in every ${bc.mine_ratio[1]} tiles mined`));
a.append(h1);
@@ -26,6 +33,16 @@
rlist.append(document.createElement('br'));
});
});
+ fetch("rspace").then(resp => resp.text()).then(roomspace => {
+ let roomspacenum = Number(roomspace);
+ let e = document.getElementById('rspace');
+ let t = document.createTextNode("room slots filled, if a room empties of active players it can be replaced by a new one");
+ if (roomspacenum == 1) {
+ e.appendChild(document.createTextNode(`there is one available room slot`));
+ } else if (roomspacenum > 1) {
+ e.appendChild(document.createTextNode(`there are ${roomspacenum} available room slots`));
+ }
+ })
</script>
<form method="post" action="r" class="cent">
<fieldset>