hoopstats-tracker / script.js
cometryai's picture
import React, { useState, useEffect } from ‘react’;
c8fe9c8 verified
Raw History Blame Contribute Delete
2.91 kB
// Main application logic
document.addEventListener('DOMContentLoaded', () => {
console.log('HoopStats Tracker loaded');
// Initialize components
initializeApp();
// Example data fetch - in a real app you would replace this with actual API calls
fetchPlayerData();
});
function initializeApp() {
// This would be replaced with your actual app initialization logic
console.log('Initializing HoopStats Tracker...');
}
async function fetchPlayerData() {
try {
// In a real implementation, you would fetch from an NBA API
console.log('Fetching player data...');
// Simulate API call delay
await new Promise(resolve => setTimeout(resolve, 1000));
// Update UI with loaded data
document.getElementById('app').innerHTML = `
<div class="fade-in">
<div class="text-center mb-12">
<h1 class="text-4xl font-bold text-primary-500 mb-2">HoopStats Tracker</h1>
<p class="text-gray-400">2025-26 Season • Points + Rebounds + Assists Analytics</p>
</div>
<div class="bg-gray-800 rounded-xl p-6 border border-gray-700 max-w-4xl mx-auto">
<h2 class="text-2xl font-bold mb-6">Player Dashboard</h2>
<p class="text-gray-400">Select a player from the navigation to view their stats.</p>
<p class="text-gray-400 mt-4">To get started, add a new player and log their game stats.</p>
<div class="mt-8 flex justify-center">
<a href="/add-player.html" class="bg-primary-600 hover:bg-primary-700 text-white font-bold py-3 px-6 rounded-lg transition duration-200 flex items-center gap-2">
<i data-feather="plus"></i>
Add New Player
</a>
</div>
</div>
</div>
`;
feather.replace();
} catch (error) {
console.error('Error fetching player data:', error);
document.getElementById('app').innerHTML = `
<div class="text-center py-12 text-red-400">
<i data-feather="alert-triangle" class="w-16 h-16 mx-auto mb-4"></i>
<p class="text-xl">Failed to load player data</p>
<p class="text-gray-400 mt-2">Please check your connection and try again.</p>
</div>
`;
feather.replace();
}
}
// Shared utility functions
function formatDate(dateString) {
const options = { year: 'numeric', month: 'short', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
}
function calculatePRA(points, rebounds, assists) {
return (parseInt(points) || 0) + (parseInt(rebounds) || 0) + (parseInt(assists) || 0);
}