Skyline Ledger Review

Your basket

A considered stack of reading.

Review your Horizon Lens selections before checkout.

Current total

$0.00

Continue browsing the catalog
`; const footerHTML = ` `; document.getElementById('site-header').innerHTML = headerHTML; document.getElementById('site-footer').innerHTML = footerHTML; } // Theme toggle, mobile menu, account modal, cookie banner function initInteractiveElements() { // Theme toggle const themeBtn = document.querySelector('[data-theme-toggle]'); if (themeBtn) { themeBtn.addEventListener('click', () => { const body = document.body; if (body.classList.contains('bg-[#F7F1E8]')) { body.classList.remove('bg-[#F7F1E8]', 'text-[#2F332E]'); body.classList.add('bg-[#2F332E]', 'text-[#F7F1E8]'); } else { body.classList.add('bg-[#F7F1E8]', 'text-[#2F332E]'); body.classList.remove('bg-[#2F332E]', 'text-[#F7F1E8]'); } }); } // Mobile menu const menuToggle = document.querySelector('[data-menu-toggle]'); const mobileMenu = document.querySelector('[data-mobile-menu]'); if (menuToggle && mobileMenu) { menuToggle.addEventListener('click', () => { mobileMenu.classList.toggle('hidden'); }); } // Account modal const accountOpen = document.querySelector('[data-account-open]'); const accountModal = document.getElementById('account-modal'); const accountClose = document.querySelector('[data-modal-close]'); const accountForm = document.getElementById('account-form'); if (accountOpen && accountModal) { accountOpen.addEventListener('click', () => accountModal.classList.remove('hidden')); if (accountClose) accountClose.addEventListener('click', () => accountModal.classList.add('hidden')); if (accountForm) { accountForm.addEventListener('submit', (e) => { e.preventDefault(); accountModal.classList.add('hidden'); alert('Welcome back to Skyline Ledger Review. You are now signed in.'); }); } } // Cookie banner const cookieBanner = document.getElementById('cookie-banner'); const cookieAccept = document.querySelector('[data-cookie-accept]'); if (cookieBanner && cookieAccept) { if (!localStorage.getItem('slr-cookie-consent')) { setTimeout(() => cookieBanner.style.display = 'block', 1200); } cookieAccept.addEventListener('click', () => { localStorage.setItem('slr-cookie-consent', 'true'); cookieBanner.style.display = 'none'; }); } } // Cart functionality let cart = {}; let catalogData = {}; async function loadCatalog() { try { const response = await fetch('./catalog.json'); if (!response.ok) throw new Error('Catalog not found'); catalogData = await response.json(); } catch (e) { // Fallback data if catalog.json not available catalogData = { "horizon-signal-01": { id: "horizon-signal-01", title: "Signal: Market Outlook 2025", price: 2400, horizon: "Signal" }, "horizon-context-02": { id: "horizon-context-02", title: "Context: Regulatory Shifts", price: 1850, horizon: "Context" }, "horizon-practice-03": { id: "horizon-practice-03", title: "Practice: Portfolio Frameworks", price: 3200, horizon: "Practice" }, "horizon-outlook-04": { id: "horizon-outlook-04", title: "Outlook: Emerging Markets", price: 2100, horizon: "Outlook" } }; } } function loadCart() { const saved = localStorage.getItem('slr-cart'); cart = saved ? JSON.parse(saved) : {}; } function saveCart() { localStorage.setItem('slr-cart', JSON.stringify(cart)); } function calculateTotal() { let total = 0; Object.keys(cart).forEach(id => { const item = catalogData[id]; if (item) { total += item.price * cart[id]; } }); return (total / 100).toFixed(2); } function renderCart() { const container = document.getElementById('cart-items'); container.innerHTML = ''; const keys = Object.keys(cart); if (keys.length === 0) { container.innerHTML = `

Your cart is empty. Explore our Horizon Lens publications.

Browse catalog
`; document.getElementById('cart-total').textContent = '$0.00'; return; } keys.forEach(id => { const item = catalogData[id]; if (!item) return; const qty = cart[id]; const row = document.createElement('div'); row.className = `dd23l flex flex-col md:flex-row md:items-center justify-between rounded-3xl border border-[#DCCFC0] bg-white p-6 xk9h7`; row.innerHTML = `
${item.horizon} ${item.title}

$${ (item.price / 100).toFixed(2) } per unit

${qty}
$${(item.price * qty / 100).toFixed(2)}
`; container.appendChild(row); }); document.getElementById('cart-total').textContent = `$${calculateTotal()}`; // Attach listeners container.querySelectorAll('[data-increase]').forEach(btn => { btn.addEventListener('click', () => { const id = btn.getAttribute('data-increase'); cart[id] = (cart[id] || 0) + 1; saveCart(); renderCart(); }); }); container.querySelectorAll('[data-decrease]').forEach(btn => { btn.addEventListener('click', () => { const id = btn.getAttribute('data-decrease'); if (cart[id] > 1) { cart[id]--; saveCart(); renderCart(); } }); }); container.querySelectorAll('[data-remove]').forEach(btn => { btn.addEventListener('click', () => { const id = btn.getAttribute('data-remove'); delete cart[id]; saveCart(); renderCart(); }); }); } function initCheckout() { const checkoutBtn = document.getElementById('checkout'); const modal = document.getElementById('checkout-modal'); const closeBtn = document.getElementById('close-checkout-modal'); const confirmBtn = document.getElementById('confirm-checkout'); checkoutBtn.addEventListener('click', () => { if (Object.keys(cart).length > 0) { modal.classList.remove('hidden'); modal.classList.add('flex'); } }); closeBtn.addEventListener('click', () => { modal.classList.remove('flex'); modal.classList.add('hidden'); }); confirmBtn.addEventListener('click', () => { modal.classList.remove('flex'); modal.classList.add('hidden'); localStorage.removeItem('slr-cart'); window.location.href = './index.html'; }); } async function initCartPage() { initTailwind(); injectHeaderFooter(); initInteractiveElements(); await loadCatalog(); loadCart(); renderCart(); initCheckout(); } window.onload = initCartPage;