Skip to content

Commit

Permalink
Automatically update matched percent when zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
knittl committed Aug 12, 2019
1 parent 1b1c6de commit 2278e4c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions flamegraph.pl
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,15 @@ sub flow {
<script type="text/ecmascript">
<![CDATA[
"use strict";
var details, searchbtn, unzoombtn, matchedtxt, svg, searching;
var details, searchbtn, unzoombtn, matchedtxt, svg, searching, currentSearchTerm;
function init(evt) {
details = document.getElementById("details").firstChild;
searchbtn = document.getElementById("search");
unzoombtn = document.getElementById("unzoom");
matchedtxt = document.getElementById("matched");
svg = document.getElementsByTagName("svg")[0];
searching = 0;
currentSearchTerm = null;
}
window.addEventListener("click", function(e) {
Expand Down Expand Up @@ -946,6 +947,7 @@ sub flow {
}
}
}
search();
}
function unzoom() {
unzoombtn.classList.add("hide");
Expand All @@ -956,6 +958,7 @@ sub flow {
zoom_reset(el[i]);
update_text(el[i]);
}
search();
}
// search
Expand All @@ -970,18 +973,23 @@ sub flow {
var term = prompt("Enter a search term (regexp " +
"allowed, eg: ^ext4_)", "");
if (term != null) {
search(term)
currentSearchTerm = term;
search();
}
} else {
reset_search();
searching = 0;
currentSearchTerm = null;
searchbtn.classList.remove("show");
searchbtn.firstChild.nodeValue = "Search"
matchedtxt.classList.add("hide");
matchedtxt.firstChild.nodeValue = ""
}
}
function search(term) {
if (currentSearchTerm === null) return;
var term = currentSearchTerm;
var re = new RegExp(term);
var el = document.getElementById("frames").children;
var matches = new Object();
Expand Down

0 comments on commit 2278e4c

Please sign in to comment.