Skip to content

Commit

Permalink
Populate the global timeframe with the profile's timeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
Lindsay Holmwood authored and jessereynolds committed Jul 16, 2012
1 parent 8ba4367 commit 3515288
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/visage-app/public/javascripts/builder.js
Expand Up @@ -463,8 +463,13 @@ var ChartBuilder = new Class({
});
this.searchers.metric = searcher;
},
getURLTimeframe: function() {
var urlTimeframe = window.location.hash.split('|').filter(function(parameter) { return parameter.test('^timeframe') })[0];
getTimeframe: function() {
var optionTimeframe = this.options.timeframe,
urlTimeframe = window.location.hash.split('|').filter(function(parameter) { return parameter.test('^timeframe') })[0];

if (optionTimeframe && !urlTimeframe) {
return optionTimeframe
}

if (urlTimeframe) {
return decodeURI(urlTimeframe.split('=')[1]);
Expand Down Expand Up @@ -551,7 +556,8 @@ var ChartBuilder = new Class({
'1 year': 8760,
'2 years': 17520 });

timeframe = this.getURLTimeframe();
timeframe = this.getTimeframe();
console.log(timeframe, 'timeframe')
timescales.each(function(hour, label) {
var value = "start={start}".substitute({'start': currentUnixTime - (hour * 3600)});
var html = 'last {label}'.substitute({'label': label });
Expand Down Expand Up @@ -634,7 +640,7 @@ var ChartBuilder = new Class({
metrics = this.searchers.metric.tokenValues();
percentiles = [];
percentile95 = this.options.percentile95;
timeframe = this.getURLTimeframe();
timeframe = this.getTimeframe();

if (percentile95) {
percentiles.push(95);
Expand Down

0 comments on commit 3515288

Please sign in to comment.