diff options
author | Richard Wall <richard@aziz> | 2010-04-10 01:42:40 +0100 |
---|---|---|
committer | Richard Wall <richard@aziz> | 2010-04-10 01:42:40 +0100 |
commit | d6a57318678671ad85972a6d69ebeedabd5eefea (patch) | |
tree | 42d31e0d5d7f614213f414286035eb311d11b651 /jrrd.js | |
parent | d5edf591ea1d83af0371c9e741d01f4638fa6f94 (diff) |
Add a jrrd namespace
Diffstat (limited to 'jrrd.js')
-rw-r--r-- | jrrd.js | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -1,4 +1,9 @@ -function downloadBinary(url) { + +if(typeof jrrd == 'undefined') { + var jrrd = {}; +} + +jrrd.downloadBinary = function(url) { var d = new MochiKit.Async.Deferred(); $.ajax({ @@ -31,14 +36,14 @@ function downloadBinary(url) { } }); return d; -} +}; -var RrdQuery = function(rrd) { +jrrd.RrdQuery = function(rrd) { this.rrd = rrd; -} +}; -RrdQuery.prototype.getData = function(startTime, endTime) { +jrrd.RrdQuery.prototype.getData = function(startTime, endTime) { var startTimestamp = startTime.getTime()/1000; var endTimestamp = endTime.getTime()/1000; @@ -84,17 +89,17 @@ RrdQuery.prototype.getData = function(startTime, endTime) { }; -var RrdQueryRemote = function(url) { +jrrd.RrdQueryRemote = function(url) { this.url = url; this.rrd = null; -} +}; -RrdQueryRemote.prototype.getData = function(startTime, endTime) { +jrrd.RrdQueryRemote.prototype.getData = function(startTime, endTime) { var endTimestamp = endTime.getTime()/1000; var d, self = this; if(!this.rrd || this.rrd.getLastUpdate() < endTimestamp) { - d = downloadBinary(this.url) + d = jrrd.downloadBinary(this.url) .addCallback( function(binary) { var rrd = new RRDFile(binary); @@ -108,7 +113,7 @@ RrdQueryRemote.prototype.getData = function(startTime, endTime) { d.addCallback( function(rrd) { - return new RrdQuery(rrd).getData(startTime, endTime); + return new jrrd.RrdQuery(rrd).getData(startTime, endTime); }); return d; |