]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: encode selection in trace URL
authorAustin Clements <austin@google.com>
Fri, 28 Jul 2017 14:23:04 +0000 (10:23 -0400)
committerAustin Clements <austin@google.com>
Tue, 20 Feb 2018 18:22:54 +0000 (18:22 +0000)
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>
src/cmd/trace/trace.go

index b8a7e5d6d262fa4cc8d7c0c4aad15c59a1dc5f79..b0712c9ac7a07b4a571a9528898e32fbc75f3f6f 100644 (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) {