File size: 2,913 Bytes
c8fe9c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// 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);
}