cinepulse / script.js
srab1980's picture
redesign this website https://www.imdb.com/
78f0a1f verified
// Toggle mobile menu
function toggleMenu() {
const menu = document.getElementById('mobile-menu');
menu?.classList.toggle('hidden');
}
// Sticky header on scroll
window.addEventListener('scroll', function() {
const header = document.querySelector('header');
if (window.scrollY > 50) {
header?.classList.add('bg-gray-900', 'shadow-lg');
} else {
header?.classList.remove('bg-gray-900', 'shadow-lg');
}
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// Dynamic movie cards hover effects
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Add click handlers for movie cards
document.querySelectorAll('.group.cursor-pointer').forEach(card => {
card.addEventListener('click', function() {
// Simulate navigation to movie details
window.location.href = 'movie-details.html';
});
});
// Load more functionality
const loadMoreBtn = document.querySelector('button:contains("Load More")');
if (loadMoreBtn) {
loadMoreBtn.addEventListener('click', function() {
this.innerHTML = '<i data-feather="loader" class="w-5 h-5 mr-2 animate-spin"></i> Loading...';
setTimeout(() => {
this.innerHTML = 'Load More Movies';
feather.replace();
}, 2000);
});
}
});
// Filter functionality for movies page
document.addEventListener('DOMContentLoaded', function() {
const filterButtons = document.querySelectorAll('select');
filterButtons.forEach(select => {
select.addEventListener('change', function() {
// Simulate filtering movies
const cards = document.querySelectorAll('.group.cursor-pointer');
cards.forEach(card => {
card.style.opacity = '0.5';
setTimeout(() => card.style.opacity = '1', 300);
});
});
});
});