const API_BASE = 'https://d5dkd0fa5q03ce96ld3p.tmjd4m4j.apigw.yandexcloud.net'; async function submitConnectionRequest(event) { event.preventDefault(); const form = event.target; const status = document.getElementById('formStatus'); const submitButton = form.querySelector('button[type="submit"]'); const name = document.getElementById('leadName').value.trim(); const phone = document.getElementById('leadPhone').value.trim(); const avitoUrl = document.getElementById('leadAvitoUrl').value.trim(); const comment = document.getElementById('leadComment').value.trim(); if (!name || !phone) { status.textContent = 'Укажите имя и телефон.'; return false; } try { submitButton.disabled = true; status.textContent = 'Отправляем заявку...'; const url = new URL(API_BASE); url.searchParams.set('action', 'connection-request'); const response = await fetch(url.toString(), { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, phone, avitoUrl, comment, pageUrl: window.location.href }) }); const data = await response.json().catch(function() { return null; }); if (!response.ok || !data || !data.ok) { throw new Error((data && data.error) || 'Не удалось отправить заявку.'); } status.textContent = 'Заявка отправлена. Мы свяжемся с вами в ближайшее время.'; form.reset(); } catch (error) { status.textContent = error.message || 'Не удалось отправить заявку.'; } finally { submitButton.disabled = false; } return false; } window.submitConnectionRequest = submitConnectionRequest; const observer = new IntersectionObserver((entries)=>{ entries.forEach(entry=>{ if(entry.isIntersecting){entry.target.classList.add('show')} }) },{threshold:.12}); document.querySelectorAll('.compare-card,.demo-card,.feature,.steps div,.launch-list p,.need-card,.price-card,.lead,.faq details').forEach(el=>{ el.classList.add('reveal'); observer.observe(el); }); const style = document.createElement('style'); style.textContent = `.reveal{opacity:0;transform:translateY(18px);transition:.55s ease}.reveal.show{opacity:1;transform:none}`; document.head.appendChild(style);