From d0237e13a603928feca838acf8e25b8c2d431c2f Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 13 Aug 2026 22:08:21 +0200 Subject: [PATCH] add a button to display bag content --- public/index.html | 1 + public/trivabble.js | 25 +++++++++++++++++++++++++ server/trivabble-server.js | 10 ++++++++++ 3 files changed, 36 insertions(+) diff --git a/public/index.html b/public/index.html index 182d8a0..eb03bab 100644 --- a/public/index.html +++ b/public/index.html @@ -166,6 +166,7 @@ +

Tip!

diff --git a/public/trivabble.js b/public/trivabble.js index b3d65f4..41490f5 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -1182,6 +1182,16 @@ } } + function showBag(bag) { + const letters = document.createElement("div"); + letters.className = "tile-list"; + + const content = infoMessage(_("Bag contains:") + " "); + bag.sort().map(function (letter) { letters.appendChild(makeLetter(letter, false, true))}); + content.appendChild(letters); + //myAlert(letters); + } + function applyAction(data) { switch (data.action) { case "pushBag": //TODO @@ -1235,6 +1245,11 @@ case "setRackCell": setRackCell(data.indexTo, data.letter); + break; + + case "showBag": + showBag(data.bag); + break; } } @@ -2179,6 +2194,15 @@ ); } + function askShowBag() { + myConfirm( + _("Do you really want to see bag content? It's a kind of cheating!"), + function () { + sendCmds([{cmd: "showBag"}]); + } + ); + } + function triggerFlashLight(cell) { if (!cell) { return; @@ -2682,6 +2706,7 @@ document.getElementById("next-help-msg").onclick = nextHelpMessage; document.getElementById("disable-spell-checker").onclick = toggleSpellChecker; document.getElementById("score-words").onclick = scoreWords; + document.getElementById("ask-show-bag").onclick = askShowBag; document.getElementById("theme").onchange = onChangeTheme; window.addEventListener("keydown", function (e) { if (e.key === "Escape") { diff --git a/server/trivabble-server.js b/server/trivabble-server.js index 3216cbf..63325a1 100644 --- a/server/trivabble-server.js +++ b/server/trivabble-server.js @@ -929,6 +929,16 @@ function handleCommand(cmdNumber, message, response) { } + case "showBag": { + reply(message, response, cmdNumber, { + error: 0, + action: "showBag", + bag: game.bag + }); + + break; + } + case "msg": { const msg = { date: new Date(), -- 2.30.2