-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1 lines (1 loc) · 2.55 KB
/
script.js
File metadata and controls
1 lines (1 loc) · 2.55 KB
1
document.addEventListener('DOMContentLoaded',()=>{const navToggle=document.querySelector('.nav-toggle');const navLinks=document.querySelector('.nav-links');if(navToggle){navToggle.addEventListener('click',()=>{navLinks.classList.toggle('active');});}document.querySelectorAll('.nav-links a').forEach(link=>{link.addEventListener('click',()=>{navLinks.classList.remove('active');});});const observerOptions={threshold:0.1,rootMargin:'0px 0px -100px 0px'};const observer=new IntersectionObserver((entries)=>{entries.forEach(entry=>{if(entry.isIntersecting){entry.target.style.opacity='1';entry.target.style.transform='translateY(0)';observer.unobserve(entry.target);}});},observerOptions);document.querySelectorAll('.benefit-card,.module-card,.pricing-card').forEach(el=>{el.style.opacity='0';el.style.transform='translateY(30px)';el.style.transition='opacity 0.6s ease, transform 0.6s ease';observer.observe(el);});const contactForm=document.getElementById('contactForm');const formMessage=document.getElementById('formMessage');if(contactForm){contactForm.addEventListener('submit',async(e)=>{e.preventDefault();const submitBtn=contactForm.querySelector('button[type="submit"]');const originalBtnText=submitBtn.innerHTML;submitBtn.disabled=true;submitBtn.innerHTML='Enviando...';const formData={name:document.getElementById('name').value,email:document.getElementById('email').value,company:document.getElementById('company').value,employees:document.getElementById('employees').value,message:document.getElementById('message').value};try{const response=await fetch('https://landinghub.codeflakes.io/send_contact_mailer',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({client_id:7,briefing_id:6,token:'VWmxY2_ILHzSxpzUysq4cG0kBhbjJRUAUN4hvxKNGtU',...formData})});if(response.ok){formMessage.textContent='¡Gracias! Nos pondremos en contacto pronto.';formMessage.className='form-message success';formMessage.style.display='block';contactForm.reset();}else{throw new Error('Error en el envío');}}catch(error){formMessage.textContent='Hubo un error. Por favor intenta de nuevo.';formMessage.className='form-message error';formMessage.style.display='block';}finally{submitBtn.disabled=false;submitBtn.innerHTML=originalBtnText;setTimeout(()=>{formMessage.style.display='none';},5000);}});}document.querySelectorAll('a[href^="#"]').forEach(anchor=>{anchor.addEventListener('click',function(e){e.preventDefault();const target=document.querySelector(this.getAttribute('href'));if(target){const offsetTop=target.offsetTop-80;window.scrollTo({top:offsetTop,behavior:'smooth'});}});});});