From 1590d0be000391d3a98f4fefda181f849bfff41b Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Mon, 3 Feb 2025 23:44:02 +0100 Subject: [PATCH] add a warning when leaving a game in progess during a join --- public/trivabble.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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) { -- 2.30.2