From 441ea683dc8ce619ad446825b678c1b791b82de8 Mon Sep 17 00:00:00 2001 From: Chaoscat Date: Mon, 11 Aug 2025 06:34:51 +0000 Subject: [PATCH] =?UTF-8?q?static/app.js=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/app.js | 121 -------------------------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 static/app.js diff --git a/static/app.js b/static/app.js deleted file mode 100644 index 251cdf0..0000000 --- a/static/app.js +++ /dev/null @@ -1,121 +0,0 @@ -/** - * AniWorld Downloader Web Interface - * Main JavaScript file - */ - -// Format timestamps -function formatDateTime(dateString) { - const date = new Date(dateString); - return date.toLocaleString('de-DE', { - day: '2-digit', - month: '2-digit', - year: 'numeric', - hour: '2-digit', - minute: '2-digit' - }); -} - -// Helper to capitalize first letter -function capitalizeFirst(string) { - return string.charAt(0).toUpperCase() + string.slice(1); -} - -// Helper to truncate text with ellipsis -function truncateText(text, maxLength) { - return text.length > maxLength ? text.substring(0, maxLength) + '...' : text; -} - -// Parse URL parameters -function getUrlParams() { - const params = {}; - const queryString = window.location.search; - const urlParams = new URLSearchParams(queryString); - - for (const [key, value] of urlParams) { - params[key] = value; - } - - return params; -} - -// Show notification -function showNotification(message, type = 'info') { - // Check if notification container exists - let container = document.getElementById('notification-container'); - - if (!container) { - container = document.createElement('div'); - container.id = 'notification-container'; - container.style.position = 'fixed'; - container.style.top = '20px'; - container.style.right = '20px'; - container.style.zIndex = '9999'; - document.body.appendChild(container); - } - - // Create notification - const notification = document.createElement('div'); - notification.className = `alert alert-${type} alert-dismissible fade show`; - notification.innerHTML = ` - ${message} - - `; - - container.appendChild(notification); - - // Auto-close after 5 seconds - setTimeout(() => { - notification.classList.remove('show'); - setTimeout(() => { - notification.remove(); - }, 150); - }, 5000); -} - -// Extract title from URL -function extractTitleFromUrl(url) { - try { - if (url.includes('bs.to')) { - const match = url.match(/\/serie\/([^\/]+)/); - return match ? match[1].replace(/-/g, ' ') : 'Unknown Title'; - } else { - const match = url.match(/\/stream\/([^\/]+)/); - return match ? match[1].replace(/-/g, ' ') : 'Unknown Title'; - } - } catch (e) { - return 'Unknown Title'; - } -} - -// Check if URL is valid -function isValidUrl(url) { - const pattern = /^(https?:\/\/)?(www\.)?(aniworld\.to|s\.to|bs\.to)\/.*$/; - return pattern.test(url); -} - -// Initialize page-specific scripts when DOM is loaded -document.addEventListener('DOMContentLoaded', function() { - // Check for link parameter and populate the input - const urlParams = getUrlParams(); - if (urlParams.link && document.getElementById('animeLink')) { - document.getElementById('animeLink').value = urlParams.link; - - // Auto-analyze if requested - if (urlParams.analyze === 'true') { - document.getElementById('analyzeButton').click(); - } - } - - // Apply theme preference - const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; - if (prefersDarkMode) { - document.body.classList.add('dark-mode'); - } -}); - -// Handle AJAX errors globally -window.addEventListener('error', function(e) { - if (e.message.includes('NetworkError') || e.message.includes('Failed to fetch')) { - showNotification('Netzwerkfehler. Bitte überprüfe deine Verbindung.', 'danger'); - } -}); \ No newline at end of file