-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpage.html
93 lines (90 loc) · 2.1 KB
/
page.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<title>heap profile</title>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
font-size: 0.8em;
display: -webkit-box;
}
#control {
border-right: solid 1px black;
padding: 16px;
}
#display {
overflow: scroll;
-webkit-box-flex: 1;
}
</style>
<body>
<script>
var kNodeSizes = {{.Graph.NodeSizes | firstn 500 | json}};
</script>
<div id=control>
{{with .Profile.Header}}
{{.InuseBytes | kb}} total allocated<br>
{{end}}
<form method=post>
<p>
show top <input id=nodecountText name=nodecount size=2 autocomplete=0 value={{.Params.NodeKeepCount}}><br>
(> <span id=nodekb>X</span>kb) functions<br>
<input id=nodecountRange type=range min=10 max=300 step=10 value={{.Params.NodeKeepCount}}><br>
</p>
<script>
var textbox = document.getElementById('nodecountText');
var range = document.getElementById('nodecountRange');
var kb = document.getElementById('nodekb');
function updateKb() {
var min = kNodeSizes[parseInt(textbox.value)];
kb.innerText = (min/1024).toFixed(0);
}
textbox.addEventListener('keyup', function() {
range.value = textbox.value;
updateKb();
});
range.addEventListener('change', function() {
textbox.value = range.value;
updateKb();
});
updateKb();
</script>
<input type=submit value=rerender>
</form>
</div>
<div id=display>
<!-- Use a bogus CGI param to bypass browser cache. -->
<img src="graph.png?{{.Params}}">
</div>
<script>
var display = document.getElementById('display');
var last = null;
display.addEventListener('mousedown', function(e) {
if (e.button == 1) {
last = {x:e.x, y:e.y};
}
e.preventDefault();
});
display.addEventListener('mousemove', function(e) {
if (!last) return;
if (e.button == 1) {
display.scrollTop -= e.y - last.y;
display.scrollLeft -= e.x - last.x;
last = {x:e.x, y:e.y};
} else {
last = null;
}
e.preventDefault();
});
display.addEventListener('mouseup', function(e) {
last = null;
e.preventDefault();
});
</script>
</body>
</html>