From c72986748e618b2dbd20e21a11ff7bb8e3b7a160 Mon Sep 17 00:00:00 2001 From: Theouche Date: Thu, 22 Aug 2024 14:31:43 +0200 Subject: [PATCH] hideAllTable() --- pong/static/game.js | 24 ++++++++++++++++++++---- pong/static/index.html | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pong/static/game.js b/pong/static/game.js index e4aee56..9407136 100644 --- a/pong/static/game.js +++ b/pong/static/game.js @@ -16,6 +16,7 @@ document.addEventListener('DOMContentLoaded', () => { const playerList = document.getElementById('player-list'); const matchList = document.getElementById('match-list'); const tournoiList = document.getElementById('tournoi-list'); + const blockchainList = document.getElementById('blockchain-list'); const dropdownMenu = document.getElementById('dropdown-menu'); const pongElements = document.getElementById('pong-elements'); @@ -284,18 +285,26 @@ document.addEventListener('DOMContentLoaded', () => { console.log('Menu toggled'); if (dropdownMenu.style.display === "block") { dropdownMenu.style.display = "none"; + hideAllTables(); } else { dropdownMenu.style.display = "block"; } } + function hideAllTables(){ + if (playerList) playerList.style.display = 'none'; + if (matchList) matchList.style.display = 'none'; + if (tournoiList) tournoiList.style.display = 'none'; + if (blockchainList) blockchainList.style.display = 'none'; + } + const links = document.querySelectorAll('#dropdown-menu a'); links.forEach(link => { link.addEventListener('click', (event) => { event.preventDefault(); // Empêche le comportement par défaut du lien const tableId = link.getAttribute('data-table'); - console.log("Here !!!!!!!!!!!! NNNNNNNN"); + //console.log("Here !!!!!!!!!!!! NNNNNNNN"); showTable(tableId); }); }); @@ -303,9 +312,7 @@ document.addEventListener('DOMContentLoaded', () => { function showTable(tableId) { // Masquer tous les tableaux console.log('Entering showTable', tableId); - if (playerList) playerList.style.display = 'none'; - if (matchList) matchList.style.display = 'none'; - if (tournoiList) tournoiList.style.display = 'none'; + hideAllTables(); // Afficher le tableau sélectionné if (tableId === 'player-list') { @@ -324,6 +331,15 @@ document.addEventListener('DOMContentLoaded', () => { //if (tournoiList) tournoiList.style.display = 'block'; fetchTournois(); + } else if (tableId === blockchainList) { + console.log('Showing tournoi list'); + blockchainList.style.display = 'block'; + fetch('/web3/') + .then(response => response.json()) + .then(data => { + jsonContent.textContent = JSON.stringify(data, null, 2); + //modal.style.display = "block"; + }); } // Masquer le menu après la sélection if (dropdownMenu) { diff --git a/pong/static/index.html b/pong/static/index.html index fb590e0..8503345 100644 --- a/pong/static/index.html +++ b/pong/static/index.html @@ -6,7 +6,7 @@ Pong Game - +