if(typeof jrrd == 'undefined') { var jrrd = {}; } jrrd.downloadBinary = function(url) { var d = new MochiKit.Async.Deferred(); $.ajax({ url: url, dataType: 'text', cache: false, beforeSend: function(request) { try { request.overrideMimeType('text/plain; charset=x-user-defined'); } catch(e) { // IE doesn't support overrideMimeType } }, success: function(data) { try { d.callback(new BinaryFile(data)); } catch(e) { d.errback(e); } }, error: function(xhr, textStatus, errorThrown) { // Special case for IE which handles binary data slightly // differently. if(textStatus == 'parsererror') { if (typeof xhr.responseBody != 'undefined') { return this.success(xhr.responseBody); } } d.errback(new Error(xhr.status)); } }); return d; }; jrrd.RrdQuery = function(rrd) { this.rrd = rrd; }; jrrd.RrdQuery.prototype.getData = function(startTime, endTime, dsId) { var startTimestamp = startTime.getTime()/1000; var endTimestamp = endTime.getTime()/1000; if(dsId == null) { dsId = 0; } var ds = this.rrd.getDS(dsId); var consolidationFunc = 'AVERAGE'; var lastUpdated = this.rrd.getLastUpdate(); var bestRRA = null; for(var i=0; i