add ability for admin to enqueue updates to the map; v0.2.6

This commit is contained in:
Iris Lightshard 2023-10-29 00:04:22 -06:00
parent 4435d1e130
commit 140e775d66
Signed by: nilix
GPG key ID: F54E0D40695271D4
5 changed files with 36 additions and 16 deletions

View file

@ -28,6 +28,7 @@ async function loadAdmin(name, pass) {
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 @@ async function loadAdmin(name, pass) {
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 @@ 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 = "<option value=''>select</option>";
@ -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});
}
}

View file

@ -146,14 +146,14 @@
</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>

View file

@ -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 || " ";
}
}

View file

@ -23,5 +23,5 @@
{{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>

View file

@ -19,5 +19,5 @@
{{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>