Skip to content

Commit

Permalink
dynamic timeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
doertehasselberg committed May 11, 2011
1 parent e58431e commit 5374e8e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions public/js/main.js
Expand Up @@ -25,12 +25,11 @@ var Healthety = function(){
setInterval(function(){
// clean up values
for(var name in lines){
// ((new Date()).getTime()-300000)
var threshold = getThreshold(json.name);
for(var host in lines[name]){
for(var value in lines[name][host]['data']){
var ref = ((new Date()).getTime()-300000);
if(
lines[name][host]['data'][value][0] < ref
lines[name][host]['data'][value][0] < threshold
){
lines[name][host]['data'].shift();
}
Expand Down Expand Up @@ -132,6 +131,17 @@ var Healthety = function(){
return colors[hosts.indexOf(hostname)];
}

function getThreshold(hostname){
var custom = $(document).getUrlParam(hostname+'_thres');
var threshold;
if(custom == null){
threshold = 300000;
} else {
threshold = parseInt($(document).getUrlParam(hostname+'_thres')) * 60*1000;
}
return (new Date()).getTime() - threshold;
}

return minime;
}

0 comments on commit 5374e8e

Please sign in to comment.