[perf-web] Pass range type and position when navigating between pages



commit 78437389eb9f2c7eefccf6a184420fa6defd6cfa
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Wed Jul 23 19:42:16 2014 -0400

    Pass range type and position when navigating between pages
    
    When the user switches pages, pass the range type (day, week,
    etc) and the center position so they can investigate the same
    data on other pages. Do this dynamically by intercepting
    the click event on URLs.

 static/main.js |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/static/main.js b/static/main.js
index f6071bc..6580653 100644
--- a/static/main.js
+++ b/static/main.js
@@ -1103,6 +1103,17 @@ PerfDisplay.prototype.onWindowLoaded = function() {
 
     this.windowLoaded = true;
 
+    $( "a" ).click(function(e) {
+        var href = this.getAttribute("href");
+        if (href == null)
+            href = this.getAttributeNS("http://www.w3.org/1999/xlink";, "href");
+        if (href && href.indexOf("/") == 0) {
+            href = href.replace(/(\?.*|$)/, "?r=" + theDisplay.rangeType + "&c=" + theDisplay.centerTime);
+            e.preventDefault();
+            window.open(href, "_self");
+        }
+    });
+
     $( ".chart" ).each(function() {
         theDisplay.charts.push(new Chart(this));
     });
@@ -1165,6 +1176,7 @@ function getQueryParams() {
 function initialize(target, metric, dataMinTime, dataMaxTime) {
     var params = getQueryParams();
     var rangeType = ('r' in params) ? params['r'] : 'week';
+    var centerTime = ('c' in params) ? Number(params['c']) : Date.now() / 1000;
 
-    theDisplay = new PerfDisplay(target, metric, dataMinTime, dataMaxTime, Date.now() / 1000, rangeType);
+    theDisplay = new PerfDisplay(target, metric, dataMinTime, dataMaxTime, centerTime, rangeType);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]