| // Form validation for the YouTube URL input | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const youtubeInput = document.querySelector('input[type="text"]'); | |
| const startButton = document.querySelector('button.bg-primary-500'); | |
| youtubeInput.addEventListener('input', function() { | |
| const url = this.value; | |
| const youtubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/; | |
| if (youtubeRegex.test(url)) { | |
| this.classList.remove('border-red-500'); | |
| this.classList.add('border-green-500'); | |
| startButton.disabled = false; | |
| } else { | |
| this.classList.remove('border-green-500'); | |
| this.classList.add('border-red-500'); | |
| startButton.disabled = true; | |
| } | |
| }); | |
| // Add animation to the main CTA button | |
| const ctaButton = document.querySelector('a.bg-primary-500'); | |
| ctaButton.classList.add('animate-pulse'); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| }); |