From: Ardis Lu Date: Thu, 12 Sep 2024 05:54:09 +0000 (-0700) Subject: Highlight repeated or circular addresses X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=8fe0306f1a97623fe53cf828a49d3f441b397f9c;p=safe-owners Highlight repeated or circular addresses --- 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'); });