diff --git a/js/prediction.js b/js/prediction.js index f11d88a..a9d79d2 100644 --- a/js/prediction.js +++ b/js/prediction.js @@ -1,11 +1,9 @@ -// Données utilisateurs locales persistantes pour éviter les pannes d'API au chargement local let currentUser = JSON.parse(localStorage.getItem('currentUser')) || { username: "Pronostiqueur Pro 2026", points: 320, predictionsCount: 3, successRate: 66 }; - let currentMatch = null; let currentCategoryFilter = 'all'; @@ -14,11 +12,8 @@ window.onload = function() { }; function initDashboard() { - // Affichage des informations de l'utilisateur connecté document.getElementById('userName').textContent = currentUser.username; document.getElementById('userPoints').textContent = `${currentUser.points} pts`; - - // Rendu initial des sections loadMatches(); loadPlayers(); loadLeaderboard(); @@ -28,49 +23,40 @@ function initDashboard() { function showSection(sectionId) { document.querySelectorAll('.section').forEach(s => s.classList.remove('active')); document.querySelectorAll('.sidebar li').forEach(l => l.classList.remove('active')); - document.getElementById(sectionId).classList.add('active'); document.getElementById(`tab-${sectionId}`).classList.add('active'); } -// --- FILTRES ET ENREGISTREMENT DES MATCHES --- function filterMatchesCategory(category) { currentCategoryFilter = category; document.querySelectorAll('.filter-btn').forEach(btn => btn.classList.remove('active')); - - if(category === 'all') document.getElementById('btn-all-matches').classList.add('active'); - if(category === 'Messieurs') document.getElementById('btn-mens-matches').classList.add('active'); - if(category === 'Dames') document.getElementById('btn-womens-matches').classList.add('active'); - + if (category === 'all') document.getElementById('btn-all-matches').classList.add('active'); + if (category === 'Messieurs') document.getElementById('btn-mens-matches').classList.add('active'); + if (category === 'Dames') document.getElementById('btn-womens-matches').classList.add('active'); loadMatches(); } function loadMatches() { const container = document.getElementById('matchesList'); - if(!container) return; + if (!container) return; container.innerHTML = ''; - const filteredMatches = tournamentMatches.filter(match => { return currentCategoryFilter === 'all' || match.gender === currentCategoryFilter; }); - filteredMatches.forEach(match => { const p1 = playersData[match.player1]; const p2 = playersData[match.player2]; - if(!p1 || !p2) return; - + if (!p1 || !p2) return; const matchCard = document.createElement('div'); matchCard.className = 'match-card'; matchCard.onclick = () => openPredictionModal(match); - const badgeColor = match.gender === 'Messieurs' ? '#e85d04' : '#0077b6'; - matchCard.innerHTML = `
${p1.nationality} • ${p1.handedness}
+${p1.nationality} — ${p1.handedness}
Classement : #${p1.ranking}
${p2.nationality} • ${p2.handedness}
+${p2.nationality} — ${p2.handedness}
Classement : #${p2.ranking}
${new Date(match.date).toLocaleDateString('fr-FR', {day: 'numeric', month: 'long'})}
${match.court}
- ${match.status === 'completed' ? `${match.score}
` : '👉 Pronostiquer
'} + ${match.status === 'completed' ? `${match.score}
` : '⚡ Pronostiquer
'} `; container.appendChild(matchCard); }); } -// --- MOTEUR DE RECHERCHE ET RENDU DES JOUEURS --- function handlePlayerSearch() { loadPlayers(); } function loadPlayers() { const container = document.getElementById('playersGrid'); - if(!container) return; + if (!container) return; container.innerHTML = ''; - const searchQuery = document.getElementById('playerSearch').value.toLowerCase(); const genderFilter = document.getElementById('genderFilter').value; - Object.keys(playersData).forEach(key => { const player = playersData[key]; - - // Validation des filtres de recherche croisés const matchesSearch = player.name.toLowerCase().includes(searchQuery) || player.nationality.toLowerCase().includes(searchQuery); const matchesGender = genderFilter === 'all' || player.gender === genderFilter; - if (matchesSearch && matchesGender) { const card = document.createElement('div'); card.className = 'player-card'; - const strengthsHtml = player.strengths.map(s => `${s}`).join(''); const weaknessesHtml = player.weaknesses.map(w => `${w}`).join(''); const genderBadgeColor = player.gender === 'Messieurs' ? '#e85d04' : '#0077b6'; - card.innerHTML = `#${player.ranking} Mondial • ${player.points} pts
+#${player.ranking} Mondial — ${player.points} pts
${match.round} — ${match.court}
`; - - // Calcul des probabilités de réussite via l'algorithme croisé const probs = calculateWinProbability(match.player1, match.player2); document.getElementById('prob1').style.width = `${probs.player1}%`; document.getElementById('prob2').style.width = `${probs.player2}%`; document.getElementById('probText1').textContent = `${probs.player1}%`; document.getElementById('probText2').textContent = `${probs.player2}%`; - document.getElementById('predictBtn1').textContent = `Miser sur ${p1.name}`; document.getElementById('predictBtn2').textContent = `Miser sur ${p2.name}`; - - // Calcul dynamique des forces/défauts en face à face const analysis = getMatchupAnalysis(match.player1, match.player2); const analysisDiv = document.getElementById('matchupAnalysis'); - analysisDiv.innerHTML = ` -