Download index.html from Foresopa/https-huggingface-co-spaces-foresopa-torneo: direct link, hf CLI and curl.
- Browser
- Download file 42.7 kB
-
https://huggingface.co/spaces/Foresopa/https-huggingface-co-spaces-foresopa-torneo/resolve/main/index.html
- Command line
-
hf download hf://spaces/Foresopa/https-huggingface-co-spaces-foresopa-torneo/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Foresopa/https-huggingface-co-spaces-foresopa-torneo/resolve/main/index.html
42.7 kB
| <html lang="es"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Torneo de Fútbol 2025</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .animate-pulse { | |
| animation: pulse 1.5s infinite; | |
| } | |
| @keyframes pulse { | |
| 0%, 100% { opacity: 1; } | |
| 50% { opacity: 0.5; } | |
| } | |
| .live-badge { | |
| box-shadow: 0 0 10px rgba(255, 0, 0, 0.7); | |
| } | |
| .fade-in { | |
| animation: fadeIn 0.5s ease-in; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .player-number { | |
| width: 30px; | |
| height: 30px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| border-radius: 50%; | |
| background-color: #3b82f6; | |
| color: white; | |
| font-weight: bold; | |
| margin-right: 8px; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 font-sans"> | |
| <div class="container mx-auto px-4 py-8 max-w-6xl"> | |
| <!-- Header --> | |
| <header class="mb-10 text-center"> | |
| <h1 class="text-4xl md:text-5xl font-bold text-gray-800 mb-2"> | |
| <i class="fas fa-trophy text-yellow-500 mr-3"></i> | |
| Torneo de Fútbol 2025 | |
| </h1> | |
| <p class="text-lg text-gray-600">Organiza y sigue tu torneo favorito</p> | |
| </header> | |
| <!-- Navigation Tabs --> | |
| <div class="flex border-b border-gray-200 mb-8"> | |
| <button id="teams-tab" class="tab-button active px-6 py-3 font-medium text-sm md:text-base rounded-t-lg" data-tab="teams"> | |
| <i class="fas fa-users mr-2"></i>Equipos | |
| </button> | |
| <button id="matches-tab" class="tab-button px-6 py-3 font-medium text-sm md:text-base" data-tab="matches"> | |
| <i class="fas fa-calendar-alt mr-2"></i>Partidos | |
| </button> | |
| <button id="standings-tab" class="tab-button px-6 py-3 font-medium text-sm md:text-base" data-tab="standings"> | |
| <i class="fas fa-table mr-2"></i>Posiciones | |
| </button> | |
| <button id="live-tab" class="tab-button px-6 py-3 font-medium text-sm md:text-base" data-tab="live"> | |
| <i class="fas fa-broadcast-tower mr-2"></i>En Vivo | |
| </button> | |
| </div> | |
| <!-- Teams Section --> | |
| <section id="teams" class="tab-content active fade-in"> | |
| <div class="bg-white rounded-lg shadow-md p-6 mb-6"> | |
| <h2 class="text-2xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-plus-circle text-blue-500 mr-2"></i> | |
| Registrar Nuevo Equipo | |
| </h2> | |
| <form id="team-form" class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <div> | |
| <label for="team-name" class="block text-sm font-medium text-gray-700 mb-1">Nombre del Equipo</label> | |
| <input type="text" id="team-name" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="team-coach" class="block text-sm font-medium text-gray-700 mb-1">Entrenador</label> | |
| <input type="text" id="team-coach" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div class="flex items-end"> | |
| <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-md transition duration-300 flex items-center"> | |
| <i class="fas fa-save mr-2"></i> Guardar | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| <div class="bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-2xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-users text-blue-500 mr-2"></i> | |
| Equipos Registrados | |
| </h2> | |
| <div id="teams-list" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"> | |
| <!-- Teams will be added here dynamically --> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Matches Section --> | |
| <section id="matches" class="tab-content hidden fade-in"> | |
| <div class="bg-white rounded-lg shadow-md p-6 mb-6"> | |
| <h2 class="text-2xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-plus-circle text-blue-500 mr-2"></i> | |
| Programar Nuevo Partido | |
| </h2> | |
| <form id="match-form" class="grid grid-cols-1 md:grid-cols-4 gap-4"> | |
| <div> | |
| <label for="match-date" class="block text-sm font-medium text-gray-700 mb-1">Fecha</label> | |
| <input type="date" id="match-date" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="match-time" class="block text-sm font-medium text-gray-700 mb-1">Hora</label> | |
| <input type="time" id="match-time" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| </div> | |
| <div> | |
| <label for="home-team" class="block text-sm font-medium text-gray-700 mb-1">Equipo Local</label> | |
| <select id="home-team" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="">Seleccionar</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label for="away-team" class="block text-sm font-medium text-gray-700 mb-1">Equipo Visitante</label> | |
| <select id="away-team" required class="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="">Seleccionar</option> | |
| </select> | |
| </div> | |
| <div class="md:col-span-4 flex justify-end"> | |
| <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-md transition duration-300 flex items-center"> | |
| <i class="fas fa-calendar-plus mr-2"></i> Programar Partido | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| <div class="bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-2xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-calendar-alt text-blue-500 mr-2"></i> | |
| Calendario de Partidos | |
| </h2> | |
| <div id="matches-list" class="space-y-4"> | |
| <!-- Matches will be added here dynamically --> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Standings Section --> | |
| <section id="standings" class="tab-content hidden fade-in"> | |
| <div class="bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-2xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-table text-blue-500 mr-2"></i> | |
| Tabla de Posiciones | |
| </h2> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-200"> | |
| <thead class="bg-gray-50"> | |
| <tr> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Posición</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Equipo</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">PJ</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">PG</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">PE</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">PP</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">GF</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">GC</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">DG</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Pts</th> | |
| </tr> | |
| </thead> | |
| <tbody id="standings-body" class="bg-white divide-y divide-gray-200"> | |
| <!-- Standings will be added here dynamically --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Live Section --> | |
| <section id="live" class="tab-content hidden fade-in"> | |
| <div class="bg-white rounded-lg shadow-md p-6"> | |
| <h2 class="text-2xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-broadcast-tower text-red-500 mr-2"></i> | |
| Partidos en Vivo | |
| </h2> | |
| <div id="live-matches" class="space-y-6"> | |
| <!-- Live matches will be added here dynamically --> | |
| </div> | |
| </div> | |
| </section> | |
| </div> | |
| <!-- Team Details Modal --> | |
| <div id="team-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-semibold text-gray-800" id="team-modal-title"></h3> | |
| <button id="close-team-modal" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="mb-6"> | |
| <div class="flex items-center mb-4"> | |
| <i class="fas fa-user-tie text-blue-500 mr-2"></i> | |
| <span id="team-coach-name" class="text-gray-700"></span> | |
| </div> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h4 class="text-lg font-medium text-gray-800"> | |
| <i class="fas fa-users text-blue-500 mr-2"></i> | |
| Jugadores | |
| </h4> | |
| <button id="add-player-btn" class="text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded flex items-center"> | |
| <i class="fas fa-plus mr-1"></i> Agregar | |
| </button> | |
| </div> | |
| <div id="players-list" class="space-y-2"> | |
| <!-- Players will be added here dynamically --> | |
| </div> | |
| <div id="add-player-form" class="mt-4 hidden"> | |
| <div class="grid grid-cols-2 gap-4 mb-4"> | |
| <div> | |
| <label for="player-name" class="block text-sm font-medium text-gray-700 mb-1">Nombre</label> | |
| <input type="text" id="player-name" class="w-full px-3 py-1 border border-gray-300 rounded-md"> | |
| </div> | |
| <div> | |
| <label for="player-number" class="block text-sm font-medium text-gray-700 mb-1">Número</label> | |
| <input type="number" id="player-number" min="1" max="99" class="w-full px-3 py-1 border border-gray-300 rounded-md"> | |
| </div> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <button type="button" id="cancel-add-player" class="px-3 py-1 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-100 transition duration-300"> | |
| Cancelar | |
| </button> | |
| <button type="button" id="save-player" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded-md transition duration-300"> | |
| Guardar | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="flex justify-end"> | |
| <button id="close-team-modal-btn" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-md transition duration-300"> | |
| Cerrar | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Match Details Modal --> | |
| <div id="match-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-semibold text-gray-800">Actualizar Marcador</h3> | |
| <button id="close-modal" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div id="match-details" class="mb-6"> | |
| <!-- Match details will be added here --> | |
| </div> | |
| <form id="score-form"> | |
| <div class="grid grid-cols-2 gap-4 mb-6"> | |
| <div class="text-center"> | |
| <label class="block text-sm font-medium text-gray-700 mb-2" id="home-team-name"></label> | |
| <input type="number" id="home-score" min="0" class="w-20 px-4 py-2 border border-gray-300 rounded-md text-center text-xl font-bold"> | |
| </div> | |
| <div class="text-center"> | |
| <label class="block text-sm font-medium text-gray-700 mb-2" id="away-team-name"></label> | |
| <input type="number" id="away-score" min="0" class="w-20 px-4 py-2 border border-gray-300 rounded-md text-center text-xl font-bold"> | |
| </div> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <button type="button" id="cancel-score" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-100 transition duration-300"> | |
| Cancelar | |
| </button> | |
| <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md transition duration-300"> | |
| Guardar Marcador | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Data storage | |
| let teams = JSON.parse(localStorage.getItem('teams')) || []; | |
| let matches = JSON.parse(localStorage.getItem('matches')) || []; | |
| let liveMatches = JSON.parse(localStorage.getItem('liveMatches')) || []; | |
| let currentTeamId = null; | |
| // DOM Elements | |
| const tabButtons = document.querySelectorAll('.tab-button'); | |
| const tabContents = document.querySelectorAll('.tab-content'); | |
| const teamForm = document.getElementById('team-form'); | |
| const teamsList = document.getElementById('teams-list'); | |
| const matchForm = document.getElementById('match-form'); | |
| const homeTeamSelect = document.getElementById('home-team'); | |
| const awayTeamSelect = document.getElementById('away-team'); | |
| const matchesList = document.getElementById('matches-list'); | |
| const standingsBody = document.getElementById('standings-body'); | |
| const liveMatchesContainer = document.getElementById('live-matches'); | |
| const matchModal = document.getElementById('match-modal'); | |
| const closeModal = document.getElementById('close-modal'); | |
| const cancelScore = document.getElementById('cancel-score'); | |
| const scoreForm = document.getElementById('score-form'); | |
| const teamModal = document.getElementById('team-modal'); | |
| const closeTeamModal = document.getElementById('close-team-modal'); | |
| const closeTeamModalBtn = document.getElementById('close-team-modal-btn'); | |
| const teamModalTitle = document.getElementById('team-modal-title'); | |
| const teamCoachName = document.getElementById('team-coach-name'); | |
| const playersList = document.getElementById('players-list'); | |
| const addPlayerBtn = document.getElementById('add-player-btn'); | |
| const addPlayerForm = document.getElementById('add-player-form'); | |
| const cancelAddPlayer = document.getElementById('cancel-add-player'); | |
| const savePlayerBtn = document.getElementById('save-player'); | |
| const playerNameInput = document.getElementById('player-name'); | |
| const playerNumberInput = document.getElementById('player-number'); | |
| let currentMatchId = null; | |
| // Initialize the app | |
| function init() { | |
| renderTeams(); | |
| renderTeamSelects(); | |
| renderMatches(); | |
| renderStandings(); | |
| renderLiveMatches(); | |
| setupEventListeners(); | |
| } | |
| // Set up event listeners | |
| function setupEventListeners() { | |
| // Tab navigation | |
| tabButtons.forEach(button => { | |
| button.addEventListener('click', () => { | |
| const tabId = button.getAttribute('data-tab'); | |
| switchTab(tabId); | |
| }); | |
| }); | |
| // Team form submission | |
| teamForm.addEventListener('submit', handleTeamSubmit); | |
| // Match form submission | |
| matchForm.addEventListener('submit', handleMatchSubmit); | |
| // Modal controls | |
| closeModal.addEventListener('click', () => matchModal.classList.add('hidden')); | |
| cancelScore.addEventListener('click', () => matchModal.classList.add('hidden')); | |
| scoreForm.addEventListener('submit', handleScoreSubmit); | |
| // Team modal controls | |
| closeTeamModal.addEventListener('click', () => teamModal.classList.add('hidden')); | |
| closeTeamModalBtn.addEventListener('click', () => teamModal.classList.add('hidden')); | |
| // Player management | |
| addPlayerBtn.addEventListener('click', () => { | |
| addPlayerForm.classList.remove('hidden'); | |
| addPlayerBtn.classList.add('hidden'); | |
| }); | |
| cancelAddPlayer.addEventListener('click', () => { | |
| addPlayerForm.classList.add('hidden'); | |
| addPlayerBtn.classList.remove('hidden'); | |
| playerNameInput.value = ''; | |
| playerNumberInput.value = ''; | |
| }); | |
| savePlayerBtn.addEventListener('click', addPlayerToTeam); | |
| // Close modals when clicking outside | |
| matchModal.addEventListener('click', (e) => { | |
| if (e.target === matchModal) { | |
| matchModal.classList.add('hidden'); | |
| } | |
| }); | |
| teamModal.addEventListener('click', (e) => { | |
| if (e.target === teamModal) { | |
| teamModal.classList.add('hidden'); | |
| } | |
| }); | |
| } | |
| // Switch between tabs | |
| function switchTab(tabId) { | |
| tabButtons.forEach(button => { | |
| button.classList.remove('active'); | |
| if (button.getAttribute('data-tab') === tabId) { | |
| button.classList.add('active'); | |
| } | |
| }); | |
| tabContents.forEach(content => { | |
| content.classList.add('hidden'); | |
| content.classList.remove('active'); | |
| if (content.id === tabId) { | |
| content.classList.remove('hidden'); | |
| content.classList.add('active'); | |
| } | |
| }); | |
| } | |
| // Handle team form submission | |
| function handleTeamSubmit(e) { | |
| e.preventDefault(); | |
| const teamName = document.getElementById('team-name').value; | |
| const teamCoach = document.getElementById('team-coach').value; | |
| const newTeam = { | |
| id: Date.now().toString(), | |
| name: teamName, | |
| coach: teamCoach || 'Sin entrenador', | |
| players: [], | |
| matchesPlayed: 0, | |
| wins: 0, | |
| draws: 0, | |
| losses: 0, | |
| goalsFor: 0, | |
| goalsAgainst: 0, | |
| points: 0 | |
| }; | |
| teams.push(newTeam); | |
| saveTeams(); | |
| renderTeams(); | |
| renderTeamSelects(); | |
| teamForm.reset(); | |
| } | |
| // Handle match form submission | |
| function handleMatchSubmit(e) { | |
| e.preventDefault(); | |
| const date = document.getElementById('match-date').value; | |
| const time = document.getElementById('match-time').value; | |
| const homeTeamId = document.getElementById('home-team').value; | |
| const awayTeamId = document.getElementById('away-team').value; | |
| if (homeTeamId === awayTeamId) { | |
| alert('Un equipo no puede jugar contra sí mismo'); | |
| return; | |
| } | |
| const homeTeam = teams.find(team => team.id === homeTeamId); | |
| const awayTeam = teams.find(team => team.id === awayTeamId); | |
| const newMatch = { | |
| id: Date.now().toString(), | |
| date: date, | |
| time: time, | |
| homeTeam: { | |
| id: homeTeamId, | |
| name: homeTeam.name, | |
| score: null | |
| }, | |
| awayTeam: { | |
| id: awayTeamId, | |
| name: awayTeam.name, | |
| score: null | |
| }, | |
| status: 'scheduled', // scheduled, in_progress, completed | |
| isLive: false | |
| }; | |
| matches.push(newMatch); | |
| saveMatches(); | |
| renderMatches(); | |
| renderTeamSelects(); | |
| matchForm.reset(); | |
| switchTab('matches'); | |
| } | |
| // Handle score form submission | |
| function handleScoreSubmit(e) { | |
| e.preventDefault(); | |
| const homeScore = parseInt(document.getElementById('home-score').value); | |
| const awayScore = parseInt(document.getElementById('away-score').value); | |
| const matchIndex = matches.findIndex(match => match.id === currentMatchId); | |
| if (matchIndex !== -1) { | |
| matches[matchIndex].homeTeam.score = homeScore; | |
| matches[matchIndex].awayTeam.score = awayScore; | |
| matches[matchIndex].status = 'completed'; | |
| // Remove from live matches if it was live | |
| const liveIndex = liveMatches.findIndex(match => match.id === currentMatchId); | |
| if (liveIndex !== -1) { | |
| liveMatches.splice(liveIndex, 1); | |
| saveLiveMatches(); | |
| } | |
| // Update team statistics | |
| updateTeamStats( | |
| matches[matchIndex].homeTeam.id, | |
| matches[matchIndex].awayTeam.id, | |
| homeScore, | |
| awayScore | |
| ); | |
| saveMatches(); | |
| renderMatches(); | |
| renderStandings(); | |
| renderLiveMatches(); | |
| matchModal.classList.add('hidden'); | |
| } | |
| } | |
| // Add player to team | |
| function addPlayerToTeam() { | |
| const playerName = playerNameInput.value.trim(); | |
| const playerNumber = parseInt(playerNumberInput.value); | |
| if (!playerName || isNaN(playerNumber) || playerNumber < 1 || playerNumber > 99) { | |
| alert('Por favor ingresa un nombre válido y un número entre 1 y 99'); | |
| return; | |
| } | |
| const teamIndex = teams.findIndex(team => team.id === currentTeamId); | |
| if (teamIndex !== -1) { | |
| if (!teams[teamIndex].players) { | |
| teams[teamIndex].players = []; | |
| } | |
| // Check if number is already taken | |
| const numberTaken = teams[teamIndex].players.some(p => p.number === playerNumber); | |
| if (numberTaken) { | |
| alert('Este número ya está asignado a otro jugador'); | |
| return; | |
| } | |
| teams[teamIndex].players.push({ | |
| name: playerName, | |
| number: playerNumber | |
| }); | |
| saveTeams(); | |
| renderTeamPlayers(currentTeamId); | |
| // Reset form | |
| playerNameInput.value = ''; | |
| playerNumberInput.value = ''; | |
| addPlayerForm.classList.add('hidden'); | |
| addPlayerBtn.classList.remove('hidden'); | |
| } | |
| } | |
| // Open team modal to view and manage players | |
| function openTeamModal(teamId) { | |
| const team = teams.find(team => team.id === teamId); | |
| if (team) { | |
| currentTeamId = teamId; | |
| teamModalTitle.textContent = team.name; | |
| teamCoachName.textContent = team.coach || 'Sin entrenador'; | |
| renderTeamPlayers(teamId); | |
| teamModal.classList.remove('hidden'); | |
| } | |
| } | |
| // Render players for a team | |
| function renderTeamPlayers(teamId) { | |
| const team = teams.find(team => team.id === teamId); | |
| playersList.innerHTML = ''; | |
| if (!team.players || team.players.length === 0) { | |
| playersList.innerHTML = ` | |
| <div class="text-center py-4 text-gray-500"> | |
| No hay jugadores registrados | |
| </div> | |
| `; | |
| return; | |
| } | |
| // Sort players by number | |
| const sortedPlayers = [...team.players].sort((a, b) => a.number - b.number); | |
| sortedPlayers.forEach((player, index) => { | |
| const playerItem = document.createElement('div'); | |
| playerItem.className = 'flex items-center justify-between py-2 border-b border-gray-100'; | |
| playerItem.innerHTML = ` | |
| <div class="flex items-center"> | |
| <div class="player-number">${player.number}</div> | |
| <span class="text-gray-800">${player.name}</span> | |
| </div> | |
| <button onclick="removePlayer('${teamId}', ${index})" class="text-red-500 hover:text-red-700"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| `; | |
| playersList.appendChild(playerItem); | |
| }); | |
| } | |
| // Remove player from team | |
| function removePlayer(teamId, playerIndex) { | |
| const teamIndex = teams.findIndex(team => team.id === teamId); | |
| if (teamIndex !== -1 && teams[teamIndex].players && teams[teamIndex].players[playerIndex]) { | |
| if (confirm(`¿Estás seguro de eliminar a ${teams[teamIndex].players[playerIndex].name}?`)) { | |
| teams[teamIndex].players.splice(playerIndex, 1); | |
| saveTeams(); | |
| renderTeamPlayers(teamId); | |
| } | |
| } | |
| } | |
| // Update team statistics based on match results | |
| function updateTeamStats(homeTeamId, awayTeamId, homeScore, awayScore) { | |
| const homeTeamIndex = teams.findIndex(team => team.id === homeTeamId); | |
| const awayTeamIndex = teams.findIndex(team => team.id === awayTeamId); | |
| if (homeTeamIndex !== -1 && awayTeamIndex !== -1) { | |
| // Update matches played | |
| teams[homeTeamIndex].matchesPlayed += 1; | |
| teams[awayTeamIndex].matchesPlayed += 1; | |
| // Update goals | |
| teams[homeTeamIndex].goalsFor += homeScore; | |
| teams[homeTeamIndex].goalsAgainst += awayScore; | |
| teams[awayTeamIndex].goalsFor += awayScore; | |
| teams[awayTeamIndex].goalsAgainst += homeScore; | |
| // Update results and points | |
| if (homeScore > awayScore) { | |
| teams[homeTeamIndex].wins += 1; | |
| teams[homeTeamIndex].points += 3; | |
| teams[awayTeamIndex].losses += 1; | |
| } else if (homeScore < awayScore) { | |
| teams[awayTeamIndex].wins += 1; | |
| teams[awayTeamIndex].points += 3; | |
| teams[homeTeamIndex].losses += 1; | |
| } else { | |
| teams[homeTeamIndex].draws += 1; | |
| teams[awayTeamIndex].draws += 1; | |
| teams[homeTeamIndex].points += 1; | |
| teams[awayTeamIndex].points += 1; | |
| } | |
| saveTeams(); | |
| } | |
| } | |
| // Start a live match | |
| function startLiveMatch(matchId) { | |
| const matchIndex = matches.findIndex(match => match.id === matchId); | |
| if (matchIndex !== -1) { | |
| matches[matchIndex].status = 'in_progress'; | |
| matches[matchIndex].isLive = true; | |
| // Add to live matches if not already there | |
| if (!liveMatches.some(match => match.id === matchId) { | |
| liveMatches.push({...matches[matchIndex]}); | |
| saveLiveMatches(); | |
| } | |
| saveMatches(); | |
| renderMatches(); | |
| renderLiveMatches(); | |
| switchTab('live'); | |
| } | |
| } | |
| // Open match modal to update score | |
| function openMatchModal(matchId) { | |
| const match = matches.find(match => match.id === matchId); | |
| if (match) { | |
| currentMatchId = matchId; | |
| const matchDetails = document.getElementById('match-details'); | |
| matchDetails.innerHTML = ` | |
| <div class="text-center mb-4"> | |
| <p class="text-gray-600">${formatDate(match.date)} - ${match.time}</p> | |
| </div> | |
| <div class="flex justify-between items-center mb-2"> | |
| <div class="text-right w-2/5"> | |
| <h4 class="text-lg font-semibold">${match.homeTeam.name}</h4> | |
| </div> | |
| <div class="text-center w-1/5 text-xl font-bold">VS</div> | |
| <div class="text-left w-2/5"> | |
| <h4 class="text-lg font-semibold">${match.awayTeam.name}</h4> | |
| </div> | |
| </div> | |
| `; | |
| document.getElementById('home-team-name').textContent = match.homeTeam.name; | |
| document.getElementById('away-team-name').textContent = match.awayTeam.name; | |
| document.getElementById('home-score').value = match.homeTeam.score || '0'; | |
| document.getElementById('away-score').value = match.awayTeam.score || '0'; | |
| matchModal.classList.remove('hidden'); | |
| } | |
| } | |
| // Render teams list | |
| function renderTeams() { | |
| teamsList.innerHTML = ''; | |
| if (teams.length === 0) { | |
| teamsList.innerHTML = ` | |
| <div class="col-span-full text-center py-8"> | |
| <i class="fas fa-exclamation-circle text-gray-400 text-4xl mb-3"></i> | |
| <p class="text-gray-500">No hay equipos registrados</p> | |
| </div> | |
| `; | |
| return; | |
| } | |
| teams.forEach(team => { | |
| const teamCard = document.createElement('div'); | |
| teamCard.className = 'bg-white border border-gray-200 rounded-lg p-4 shadow-sm hover:shadow-md transition duration-300'; | |
| teamCard.innerHTML = ` | |
| <div class="flex items-center mb-3 cursor-pointer" onclick="openTeamModal('${team.id}')"> | |
| <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3"> | |
| <i class="fas fa-shield-alt text-blue-500"></i> | |
| </div> | |
| <div> | |
| <h3 class="font-semibold text-lg">${team.name}</h3> | |
| <p class="text-sm text-gray-500">${team.coach}</p> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-2 text-sm"> | |
| <div class="bg-gray-50 p-2 rounded"> | |
| <span class="block text-xs text-gray-500">Partidos</span> | |
| <span class="font-medium">${team.matchesPlayed}</span> | |
| </div> | |
| <div class="bg-gray-50 p-2 rounded"> | |
| <span class="block text-xs text-gray-500">Puntos</span> | |
| <span class="font-medium">${team.points}</span> | |
| </div> | |
| </div> | |
| <div class="mt-3 flex justify-between items-center"> | |
| <span class="text-xs text-gray-500"> | |
| <i class="fas fa-user-friends mr-1"></i> | |
| ${team.players ? team.players.length : 0} jugadores | |
| </span> | |
| <button onclick="openTeamModal('${team.id}')" class="text-xs text-blue-600 hover:text-blue-800"> | |
| <i class="fas fa-edit mr-1"></i> Gestionar | |
| </button> | |
| </div> | |
| `; | |
| teamsList.appendChild(teamCard); | |
| }); | |
| } | |
| // Render team selects for match form | |
| function renderTeamSelects() { | |
| homeTeamSelect.innerHTML = '<option value="">Seleccionar</option>'; | |
| awayTeamSelect.innerHTML = '<option value="">Seleccionar</option>'; | |
| teams.forEach(team => { | |
| const option1 = document.createElement('option'); | |
| option1.value = team.id; | |
| option1.textContent = team.name; | |
| homeTeamSelect.appendChild(option1); | |
| const option2 = document.createElement('option'); | |
| option2.value = team.id; | |
| option2.textContent = team.name; | |
| awayTeamSelect.appendChild(option2); | |
| }); | |
| } | |
| // Render matches list | |
| function renderMatches() { | |
| matchesList.innerHTML = ''; | |
| if (matches.length === 0) { | |
| matchesList.innerHTML = ` | |
| <div class="text-center py-8"> | |
| <i class="fas fa-calendar-times text-gray-400 text-4xl mb-3"></i> | |
| <p class="text-gray-500">No hay partidos programados</p> | |
| </div> | |
| `; | |
| return; | |
| } | |
| // Sort matches by date and time | |
| const sortedMatches = [...matches].sort((a, b) => { | |
| const dateA = new Date(`${a.date}T${a.time}`); | |
| const dateB = new Date(`${b.date}T${b.time}`); | |
| return dateA - dateB; | |
| }); | |
| sortedMatches.forEach(match => { | |
| const matchCard = document.createElement('div'); | |
| matchCard.className = 'bg-white border border-gray-200 rounded-lg p-4 shadow-sm hover:shadow-md transition duration-300'; | |
| let statusBadge = ''; | |
| let actionButton = ''; | |
| if (match.status === 'scheduled') { | |
| statusBadge = '<span class="bg-yellow-100 text-yellow-800 text-xs px-2 py-1 rounded">Programado</span>'; | |
| actionButton = ` | |
| <button onclick="startLiveMatch('${match.id}')" class="text-blue-600 hover:text-blue-800 text-sm font-medium flex items-center"> | |
| <i class="fas fa-play-circle mr-1"></i> Iniciar | |
| </button> | |
| `; | |
| } else if (match.status === 'in_progress') { | |
| statusBadge = '<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded flex items-center"><span class="w-2 h-2 bg-green-500 rounded-full mr-1 animate-pulse"></span> En Vivo</span>'; | |
| actionButton = ` | |
| <button onclick="openMatchModal('${match.id}')" class="text-green-600 hover:text-green-800 text-sm font-medium flex items-center"> | |
| <i class="fas fa-edit mr-1"></i> Actualizar | |
| </button> | |
| `; | |
| } else if (match.status === 'completed') { | |
| statusBadge = '<span class="bg-gray-100 text-gray-800 text-xs px-2 py-1 rounded">Finalizado</span>'; | |
| actionButton = ` | |
| <button onclick="openMatchModal('${match.id}')" class="text-gray-600 hover:text-gray-800 text-sm font-medium flex items-center"> | |
| <i class="fas fa-eye mr-1"></i> Ver | |
| </button> | |
| `; | |
| } | |
| matchCard.innerHTML = ` | |
| <div class="flex justify-between items-start mb-2"> | |
| <div> | |
| <p class="text-sm text-gray-500">${formatDate(match.date)} - ${match.time}</p> | |
| </div> | |
| <div> | |
| ${statusBadge} | |
| </div> | |
| </div> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="text-right w-2/5"> | |
| <h4 class="text-lg font-semibold">${match.homeTeam.name}</h4> | |
| </div> | |
| <div class="text-center w-1/5"> | |
| ${match.status === 'completed' ? ` | |
| <div class="text-2xl font-bold">${match.homeTeam.score} - ${match.awayTeam.score}</div> | |
| ` : ` | |
| <div class="text-xl font-bold text-gray-400">VS</div> | |
| `} | |
| </div> | |
| <div class="text-left w-2/5"> | |
| <h4 class="text-lg font-semibold">${match.awayTeam.name}</h4> | |
| </div> | |
| </div> | |
| <div class="flex justify-end"> | |
| ${actionButton} | |
| </div> | |
| `; | |
| matchesList.appendChild(matchCard); | |
| }); | |
| } | |
| // Render standings table | |
| function renderStandings() { | |
| standingsBody.innerHTML = ''; | |
| if (teams.length === 0) { | |
| standingsBody.innerHTML = ` | |
| <tr> | |
| <td colspan="10" class="px-6 py-4 text-center text-gray-500"> | |
| No hay equipos registrados | |
| </td> | |
| </tr> | |
| `; | |
| return; | |
| } | |
| // Sort teams by points, goal difference, and goals for | |
| const sortedTeams = [...teams].sort((a, b) => { | |
| if (b.points !== a.points) return b.points - a.points; | |
| const diffA = a.goalsFor - a.goalsAgainst; | |
| const diffB = b.goalsFor - b.goalsAgainst; | |
| if (diffB !== diffA) return diffB - diffA; | |
| return b.goalsFor - a.goalsFor; | |
| }); | |
| sortedTeams.forEach((team, index) => { | |
| const row = document.createElement('tr'); | |
| row.className = index % 2 === 0 ? 'bg-gray-50' : 'bg-white'; | |
| row.innerHTML = ` | |
| <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${index + 1}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> | |
| <div class="flex items-center"> | |
| <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center mr-2"> | |
| <i class="fas fa-shield-alt text-blue-500 text-xs"></i> | |
| </div> | |
| ${team.name} | |
| </div> | |
| </td> | |
| <td class="px-6 py- | |
| </html> |