From: Laurent Mazet Date: Mon, 3 Feb 2025 22:44:02 +0000 (+0100) Subject: add a warning when leaving a game in progess during a join X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=1590d0be000391d3a98f4fefda181f849bfff41b;p=trivabble.git add a warning when leaving a game in progess during a join --- diff --git a/public/trivabble.js b/public/trivabble.js index 1ba9d61..487fc1f 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -205,7 +205,7 @@ let blockMove = 0; let remainingLetters = 0; let needsRestart = false; - const gameInProgress = false; + let gameInProgress = true; let currentTilePlayed = {}; let eventSource = null; @@ -801,15 +801,7 @@ myConfirm( _("Your game is not over. Are you sure you want to leave now?"), - function () { - myAlert( - format( - _("You are about to leave the current game. To recover it, please note its number: {0}"), - getSetting("GameNumber") - ), - f - ); - } + f ); } @@ -978,6 +970,7 @@ participantPlaceholder = null; } + let nbTilesInRacks = 0; for (let i = 0; i < players.length; i++) { const player = players[i]; const playerName = players[i].player; @@ -1100,10 +1093,12 @@ const countCell = tablePlayers[playerName].childNodes[1]; countCell.textContent = player.rackCount; blink(countCell); + nbTilesInRacks += player.rackCount; } } refreshCurrentPlayer(); + gameInProgress = (nbTilesInRacks + remainingLetters > 0); } function handleLastPlayer(data) {