From c3e8ef9067f338b2a48c2438d468f66f6b36d49a Mon Sep 17 00:00:00 2001 From: Frank Schwenk Date: Fri, 4 Apr 2025 11:05:37 +0200 Subject: [PATCH] Move New Game button to top of game list and improve spacing --- index.html | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 00dbba1..e690fd9 100644 --- a/index.html +++ b/index.html @@ -389,7 +389,7 @@ display: flex; flex-direction: column; gap: 10px; - margin-top: 20px; + margin: 20px 0 40px 0; /* Increased bottom margin */ } .nav-button { @@ -549,6 +549,10 @@ height: 100%; background-color: rgba(0, 0, 0, 0.7); z-index: 1000; + } + + .modal.show { + display: flex; justify-content: center; align-items: center; } @@ -818,6 +822,9 @@

Spiele

+
@@ -827,9 +834,6 @@
-
@@ -1100,10 +1104,29 @@ } function deleteGame(gameId) { - if (!confirm('Möchten Sie dieses Spiel wirklich löschen?')) { - return; - } + const game = games.find(g => g.id === gameId); + if (!game) return; + currentGameId = gameId; // Set the currentGameId for the modal + + const modal = document.getElementById('modal'); + const modalTitle = document.getElementById('modal-title'); + const modalMessage = document.getElementById('modal-message'); + + modalTitle.textContent = 'Spiel löschen'; + modalMessage.textContent = `Möchten Sie das Spiel zwischen ${game.player1} und ${game.player2} wirklich löschen?`; + modal.classList.add('show'); + } + + function closeModal() { + const modal = document.getElementById('modal'); + modal.classList.remove('show'); + currentGameId = null; // Clear the currentGameId when closing the modal + } + + function confirmDeleteGame(gameId) { + if (!gameId) return; // Guard against missing gameId + showLoading(); setTimeout(() => { const gameIndex = games.findIndex(g => g.id === gameId); @@ -1111,8 +1134,12 @@ games.splice(gameIndex, 1); saveGames(); renderGames(); + if (currentGameId === gameId) { + showScreen('game-list-screen'); + } } hideLoading(); + closeModal(); }, 500); }