diff options
author | stale <redkugelblitzin@gmail.com> | 2022-05-31 04:04:53 -0300 |
---|---|---|
committer | stale <redkugelblitzin@gmail.com> | 2022-05-31 04:04:53 -0300 |
commit | d9eededb736e4ada13ee6e7fe517adcc6a606f88 (patch) | |
tree | 726e1e2a335cab290963dbd547e0dd0093de3f99 /assets/index.html | |
parent | 746a810eea15e52f7d1b17778239825daad90e01 (diff) |
room limits and player counts
Diffstat (limited to 'assets/index.html')
-rw-r--r-- | assets/index.html | 23 |
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> |