Skip to content

Instantly share code, notes, and snippets.

@dhensby
Last active August 29, 2015 13:56
Show Gist options
  • Save dhensby/8955816 to your computer and use it in GitHub Desktop.
Save dhensby/8955816 to your computer and use it in GitHub Desktop.
Script to auto reload DigitalOcean graphs on the droplet page
/**
* Refreshes the graphs at their interval
*/
//generic function for generating a graph by parent ID
function genNewGraphByID(id) {
$(id).find('div.graph').each(function() {
$(this).children().remove();
drawGraph(this);
});
}
// real time
setInterval(function() {
genNewGraphByID('#action-graphs_real');
}, 60000);
// daily
setInterval(function() {
genNewGraphByID('#action-graphs_daily');
}, 300000);
// weekly
setInterval(function() {
genNewGraphByID('#action-graphs_weekly');
}, 1800000);
// monthly
setInterval(function() {
genNewGraphByID('#action-graphs_monthly');
}, 7200000);
// yearly
setInterval(function() {
genNewGraphByID('#action-graphs_yearly');
}, 86400000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment