document.addEventListener('DOMContentLoaded', function() { // Initialize Chart const ctx = document.getElementById('airdropChart').getContext('2d'); let airdropChart = new Chart(ctx, { type: 'bar', data: { labels: [], datasets: [{ label: 'Airdrop Value (USD)', data: [], backgroundColor: '#3B82F6', borderColor: '#3B82F6', borderWidth: 1 }] }, options: { responsive: true, scales: { y: { beginAtZero: true } } } }); // Sample data (in a real app, this would come from a database) let airdrops = [ { id: 1, project: 'Ethereum', token: 'ETH', amount: 0.5, value: 1000, status: 'claimed', date: '2023-05-15' }, { id: 2, project: 'Solana', token: 'SOL', amount: 10, value: 500, status: 'pending', date: '2023-06-20' }, { id: 3, project: 'Polygon', token: 'MATIC', amount: 200, value: 150, status: 'pending', date: '2023-07-10' } ]; // DOM Elements const airdropTableBody = document.getElementById('airdropTableBody'); const totalAirdropsElement = document.getElementById('totalAirdrops'); const claimedAirdropsElement = document.getElementById('claimedAirdrops'); const pendingAirdropsElement = document.getElementById('pendingAirdrops'); const openModalBtn = document.getElementById('openModalBtn'); const modal = document.querySelector('custom-add-airdrop-modal'); // Render airdrops table function renderAirdrops() { airdropTableBody.innerHTML = ''; // Update stats totalAirdropsElement.textContent = airdrops.length; claimedAirdropsElement.textContent = airdrops.filter(a => a.status === 'claimed').length; pendingAirdropsElement.textContent = airdrops.filter(a => a.status === 'pending').length; // Update chart data const chartLabels = airdrops.map(a => a.project); const chartData = airdrops.map(a => a.value); airdropChart.data.labels = chartLabels; airdropChart.data.datasets[0].data = chartData; airdropChart.update(); // Render table rows airdrops.forEach(airdrop => { const row = document.createElement('tr'); // Determine status class let statusClass = 'status-pending'; if (airdrop.status === 'claimed') statusClass = 'status-claimed'; if (airdrop.status === 'failed') statusClass = 'status-failed'; row.innerHTML = `