/** * Main Script - Profice Website * All API calls go through server-side PHP * * @version 2.1.0 */ document.addEventListener("DOMContentLoaded", function() { // ========================================== // SOUND VISUALIZATION ANIMATION // ========================================== function initSoundVisualization() { const soundVisualization = document.getElementById('soundVisualization'); const demoPhoneBtn = document.getElementById('demoPhoneBtn'); if (soundVisualization && demoPhoneBtn) { // Start animation on hover demoPhoneBtn.addEventListener('mouseenter', () => { soundVisualization.classList.add('active'); }); demoPhoneBtn.addEventListener('mouseleave', () => { soundVisualization.classList.remove('active'); }); // Toggle animation on click/touch demoPhoneBtn.addEventListener('click', (e) => { e.preventDefault(); soundVisualization.classList.toggle('active'); // Simulate call action after a brief delay setTimeout(() => { window.location.href = demoPhoneBtn.href; }, 500); }); // Touch support for mobile demoPhoneBtn.addEventListener('touchstart', (e) => { e.preventDefault(); soundVisualization.classList.add('active'); }); demoPhoneBtn.addEventListener('touchend', () => { setTimeout(() => { soundVisualization.classList.remove('active'); }, 1000); }); } } initSoundVisualization(); // Use absolute path from site root const API_ENDPOINT = '/scripts/add/send.php'; const isLocalFile = window.location.protocol === 'file:'; // ========================================== // 1. SMOOTH SCROLLING // ========================================== function initSmoothScrolling() { document.querySelectorAll('a[href^="#"]').forEach(link => { link.addEventListener('click', function(e) { const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { e.preventDefault(); const header = document.querySelector('.top-banner'); const headerHeight = header ? header.offsetHeight : 90; window.scrollTo({ top: targetElement.offsetTop - headerHeight - 20, behavior: 'smooth' }); history.pushState(null, null, targetId); } }); }); } initSmoothScrolling(); // ========================================== // 1.5. BUTTON NAVIGATION TO DEMO SECTION // ========================================== function initButtonNavigation() { const kiPhoneBtn = document.getElementById('kiPhoneBtn'); const chatBtn = document.getElementById('chatBtn'); const demoSection = document.getElementById('demo-section'); if (demoSection) { const scrollToDemo = () => { const header = document.querySelector('.top-banner'); const headerHeight = header ? header.offsetHeight : 90; window.scrollTo({ top: demoSection.offsetTop - headerHeight - 20, behavior: 'smooth' }); }; if (kiPhoneBtn) { kiPhoneBtn.addEventListener('click', scrollToDemo); } if (chatBtn) { chatBtn.addEventListener('click', scrollToDemo); } } } initButtonNavigation(); // ========================================== // 1.6. PHONE CALL FUNCTIONALITY // ========================================== function initPhoneCallFunctionality() { const demoPhoneBtn = document.getElementById('demoPhoneBtn'); // Phone button functionality commented out for now // Will be implemented later /* if (demoPhoneBtn) { demoPhoneBtn.addEventListener('click', function(e) { // Check if mobile device const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); if (!isMobile) { e.preventDefault(); // Show desktop fallback message const phoneNumber = '+493021927825'; const message = `Bald verfügbar`; // Create a custom modal instead of alert const modal = document.createElement('div'); modal.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 10000; font-family: system-ui, -apple-system, sans-serif; `; modal.innerHTML = `
${message}