From 8fd3f81e72f75c01e8ce00d7ff54fc521e35c1d7 Mon Sep 17 00:00:00 2001 From: you Date: Sat, 21 Mar 2026 03:38:42 +0000 Subject: [PATCH] feat: add paths-through section to live map node detail panel --- public/index.html | 2 +- public/live.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 5023ac7f..11319aa1 100644 --- a/public/index.html +++ b/public/index.html @@ -88,7 +88,7 @@ - + diff --git a/public/live.js b/public/live.js index d7ba7f6f..32293aa4 100644 --- a/public/live.js +++ b/public/live.js @@ -1098,12 +1098,48 @@ ''; } + html += `
Loading paths…
`; + html += `
Full Detail → 📊 Analytics
`; content.innerHTML = html; + + // Fetch paths asynchronously + api('/nodes/' + encodeURIComponent(n.public_key) + '/paths', { ttl: 300 }).then(pathData => { + const pathEl = document.getElementById('liveNodePaths'); + if (!pathEl) return; + if (!pathData || !pathData.paths || !pathData.paths.length) { + pathEl.innerHTML = ''; + return; + } + const COLLAPSE = 5; + function renderPathList(paths) { + return paths.map(p => { + const chain = p.hops.map(h => { + const isThis = h.pubkey === n.public_key || (h.prefix && n.public_key.toLowerCase().startsWith(h.prefix.toLowerCase())); + const name = escapeHtml(h.name || h.prefix); + if (isThis) return `${name}`; + return h.pubkey ? `${name}` : name; + }).join(' → '); + return `
${chain} (${p.count}×)
`; + }).join(''); + } + pathEl.innerHTML = `

Paths Through (${pathData.totalPaths})

` + + `
` + + renderPathList(pathData.paths.slice(0, COLLAPSE)) + + (pathData.paths.length > COLLAPSE ? `` : '') + + '
'; + const moreBtn = document.getElementById('showMorePaths'); + if (moreBtn) moreBtn.addEventListener('click', () => { + document.getElementById('livePathsList').innerHTML = renderPathList(pathData.paths); + }); + }).catch(() => { + const pathEl = document.getElementById('liveNodePaths'); + if (pathEl) pathEl.innerHTML = ''; + }); } catch (e) { content.innerHTML = `
Error: ${e.message}
`; }