]> git.ardis.lu - safe-owners/commitdiff
Highlight repeated or circular addresses
authorArdis Lu <ardisglu@gmail.com>
Thu, 12 Sep 2024 05:54:09 +0000 (22:54 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 12 Sep 2024 05:54:09 +0000 (22:54 -0700)
index.html

index cf3a60f2e3bea0e716e28e58ce0d0a633b619244..88cb93a540dba9447a3a573567292db7d51785a4 100644 (file)
         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;
     }
   </style>
 </head>
       }
     }
 
+    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();
 
       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');
     });
This page took 0.039572 seconds and 4 git commands to generate.