home
/
aioutajg
/
playpauseonline.com
/
assets
/
js
/
Go to Home Directory
+
Upload
Create File
root@0UT1S:~$
Execute
By Order of Mr.0UT1S
[DIR] ..
N/A
index.php
0 bytes
Rename
Delete
script.js
7.15 KB
Rename
Delete
document.addEventListener('DOMContentLoaded', function() { const hamburger = document.querySelector('.hamburger'); const mobileMenu = document.querySelector('.mobile-menu-wrapper'); hamburger.addEventListener('click', function() { this.classList.toggle('hamburger--active'); mobileMenu.classList.toggle('active'); }); // Close menu when clicking outside document.addEventListener('click', function(event) { if (!event.target.closest('.navbar')) { hamburger.classList.remove('hamburger--active'); mobileMenu.classList.remove('active'); } }); // Close menu on resize window.addEventListener('resize', function() { if (window.innerWidth > 768) { hamburger.classList.remove('hamburger--active'); mobileMenu.classList.remove('active'); } }); }); document.addEventListener('DOMContentLoaded', function() { 'use strict'; // Mobile Menu const menuToggle = document.querySelector('.menu-toggle'); const navMenu = document.querySelector('.nav-menu'); if (menuToggle && navMenu) { menuToggle.addEventListener('click', () => { navMenu.classList.toggle('active'); }); } // Thumbnail Tool const form = document.getElementById('thumbnailForm'); const loader = document.querySelector('.loader'); const grid = document.getElementById('thumbnailsGrid'); const videoInfo = document.getElementById('videoInfo'); if (form) { form.addEventListener('submit', async (e) => { e.preventDefault(); const videoInput = document.getElementById('videoInput')?.value || ''; const videoId = extractVideoId(videoInput); if (!videoId) { alert('Invalid YouTube URL or Video ID'); return; } try { showLoading(); const response = await fetch('/thumbnails', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' }, body: new URLSearchParams({ videoId }) }); const data = await response.json(); if (!response.ok || !data.success) { throw new Error(data?.message || 'Request failed'); } displayResults(data); } catch (error) { console.error('Error:', error); alert(error.message || 'Something went wrong'); clearResults(); } finally { hideLoading(); } }); } function extractVideoId(url) { const regex = /^.*(youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#\&\?]*).*/; const match = url.match(regex); return (match && match[2].length === 11) ? match[2] : null; } function displayResults(data) { if (!videoInfo || !grid) return; // Format video info videoInfo.innerHTML = ` <h3>${escapeHtml(data.videoDetails.title)}</h3> <p>Channel: ${escapeHtml(data.videoDetails.channel)}</p> <p>Published: ${formatDate(data.videoDetails.published)}</p> `; // Generate thumbnail grid grid.innerHTML = data.thumbnails.map(thumb => ` <div class="thumbnail-card"> <img src="${escapeHtml(thumb.url)}" alt="Thumbnail ${escapeHtml(thumb.resolution)}"> <div class="card-body"> <p>Resolution: ${escapeHtml(thumb.resolution)}</p> <button class="btn btn-primary" data-url="${escapeHtml(thumb.url)}">Download</button> <button class="btn btn-secondary" data-clipboard="${escapeHtml(thumb.url)}">Copy URL</button> </div> </div> `).join(''); // Add event listeners to new buttons grid.querySelectorAll('.btn-primary').forEach(btn => { btn.addEventListener('click', () => downloadThumbnail(btn.dataset.url)); }); grid.querySelectorAll('.btn-secondary').forEach(btn => { btn.addEventListener('click', () => copyToClipboard(btn.dataset.clipboard)); }); } function showLoading() { if (loader) loader.style.display = 'block'; if (grid) grid.innerHTML = ''; if (videoInfo) videoInfo.innerHTML = ''; } function hideLoading() { if (loader) loader.style.display = 'none'; } function clearResults() { if (grid) grid.innerHTML = ''; if (videoInfo) videoInfo.innerHTML = ''; } // Security: Basic HTML escaping function escapeHtml(str) { return str.replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } // Better date formatting function formatDate(isoDate) { const date = new Date(isoDate); return date.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' }); } // Clipboard handling function copyToClipboard(text) { if (!text) return; navigator.clipboard.writeText(text) .then(() => { alert('URL copied to clipboard!'); }) .catch(err => { console.error('Copy failed:', err); alert('Copy failed. Please try again.'); }); } // Download handling using form submission function downloadThumbnail(url) { if (!url) return; const form = document.createElement('form'); form.method = 'POST'; form.action = '/download'; form.style.display = 'none'; const input = document.createElement('input'); input.type = 'hidden'; input.name = 'url'; input.value = url; form.appendChild(input); document.body.appendChild(form); form.submit(); document.body.removeChild(form); } }); document.addEventListener("DOMContentLoaded", function() { // Add 'post-featured-image' to all figures with class 'image' const figures = document.querySelectorAll('figure.image'); figures.forEach(figure => { figure.classList.add('post-featured-image'); }); // Apply attributes and classes to all <img> inside <figure> const images = document.querySelectorAll('figure img'); images.forEach(img => { img.classList.add('img-fluid', 'rounded-3', 'w-100'); img.setAttribute('loading', 'lazy'); img.setAttribute('width', '1200'); img.setAttribute('height', '630'); img.style.objectFit = 'cover'; img.style.maxHeight = '500px'; }); });
Save