File size: 7,505 Bytes
4b8de9c c38de01 ac2d558 c38de01 ac2d558 f6ef2db ac2d558 5be3c88 92602d0 ac2d558 c38de01 c83dd1f 067f21a 70c70a9 067f21a 70c70a9 a6afdbe 70c70a9 25baa13 70c70a9 c38de01 70c70a9 a6afdbe 70c70a9 14073d9 70c70a9 |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
// Carousel functionality
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}%)`;
// Update dots
dots.forEach((dot, index) => {
dot.classList.toggle('active', index === currentIndex);
});
// Update descriptions
descriptions.forEach((desc, index) => {
desc.classList.toggle('hidden', index !== currentIndex);
desc.classList.toggle('active', index === currentIndex);
});
}
// Navigation
prevBtn.addEventListener('click', () => {
currentIndex = (currentIndex - 1 + totalSlides) % totalSlides;
updateCarousel();
});
nextBtn.addEventListener('click', () => {
currentIndex = (currentIndex + 1) % totalSlides;
updateCarousel();
});
// Dot navigation
dots.forEach(dot => {
dot.addEventListener('click', () => {
currentIndex = parseInt(dot.dataset.index);
updateCarousel();
});
});
// Auto-rotate (optional)
setInterval(() => {
currentIndex = (currentIndex + 1) % totalSlides;
updateCarousel();
}, 5000);
}
// Initialize carousel if exists
if (document.querySelector('.carousel-container')) {
initCarousel();
}
// Form handling
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;
// URL del webhook de Make
const webhookUrl = 'https://hook.eu2.make.com/a16fg7o2i2nyh5s220ywhplaxnhxjx1x';
// Enviar datos al webhook
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.');
});
});
}
// Calculator functionality
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(); // Initialize
}
function updateCalculator() {
// Update displayed values
hoursValue.textContent = hoursRange.value + 'h';
purchasesValue.textContent = new Intl.NumberFormat('es-ES').format(purchasesRange.value) + '€';
errorsValue.textContent = errorsRange.value;
// Calculate total loss
const hoursCost = hoursRange.value * 25 * 4; // 25€/h * 4 weeks
const purchasesCost = purchasesRange.value * 0.03 * 0.5; // 3% savings on 50% of purchases
const errorsCost = errorsRange.value * 150; // Avg 150€ per error
const totalLoss = Math.round(hoursCost + purchasesCost + errorsCost);
lossValue.textContent = new Intl.NumberFormat('es-ES').format(totalLoss);
}
// Feature accordions
document.querySelectorAll('.feature-card').forEach(card => {
card.addEventListener('click', function() {
this.querySelector('.feature-list').classList.toggle('hidden');
});
});
// Plan selection tracking
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);
// Here you would typically send this to your analytics
});
});
// Animate elements on scroll
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');
}
});
};
// FAQ Accordion
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');
// Close all other items
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');
// Remove feather.replace() since we're using SVG icons directly now
}
});
// Toggle current item
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();
});
});
// Cookie Consent
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');
});
// Exit Intent Popup
document.addEventListener('mouseout', (e) => {
if (e.relatedTarget === null && e.clientY < 50) {
// Show exit intent popup
console.log('Exit intent detected - would show popup here');
}
});
window.addEventListener('scroll', animateOnScroll);
animateOnScroll(); // Run once on load
// Initialize chatbot (placeholder)
console.log('Chatbot would be initialized here');
// Retargeting pixel (placeholder)
console.log('Retargeting pixel would be loaded here');
});
|