CoolFace
Apppublic

PlanetandPaws/ecopaws-harmony-haven

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
script.js62 linesDownload Raw Back to root
1 2// Shared JavaScript across all pages3document.addEventListener('DOMContentLoaded', () => {4    // Animate impact counter5    function animateCounter(elementId, target) {6        const element = document.getElementById(elementId);7        let current = 0;8        const increment = target / 100;9        const timer = setInterval(() => {10            current += increment;11            if (current >= target) {12                clearInterval(timer);13                current = target;14            }15            element.textContent = Math.floor(current).toLocaleString();16        }, 20);17    }18 19    // Initialize counters20    if (document.getElementById('trees-planted')) {21        animateCounter('trees-planted', 1284);22        animateCounter('carbon-offset', 328);23        animateCounter('animals-helped', 4592);24    }25console.log('Paws & Planet loaded');26    27    // Smooth scrolling for anchor links28    document.querySelectorAll('a[href^
291000
30="#"]').forEach(anchor => {31        anchor.addEventListener('click', function (e) {32            e.preventDefault();33            document.querySelector(this.getAttribute('href')).scrollIntoView({34                behavior: 'smooth'35            });36        });37    });38 39    // Mobile menu toggle40    const mobileMenuBtn = document.querySelector('custom-navbar').shadowRoot.querySelector('.mobile-menu-btn');41    if (mobileMenuBtn) {42        mobileMenuBtn.addEventListener('click', () => {43            const navLinks = document.querySelector('custom-navbar').shadowRoot.querySelector('.nav-links');44            const navActions = document.querySelector('custom-navbar').shadowRoot.querySelector('.nav-actions');45            46            if (navLinks.style.display === 'flex') {47                navLinks.style.display = 'none';48                navActions.style.display = 'none';49            } else {50                navLinks.style.display = 'flex';51                navActions.style.display = 'flex';52            }53        });54    }55});56 57// Product filtering functionality would go here58function filterProducts(category) {59    console.log(`Filtering by ${category}`);60    // Implementation would filter displayed products61}62