// 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'; window.onload = function() { initDashboard(); }; 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(); loadStats(); } 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'); loadMatches(); } function loadMatches() { const container = document.getElementById('matchesList'); 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; 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}
Classement : #${p1.ranking}
${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
'}#${player.ranking} Mondial • ${player.points} pts
#${p1.ranking} Mondial
#${p2.ranking} Mondial
${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 = `