File size: 1,329 Bytes
4d9a250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// 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'
            });
        });
    });
});