mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2025-12-16 14:07:49 +01:00
burger bouton ok
This commit is contained in:
parent
63c1c58852
commit
1cdae5aac1
@ -15,7 +15,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
//const viewSelector = document.getElementById('view-selector');
|
//const viewSelector = document.getElementById('view-selector');
|
||||||
//const viewPlayersButton = document.getElementById('view-players');
|
//const viewPlayersButton = document.getElementById('view-players');
|
||||||
//const viewMatchesButton = document.getElementById('view-matches');
|
//const viewMatchesButton = document.getElementById('view-matches');
|
||||||
const menuButton = document.querySelector('burger-menu');
|
const menuButton = document.querySelector('.burger-menu');
|
||||||
const playerList = document.getElementById('player-list');
|
const playerList = document.getElementById('player-list');
|
||||||
const matchList = document.getElementById('match-list');
|
const matchList = document.getElementById('match-list');
|
||||||
const tournoiList = document.getElementById('tournoi-list');
|
const tournoiList = document.getElementById('tournoi-list');
|
||||||
@ -280,6 +280,23 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menuButton) {
|
||||||
|
//console.log("menu bouton ok")
|
||||||
|
menuButton.addEventListener('click', toggleMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
const links = document.querySelectorAll('#dropdown-menu a');
|
||||||
|
//console.log(links);
|
||||||
|
|
||||||
|
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");
|
||||||
|
showTable(tableId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function showTable(tableId) {
|
function showTable(tableId) {
|
||||||
// Masquer tous les tableaux
|
// Masquer tous les tableaux
|
||||||
console.log('Entering showTable', tableId);
|
console.log('Entering showTable', tableId);
|
||||||
@ -289,16 +306,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
// Afficher le tableau sélectionné
|
// Afficher le tableau sélectionné
|
||||||
if (tableId === 'player-list') {
|
if (tableId === 'player-list') {
|
||||||
print('Showing player list');
|
console.log('Showing player list');
|
||||||
if (playerList) playerList.style.display = 'block';
|
//if (playerList) {
|
||||||
|
playerList.style.display = 'block';
|
||||||
fetchPlayers();
|
fetchPlayers();
|
||||||
|
//}
|
||||||
} else if (tableId === 'match-list') {
|
} else if (tableId === 'match-list') {
|
||||||
print('Showing match list');
|
console.log('Showing match list');
|
||||||
if (matchList) matchList.style.display = 'block';
|
//if (matchList)
|
||||||
|
matchList.style.display = 'block';
|
||||||
fetchMatches();
|
fetchMatches();
|
||||||
} else if (tableId === 'tournoi-list') {
|
} else if (tableId === 'tournoi-list') {
|
||||||
print('Showing tournoi list');
|
console.log('Showing tournoi list');
|
||||||
if (tournoiList) tournoiList.style.display = 'block';
|
//if (tournoiList)
|
||||||
|
tournoiList.style.display = 'block';
|
||||||
fetchTournois();
|
fetchTournois();
|
||||||
}
|
}
|
||||||
// Masquer le menu après la sélection
|
// Masquer le menu après la sélection
|
||||||
@ -307,27 +328,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//menuButton.addEventListener('click', toggleMenu);
|
|
||||||
|
|
||||||
if (menuButton) {
|
|
||||||
console.log("menu bouton ok")
|
|
||||||
menuButton.addEventListener('click', toggleMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
const links = document.querySelectorAll('#dropdown-menu a');
|
|
||||||
console.log("Here !!!!!!!!!!!!");
|
|
||||||
console.log(links);
|
|
||||||
|
|
||||||
links.forEach(link => {
|
|
||||||
link.addEventListener('click', (event) => {
|
|
||||||
event.preventDefault(); // Empêche le comportement par défaut du lien
|
|
||||||
const tableId = link.getAttribute('data-table');
|
|
||||||
//showTable(tableId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function fetchMatches() {
|
function fetchMatches() {
|
||||||
|
console.log('Fetching matches...');
|
||||||
fetch('/api/match_list/')
|
fetch('/api/match_list/')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -339,6 +341,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetchPlayers(){
|
function fetchPlayers(){
|
||||||
|
console.log('Fetching players...');
|
||||||
fetch('/api/player_list/')
|
fetch('/api/player_list/')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -350,11 +353,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetchTournois(){
|
function fetchTournois(){
|
||||||
print('Fetching tournois...');
|
console.log('Fetching tournois...');
|
||||||
fetch('/api/tournoi_list/')
|
fetch('/api/tournoi_list/')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
print('Tournois data:', data);
|
|
||||||
if (data.tournois) {
|
if (data.tournois) {
|
||||||
displayTournois(data.tournois);
|
displayTournois(data.tournois);
|
||||||
}
|
}
|
||||||
@ -363,9 +365,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayMatches(matches) {
|
function displayMatches(matches) {
|
||||||
|
console.log('Displaying matches:');
|
||||||
const matchListBody = document.querySelector('#match-list tbody');
|
const matchListBody = document.querySelector('#match-list tbody');
|
||||||
matchListBody.innerHTML = '';
|
matchListBody.innerHTML = '';
|
||||||
|
|
||||||
|
if (matches.length === 0) {
|
||||||
|
console.log('No matches to display');
|
||||||
|
}
|
||||||
|
|
||||||
matches.forEach(match => {
|
matches.forEach(match => {
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
@ -387,9 +394,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayPlayers(players) {
|
function displayPlayers(players) {
|
||||||
|
console.log('Displaying players:');
|
||||||
const playersListBody = document.querySelector('#player-list tbody');
|
const playersListBody = document.querySelector('#player-list tbody');
|
||||||
playersListBody.innerHTML = '';
|
playersListBody.innerHTML = '';
|
||||||
|
|
||||||
|
if (players.length === 0) {
|
||||||
|
console.log('No players to display');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
players.forEach(player => {
|
players.forEach(player => {
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
@ -412,12 +425,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayTournois(tournois) {
|
function displayTournois(tournois) {
|
||||||
print('Displaying tournois:');
|
console.log('Displaying tournois:');
|
||||||
const tournoisListBody = document.querySelector('#tournoi-list tbody');
|
const tournoisListBody = document.querySelector('#tournoi-list tbody');
|
||||||
tournoisListBody.innerHTML = '';
|
tournoisListBody.innerHTML = '';
|
||||||
|
|
||||||
if (tournois.length === 0) {
|
if (tournois.length === 0) {
|
||||||
print('No tournois to display');
|
console.log('No tournois to display');
|
||||||
}
|
}
|
||||||
|
|
||||||
tournois.forEach(tournoi => {
|
tournois.forEach(tournoi => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user