all repos — felt @ 140e775d66d6144444fd3ccdbb0862b2da546c07

virtual tabletop for dungeons and dragons (and similar) using Go, MongoDB, and websockets

add ability for admin to enqueue updates to the map; v0.2.6
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQR2zYvweXfSPsSU6pP1Tg1AaVJx1AUCZT315gAKCRD1Tg1AaVJx
1GTmAP45eu4oJRzWtdZfoNYOHPIShy8Vcm3UWk5DoOBDiH+AkQD9GrJQLGdP4gRc
pTBImIFkFlH7ohqRCdGkEdfUv5jXjQs=
=qNx0
-----END PGP SIGNATURE-----
commit

140e775d66d6144444fd3ccdbb0862b2da546c07

parent

4435d1e1302ef9eb758daf0087cef705f62c8601

5 files changed, 36 insertions(+), 16 deletions(-)

jump to
M static/admin.jsstatic/admin.js

@@ -28,6 +28,7 @@

const table = await tableData.json() mgmtHTML = `<a href='#' onclick='getTables();return false;'>&larr; table list</a><br>\n` + + `<button id='q_toggle' onclick='toggleQ()'>Enqueue Updates</button>` + `<textarea id='aux_msg_input'>${table.auxMsg}</textarea><br><button onclick='publishAuxMsg()'>Set Status</button>\n` + `<button onclick='destroyTable()'>Destroy Table</button><br/>\n` + `<input id='map_img_upload' type='file'/><button onclick='uploadImg("map")'>Upload Map</button><br/>\n`

@@ -43,6 +44,7 @@ } else {

mgmtHTML += "<label>Maps couldn't be retrieved</label>"; } $("table_management").innerHTML = mgmtHTML; + q = false; let spriteListHTML = `<input id='token_img_upload' type='file'/><button onclick='uploadImg("token")'>Upload Sprite</button><br/>`;

@@ -69,6 +71,18 @@ setErr(`${err.name}: ${err.message}`);

} } +function toggleQ() { + const toggleBtn = $('q_toggle'); + q = !q; + if (!q) { + emptyMsgQ(); + toggleBtn.innerText = "Enqueue Updates" + } else { + toggleBtn.innerText = "Send Updates" + } + +} + function fillSpriteDropdown(sprites) { const dropdown = $("sprite_dropdown"); let options = "<option value=''>select</option>";

@@ -90,7 +104,6 @@ drawTokenOrigin();

break; default: scaleSpritePreview(source); - console.log("default case"); } } }

@@ -310,7 +323,7 @@

function publishAuxMsg() { const txtArea = $("aux_msg_input"); if (txtArea) { - publish({auxMsg: txtArea.value, auth: adminToken.access_token}); + publish({auxMsg: txtArea.value || " ", auth: adminToken.access_token}); } }
M static/index.htmlstatic/index.html

@@ -146,14 +146,14 @@ <button onclick="setTheme()">Apply</button><button onclick="resetTheme(defaultTheme)">Reset</button>

</form> </details> <div id="lag" style="display:none;">lag...</div> - <div class="ui_win" id="felt_info"><a href="https://hacklab.nilfm.cc/felt">felt v0.2.5</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LICENSE">license</a>) | built with <a href="https://leafletjs.com">leaflet</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LEAFLET_LICENSE">license</a>) </div> + <div class="ui_win" id="felt_info"><a href="https://hacklab.nilfm.cc/felt">felt v0.2.6</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LICENSE">license</a>) | built with <a href="https://leafletjs.com">leaflet</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LEAFLET_LICENSE">license</a>) </div> </nav> </body> <script>L_DISABLE_3D = window.location.hash.toLowerCase() === "#no3d";</script> <script src="./leaflet.js?v=1.9.4" type="text/javascript"></script> - <script src="./util.js?v=0.2.5" type="text/javascript"></script> - <script src="./map.js?v=0.2.5" type="text/javascript"></script> - <script src="./socket.js?v=0.2.5" type="text/javascript"></script> - <script src="./dice.js?v=0.2.5" type="text/javascript"></script> - <script src="./admin.js?v=0.2.5" type="text/javascript"></script> + <script src="./util.js?v=0.2.6" type="text/javascript"></script> + <script src="./map.js?v=0.2.6" type="text/javascript"></script> + <script src="./socket.js?v=0.2.6" type="text/javascript"></script> + <script src="./dice.js?v=0.2.6" type="text/javascript"></script> + <script src="./admin.js?v=0.2.6" type="text/javascript"></script> </html>
M static/socket.jsstatic/socket.js

@@ -6,6 +6,7 @@

let conn = null; let offline = false; const msgQ = []; +let q = false; function dial() { // get tableKey from UI

@@ -58,6 +59,8 @@ if (mapImg) {

mapImg.removeFrom(map); mapImg = null; } + + msgQ = []; } });

@@ -73,10 +76,7 @@ if (lagDiv) {

lagDiv.style.display = "none"; } - while (msgQ.some(m=>m)) { - publish(msgQ[0]); - msgQ.shift(); - } + emptyMsgQ(); closeErr(); tabletop = $("tabletop");

@@ -117,8 +117,15 @@ setErr("Table name and passcode required");

} } +function emptyMsgQ() { + while (msgQ.some(m=>m)) { + publish(msgQ[0]); + msgQ.shift(); + } +} + async function publish(msg) { - if (offline) { + if (offline || q) { msgQ.push(msg); } else {

@@ -202,7 +209,7 @@

function setAuxMsg(msg) { const auxDiv = $("aux"); if (auxDiv) { - auxDiv.innerText = msg; + auxDiv.innerText = msg || " "; } }
M templates/register.htmltemplates/register.html

@@ -23,5 +23,5 @@ <span class="error">The registration token you provided is invalid;<br/> obtain a new one.</span>

{{end}} </main> </body> -<script src="/table/util.js?v=0.2.5" type="text/javascript"></script> +<script src="/table/util.js?v=0.2.6" type="text/javascript"></script> </html>
M templates/registered.htmltemplates/registered.html

@@ -19,5 +19,5 @@ <span class="error">Something went wrong; please try a different username or obtain a new registration code.</span>

{{end}} </main> </body> -<script src="/table/util.js?v=0.2.5" type="text/javascript"></script> +<script src="/table/util.js?v=0.2.6" type="text/javascript"></script> </html>