From 140e775d66d6144444fd3ccdbb0862b2da546c07 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sun, 29 Oct 2023 00:04:22 -0600 Subject: [PATCH] add ability for admin to enqueue updates to the map; v0.2.6 --- static/admin.js | 17 +++++++++++++++-- static/index.html | 12 ++++++------ static/socket.js | 19 +++++++++++++------ templates/register.html | 2 +- templates/registered.html | 2 +- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/static/admin.js b/static/admin.js index ae41075..1374726 100644 --- a/static/admin.js +++ b/static/admin.js @@ -28,6 +28,7 @@ async function loadAdmin(name, pass) { const table = await tableData.json() mgmtHTML = `← table list
\n` + + `` + `
\n` + `
\n` + `
\n` @@ -43,6 +44,7 @@ async function loadAdmin(name, pass) { mgmtHTML += ""; } $("table_management").innerHTML = mgmtHTML; + q = false; let spriteListHTML = `
`; @@ -69,6 +71,18 @@ async function loadAdmin(name, pass) { } } +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 = ""; @@ -90,7 +104,6 @@ function previewSprite(source) { break; default: scaleSpritePreview(source); - console.log("default case"); } } } @@ -310,7 +323,7 @@ function renderTokenMasterList() { 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}); } } diff --git a/static/index.html b/static/index.html index 872cf87..405df7e 100644 --- a/static/index.html +++ b/static/index.html @@ -146,14 +146,14 @@ -
felt v0.2.5 (license) | built with leaflet (license)
+
felt v0.2.6 (license) | built with leaflet (license)
- - - - - + + + + + diff --git a/static/socket.js b/static/socket.js index be8bd6d..9e8c45e 100644 --- a/static/socket.js +++ b/static/socket.js @@ -6,6 +6,7 @@ const tableKey = { let conn = null; let offline = false; const msgQ = []; +let q = false; function dial() { // get tableKey from UI @@ -58,6 +59,8 @@ function dial() { mapImg.removeFrom(map); mapImg = null; } + + msgQ = []; } }); @@ -73,10 +76,7 @@ function dial() { lagDiv.style.display = "none"; } - while (msgQ.some(m=>m)) { - publish(msgQ[0]); - msgQ.shift(); - } + emptyMsgQ(); closeErr(); tabletop = $("tabletop"); @@ -117,8 +117,15 @@ function dial() { } } +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 logDice(dice) { function setAuxMsg(msg) { const auxDiv = $("aux"); if (auxDiv) { - auxDiv.innerText = msg; + auxDiv.innerText = msg || " "; } } diff --git a/templates/register.html b/templates/register.html index a346f87..d7a7e6b 100644 --- a/templates/register.html +++ b/templates/register.html @@ -23,5 +23,5 @@ {{end}} - + \ No newline at end of file diff --git a/templates/registered.html b/templates/registered.html index d15df8d..1addc77 100644 --- a/templates/registered.html +++ b/templates/registered.html @@ -19,5 +19,5 @@ {{end}} - + \ No newline at end of file