From bc9f2d0ef704b5f66af8fd2afd1a382b7e1d34db Mon Sep 17 00:00:00 2001 From: AreWeFastYet Date: Mon, 3 Dec 2012 11:39:52 +0000 Subject: [PATCH] Add automatic refresh support back. --- website/awfy.js | 33 +++++++++++++++++++++++++-------- website/frontpage.js | 29 +++++++++++++++++++++++++---- website/index.html | 1 + website/tooltip.js | 8 +++++++- 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/website/awfy.js b/website/awfy.js index 8f86cdb..d408e6e 100644 --- a/website/awfy.js +++ b/website/awfy.js @@ -2,7 +2,7 @@ "use strict"; var AWFY = { }; -AWFY.refreshTime = 1000 * 60 * 5; +AWFY.refreshTime = 60 * 5; AWFY.machineId = 0; AWFY.hasLegend = false; AWFY.panes = []; @@ -12,6 +12,7 @@ AWFY.xhr = []; AWFY.view = 'none'; AWFY.suiteName = null; AWFY.lastHash = null; +AWFY.lastRefresh = 0; AWFY.request = function (files, callback) { var url = window.location.protocol + '//' + @@ -102,11 +103,13 @@ AWFY.displayNewGraph = function (name, graph) { var elt = $('#' + name + '-graph'); var display = elt.data('awfy-display'); if (!display) { - display = new Display(this, name, elt, graph); + display = new Display(this, name, elt); elt.data('awfy-display', display); } - display.setup(graph); - display.draw(); + if (display.shouldRefresh()) { + display.setup(graph); + display.draw(); + } this.aggregate[name] = graph; } @@ -434,6 +437,7 @@ AWFY.showOverview = function () { ]; this.request(['aggregate-' + this.machineId], this.computeAggregate.bind(this)); + this.lastRefresh = Date.now(); } AWFY.showBreakdown = function (name) { @@ -476,12 +480,10 @@ AWFY.showBreakdown = function (name) { var file = 'bk-aggregate-' + id + '-' + this.machineId; this.request([file], callback); } + this.lastRefresh = Date.now(); } -AWFY.changeMachine = function (machine_id) { - this.reset(this.view); - this.machineId = machine_id; - +AWFY.requestRedraw = function () { if (this.view == 'overview') { this.request(['aggregate-' + this.machineId], this.computeAggregate.bind(this)); @@ -499,6 +501,13 @@ AWFY.changeMachine = function (machine_id) { this.request([file], callback); } } + this.lastRefresh = Date.now(); +} + +AWFY.changeMachine = function (machine_id) { + this.reset(this.view); + this.machineId = machine_id; + this.requestRedraw(); } AWFY.reset = function (view) { @@ -531,6 +540,12 @@ AWFY.onHashChange = function () { this.parseURL(); } +AWFY.refresh = function () { + if (Date.now() - this.lastRefresh >= this.refreshTime) + this.requestRedraw(); + window.setTimeout(this.refresh.bind(this), this.refreshTime * 1000); +} + AWFY.parseURL = function () { if (this.lastHash == window.location.hash) return; @@ -707,5 +722,7 @@ AWFY.startup = function () { $(window).hashchange(this.onHashChange.bind(this)); $(window).bind('popstate', this.onHashChange.bind(this)); + + window.setTimeout(this.refresh.bind(this), this.refreshTime * 1000); } diff --git a/website/frontpage.js b/website/frontpage.js index ff1d7e2..b0959c8 100644 --- a/website/frontpage.js +++ b/website/frontpage.js @@ -1,20 +1,20 @@ // vim: set ts=4 sw=4 tw=99 et: "use strict"; -function Display(awfy, id, elt, graph) +function Display(awfy, id, elt) { this.awfy = awfy; this.id = id; this.elt = elt; this.attachedTips = []; + this.graph = null; + this.plot = null; + this.hovering = null; } Display.prototype.setup = function (graph) { this.graph = graph; - // The last hovering tooltip we displayed, that has not been clicked. - this.hovering = null; - this.selectDelay = null; if (graph.aggregate) @@ -43,7 +43,27 @@ Display.prototype.shutdown = function () { this.elt.unbind('plotclick'); this.elt.unbind('plotselected'); this.elt.unbind('dblclick'); + if (this.hovering) { + this.hovering.remove(); + this.hovering = null; + } this.detachTips(); + this.plot = null; + this.graph = null; +} + +Display.prototype.shouldRefresh = function () { + if (this.graph) { + for (var i = 0; i < this.attachedTips.length; i++) { + var tooltip = this.attachedTips[i]; + if (tooltip.attached()) + return false; + } + if (this.zoomInfo.level != 'aggregate') + return false; + this.shutdown(); + } + return true; } Display.prototype.setHistoricalMidpoint = function () { @@ -334,6 +354,7 @@ Display.prototype.unzoom = function () { this.plot.enableSelection(); this.plot.clearSelection(); this.detachTips(); + this.zoomInfo.level = 'aggregate'; } Display.prototype.detachTips = function () { diff --git a/website/index.html b/website/index.html index 4619cd8..6e3baa7 100755 --- a/website/index.html +++ b/website/index.html @@ -71,6 +71,7 @@
  • Use the "view" menu to drill down into individual benchmarks.
  • You can click and highlight any area of any graph to zoom in. It might pause to download data.
  • You can unzoom by double-clicking inside a graph.
  • +
  • A graph will refresh every 5 minutes if it is not zoomed in and has no attached tooltips.
  • FAQ: