// The 1975 Website JavaScript document.addEventListener('DOMContentLoaded', () => { // Initialize Lucide Icons lucide.createIcons(); // Mobile Menu Toggle const mobileMenuBtn = document.getElementById('mobile-menu-btn'); const mobileMenu = document.getElementById('mobile-menu'); if (mobileMenuBtn && mobileMenu) { mobileMenuBtn.addEventListener('click', () => { mobileMenu.classList.toggle('hidden'); const icon = mobileMenuBtn.querySelector('i'); if (mobileMenu.classList.contains('hidden')) { icon.setAttribute('data-lucide', 'menu'); } else { icon.setAttribute('data-lucide', 'x'); } lucide.createIcons(); }); } // Music Player Functionality const playPauseBtn = document.getElementById('play-pause-btn'); const playIcon = document.getElementById('play-icon'); const audioPlayer = document.getElementById('audio-player'); const progressBar = document.getElementById('progress-bar'); const progressContainer = document.getElementById('progress-container'); const currentTimeEl = document.getElementById('current-time'); const durationEl = document.getElementById('duration'); const volumeSlider = document.getElementById('volume-slider'); const prevBtn = document.getElementById('prev-btn'); const nextBtn = document.getElementById('next-btn'); let isPlaying = false; // Track list - update with your own audio files const tracks = [ { title: "Happiness", artist: "The 1975 • BFIAFL", src: "music/happiness.mp3" }, { title: "Looking For Somebody (To Love)", artist: "The 1975 • BFIAFL", src: "music/looking-for-somebody.mp3" }, { title: "Part of the Band", artist: "The 1975 • BFIAFL", src: "music/part-of-the-band.mp3" }, { title: "About You", artist: "The 1975 • BFIAFL", src: "music/about-you.mp3" }, { title: "I'm In Love With You", artist: "The 1975 • BFIAFL", src: "music/im-in-love-with-you.mp3" } ]; let currentTrackIndex = 0; // Format time in minutes:seconds const formatTime = (seconds) => { if (isNaN(seconds)) return "0:00"; const mins = Math.floor(seconds / 60); const secs = Math.floor(seconds % 60); return `${mins}:${secs.toString().padStart(2, '0')}`; }; // Load track const loadTrack = (index) => { if (index < 0 || index >= tracks.length) return; currentTrackIndex = index; audioPlayer.src = tracks[index].src; audioPlayer.load(); const titleEl = document.getElementById('track-title'); if (titleEl) { titleEl.textContent = tracks[index].title; // Update artist text in the next sibling const artistEl = titleEl.nextElementSibling; if (artistEl) artistEl.textContent = tracks[index].artist; } if (isPlaying) { audioPlayer.play().catch(e => console.error('Auto-play failed:', e)); } }; // Initialize first track on page load loadTrack(0); // Play/Pause functionality if (playPauseBtn && audioPlayer) { playPauseBtn.addEventListener('click', async () => { try { if (isPlaying) { audioPlayer.pause(); isPlaying = false; // Re-query the icon element since lucide replaces it with SVG const currentIcon = playPauseBtn.querySelector('i, svg'); if (currentIcon) { currentIcon.setAttribute('data-lucide', 'play'); currentIcon.innerHTML = ''; // Clear SVG content } playPauseBtn.classList.remove('animate-pulse'); // Remove visualizer const visualizer = document.getElementById('audio-visualizer'); if (visualizer) visualizer.remove(); } else { // Ensure we have a track loaded if (!audioPlayer.src || audioPlayer.src === window.location.href) { loadTrack(0); } const playPromise = audioPlayer.play(); if (playPromise !== undefined) { await playPromise; isPlaying = true; // Re-query the icon element const currentIcon = playPauseBtn.querySelector('i, svg'); if (currentIcon) { currentIcon.setAttribute('data-lucide', 'pause'); currentIcon.innerHTML = ''; // Clear SVG content } playPauseBtn.classList.add('animate-pulse'); // Add visualizer const playerControls = playPauseBtn.closest('.flex').querySelector('.flex.items-center.gap-4'); if (playerControls && !document.getElementById('audio-visualizer')) { const visualizer = createVisualizer(); playerControls.appendChild(visualizer); } } } lucide.createIcons(); } catch (error) { console.error('Playback failed:', error); alert('Audio playback failed. Please try again or check your browser permissions.'); } }); } // Update progress bar and time if (audioPlayer) { audioPlayer.addEventListener('timeupdate', () => { if (audioPlayer.duration) { const progress = (audioPlayer.currentTime / audioPlayer.duration) * 100; progressBar.style.width = `${progress}%`; currentTimeEl.textContent = formatTime(audioPlayer.currentTime); } }); // Update duration when metadata loaded audioPlayer.addEventListener('loadedmetadata', () => { durationEl.textContent = formatTime(audioPlayer.duration); }); // Handle track ended audioPlayer.addEventListener('ended', () => { isPlaying = false; playIcon.setAttribute('data-lucide', 'play'); playPauseBtn.classList.remove('animate-pulse'); progressBar.style.width = '0%'; lucide.createIcons(); // Auto play next track setTimeout(() => { let nextTrack = (currentTrackIndex + 1) % tracks.length; loadTrack(nextTrack); audioPlayer.play(); isPlaying = true; playIcon.setAttribute('data-lucide', 'pause'); playPauseBtn.classList.add('animate-pulse'); lucide.createIcons(); }, 1000); }); // Click on progress bar to seek if (progressContainer) { progressContainer.addEventListener('click', (e) => { const rect = progressContainer.getBoundingClientRect(); const pos = (e.clientX - rect.left) / rect.width; audioPlayer.currentTime = pos * audioPlayer.duration; }); } // Volume control if (volumeSlider) { volumeSlider.addEventListener('input', (e) => { audioPlayer.volume = e.target.value / 100; }); // Set initial volume audioPlayer.volume = 0.7; } } // Previous/Next buttons if (prevBtn) { prevBtn.addEventListener('click', async () => { let prevIndex = (currentTrackIndex - 1 + tracks.length) % tracks.length; loadTrack(prevIndex); if (isPlaying) { try { await audioPlayer.play(); } catch (e) { console.error('Playback failed:', e); } } }); } if (nextBtn) { nextBtn.addEventListener('click', async () => { let nextIndex = (currentTrackIndex + 1) % tracks.length; loadTrack(nextIndex); if (isPlaying) { try { await audioPlayer.play(); } catch (e) { console.error('Playback failed:', e); } } }); } // Add visualizer when playing const createVisualizer = () => { const visualizer = document.createElement('div'); visualizer.className = 'flex items-end gap-1 h-8 ml-4 equalizer'; visualizer.id = 'audio-visualizer'; for (let i = 0; i < 5; i++) { const bar = document.createElement('div'); bar.className = 'w-1 bg-pink-500 rounded-t transition-all duration-150'; bar.style.height = '20%'; bar.style.animation = `equalizer 0.8s ease-in-out ${i * 0.1}s infinite`; visualizer.appendChild(bar); } return visualizer; }; // Smooth Scroll for Navigation Links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { // Close mobile menu if open if (mobileMenu && !mobileMenu.classList.contains('hidden')) { mobileMenu.classList.add('hidden'); } target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Navbar Scroll Effect const nav = document.querySelector('nav'); let lastScroll = 0; window.addEventListener('scroll', () => { const currentScroll = window.pageYOffset; if (currentScroll > 100) { nav.classList.add('shadow-lg'); nav.classList.add('shadow-pink-500/10'); } else { nav.classList.remove('shadow-lg'); nav.classList.remove('shadow-pink-500/10'); } // Hide/show nav on scroll direction if (currentScroll > lastScroll && currentScroll > 200) { nav.style.transform = 'translateY(-100%)'; } else { nav.style.transform = 'translateY(0)'; } lastScroll = currentScroll; }); // Intersection Observer for Fade-in Animations const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('opacity-100', 'translate-y-0'); entry.target.classList.remove('opacity-0', 'translate-y-10'); } }); }, observerOptions); // Observe elements for animation document.querySelectorAll('section > div').forEach(section => { section.classList.add('transition-all', 'duration-1000', 'opacity-0', 'translate-y-10'); observer.observe(section); }); // Gallery Image Modal (Simple Implementation) const galleryImages = document.querySelectorAll('#gallery img'); galleryImages.forEach(img => { img.addEventListener('click', () => { // Create modal const modal = document.createElement('div'); modal.className = 'fixed inset-0 z-50 flex items-center justify-center bg-black/95 p-4'; modal.innerHTML = `
${img.alt}
`; document.body.appendChild(modal); document.body.style.overflow = 'hidden'; lucide.createIcons(); // Close modal modal.addEventListener('click', (e) => { if (e.target === modal || e.target.closest('button')) { modal.remove(); document.body.style.overflow = ''; } }); }); }); // Newsletter Form Validation Enhancement const newsletterForm = document.querySelector('form'); if (newsletterForm) { const emailInput = newsletterForm.querySelector('input[type="email"]'); emailInput.addEventListener('focus', () => { emailInput.parentElement.classList.add('scale-105'); }); emailInput.addEventListener('blur', () => { emailInput.parentElement.classList.remove('scale-105'); }); } // Add equalizer animation keyframes (if not already added) if (!document.getElementById('equalizer-style')) { const style = document.createElement('style'); style.id = 'equalizer-style'; style.textContent = ` @keyframes equalizer { 0%, 100% { height: 20%; } 50% { height: 100%; } } `; document.head.appendChild(style); } // Add visualizer to player when playing if (playPauseBtn) { playPauseBtn.addEventListener('click', () => { const playerContainer = document.querySelector('.bg-black\\\\/50'); if (!playerContainer) return; const playerControls = playerContainer.querySelector('.flex.items-center.gap-4'); if (!playerControls) return; let visualizer = document.getElementById('audio-visualizer'); if (isPlaying && !visualizer) { visualizer = createVisualizer(); playerControls.appendChild(visualizer); } else if (!isPlaying && visualizer) { visualizer.remove(); } }); } // Parallax Effect for Hero Section window.addEventListener('scroll', () => { const scrolled = window.pageYOffset; const heroImage = document.querySelector('#home img'); if (heroImage) { heroImage.style.transform = `translateY(${scrolled * 0.5}px)`; } }); // Ticket Button Interactions document.querySelectorAll('button').forEach(button => { if (button.textContent.includes('Tickets') || button.textContent.includes('Get Tickets')) { if (!button.disabled) { button.addEventListener('click', (e) => { if (!e.target.closest('form')) { // Create ripple effect const ripple = document.createElement('span'); ripple.style.cssText = ` position: absolute; background: rgba(255,255,255,0.3); border-radius: 50%; transform: scale(0); animation: ripple 0.6s ease-out; pointer-events: none; `; const rect = button.getBoundingClientRect(); const size = Math.max(rect.width, rect.height); ripple.style.width = ripple.style.height = size + 'px'; ripple.style.left = (e.clientX - rect.left - size/2) + 'px'; ripple.style.top = (e.clientY - rect.top - size/2) + 'px'; button.style.position = 'relative'; button.style.overflow = 'hidden'; button.appendChild(ripple); setTimeout(() => ripple.remove(), 600); // Show coming soon popup for demo if (!button.classList.contains('opacity-50')) { alert('Ticket purchase would open in a new window. This is a demo site.'); } } }); } } }); // Add ripple animation keyframes const rippleStyle = document.createElement('style'); rippleStyle.textContent = ` @keyframes ripple { to { transform: scale(4); opacity: 0; } } `; document.head.appendChild(rippleStyle); });