|
@@ -0,0 +1,556 @@
|
|
1
|
+// Copyright 2017 Google Inc. All Rights Reserved.
|
|
2
|
+//
|
|
3
|
+// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+// you may not use this file except in compliance with the License.
|
|
5
|
+// You may obtain a copy of the License at
|
|
6
|
+//
|
|
7
|
+// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+//
|
|
9
|
+// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+// See the License for the specific language governing permissions and
|
|
13
|
+// limitations under the License.
|
|
14
|
+
|
|
15
|
+package driver
|
|
16
|
+
|
|
17
|
+import "html/template"
|
|
18
|
+
|
|
19
|
+var graphTemplate = template.Must(template.New("graph").Parse(
|
|
20
|
+ `<!DOCTYPE html>
|
|
21
|
+<html>
|
|
22
|
+<head>
|
|
23
|
+<meta charset="utf-8">
|
|
24
|
+<title>{{.Title}}</title>
|
|
25
|
+<style type="text/css">
|
|
26
|
+html, body {
|
|
27
|
+ height: 100%;
|
|
28
|
+ min-height: 100%;
|
|
29
|
+ margin: 0px;
|
|
30
|
+}
|
|
31
|
+body {
|
|
32
|
+ width: 100%;
|
|
33
|
+ overflow: hidden;
|
|
34
|
+}
|
|
35
|
+h1 {
|
|
36
|
+ font-weight: normal;
|
|
37
|
+ font-size: 24px;
|
|
38
|
+ padding: 0em;
|
|
39
|
+ margin-top: 5px;
|
|
40
|
+ margin-bottom: 5px;
|
|
41
|
+}
|
|
42
|
+#page {
|
|
43
|
+ display: flex;
|
|
44
|
+ flex-direction: column;
|
|
45
|
+ height: 100%;
|
|
46
|
+ min-height: 100%;
|
|
47
|
+ width: 100%;
|
|
48
|
+ min-width: 100%;
|
|
49
|
+ margin: 0px;
|
|
50
|
+}
|
|
51
|
+#header {
|
|
52
|
+ flex: 0 0 auto;
|
|
53
|
+ width: 100%;
|
|
54
|
+}
|
|
55
|
+#leftbuttons {
|
|
56
|
+ float: left;
|
|
57
|
+}
|
|
58
|
+#rightbuttons {
|
|
59
|
+ float: right;
|
|
60
|
+ display: table-cell;
|
|
61
|
+ vertical-align: middle;
|
|
62
|
+}
|
|
63
|
+#rightbuttons label {
|
|
64
|
+ vertical-align: middle;
|
|
65
|
+}
|
|
66
|
+#scale {
|
|
67
|
+ vertical-align: middle;
|
|
68
|
+}
|
|
69
|
+#graph {
|
|
70
|
+ flex: 1 1 auto;
|
|
71
|
+ overflow: hidden;
|
|
72
|
+}
|
|
73
|
+svg {
|
|
74
|
+ width: 100%;
|
|
75
|
+ height: auto;
|
|
76
|
+ border: 1px solid black;
|
|
77
|
+}
|
|
78
|
+button {
|
|
79
|
+ margin-top: 5px;
|
|
80
|
+ margin-bottom: 5px;
|
|
81
|
+}
|
|
82
|
+#reset, #scale {
|
|
83
|
+ margin-left: 10px;
|
|
84
|
+}
|
|
85
|
+#detailtext {
|
|
86
|
+ display: none;
|
|
87
|
+ position: absolute;
|
|
88
|
+ background-color: #ffffff;
|
|
89
|
+ min-width: 160px;
|
|
90
|
+ border-top: 1px solid black;
|
|
91
|
+ box-shadow: 2px 2px 2px 0px #aaa;
|
|
92
|
+ z-index: 1;
|
|
93
|
+}
|
|
94
|
+</style>
|
|
95
|
+</head>
|
|
96
|
+<body>
|
|
97
|
+<h1>{{.Title}}</h1>
|
|
98
|
+<div id="page">
|
|
99
|
+
|
|
100
|
+<div id="errors">{{range .Errors}}<div>{{.}}</div>{{end}}</div>
|
|
101
|
+
|
|
102
|
+<div id="header">
|
|
103
|
+<div id="leftbuttons">
|
|
104
|
+<button id="details">▷ Details</button>
|
|
105
|
+<div id="detailtext">
|
|
106
|
+{{range .Legend}}<div>{{.}}</div>{{end}}
|
|
107
|
+</div>
|
|
108
|
+<button id="list">List</button>
|
|
109
|
+<button id="disasm">Disasm</button>
|
|
110
|
+<input id="searchbox" type="text" placeholder="Search regexp" autocomplete="off" autocapitalize="none" size=40>
|
|
111
|
+<button id="focus">Focus</button>
|
|
112
|
+<button id="ignore">Ignore</button>
|
|
113
|
+<button id="hide">Hide</button>
|
|
114
|
+<button id="show">Show</button>
|
|
115
|
+<button id="reset">Reset</button>
|
|
116
|
+</div>
|
|
117
|
+<div id="rightbuttons">
|
|
118
|
+</div>
|
|
119
|
+</div>
|
|
120
|
+
|
|
121
|
+<div id="graph">
|
|
122
|
+{{.Svg}}
|
|
123
|
+</div>
|
|
124
|
+
|
|
125
|
+</div>
|
|
126
|
+<script>
|
|
127
|
+// Make svg pannable and zoomable.
|
|
128
|
+// Call clickHandler(t) if a click event is caught by the pan event handlers.
|
|
129
|
+function initPanAndZoom(svg, clickHandler) {
|
|
130
|
+ 'use strict';
|
|
131
|
+
|
|
132
|
+ // Current mouse/touch handling mode
|
|
133
|
+ const IDLE = 0
|
|
134
|
+ const MOUSEPAN = 1
|
|
135
|
+ const TOUCHPAN = 2
|
|
136
|
+ const TOUCHZOOM = 3
|
|
137
|
+ let mode = IDLE
|
|
138
|
+
|
|
139
|
+ // State needed to implement zooming.
|
|
140
|
+ let currentScale = 1.0
|
|
141
|
+ const initWidth = svg.viewBox.baseVal.width
|
|
142
|
+ const initHeight = svg.viewBox.baseVal.height
|
|
143
|
+
|
|
144
|
+ // State needed to implement panning.
|
|
145
|
+ let panLastX = 0 // Last event X coordinate
|
|
146
|
+ let panLastY = 0 // Last event Y coordinate
|
|
147
|
+ let moved = false // Have we seen significant movement
|
|
148
|
+ let touchid = null // Current touch identifier
|
|
149
|
+
|
|
150
|
+ // State needed for pinch zooming
|
|
151
|
+ let touchid2 = null // Second id for pinch zooming
|
|
152
|
+ let initGap = 1.0 // Starting gap between two touches
|
|
153
|
+ let initScale = 1.0 // currentScale when pinch zoom started
|
|
154
|
+ let centerPoint = null // Center point for scaling
|
|
155
|
+
|
|
156
|
+ // Convert event coordinates to svg coordinates.
|
|
157
|
+ function toSvg(x, y) {
|
|
158
|
+ const p = svg.createSVGPoint()
|
|
159
|
+ p.x = x
|
|
160
|
+ p.y = y
|
|
161
|
+ let m = svg.getCTM()
|
|
162
|
+ if (m == null) m = svg.getScreenCTM() // Firefox workaround.
|
|
163
|
+ return p.matrixTransform(m.inverse())
|
|
164
|
+ }
|
|
165
|
+
|
|
166
|
+ // Change the scaling for the svg to s, keeping the point denoted
|
|
167
|
+ // by u (in svg coordinates]) fixed at the same screen location.
|
|
168
|
+ function rescale(s, u) {
|
|
169
|
+ // Limit to a good range.
|
|
170
|
+ if (s < 0.2) s = 0.2
|
|
171
|
+ if (s > 10.0) s = 10.0
|
|
172
|
+
|
|
173
|
+ currentScale = s
|
|
174
|
+
|
|
175
|
+ // svg.viewBox defines the visible portion of the user coordinate
|
|
176
|
+ // system. So to magnify by s, divide the visible portion by s,
|
|
177
|
+ // which will then be stretched to fit the viewport.
|
|
178
|
+ const vb = svg.viewBox
|
|
179
|
+ const w1 = vb.baseVal.width
|
|
180
|
+ const w2 = initWidth / s
|
|
181
|
+ const h1 = vb.baseVal.height
|
|
182
|
+ const h2 = initHeight / s
|
|
183
|
+ vb.baseVal.width = w2
|
|
184
|
+ vb.baseVal.height = h2
|
|
185
|
+
|
|
186
|
+ // We also want to adjust vb.baseVal.x so that u.x remains at same
|
|
187
|
+ // screen X coordinate. In other words, want to change it from x1 to x2
|
|
188
|
+ // so that:
|
|
189
|
+ // (u.x - x1) / w1 = (u.x - x2) / w2
|
|
190
|
+ // Simplifying that, we get
|
|
191
|
+ // (u.x - x1) * (w2 / w1) = u.x - x2
|
|
192
|
+ // x2 = u.x - (u.x - x1) * (w2 / w1)
|
|
193
|
+ vb.baseVal.x = u.x - (u.x - vb.baseVal.x) * (w2 / w1)
|
|
194
|
+ vb.baseVal.y = u.y - (u.y - vb.baseVal.y) * (h2 / h1)
|
|
195
|
+ }
|
|
196
|
+
|
|
197
|
+ function handleWheel(e) {
|
|
198
|
+ if (e.deltaY == 0) return
|
|
199
|
+ // Change scale factor by 1.1 or 1/1.1
|
|
200
|
+ rescale(currentScale * (e.deltaY < 0 ? 1.1 : (1/1.1)),
|
|
201
|
+ toSvg(e.offsetX, e.offsetY))
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+ function setMode(m) {
|
|
205
|
+ mode = m
|
|
206
|
+ touchid = null
|
|
207
|
+ touchid2 = null
|
|
208
|
+ }
|
|
209
|
+
|
|
210
|
+ function panStart(x, y) {
|
|
211
|
+ moved = false
|
|
212
|
+ panLastX = x
|
|
213
|
+ panLastY = y
|
|
214
|
+ }
|
|
215
|
+
|
|
216
|
+ function panMove(x, y) {
|
|
217
|
+ let dx = x - panLastX
|
|
218
|
+ let dy = y - panLastY
|
|
219
|
+ if (Math.abs(dx) <= 2 && Math.abs(dy) <= 2) return // Ignore tiny moves
|
|
220
|
+
|
|
221
|
+ moved = true
|
|
222
|
+ panLastX = x
|
|
223
|
+ panLastY = y
|
|
224
|
+
|
|
225
|
+ // Firefox workaround: get dimensions from parentNode.
|
|
226
|
+ const swidth = svg.clientWidth || svg.parentNode.clientWidth
|
|
227
|
+ const sheight = svg.clientHeight || svg.parentNode.clientHeight
|
|
228
|
+
|
|
229
|
+ // Convert deltas from screen space to svg space.
|
|
230
|
+ dx *= (svg.viewBox.baseVal.width / swidth)
|
|
231
|
+ dy *= (svg.viewBox.baseVal.height / sheight)
|
|
232
|
+
|
|
233
|
+ svg.viewBox.baseVal.x -= dx
|
|
234
|
+ svg.viewBox.baseVal.y -= dy
|
|
235
|
+ }
|
|
236
|
+
|
|
237
|
+ function handleScanStart(e) {
|
|
238
|
+ if (e.button != 0) return // Do not catch right-clicks etc.
|
|
239
|
+ setMode(MOUSEPAN)
|
|
240
|
+ panStart(e.clientX, e.clientY)
|
|
241
|
+ e.preventDefault()
|
|
242
|
+ svg.addEventListener("mousemove", handleScanMove)
|
|
243
|
+ }
|
|
244
|
+
|
|
245
|
+ function handleScanMove(e) {
|
|
246
|
+ if (mode == MOUSEPAN) panMove(e.clientX, e.clientY)
|
|
247
|
+ }
|
|
248
|
+
|
|
249
|
+ function handleScanEnd(e) {
|
|
250
|
+ if (mode == MOUSEPAN) panMove(e.clientX, e.clientY)
|
|
251
|
+ setMode(IDLE)
|
|
252
|
+ svg.removeEventListener("mousemove", handleScanMove)
|
|
253
|
+ if (!moved) clickHandler(e.target)
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+ // Find touch object with specified identifier.
|
|
257
|
+ function findTouch(tlist, id) {
|
|
258
|
+ for (const t of tlist) {
|
|
259
|
+ if (t.identifier == id) return t
|
|
260
|
+ }
|
|
261
|
+ return null
|
|
262
|
+ }
|
|
263
|
+
|
|
264
|
+ // Return distance between two touch points
|
|
265
|
+ function touchGap(t1, t2) {
|
|
266
|
+ const dx = t1.clientX - t2.clientX
|
|
267
|
+ const dy = t1.clientY - t2.clientY
|
|
268
|
+ return Math.hypot(dx, dy)
|
|
269
|
+ }
|
|
270
|
+
|
|
271
|
+ function handleTouchStart(e) {
|
|
272
|
+ if (mode == IDLE && e.changedTouches.length == 1) {
|
|
273
|
+ // Start touch based panning
|
|
274
|
+ const t = e.changedTouches[0]
|
|
275
|
+ setMode(TOUCHPAN)
|
|
276
|
+ touchid = t.identifier
|
|
277
|
+ panStart(t.clientX, t.clientY)
|
|
278
|
+ e.preventDefault()
|
|
279
|
+ } else if (mode == TOUCHPAN && e.touches.length == 2) {
|
|
280
|
+ // Start pinch zooming
|
|
281
|
+ setMode(TOUCHZOOM)
|
|
282
|
+ const t1 = e.touches[0]
|
|
283
|
+ const t2 = e.touches[1]
|
|
284
|
+ touchid = t1.identifier
|
|
285
|
+ touchid2 = t2.identifier
|
|
286
|
+ initScale = currentScale
|
|
287
|
+ initGap = touchGap(t1, t2)
|
|
288
|
+ centerPoint = toSvg((t1.clientX + t2.clientX) / 2,
|
|
289
|
+ (t1.clientY + t2.clientY) / 2)
|
|
290
|
+ e.preventDefault()
|
|
291
|
+ }
|
|
292
|
+ }
|
|
293
|
+
|
|
294
|
+ function handleTouchMove(e) {
|
|
295
|
+ if (mode == TOUCHPAN) {
|
|
296
|
+ const t = findTouch(e.changedTouches, touchid)
|
|
297
|
+ if (t == null) return
|
|
298
|
+ if (e.touches.length != 1) {
|
|
299
|
+ setMode(IDLE)
|
|
300
|
+ return
|
|
301
|
+ }
|
|
302
|
+ panMove(t.clientX, t.clientY)
|
|
303
|
+ e.preventDefault()
|
|
304
|
+ } else if (mode == TOUCHZOOM) {
|
|
305
|
+ // Get two touches; new gap; rescale to ratio.
|
|
306
|
+ const t1 = findTouch(e.touches, touchid)
|
|
307
|
+ const t2 = findTouch(e.touches, touchid2)
|
|
308
|
+ if (t1 == null || t2 == null) return
|
|
309
|
+ const gap = touchGap(t1, t2)
|
|
310
|
+ rescale(initScale * gap / initGap, centerPoint)
|
|
311
|
+ e.preventDefault()
|
|
312
|
+ }
|
|
313
|
+ }
|
|
314
|
+
|
|
315
|
+ function handleTouchEnd(e) {
|
|
316
|
+ if (mode == TOUCHPAN) {
|
|
317
|
+ const t = findTouch(e.changedTouches, touchid)
|
|
318
|
+ if (t == null) return
|
|
319
|
+ panMove(t.clientX, t.clientY)
|
|
320
|
+ setMode(IDLE)
|
|
321
|
+ e.preventDefault()
|
|
322
|
+ if (!moved) clickHandler(t.target)
|
|
323
|
+ } else if (mode == TOUCHZOOM) {
|
|
324
|
+ setMode(IDLE)
|
|
325
|
+ e.preventDefault()
|
|
326
|
+ }
|
|
327
|
+ }
|
|
328
|
+
|
|
329
|
+ svg.addEventListener("mousedown", handleScanStart)
|
|
330
|
+ svg.addEventListener("mouseup", handleScanEnd)
|
|
331
|
+ svg.addEventListener("touchstart", handleTouchStart)
|
|
332
|
+ svg.addEventListener("touchmove", handleTouchMove)
|
|
333
|
+ svg.addEventListener("touchend", handleTouchEnd)
|
|
334
|
+ svg.addEventListener("wheel", handleWheel, true)
|
|
335
|
+}
|
|
336
|
+
|
|
337
|
+function dotviewer(nodes) {
|
|
338
|
+ 'use strict';
|
|
339
|
+
|
|
340
|
+ // Elements
|
|
341
|
+ const detailsButton = document.getElementById("details")
|
|
342
|
+ const detailsText = document.getElementById("detailtext")
|
|
343
|
+ const listButton = document.getElementById("list")
|
|
344
|
+ const disasmButton = document.getElementById("disasm")
|
|
345
|
+ const resetButton = document.getElementById("reset")
|
|
346
|
+ const focusButton = document.getElementById("focus")
|
|
347
|
+ const showButton = document.getElementById("show")
|
|
348
|
+ const ignoreButton = document.getElementById("ignore")
|
|
349
|
+ const hideButton = document.getElementById("hide")
|
|
350
|
+ const search = document.getElementById("searchbox")
|
|
351
|
+ const graph0 = document.getElementById("graph0")
|
|
352
|
+ const svg = graph0.parentElement
|
|
353
|
+
|
|
354
|
+ let currentRe = ""
|
|
355
|
+ let selected = new Map()
|
|
356
|
+ let origFill = new Map()
|
|
357
|
+ let searchAlarm = null
|
|
358
|
+ let buttonsEnabled = true
|
|
359
|
+
|
|
360
|
+ function handleDetails() {
|
|
361
|
+ if (detailtext.style.display == "block") {
|
|
362
|
+ detailtext.style.display = "none"
|
|
363
|
+ detailsButton.innerText = "\u25b7 Details"
|
|
364
|
+ } else {
|
|
365
|
+ detailtext.style.display = "block"
|
|
366
|
+ detailsButton.innerText = "\u25bd Details"
|
|
367
|
+ }
|
|
368
|
+ }
|
|
369
|
+
|
|
370
|
+ function handleReset() { window.location.href = "/" }
|
|
371
|
+ function handleList() { navigate("/weblist", "f", true) }
|
|
372
|
+ function handleDisasm() { navigate("/disasm", "f", true) }
|
|
373
|
+ function handleFocus() { navigate("/", "f", false) }
|
|
374
|
+ function handleShow() { navigate("/", "s", false) }
|
|
375
|
+ function handleIgnore() { navigate("/", "i", false) }
|
|
376
|
+ function handleHide() { navigate("/", "h", false) }
|
|
377
|
+
|
|
378
|
+ function handleSearch() {
|
|
379
|
+ // Delay processing so a flurry of key strokes is handled once.
|
|
380
|
+ if (searchAlarm != null) {
|
|
381
|
+ clearTimeout(searchAlarm)
|
|
382
|
+ }
|
|
383
|
+ searchAlarm = setTimeout(doSearch, 300)
|
|
384
|
+ }
|
|
385
|
+
|
|
386
|
+ function doSearch() {
|
|
387
|
+ searchAlarm = null
|
|
388
|
+ let re = null
|
|
389
|
+ if (search.value != "") {
|
|
390
|
+ try {
|
|
391
|
+ re = new RegExp(search.value)
|
|
392
|
+ } catch (e) {
|
|
393
|
+ // TODO: Display error state in search box
|
|
394
|
+ return
|
|
395
|
+ }
|
|
396
|
+ }
|
|
397
|
+ currentRe = search.value
|
|
398
|
+
|
|
399
|
+ function match(text) {
|
|
400
|
+ return re != null && re.test(text)
|
|
401
|
+ }
|
|
402
|
+
|
|
403
|
+ // drop currently selected items that do not match re.
|
|
404
|
+ selected.forEach(function(v, n) {
|
|
405
|
+ if (!match(nodes[n])) {
|
|
406
|
+ unselect(n, document.getElementById("node" + n))
|
|
407
|
+ }
|
|
408
|
+ })
|
|
409
|
+
|
|
410
|
+ // add matching items that are not currently selected.
|
|
411
|
+ for (let n = 0; n < nodes.length; n++) {
|
|
412
|
+ if (!selected.has(n) && match(nodes[n])) {
|
|
413
|
+ select(n, document.getElementById("node" + n))
|
|
414
|
+ }
|
|
415
|
+ }
|
|
416
|
+
|
|
417
|
+ updateButtons()
|
|
418
|
+ }
|
|
419
|
+
|
|
420
|
+ function toggleSelect(elem) {
|
|
421
|
+ // Walk up to immediate child of graph0
|
|
422
|
+ while (elem != null && elem.parentElement != graph0) {
|
|
423
|
+ elem = elem.parentElement
|
|
424
|
+ }
|
|
425
|
+ if (!elem) return
|
|
426
|
+
|
|
427
|
+ // Disable regexp mode.
|
|
428
|
+ currentRe = ""
|
|
429
|
+
|
|
430
|
+ const n = nodeId(elem)
|
|
431
|
+ if (n < 0) return
|
|
432
|
+ if (selected.has(n)) {
|
|
433
|
+ unselect(n, elem)
|
|
434
|
+ } else {
|
|
435
|
+ select(n, elem)
|
|
436
|
+ }
|
|
437
|
+ updateButtons()
|
|
438
|
+ }
|
|
439
|
+
|
|
440
|
+ function unselect(n, elem) {
|
|
441
|
+ if (elem == null) return
|
|
442
|
+ selected.delete(n)
|
|
443
|
+ setBackground(elem, false)
|
|
444
|
+ }
|
|
445
|
+
|
|
446
|
+ function select(n, elem) {
|
|
447
|
+ if (elem == null) return
|
|
448
|
+ selected.set(n, true)
|
|
449
|
+ setBackground(elem, true)
|
|
450
|
+ }
|
|
451
|
+
|
|
452
|
+ function nodeId(elem) {
|
|
453
|
+ const id = elem.id
|
|
454
|
+ if (!id) return -1
|
|
455
|
+ if (!id.startsWith("node")) return -1
|
|
456
|
+ const n = parseInt(id.slice(4), 10)
|
|
457
|
+ if (isNaN(n)) return -1
|
|
458
|
+ if (n < 0 || n >= nodes.length) return -1
|
|
459
|
+ return n
|
|
460
|
+ }
|
|
461
|
+
|
|
462
|
+ function setBackground(elem, set) {
|
|
463
|
+ const p = findPolygon(elem)
|
|
464
|
+ if (p != null) {
|
|
465
|
+ if (set) {
|
|
466
|
+ origFill.set(p, p.style.fill)
|
|
467
|
+ p.style.fill = "#ccccff"
|
|
468
|
+ } else if (origFill.has(p)) {
|
|
469
|
+ p.style.fill = origFill.get(p)
|
|
470
|
+ }
|
|
471
|
+ }
|
|
472
|
+ }
|
|
473
|
+
|
|
474
|
+ function findPolygon(elem) {
|
|
475
|
+ if (elem.localName == "polygon") return elem
|
|
476
|
+ for (const c of elem.children) {
|
|
477
|
+ const p = findPolygon(c)
|
|
478
|
+ if (p != null) return p
|
|
479
|
+ }
|
|
480
|
+ return null
|
|
481
|
+ }
|
|
482
|
+
|
|
483
|
+ // Navigate to specified path with current selection reflected
|
|
484
|
+ // in the named parameter.
|
|
485
|
+ function navigate(path, param, newWindow) {
|
|
486
|
+ // The selection can be in one of two modes: regexp-based or
|
|
487
|
+ // list-based. Construct regular expression depending on mode.
|
|
488
|
+ let re = currentRe
|
|
489
|
+ if (re == "") {
|
|
490
|
+ selected.forEach(function(v, key) {
|
|
491
|
+ if (re != "") re += "|"
|
|
492
|
+ re += nodes[key]
|
|
493
|
+ })
|
|
494
|
+ }
|
|
495
|
+
|
|
496
|
+ const url = new URL(window.location.href)
|
|
497
|
+ url.pathname = path
|
|
498
|
+ url.hash = ""
|
|
499
|
+
|
|
500
|
+ if (re != "") {
|
|
501
|
+ // For focus/show, forget old parameter. For others, add to re.
|
|
502
|
+ const params = url.searchParams
|
|
503
|
+ if (param != "f" && param != "s" && params.has(param)) {
|
|
504
|
+ const old = params.get(param)
|
|
505
|
+ if (old != "") {
|
|
506
|
+ re += "|" + old
|
|
507
|
+ }
|
|
508
|
+ }
|
|
509
|
+ params.set(param, re)
|
|
510
|
+ }
|
|
511
|
+
|
|
512
|
+ if (newWindow) {
|
|
513
|
+ window.open(url.toString(), "_blank")
|
|
514
|
+ } else {
|
|
515
|
+ window.location.href = url.toString()
|
|
516
|
+ }
|
|
517
|
+ }
|
|
518
|
+
|
|
519
|
+ function updateButtons() {
|
|
520
|
+ const enable = (currentRe != "" || selected.size != 0)
|
|
521
|
+ if (buttonsEnabled == enable) return
|
|
522
|
+ buttonsEnabled = enable
|
|
523
|
+ listButton.disabled = !enable
|
|
524
|
+ disasmButton.disabled = !enable
|
|
525
|
+ focusButton.disabled = !enable
|
|
526
|
+ showButton.disabled = !enable
|
|
527
|
+ ignoreButton.disabled = !enable
|
|
528
|
+ hideButton.disabled = !enable
|
|
529
|
+ }
|
|
530
|
+
|
|
531
|
+ // Initialize button states
|
|
532
|
+ updateButtons()
|
|
533
|
+
|
|
534
|
+ // Setup event handlers
|
|
535
|
+ initPanAndZoom(svg, toggleSelect)
|
|
536
|
+
|
|
537
|
+ function bindButtons(evt) {
|
|
538
|
+ detailsButton.addEventListener(evt, handleDetails)
|
|
539
|
+ listButton.addEventListener(evt, handleList)
|
|
540
|
+ disasmButton.addEventListener(evt, handleDisasm)
|
|
541
|
+ resetButton.addEventListener(evt, handleReset)
|
|
542
|
+ focusButton.addEventListener(evt, handleFocus)
|
|
543
|
+ showButton.addEventListener(evt, handleShow)
|
|
544
|
+ ignoreButton.addEventListener(evt, handleIgnore)
|
|
545
|
+ hideButton.addEventListener(evt, handleHide)
|
|
546
|
+ }
|
|
547
|
+ bindButtons("click")
|
|
548
|
+ bindButtons("touchstart")
|
|
549
|
+ search.addEventListener("input", handleSearch)
|
|
550
|
+}
|
|
551
|
+
|
|
552
|
+dotviewer({{.Nodes}})
|
|
553
|
+</script>
|
|
554
|
+</body>
|
|
555
|
+</html>
|
|
556
|
+`))
|