Spaces:
Running
Running
File size: 1,650 Bytes
c4a33df | 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 | document.addEventListener('DOMContentLoaded', function() {
// Theme toggle functionality
const themeToggleBtn = document.getElementById('theme-toggle');
if (themeToggleBtn) {
themeToggleBtn.addEventListener('click', function() {
if (document.documentElement.classList.contains('dark')) {
document.documentElement.classList.remove('dark');
localStorage.setItem('theme', 'light');
} else {
document.documentElement.classList.add('dark');
localStorage.setItem('theme', 'dark');
}
});
}
// Check for saved theme preference or use preferred color scheme
if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
// Simulate loading anime data (in a real app, this would be an API call)
setTimeout(() => {
const loadingElements = document.querySelectorAll('.loading-skeleton');
loadingElements.forEach(el => el.classList.remove('loading-skeleton'));
}, 1500);
});
// Video player modal functionality
function openVideoModal(videoId) {
const modal = document.getElementById('video-modal');
modal.classList.remove('hidden');
document.body.classList.add('overflow-hidden');
}
function closeVideoModal() {
const modal = document.getElementById('video-modal');
modal.classList.add('hidden');
document.body.classList.remove('overflow-hidden');
} |