+
+ Admin Dashboard
+ +User Management
+
+
+
+ diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..1d84213 --- /dev/null +++ b/admin.php @@ -0,0 +1,59 @@ + + + + +
+ + +| ID | +Username | +Role | +Joined | +Action | +|
|---|---|---|---|---|---|
| ${user.id} | +${user.username} | +${user.email} | ++ + | +${new Date(user.created_at).toLocaleDateString()} | ++ |
${p1.strTeam}
+${p2.strTeam}
+No favorite players added yet.
No popular players yet.
No players found.
'; + } + }); + } else { + document.getElementById('favorite-players').style.display = 'block'; + document.getElementById('popular-players').style.display = 'block'; + searchResultsSection.style.display = 'none'; + searchResultsContainer.innerHTML = ''; + } + }); + } + + // --- Initial Render --- + checkSession(); + loadPopularPlayers(); + if (player1SearchInput && player2SearchInput) { + setupComparisonSearch(player1SearchInput, player1Results, 1); + setupComparisonSearch(player2SearchInput, player2Results, 2); + } +}); \ No newline at end of file diff --git a/assets/js/player-detail.js b/assets/js/player-detail.js new file mode 100644 index 0000000..5990325 --- /dev/null +++ b/assets/js/player-detail.js @@ -0,0 +1,147 @@ +document.addEventListener('DOMContentLoaded', function() { + + let gamesData = []; // To store games data for CSV export + + const playerDetailContainer = document.getElementById('player-detail-container'); + const authLinks = document.getElementById('auth-links'); + + // --- Auth Logic --- + const updateAuthUI = (user) => { + if (user) { + authLinks.innerHTML = ` + + + `; + document.getElementById('logout-btn').addEventListener('click', logout); + } else { + authLinks.innerHTML = ` + Login + Register + `; + } + }; + + const logout = () => { + fetch('/api/logout.php').then(() => window.location.href = '/'); + }; + + const checkSession = () => { + fetch('/api/check_session.php') + .then(response => response.json()) + .then(data => { + updateAuthUI(data.loggedIn ? data.user : null); + }); + }; + + // --- Player Detail Logic --- + const renderPlayerDetails = (playerData) => { + const details = playerData.details; + gamesData = playerData.recent_games; // Store for export + + let biographyHtml = ` +${details.strTeam}
+${details.strDescriptionEN || 'No biography available.'}
+Position: ${details.strPosition}
+Height: ${details.strHeight}
+Weight: ${details.strWeight}
+Nationality: ${details.strNationality}
+Date of Birth: ${details.dateBorn}
+Sport: ${details.strSport}
+| Date | +Event | +Home Team | +Away Team | +Score | +
|---|---|---|---|---|
| ${game.dateEvent} | +${game.strEvent} | +${game.strHomeTeam} | +${game.strAwayTeam} | +${game.intHomeScore} - ${game.intAwayScore} | +
Your personal sports stats dashboard.
-