Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Sample data - in real app, this would come from an API
+ const sampleGames = {
+ live: [
+ {
+ homeTeam: 'Maple Leafs',
+ awayTeam: 'Canadiens',
+ homeScore: 3,
+ awayScore: 2,
+ period: '3rd',
+ timeLeft: '12:45'
+ },
+ {
+ homeTeam: 'Rangers',
+ awayTeam: 'Bruins',
+ homeScore: 1,
+ awayScore: 1,
+ period: '2nd',
+ timeLeft: '8:30'
+ }
+ ],
+ upcoming: [
+ {
+ homeTeam: 'Penguins',
+ awayTeam: 'Flyers',
+ startTime: '7:00 PM EST'
+ },
+ {
+ homeTeam: 'Lightning',
+ awayTeam: 'Panthers',
+ startTime: '8:30 PM EST'
+ }
+ ],
+ completed: [
+ {
+ homeTeam: 'Oilers',
+ awayTeam: 'Flames',
+ homeScore: 4,
+ awayScore: 2,
+ final: 'Final'
+ }
+ ]
+ };
+
+ function createGameCard(game, type) {
+ const card = document.createElement('div');
+ card.className = 'game-card';
+
+ const teams = document.createElement('div');
+ teams.className = 'teams';
+
+ let statusText = '';
+ switch(type) {
+ case 'live':
+ statusText = `${game.period} - ${game.timeLeft}`;
+ break;
+ case 'upcoming':
+ statusText = game.startTime;
+ break;
+ case 'completed':
+ statusText = game.final;
+ break;
+ }
+
+ teams.innerHTML = `
+
+ ${game.homeScore !== undefined ? `
${game.homeScore}
` : ''}
+
+
+ ${game.awayScore !== undefined ? `
${game.awayScore}
` : ''}
+
+ `;
+
+ const status = document.createElement('div');
+ status.className = 'status';
+ status.textContent = statusText;
+
+ card.appendChild(teams);
+ card.appendChild(status);
+
+ return card;
+ }
+
+ // Populate the scores containers
+ const liveScores = document.getElementById('live-scores');
+ sampleGames.live.forEach(game => {
+ liveScores.appendChild(createGameCard(game, 'live'));
+ });
+
+ const upcomingGames = document.getElementById('upcoming-games');
+ sampleGames.upcoming.forEach(game => {
+ upcomingGames.appendChild(createGameCard(game, 'upcoming'));
+ });
+
+ const completedGames = document.getElementById('completed-games');
+ sampleGames.completed.forEach(game => {
+ completedGames.appendChild(createGameCard(game, 'completed'));
+ });
+ });