From c95737f3663599a481535a5fd17305989bd72e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Thu, 14 Nov 2024 18:43:41 +0100 Subject: [PATCH] Le fix again --- Front/js/backend/match.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Front/js/backend/match.js b/Front/js/backend/match.js index 07b0dd2..9d7eb26 100644 --- a/Front/js/backend/match.js +++ b/Front/js/backend/match.js @@ -657,15 +657,24 @@ if (window.location.href.includes("index.html") || window.location.href === "htt //alert("Bonjour Madame Daniau"); } +// Add event listeners for voting buttons // Add event listeners for voting buttons matchList.forEach(record => { const voteTeam1Button = document.getElementById(`voteTeam1${record.id}`); const voteTeam2Button = document.getElementById(`voteTeam2${record.id}`); const progressTeam1 = document.getElementById(`progressTeam1${record.id}`); const progressTeam2 = document.getElementById(`progressTeam2${record.id}`); - voteTeam1Button.addEventListener('click', () => handleVote(record.id, 'team1', progressTeam1, progressTeam2)); - voteTeam2Button.addEventListener('click', () => handleVote(record.id, 'team2', progressTeam1, progressTeam2)); + + const handleVoteTeam1 = () => handleVote(record.id, 'team1', progressTeam1, progressTeam2); + const handleVoteTeam2 = () => handleVote(record.id, 'team2', progressTeam1, progressTeam2); + + voteTeam1Button.addEventListener('click', handleVoteTeam1); + voteTeam1Button.addEventListener('touchstart', handleVoteTeam1); + + voteTeam2Button.addEventListener('click', handleVoteTeam2); + voteTeam2Button.addEventListener('touchstart', handleVoteTeam2); }); + // Function to handle voting async function handleVote(matchId, team, progressTeam1, progressTeam2) { const match = await pb.collection('match').getOne(matchId);