|
|
|
|
|
|
|
|
function initCarousel() { |
|
|
const carousel = document.querySelector('.carousel-slides'); |
|
|
const prevBtn = document.querySelector('.carousel-prev'); |
|
|
const nextBtn = document.querySelector('.carousel-next'); |
|
|
const dots = document.querySelectorAll('.dot'); |
|
|
const descriptions = document.querySelectorAll('.feature-description'); |
|
|
let currentIndex = 0; |
|
|
const totalSlides = document.querySelectorAll('.carousel-slide').length; |
|
|
|
|
|
function updateCarousel() { |
|
|
carousel.style.transform = `translateX(-${currentIndex * 100}%)`; |
|
|
|
|
|
|
|
|
dots.forEach((dot, index) => { |
|
|
dot.classList.toggle('active', index === currentIndex); |
|
|
}); |
|
|
|
|
|
|
|
|
descriptions.forEach((desc, index) => { |
|
|
desc.classList.toggle('hidden', index !== currentIndex); |
|
|
desc.classList.toggle('active', index === currentIndex); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
prevBtn.addEventListener('click', () => { |
|
|
currentIndex = (currentIndex - 1 + totalSlides) % totalSlides; |
|
|
updateCarousel(); |
|
|
}); |
|
|
|
|
|
nextBtn.addEventListener('click', () => { |
|
|
currentIndex = (currentIndex + 1) % totalSlides; |
|
|
updateCarousel(); |
|
|
}); |
|
|
|
|
|
|
|
|
dots.forEach(dot => { |
|
|
dot.addEventListener('click', () => { |
|
|
currentIndex = parseInt(dot.dataset.index); |
|
|
updateCarousel(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
setInterval(() => { |
|
|
currentIndex = (currentIndex + 1) % totalSlides; |
|
|
updateCarousel(); |
|
|
}, 5000); |
|
|
} |
|
|
|
|
|
|
|
|
if (document.querySelector('.carousel-container')) { |
|
|
initCarousel(); |
|
|
} |
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
const demoForm = document.querySelector('form'); |
|
|
if (demoForm) { |
|
|
demoForm.addEventListener('submit', function(e) { |
|
|
e.preventDefault(); |
|
|
|
|
|
const name = document.getElementById('name').value; |
|
|
const email = document.getElementById('email').value; |
|
|
const phone = document.getElementById('phone').value; |
|
|
|
|
|
|
|
|
const webhookUrl = 'https://hook.eu2.make.com/a16fg7o2i2nyh5s220ywhplaxnhxjx1x'; |
|
|
|
|
|
|
|
|
fetch(webhookUrl, { |
|
|
method: 'POST', |
|
|
headers: { |
|
|
'Content-Type': 'application/json', |
|
|
'x-make-apikey': '-iqndT.Ox2zFn?wa' |
|
|
}, |
|
|
body: JSON.stringify({ name, email, phone }) |
|
|
}) |
|
|
.then(response => { |
|
|
if (response.ok) { |
|
|
alert(`¡Gracias ${name}! Hemos recibido tu solicitud de demo. Nos pondremos en contacto contigo pronto.`); |
|
|
demoForm.reset(); |
|
|
} else { |
|
|
alert('Hubo un problema al enviar tu solicitud. Inténtalo de nuevo.'); |
|
|
} |
|
|
}) |
|
|
.catch(error => { |
|
|
console.error('Error al enviar al webhook:', error); |
|
|
alert('Error de conexión. Inténtalo más tarde.'); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
const hoursRange = document.getElementById('hours-range'); |
|
|
const hoursValue = document.getElementById('hours-value'); |
|
|
const purchasesRange = document.getElementById('purchases-range'); |
|
|
const purchasesValue = document.getElementById('purchases-value'); |
|
|
const errorsRange = document.getElementById('errors-range'); |
|
|
const errorsValue = document.getElementById('errors-value'); |
|
|
const lossValue = document.getElementById('loss-value'); |
|
|
|
|
|
if (hoursRange) { |
|
|
hoursRange.addEventListener('input', updateCalculator); |
|
|
purchasesRange.addEventListener('input', updateCalculator); |
|
|
errorsRange.addEventListener('input', updateCalculator); |
|
|
updateCalculator(); |
|
|
} |
|
|
|
|
|
function updateCalculator() { |
|
|
|
|
|
hoursValue.textContent = hoursRange.value + 'h'; |
|
|
purchasesValue.textContent = new Intl.NumberFormat('es-ES').format(purchasesRange.value) + '€'; |
|
|
errorsValue.textContent = errorsRange.value; |
|
|
|
|
|
|
|
|
const hoursCost = hoursRange.value * 25 * 4; |
|
|
const purchasesCost = purchasesRange.value * 0.03 * 0.5; |
|
|
const errorsCost = errorsRange.value * 150; |
|
|
|
|
|
const totalLoss = Math.round(hoursCost + purchasesCost + errorsCost); |
|
|
lossValue.textContent = new Intl.NumberFormat('es-ES').format(totalLoss); |
|
|
} |
|
|
|
|
|
|
|
|
document.querySelectorAll('.feature-card').forEach(card => { |
|
|
card.addEventListener('click', function() { |
|
|
this.querySelector('.feature-list').classList.toggle('hidden'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
document.querySelectorAll('[href="#demo"]').forEach(link => { |
|
|
link.addEventListener('click', function() { |
|
|
const plan = this.closest('.pricing-card')?.querySelector('h3')?.textContent || 'Custom'; |
|
|
console.log('Selected plan:', plan); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
const animateOnScroll = () => { |
|
|
const elements = document.querySelectorAll('.animate-on-scroll'); |
|
|
elements.forEach(el => { |
|
|
const elementPosition = el.getBoundingClientRect().top; |
|
|
const screenPosition = window.innerHeight / 1.3; |
|
|
|
|
|
if (elementPosition < screenPosition) { |
|
|
el.classList.add('animate-fade-in'); |
|
|
} |
|
|
}); |
|
|
}; |
|
|
|
|
|
|
|
|
document.querySelectorAll('.faq-item').forEach(item => { |
|
|
const button = item.querySelector('button'); |
|
|
const content = item.querySelector('.faq-content'); |
|
|
const icon = item.querySelector('.faq-icon'); |
|
|
|
|
|
button.addEventListener('click', () => { |
|
|
const isOpen = content.classList.contains('hidden'); |
|
|
|
|
|
|
|
|
document.querySelectorAll('.faq-content').forEach(el => { |
|
|
if (el !== content) el.classList.add('hidden'); |
|
|
}); |
|
|
document.querySelectorAll('.faq-icon').forEach(el => { |
|
|
if (el !== icon) { |
|
|
el.setAttribute('data-feather', 'chevron-down'); |
|
|
|
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
if (isOpen) { |
|
|
content.classList.remove('hidden'); |
|
|
icon.setAttribute('data-feather', 'chevron-up'); |
|
|
} else { |
|
|
content.classList.add('hidden'); |
|
|
icon.setAttribute('data-feather', 'chevron-down'); |
|
|
} |
|
|
feather.replace(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const cookieConsent = document.getElementById('cookie-consent'); |
|
|
const cookieAccept = document.getElementById('cookie-accept'); |
|
|
|
|
|
if (!localStorage.getItem('cookieConsent')) { |
|
|
cookieConsent.classList.remove('hidden'); |
|
|
} |
|
|
|
|
|
cookieAccept.addEventListener('click', () => { |
|
|
localStorage.setItem('cookieConsent', 'true'); |
|
|
cookieConsent.classList.add('hidden'); |
|
|
}); |
|
|
|
|
|
|
|
|
document.addEventListener('mouseout', (e) => { |
|
|
if (e.relatedTarget === null && e.clientY < 50) { |
|
|
|
|
|
console.log('Exit intent detected - would show popup here'); |
|
|
} |
|
|
}); |
|
|
|
|
|
window.addEventListener('scroll', animateOnScroll); |
|
|
animateOnScroll(); |
|
|
|
|
|
|
|
|
console.log('Chatbot would be initialized here'); |
|
|
|
|
|
|
|
|
console.log('Retargeting pixel would be loaded here'); |
|
|
}); |
|
|
|