Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const searchInput = document.getElementById('movieSearch');
+ const searchButton = document.getElementById('searchButton');
+ const resultsSection = document.getElementById('results');
+
+ // Sample movie data (in real app, this would come from an API)
+ const sampleMovies = [
+ { title: 'Sample Movie 1', year: 2023, rating: 8.5 },
+ { title: 'Sample Movie 2', year: 2023, rating: 7.9 },
+ { title: 'Sample Movie 3', year: 2023, rating: 8.2 }
+ ];
+
+ function createMovieCard(movie) {
+ return `
+
+
+
${movie.title}
+
Rating: ${movie.rating}/10
+
+
+ `;
+ }
+
+ function handleSearch() {
+ const searchTerm = searchInput.value.trim().toLowerCase();
+ if (searchTerm.length < 2) return;
+
+ // Filter movies (in real app, this would be an API call)
+ const filteredMovies = sampleMovies.filter(movie =>
+ movie.title.toLowerCase().includes(searchTerm)
+ );
+
+ // Display results
+ resultsSection.innerHTML = filteredMovies
+ .map(movie => createMovieCard(movie))
+ .join('');
+ }
+
+ // Event listeners
+ searchButton.addEventListener('click', handleSearch);
+ searchInput.addEventListener('keypress', (e) => {
+ if (e.key === 'Enter') handleSearch();
+ });
+
+ // Smooth scroll for navigation
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ // Animation on scroll
+ const observer = new IntersectionObserver((entries) => {
+ entries.forEach(entry => {
+ if (entry.isIntersecting) {
+ entry.target.style.opacity = 1;
+ entry.target.style.transform = 'translateY(0)';
+ }
+ });
+ });
+
+ document.querySelectorAll('.movie-card').forEach(card => {
+ card.style.opacity = 0;
+ card.style.transform = 'translateY(20px)';
+ observer.observe(card);
+ });
+ });