| |
| document.addEventListener('DOMContentLoaded', function() { |
| |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
| anchor.addEventListener('click', function (e) { |
| e.preventDefault(); |
| const target = document.querySelector(this.getAttribute('href')); |
| if (target) { |
| target.scrollIntoView({ |
| behavior: 'smooth', |
| block: 'start' |
| }); |
| } |
| }); |
| }); |
|
|
| |
| const observerOptions = { |
| threshold: 0.1, |
| rootMargin: '0px 0px -50px 0px' |
| }; |
|
|
| const observer = new IntersectionObserver(function(entries) { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.classList.add('animate-fade-in'); |
| } |
| }); |
| }, observerOptions); |
|
|
| |
| document.querySelectorAll('section').forEach(section => { |
| observer.observe(section); |
| }); |
|
|
| |
| window.toggleMobileMenu = function() { |
| const mobileMenu = document.getElementById('mobileMenu'); |
| if (mobileMenu) { |
| mobileMenu.classList.toggle('hidden'); |
| mobileMenu.classList.toggle('flex'); |
| } |
| }; |
|
|
| |
| window.handleCookieConsent = function(action) { |
| const consentBanner = document.getElementById('cookieConsent'); |
| if (consentBanner) { |
| consentBanner.classList.add('hidden'); |
| } |
| |
| if (action === 'accept') { |
| localStorage.setItem('cookieConsent', 'accepted'); |
| } else if (action === 'reject') { |
| localStorage.setItem('cookieConsent', 'rejected'); |
| } |
| }; |
|
|
| |
| if (localStorage.getItem('cookieConsent')) { |
| const consentBanner = document.getElementById('cookieConsent'); |
| if (consentBanner) { |
| consentBanner.classList.add('hidden'); |
| } |
| } |
| }); |
|
|
| |
| async function apiCall(endpoint, options = {}) { |
| try { |
| const response = await fetch(endpoint, { |
| headers: { |
| 'Content-Type': 'application/json', |
| ...options.headers |
| }, |
| ...options |
| }); |
| |
| if (!response.ok) { |
| throw new Error(`API call failed: ${response.statusText}`); |
| } |
| |
| return await response.json(); |
| } catch (error) { |
| console.error('API call error:', error); |
| return null; |
| } |
| } |