document.addEventListener('DOMContentLoaded', function() { const fetchBtn = document.getElementById('fetch-btn'); const instagramUrl = document.getElementById('instagram-url'); const loading = document.getElementById('loading'); const results = document.getElementById('results'); const winner = document.getElementById('winner'); const participants = document.getElementById('participants'); const pickAgain = document.getElementById('pick-again'); // Mock data for demonstration const mockParticipants = [ "@user123", "@giveawaylover", "@instafan", "@shopaholic", "@fitnessguru", "@travelbug", "@foodieforever", "@techgeek", "@fashionista", "@bookworm", "@petlover", "@musicfan", "@artistlife", "@photographypro", "@entrepreneur", "@studentlife" ]; fetchBtn.addEventListener('click', function() { if (!instagramUrl.value) { alert('Please enter an Instagram post URL'); return; } // Show loading state loading.classList.remove('hidden'); results.classList.add('hidden'); // Simulate API call with timeout setTimeout(() => { loading.classList.add('hidden'); results.classList.remove('hidden'); // Display all participants participants.innerHTML = ''; mockParticipants.forEach(participant => { const p = document.createElement('p'); p.textContent = participant; p.className = 'py-1 border-b border-gray-100 last:border-0'; participants.appendChild(p); }); // Pick a random winner pickRandomWinner(); }, 2000); }); pickAgain.addEventListener('click', pickRandomWinner); function pickRandomWinner() { // Reset animation winner.classList.remove('winner-pulse'); // Force reflow to restart animation void winner.offsetWidth; // Pick random winner const randomIndex = Math.floor(Math.random() * mockParticipants.length); winner.textContent = mockParticipants[randomIndex]; // Add animation winner.classList.add('winner-pulse'); } });