// Initialize tooltips document.addEventListener('DOMContentLoaded', () => { // Platform click handler document.querySelectorAll('.platform-card').forEach(card => { card.addEventListener('click', () => { const platform = card.getAttribute('data-platform'); document.querySelector('input[type="text"]').placeholder = `https://${platform}.com/...`; }); }); // Download button handler (simulation) document.querySelector('.download-btn').addEventListener('click', async () => { const urlInput = document.querySelector('input[type="text"]'); const url = urlInput.value.trim(); if (!url) { showAlert('يرجى إدخال رابط أولاً', 'error'); return; } try { showAlert('جاري معالجة الرابط...', 'info'); // Simulate API call await new Promise(resolve => setTimeout(resolve, 1500)); showAlert('تم العثور على المحتوى بنجاح!', 'success'); // Simulate showing download options showDownloadOptions(); } catch (error) { showAlert('حدث خطأ أثناء معالجة الرابط', 'error'); } }); }); function showAlert(message, type) { const alert = document.createElement('div'); alert.className = `fixed top-4 right-4 px-6 py-3 rounded-lg shadow-lg ${ type === 'error' ? 'bg-red-500' : type === 'success' ? 'bg-green-500' : 'bg-blue-500' } text-white font-medium`; alert.textContent = message; document.body.appendChild(alert); setTimeout(() => { alert.remove(); }, 3000); } function showDownloadOptions() { const optionsContainer = document.createElement('div'); optionsContainer.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50'; optionsContainer.innerHTML = `