From 8ec74176c80e8339f02f94f8e12839559a6d0db8 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 10 Apr 2020 15:58:46 +0200 Subject: [PATCH] Dumper: hash highlighting on mouseover --- src/Tracy/Bar/assets/bar.css | 8 ++++++++ src/Tracy/Dumper/assets/dumper.css | 8 ++++++++ src/Tracy/Dumper/assets/dumper.js | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/Tracy/Bar/assets/bar.css b/src/Tracy/Bar/assets/bar.css index 605fd9439..d9b04004b 100644 --- a/src/Tracy/Bar/assets/bar.css +++ b/src/Tracy/Bar/assets/bar.css @@ -401,6 +401,14 @@ body#tracy-debug .tracy-panel { /* in popup window */ display: none; } +#tracy-debug .tracy-dump-highlight { + background: #C22; + color: white; + border-radius: 2px; + padding: 0 2px; + margin: 0 -2px; +} + /* toggle */ #tracy-debug .tracy-toggle:after { diff --git a/src/Tracy/Dumper/assets/dumper.css b/src/Tracy/Dumper/assets/dumper.css index 2d2624f1b..7c840f878 100644 --- a/src/Tracy/Dumper/assets/dumper.css +++ b/src/Tracy/Dumper/assets/dumper.css @@ -55,6 +55,14 @@ pre.tracy-dump a:focus { display: none; } +.tracy-dump-highlight { + background: #C22; + color: white; + border-radius: 2px; + padding: 0 2px; + margin: 0 -2px; +} + span[data-tracy-href] { border-bottom: 1px dotted rgba(0, 0, 0, .2); } diff --git a/src/Tracy/Dumper/assets/dumper.js b/src/Tracy/Dumper/assets/dumper.js index f10b56ec1..8005a128f 100644 --- a/src/Tracy/Dumper/assets/dumper.js +++ b/src/Tracy/Dumper/assets/dumper.js @@ -66,6 +66,25 @@ } }); + document.addEventListener('mouseover', (e) => { + let dump; + if (e.target.matches('.tracy-dump-hash') && (dump = e.target.closest('.tracy-dump'))) { + dump.querySelectorAll('.tracy-dump-hash').forEach((el) => { + if (el.textContent === e.target.textContent) { + el.classList.add('tracy-dump-highlight'); + } + }); + } + }); + + document.addEventListener('mouseout', (e) => { + if (e.target.matches('.tracy-dump-hash')) { + document.querySelectorAll('.tracy-dump-hash.tracy-dump-highlight').forEach((el) => { + el.classList.remove('tracy-dump-highlight'); + }); + } + }); + Tracy.Toggle.init(); } }