From 8fe0306f1a97623fe53cf828a49d3f441b397f9c Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 11 Sep 2024 22:54:09 -0700 Subject: [PATCH] Highlight repeated or circular addresses --- index.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/index.html b/index.html index cf3a60f..88cb93a 100644 --- a/index.html +++ b/index.html @@ -138,12 +138,17 @@ border-radius: 8px; background: hsl(216deg 50% 60%); } + + &::highlight(yellow) { + background-color: yellow; + } } svg { inline-size: 20px; vertical-align: middle; margin-inline-start: 4px; + cursor: pointer; } @@ -234,6 +239,21 @@ } } + function highlightAddress(tree, address) { + const highlight = new Highlight(); + for (const e of [...tree.querySelectorAll('*')]) { + if (e.tagName !== 'LI' || e.textContent.substring(0, 42) !== address) { + continue; + } + const textNode = e.childNodes[0]; + const range = new Range(); + range.setStart(textNode, 0); + range.setEnd(textNode, 42); + highlight.add(range); + } + CSS.highlights.set('yellow', highlight); + } + form.addEventListener('submit', async e => { e.preventDefault(); @@ -246,6 +266,10 @@ tree.innerHTML = ''; allAddresses.length = 0; await insertTreeNode(tree, safe.replace(/^.+:/, '').toLowerCase(), rpc); + document.querySelectorAll('svg').forEach(svg => { + svg.addEventListener('mouseover', e => highlightAddress(tree, svg.closest('li').textContent.substring(0, 42))); + svg.addEventListener('mouseout', e => CSS.highlights.clear()); + }); e.target.removeAttribute('data-loading'); }); -- 2.47.3