Spaces:
Running
Running
Download script.js from mfsobrin/aqualab-pro: direct link, hf CLI and curl.
- Browser
- Download file 7.9 kB
-
https://huggingface.co/spaces/mfsobrin/aqualab-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/mfsobrin/aqualab-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/mfsobrin/aqualab-pro/resolve/main/script.js
7.9 kB
| // Mobile menu toggle | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const mobileMenuBtn = document.getElementById('mobile-menu-btn'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| mobileMenuBtn.addEventListener('click', function() { | |
| mobileMenu.classList.toggle('hidden'); | |
| }); | |
| // Close mobile menu when clicking on a link | |
| const mobileLinks = mobileMenu.querySelectorAll('a'); | |
| mobileLinks.forEach(link => { | |
| link.addEventListener('click', () => { | |
| mobileMenu.classList.add('hidden'); | |
| }); | |
| }); | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| const target = document.querySelector(this.getAttribute('href')); | |
| if (target) { | |
| target.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Form submission handling | |
| document.getElementById('contact-form')?.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Add loading state | |
| const submitBtn = this.querySelector('button[type="submit"]'); | |
| const originalText = submitBtn.textContent; | |
| submitBtn.innerHTML = '<span class="loading"></span> Enviando...'; | |
| submitBtn.disabled = true; | |
| // Simulate form submission | |
| setTimeout(() => { | |
| // Reset form | |
| this.reset(); | |
| // Show success message | |
| submitBtn.textContent = '✓ Enviado com sucesso!'; | |
| submitBtn.classList.add('bg-green-600', 'form-success'); | |
| submitBtn.classList.remove('bg-blue-600'); | |
| // Reset button after 3 seconds | |
| setTimeout(() => { | |
| submitBtn.textContent = originalText; | |
| submitBtn.classList.remove('bg-green-600', 'form-success'); | |
| submitBtn.classList.add('bg-blue-600'); | |
| submitBtn.disabled = false; | |
| }, 3000); | |
| }, 2000); | |
| }); | |
| // Parallax effect for hero section | |
| window.addEventListener('scroll', () => { | |
| const scrolled = window.pageYOffset; | |
| const hero = document.querySelector('#home'); | |
| if (hero) { | |
| hero.style.transform = `translateY(${scrolled * 0.5}px)`; | |
| } | |
| }); | |
| // 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.style.opacity = '1'; | |
| entry.target.style.transform = 'translateY(0)'; | |
| } | |
| }); | |
| }, observerOptions); | |
| // Observe all sections for animation | |
| document.querySelectorAll('section').forEach(section => { | |
| section.style.opacity = '0'; | |
| section.style.transform = 'translateY(20px)'; | |
| section.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; | |
| observer.observe(section); | |
| }); | |
| // Dynamic particles effect | |
| function createParticles() { | |
| const hero = document.querySelector('#home'); | |
| if (!hero) return; | |
| const particlesContainer = document.createElement('div'); | |
| particlesContainer.className = 'hero-particles'; | |
| for (let i = 0; i < 20; i++) { | |
| const particle = document.createElement('div'); | |
| particle.className = 'particle'; | |
| particle.style.width = Math.random() * 50 + 20 + 'px'; | |
| particle.style.height = particle.style.width; | |
| particle.style.left = Math.random() * 100 + '%'; | |
| particle.style.top = Math.random() * 100 + '%'; | |
| particle.style.animationDelay = Math.random() * 6 + 's'; | |
| particle.style.animationDuration = (Math.random() * 3 + 3) + 's'; | |
| particlesContainer.appendChild(particle); | |
| } | |
| hero.appendChild(particlesContainer); | |
| } | |
| // Initialize particles when page loads | |
| window.addEventListener('load', createParticles); | |
| // Dynamic copyright year | |
| const currentYear = new Date().getFullYear(); | |
| const copyrightElement = document.querySelector('footer p'); | |
| if (copyrightElement) { | |
| copyrightElement.textContent = `© ${currentYear} E-quality Lab. Todos os direitos reservados.`; | |
| } | |
| // Floating WhatsApp button (optional) | |
| function createWhatsAppButton() { | |
| const whatsappBtn = document.createElement('a'); | |
| whatsappBtn.href = 'https://wa.me/5511123456789'; // Replace with actual number | |
| whatsappBtn.target = '_blank'; | |
| whatsappBtn.className = 'floating-btn bg-green-600 hover:bg-green-700 w-14 h-14 rounded-full flex items-center justify-center shadow-lg transition-all'; | |
| whatsappBtn.innerHTML = '<i data-feather="message-circle" class="w-7 h-7 text-white"></i>'; | |
| // Add to DOM | |
| document.body.appendChild(whatsappBtn); | |
| // Re-render feather icons | |
| feather.replace(); | |
| } | |
| // Initialize WhatsApp button (optional) | |
| // createWhatsAppButton(); | |
| // Active navigation highlight | |
| window.addEventListener('scroll', () => { | |
| const sections = document.querySelectorAll('section[id]'); | |
| const scrollPosition = window.scrollY + 100; | |
| sections.forEach(section => { | |
| const sectionTop = section.offsetTop; | |
| const sectionHeight = section.clientHeight; | |
| const sectionId = section.getAttribute('id'); | |
| if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) { | |
| document.querySelectorAll('nav a').forEach(link => { | |
| link.classList.remove('text-blue-400'); | |
| if (link.getAttribute('href') === `#${sectionId}`) { | |
| link.classList.add('text-blue-400'); | |
| } | |
| }); | |
| } | |
| }); | |
| }); | |
| // Debounce function for scroll events | |
| function debounce(func, wait, immediate) { | |
| let timeout; | |
| return function executedFunction(...args) { | |
| const later = () => { | |
| timeout = null; | |
| if (!immediate) func(...args); | |
| }; | |
| const callNow = immediate && !timeout; | |
| clearTimeout(timeout); | |
| timeout = setTimeout(later, wait); | |
| if (callNow) func(...args); | |
| }; | |
| } | |
| // Improve performance with debounced scroll events | |
| const debouncedScrollHandler = debounce(() => { | |
| // Scroll-related code here | |
| }, 10); | |
| window.addEventListener('scroll', debouncedScrollHandler); | |
| // Add loading animation for images | |
| document.querySelectorAll('img').forEach(img => { | |
| img.addEventListener('load', function() { | |
| this.style.opacity = '0'; | |
| this.style.transition = 'opacity 0.3s ease'; | |
| setTimeout(() => { | |
| this.style.opacity = '1'; | |
| }, 100); | |
| }); | |
| }); | |
| // Preload images for better performance | |
| function preloadImages() { | |
| const images = [ | |
| 'http://static.photos/laboratory/1200x630/42', | |
| 'http://static.photos/laboratory/640x360/123', | |
| 'http://static.photos/technology/640x360/456', | |
| 'http://static.photos/science/640x480/789' | |
| ]; | |
| images.forEach(src => { | |
| const img = new Image(); | |
| img.src = src; | |
| }); | |
| } | |
| // Initialize preloading | |
| preloadImages(); | |
| // Add typing effect to hero title | |
| function typeWriter(element, text, speed = 50) { | |
| let i = 0; | |
| element.textContent = ''; | |
| function type() { | |
| if (i < text.length) { | |
| element.textContent += text.charAt(i); | |
| i++; | |
| setTimeout(type, speed); | |
| } | |
| } | |
| type(); | |
| } | |
| // Initialize typing effect when hero is visible | |
| const heroTitle = document.querySelector('#home h1'); | |
| if (heroTitle) { | |
| const originalText = heroTitle.textContent; | |
| const heroObserver = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| typeWriter(heroTitle, originalText, 50); | |
| heroObserver.unobserve(entry.target); | |
| } | |
| }); | |
| }); | |
| heroObserver.observe(heroTitle); | |
| } |