From 6708ba3b03e05ada12b4667928329041c47b35e4 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Sat, 10 Jul 2010 17:26:52 +0100 Subject: partially working selectable time range and tzoffset --- index.html | 17 ++++----------- jarmon.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index b4e0ab8..cec632a 100644 --- a/index.html +++ b/index.html @@ -116,15 +116,6 @@ } $(function() { - // Add dhtml calendars to the date input fields - $(":date").dateinput({format: 'mmm dd yyyy', max: +1}); - $(":date[name=startTime]").data("dateinput").change(function() { - $(":date[name=endTime]").data("dateinput").setMin(this.getValue(), true); - }); - $(":date[name=endTime]").data("dateinput").change(function() { - $(":date[name=startTime]").data("dateinput").setMax(this.getValue(), true); - }); - // Setup dhtml tabs $(".css-tabs").tabs(".css-panes > div", {history: true}); @@ -143,11 +134,11 @@
- - - + + + + -
diff --git a/jarmon.js b/jarmon.js index ec6ddb9..3cd44e2 100644 --- a/jarmon.js +++ b/jarmon.js @@ -611,6 +611,57 @@ jarmon.Chart.STACKED_OPTIONS = { **/ jarmon.ChartCoordinator = function(ui) { this.ui = ui; + + // Populate the time range selector + var timeRangeChoices = [ + [-60*60*1000*1, 'last hour'], + [-60*60*1000*6, 'last six hours'], + [-60*60*1000*24, 'last day'], + [-60*60*1000*24*7, 'last week'], + [-60*60*1000*24*31, 'last month'], + [-60*60*1000*24*365, 'last year'] + ]; + + var val, label, option, options = this.ui.find('select[name="from"]'); + + for(var i=0; i').attr('value', val).text(label)); + } + + // Default timezone offset based on localtime + var tzoffset = -1 * new Date().getTimezoneOffset() / 60; + + // Populate a list of tzoffset options + options = this.ui.find('select[name="tzoffset"]'); + for(var i=-12; i<=12; i++) { + label = 'UTC'; + if(i >= 0) { + label += ' + '; + } else { + label += ' - '; + } + label += Math.abs(i) + 'h'; + option = $('