1
0
mirror of https://github.com/golang/go synced 2024-11-19 14:54:43 -07:00

cmd/trace: encode selection in trace URL

This adds the ability to add a #x:y anchor to the trace view URL that
causes the viewer to initially select from x ms to y ms.

Change-Id: I4a980d8128ecc85dbe41f224e8ae336707a4eaab
Reviewed-on: https://go-review.googlesource.com/60794
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Austin Clements 2017-07-28 10:23:04 -04:00
parent 70fd25e4e1
commit 21ced9c748

View File

@ -112,6 +112,17 @@ var templTrace = `
function onModelLoaded() {
viewer.model = model;
viewer.viewTitle = "trace";
if (!model || model.bounds.isEmpty)
return;
var sel = window.location.hash.substr(1);
if (sel === '')
return;
var parts = sel.split(':');
var range = new (tr.b.Range || tr.b.math.Range)();
range.addValue(parseFloat(parts[0]));
range.addValue(parseFloat(parts[1]));
viewer.trackView.viewport.interestRange.set(range);
}
function onImportFail(err) {