🎁 Premii Gratuite

Participă la giveaway-uri și câștigă jocuri pentru platformele tale favorite

47
Active Acum
12,450
Chei Disponibile
8,923
Participanți
`; modal.classList.add('show'); // Check tasks const btnParticipate = document.getElementById('btnParticipate'); const checkboxes = modalBody.querySelectorAll('.task-check'); function updateButton() { const checkedCount = Array.from(checkboxes).filter(cb => cb.checked).length; const totalPoints = checkedCount * 10; btnParticipate.disabled = checkedCount === 0; btnParticipate.style.opacity = checkedCount > 0 ? '1' : '0.5'; btnParticipate.style.cursor = checkedCount > 0 ? 'pointer' : 'not-allowed'; // Update button text with points const btnText = checkedCount > 0 ? `🎁 Participă acum (${totalPoints} Points)` : '🎁 Participă acum'; btnParticipate.querySelector('span:first-child').textContent = btnText; } checkboxes.forEach(cb => { cb.addEventListener('change', updateButton); }); updateButton(); btnParticipate.addEventListener('click', () => { if (!currentUser) { modal.classList.remove('show'); document.getElementById('loginModal').classList.add('show'); return; } const allChecked = Array.from(checkboxes).every(cb => cb.checked); if (allChecked) { alert(`✅ Felicitări! Ai fost înscris la giveaway-ul "${giveaway.title}"!\n\nÎți vom trimite notificare când sunt anunțați câștigătorii.`); modal.classList.remove('show'); } }); } // ===== EVENT LISTENERS ===== function setupEventListeners() { // Modal close buttons document.getElementById('modalClose')?.addEventListener('click', () => { document.getElementById('giveawayModal').classList.remove('show'); }); document.getElementById('loginModalClose')?.addEventListener('click', () => { document.getElementById('loginModal').classList.remove('show'); }); // Close modal on backdrop click document.querySelectorAll('.modal').forEach(modal => { modal.addEventListener('click', (e) => { if (e.target === modal) { modal.classList.remove('show'); } }); }); // Platform filters document.querySelectorAll('#platformFilters .filter-chip').forEach(chip => { chip.addEventListener('click', () => { document.querySelectorAll('#platformFilters .filter-chip').forEach(c => c.classList.remove('active')); chip.classList.add('active'); currentFilters.platform = chip.dataset.filter; renderGiveaways(); }); }); // Category filters document.querySelectorAll('#categoryFilters .filter-chip').forEach(chip => { chip.addEventListener('click', () => { document.querySelectorAll('#categoryFilters .filter-chip').forEach(c => c.classList.remove('active')); chip.classList.add('active'); currentFilters.category = chip.dataset.category; renderGiveaways(); }); }); // Sort filters document.querySelectorAll('#sortFilters .filter-chip').forEach(chip => { chip.addEventListener('click', () => { document.querySelectorAll('#sortFilters .filter-chip').forEach(c => c.classList.remove('active')); chip.classList.add('active'); currentFilters.sort = chip.dataset.sort; renderGiveaways(); }); }); // Search const searchInput = document.getElementById('searchInput'); let searchTimeout; searchInput?.addEventListener('input', (e) => { clearTimeout(searchTimeout); searchTimeout = setTimeout(() => { currentFilters.search = e.target.value; renderGiveaways(); }, 300); }); // User menu document.getElementById('btnUserMenu')?.addEventListener('click', () => { if (currentUser) { if (confirm('Vrei să te deconectezi?')) { currentUser = null; localStorage.removeItem('retroplay_user'); document.getElementById('userName').textContent = 'Login'; } } else { document.getElementById('loginModal').classList.add('show'); } }); // Login form document.getElementById('loginForm')?.addEventListener('submit', (e) => { e.preventDefault(); const email = document.getElementById('loginEmail').value; currentUser = { name: email.split('@')[0], email: email }; localStorage.setItem('retroplay_user', JSON.stringify(currentUser)); updateUserUI(); document.getElementById('loginModal').classList.remove('show'); alert(`Bun venit, ${currentUser.name}! Acum poți participa la giveaway-uri! 🎉`); }); // Social login document.querySelectorAll('.btn-social').forEach(btn => { btn.addEventListener('click', () => { const provider = btn.dataset.provider; alert(`Demo: Autentificare cu ${provider}\n\nÎn producție, acesta ar redirecta către OAuth.`); }); }); } // ===== TIMER FUNCTIONS ===== function startTimers() { setInterval(() => { document.querySelectorAll('.card-timer').forEach(timer => { let timeLeft = parseInt(timer.dataset.time); if (timeLeft > 0) { timeLeft--; timer.dataset.time = timeLeft; const textEl = timer.querySelector('.timer-text'); if (textEl) { textEl.textContent = formatTime(timeLeft); } // Update color based on time const percentage = timeLeft / 604800; // 7 days if (percentage < 0.1) { timer.style.background = 'rgba(239, 68, 68, 0.9)'; } else if (percentage < 0.3) { timer.style.background = 'rgba(245, 158, 11, 0.9)'; } } }); }, 1000); } function formatTime(seconds) { const days = Math.floor(seconds / 86400); const hours = Math.floor((seconds % 86400) / 3600); const minutes = Math.floor((seconds % 3600) / 60); if (days > 0) return `${days}z ${hours}h`; if (hours > 0) return `${hours}h ${minutes}m`; return `${minutes}m`; } function formatNumber(num) { if (num >= 1000) { return (num / 1000).toFixed(1) + 'k'; } return num.toString(); }