Aurelivo.

Your learning basket

Make space for a useful next step.

Review your selections and prepare for enrollment.

Estimated total

$0

Review enrollment
Continue browsing the catalog
`; document.querySelector('header').innerHTML = headerHTML; document.querySelector('footer').innerHTML = footerHTML; } // Theme toggle function initTheme() { const toggle = document.getElementById('themeToggle'); if (!toggle) return; function updateButton(isDark) { toggle.textContent = isDark ? 'Light mode' : 'Dark mode'; } const saved = localStorage.getItem('aurelivo-theme'); if (saved === 'light') { document.body.classList.add('bg-slate-100', 'text-slate-950'); document.body.classList.remove('bg-slate-950', 'text-slate-100'); updateButton(false); } toggle.addEventListener('click', () => { const isLight = document.body.classList.contains('bg-slate-100'); if (isLight) { document.body.classList.remove('bg-slate-100', 'text-slate-950'); document.body.classList.add('bg-slate-950', 'text-slate-100'); localStorage.setItem('aurelivo-theme', 'dark'); updateButton(true); } else { document.body.classList.add('bg-slate-100', 'text-slate-950'); document.body.classList.remove('bg-slate-950', 'text-slate-100'); localStorage.setItem('aurelivo-theme', 'light'); updateButton(false); } }); } // Login / Register modals function initModals() { const loginOpen = document.getElementById('loginOpen'); const registerOpen = document.getElementById('registerOpen'); const loginModal = document.getElementById('loginModal'); if (loginOpen) loginOpen.addEventListener('click', (e) => { e.preventDefault(); loginModal.classList.remove('hidden'); }); if (registerOpen) registerOpen.addEventListener('click', (e) => { e.preventDefault(); loginModal.classList.remove('hidden'); loginModal.querySelector('h3').textContent = 'Create account'; }); window.closeLoginModal = function() { loginModal.classList.add('hidden'); }; } function handleLogin(e) { e.preventDefault(); const modal = document.getElementById('loginModal'); modal.classList.add('hidden'); alert('Sign-in successful (demo). Welcome back to Aurelivo.'); } // Cart functionality function initCart() { const cartKey = 'aurelivo-cart'; const params = new URLSearchParams(location.search); let cart = JSON.parse(localStorage.getItem(cartKey) || '[]'); // Handle add via query param if (params.get('add')) { const id = params.get('add'); const existing = cart.find(x => x.id === id); if (existing) existing.quantity++; else cart.push({ id: id, quantity: 1 }); localStorage.setItem(cartKey, JSON.stringify(cart)); // Remove add param from URL window.history.replaceState({}, '', './cart.html'); } const cartList = document.getElementById('cartList'); const totalEl = document.getElementById('total'); const checkoutBtn = document.getElementById('checkout'); const checkoutModal = document.getElementById('checkoutModal'); fetch('./catalog.json') .then(r => r.json()) .then(items => { let totalValue = 0; let html = ''; cart.forEach(row => { const item = items.find(i => i.id === row.id); if (!item) return; totalValue += item.price * row.quantity; html += `

${item.title}

$${item.price} per enrollment

`; }); cartList.innerHTML = html || `

Your cart is currently empty.

`; totalEl.textContent = '$' + totalValue; // Quantity change handlers document.querySelectorAll('input[data-id]').forEach(input => { input.onchange = () => { let value = Math.max(1, parseInt(input.value) || 1); let updatedCart = JSON.parse(localStorage.getItem(cartKey) || '[]'); const item = updatedCart.find(x => x.id === input.dataset.id); if (item) item.quantity = value; localStorage.setItem(cartKey, JSON.stringify(updatedCart)); location.reload(); }; }); // Remove handlers document.querySelectorAll('button[data-remove]').forEach(btn => { btn.onclick = () => { let updatedCart = JSON.parse(localStorage.getItem(cartKey) || '[]'); updatedCart = updatedCart.filter(x => x.id !== btn.dataset.remove); localStorage.setItem(cartKey, JSON.stringify(updatedCart)); location.reload(); }; }); // Checkout parameter handling if (params.get('checkout') === 'true') { checkoutModal.classList.remove('hidden'); } }); window.closeCheckoutModal = function() { checkoutModal.classList.add('hidden'); window.history.replaceState({}, '', './cart.html'); }; } function initCookieBanner() { const banner = document.getElementById('cookieBanner'); const accept = document.getElementById('cookieAccept'); if (!banner || !accept) return; if (!localStorage.getItem('aurelivo-cookie-consent')) { setTimeout(() => banner.classList.remove('hidden'), 2200); } accept.onclick = () => { localStorage.setItem('aurelivo-cookie-consent', 'true'); banner.classList.add('hidden'); }; } // Boot everything function bootstrap() { initTailwind(); injectHeaderFooter(); initTheme(); initModals(); initCart(); initCookieBanner(); } window.onload = bootstrap;