summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-04-16 01:24:53 +0100
committerRichard Wall <richard@aziz>2010-04-16 01:24:53 +0100
commit5325e54e84a394ae8127785f757d0c7c2c4065f0 (patch)
treeb562fce92d76be7de23848c4d3c0975df3d3138a /index.html
parent42422fae12e64c44dc38510eb68f561000860d61 (diff)
Move the chart coordinator into the library file
Diffstat (limited to 'index.html')
-rw-r--r--index.html72
1 files changed, 1 insertions, 71 deletions
diff --git a/index.html b/index.html
index f8f2838..714b85c 100644
--- a/index.html
+++ b/index.html
@@ -130,78 +130,8 @@
return c;
}
- var ChartCoordinator = function(ui) {
- this.ui = ui;
- this.charts = [];
-
- var self = this;
- this.ui.bind('submit', function(e) {
- self.update();
- return false;
- });
-
- this.ui.bind('reset', function(e) {
- self.reset();
- return false;
- });
- var rangePreviewOptions = {
- selection: {
- mode: 'x'
- },
- xaxis: {
- mode: "time"
- },
- yaxis: {
- ticks: []
- }
- };
- var now = new Date().getTime();
- var HOUR = 1000 * 60 * 60;
- var DAY = HOUR * 24;
- var WEEK = DAY * 7;
- var MONTH = DAY * 31;
- var YEAR = DAY * 365;
-
- var data = [
- [now - WEEK, null],
- [now, null]];
-
- this.rangePreview = $.plot(this.ui.find('.range-preview'), [data], rangePreviewOptions);
-
- this.ui.bind("plotselected", function(event, ranges) {
- self.setTimeRange(new Date(ranges.xaxis.from),
- new Date(ranges.xaxis.to));
- });
- };
-
- ChartCoordinator.prototype.update = function() {
- var startTime = new Date(this.ui[0].startTime.value);
- var endTime = new Date(this.ui[0].endTime.value);
- var ranges = {
- xaxis: {
- from: startTime.getTime(),
- to: endTime.getTime()
- }
- };
- this.rangePreview.setSelection(ranges, true);
- for(var i=0; i<this.charts.length; i++){
- this.charts[i].draw(startTime, endTime);
- }
- };
-
- ChartCoordinator.prototype.setTimeRange = function(startTime, endTime) {
- this.ui[0].startTime.value = startTime.toString().split(' ').slice(1,5).join(' ');
- this.ui[0].endTime.value = endTime.toString().split(' ').slice(1,5).join(' ');
- this.update();
- };
-
- ChartCoordinator.prototype.reset = function() {
- this.setTimeRange(new Date(new Date().getTime()-1*60*60*1000),
- new Date());
- };
-
$(function() {
- var cc = new ChartCoordinator($('.chartRangeControl'));
+ var cc = new jrrd.ChartCoordinator($('.chartRangeControl'));
var chartTemplate = $('.chart').remove();
cc.charts = [
//dnsChartFactory(