Spaces:
Running
Running
File size: 3,366 Bytes
5cc4786 | 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 71 72 73 74 75 76 77 78 79 80 81 82 | // 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 = `
<div class="bg-gray-800 rounded-xl p-6 max-w-md w-full">
<h3 class="text-xl font-bold mb-4">خيارات التنزيل</h3>
<div class="space-y-3">
<button class="w-full bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg flex justify-between items-center">
<span>تنزيل الفيديو (HD)</span>
<span class="text-sm">1080p</span>
</button>
<button class="w-full bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg flex justify-between items-center">
<span>تنزيل الفيديو (SD)</span>
<span class="text-sm">720p</span>
</button>
<button class="w-full bg-purple-600 hover:bg-purple-700 px-4 py-2 rounded-lg flex justify-between items-center">
<span>تنزيل الصور فقط</span>
<i data-feather="image"></i>
</button>
</div>
<button class="mt-4 w-full bg-gray-700 hover:bg-gray-600 px-4 py-2 rounded-lg">
إلغاء
</button>
</div>
`;
document.body.appendChild(optionsContainer);
feather.replace();
optionsContainer.querySelector('button:last-child').addEventListener('click', () => {
optionsContainer.remove();
});
} |