File size: 1,910 Bytes
84b2f10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
document.addEventListener('DOMContentLoaded', function() {
    // Add to cart functionality
    const addToCartButtons = document.querySelectorAll('button:contains("Add to Cart")');
    
    addToCartButtons.forEach(button => {
        button.addEventListener('click', function() {
            const productName = this.closest('.bg-white').querySelector('h3').textContent;
            const productPrice = this.closest('.bg-white').querySelector('span').textContent;
            
            // Create cookie animation
            const cookie = document.createElement('div');
            cookie.innerHTML = '<i data-feather="cookie" class="text-cookie-500"></i>';
            cookie.className = 'fixed bottom-4 right-4 text-4xl cookie-spin';
            document.body.appendChild(cookie);
            feather.replace();
            
            // Show notification
            const notification = document.createElement('div');
            notification.className = 'fixed bottom-4 left-4 bg-white text-cookie-800 px-4 py-2 rounded-lg shadow-lg flex items-center';
            notification.innerHTML = `
                <i data-feather="check-circle" class="text-green-500 mr-2"></i>
                Added ${productName} (${productPrice}) to cart!
            `;
            document.body.appendChild(notification);
            feather.replace();
            
            // Remove notification after 3 seconds
            setTimeout(() => {
                notification.remove();
                cookie.remove();
            }, 3000);
        });
    });
    
    // 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'
            });
        });
    });
});