/** * Live Pulse article cards with LPS-1 mint buttons — pulse.html + index fallback grid. */ (function () { 'use strict'; var root = document.getElementById('pulse-live-feed'); if (!root) return; function esc(s) { return String(s || '') .replace(/&/g, '&') .replace(//g, '>'); } function renderCard(art) { var card = document.createElement('article'); card.className = 'pulse-live-card'; card.setAttribute('data-article-id', art.id || ''); var meta = (art.desk || 'desk') + ' · R' + (art.ring || '?') + ' · Signal ' + (art.signal != null ? art.signal : '—') + (art.lps1_registration_id ? ' · ' + art.lps1_registration_id : ''); card.innerHTML = '
' + esc((art.summary || '').slice(0, 280)) + (art.summary && art.summary.length > 280 ? '…' : '') + '
' + ''; var host = card.querySelector('.lps-mint-host'); if (window.GMIIELpsMint && art.id) { window.GMIIELpsMint.renderButton(host, { briefId: art.id, title: art.title, lps1Id: art.lps1_registration_id, }); } return card; } fetch('/api/articles?limit=12', { cache: 'no-store', signal: AbortSignal.timeout(15000) }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (data) { var articles = (data && data.articles) || []; if (!articles.length) { root.innerHTML = ''; return; } var hd = document.createElement('div'); hd.className = 'pulse-live-feed-hd'; hd.textContent = 'Live edition · ' + articles.length + ' briefs · mint + yield on every card'; root.appendChild(hd); articles.forEach(function (art) { root.appendChild(renderCard(art)); }); }) .catch(function () { root.innerHTML = ''; }); })();