document.addEventListener('DOMContentLoaded', ()=>{ renderDirectory(); renderKarma(); renderResources(); bindCheckout(); }); // Listing JSON generator function generateListingJSON(){ const name = document.getElementById('new_name').value.trim(); const category = document.getElementById('new_category').value.trim(); const city = document.getElementById('new_city').value.trim(); const url = document.getElementById('new_url').value.trim(); const tags = document.getElementById('new_tags').value.split(',').map(s=>s.trim()).filter(Boolean); const desc = document.getElementById('new_desc').value.trim(); const id = name.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/(^-|-$)/g,''); -- async function bindCheckout(){ try{ const map = await getJSON('./data/checkout.json'); document.querySelectorAll('[data-checkout]').forEach(btn=>{ btn.addEventListener('click', ()=>{ const key = btn.getAttribute('data-checkout'); const prod = map.products && map.products[key]; if(prod && prod.checkout_url && !prod.checkout_url.includes('REPLACE_ME')){ window.location.href = prod.checkout_url; }else{ alert('Checkout not configured yet. Replace the checkout_url in /data/checkout.json for \"'+key+'\".');