/** * pricing.js * * Powers the Pricing page. * * Features: * - Loads the three plan definitions from `./data/pricing.json` * asynchronously via fetch(). * - Dynamically renders one card per plan, highlighting the * "featured" plan with a coloured border and a "Most popular" * badge. * - Shows a graceful error message if the JSON file cannot be * loaded. * * Keeping plan data in a separate JSON file means marketing copy and * prices can be updated without touching the page markup. */ const pricingContainer = document.getElementById('pricingContainer'); async function loadPricing() { try { const response = await fetch('./data/pricing.json'); if (!response.ok) { throw new Error(`Failed to load pricing: ${response.status}`); } const data = await response.json(); renderPlans(data.plans); } catch (error) { console.error('Error:', error); pricingContainer.innerHTML = `

Unable to load pricing. Please try again later.

`; } } function renderPlans(plans) { pricingContainer.innerHTML = ''; plans.forEach(plan => { const col = document.createElement('div'); col.className = 'col-12 col-md-4 mb-4'; const featuresHtml = plan.features .map(f => `
  • ${f}
  • `) .join(''); const highlight = plan.featured ? 'pinkBorder' : ''; const badge = plan.featured ? 'Most popular' : ''; col.innerHTML = `
    ${badge}

    ${plan.name}

    ${plan.tagline}

    $${plan.price} ${plan.period}
    ${plan.cta}
    `; pricingContainer.appendChild(col); }); } window.addEventListener('DOMContentLoaded', loadPricing);