diff options
author | Richard Wall <richard@aziz> | 2010-07-12 23:39:09 +0100 |
---|---|---|
committer | Richard Wall <richard@aziz> | 2010-07-12 23:39:09 +0100 |
commit | cc024d3b834a6c2417bbac0ea7799bbc2dd3a045 (patch) | |
tree | 2b836ea54bce0ddc5a88d4433ef43061e336da1a | |
parent | 883063cbaedce812694b0608630c93d49cd51bb3 (diff) |
allow tzoffset to be hidden
-rw-r--r-- | index.html | 4 | ||||
-rw-r--r-- | jarmon.js | 44 |
2 files changed, 26 insertions, 22 deletions
@@ -1,4 +1,4 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> @@ -163,7 +163,7 @@ </span> <input name="from" type="hidden" /> <input name="to" type="hidden" /> - <select name="tzoffset"></select> + <select name="tzoffset" ></select> <input name="action" value="Update" type="button" /> </div> <div class="range-preview"></div> @@ -675,29 +675,33 @@ jarmon.ChartCoordinator = function(ui) { self.update(); } ); - // Populate a list of tzoffset options - var label, val; + // Populate a list of tzoffset options if the element is present in the + // template as a select list + options = this.ui.find('select[name="tzoffset"]'); - for(var i=-12; i<=12; i++) { - label = 'UTC'; - val = i; - if(val >= 0) { - label += ' + '; - } else { - label += ' - '; - } - val = Math.abs(val).toString(); - if(val.length == 1) { - label += '0'; + if(options.length == 1) { + console.log(options); + var label, val; + for(var i=-12; i<=12; i++) { + label = 'UTC'; + val = i; + if(val >= 0) { + label += ' + '; + } else { + label += ' - '; + } + val = Math.abs(val).toString(); + if(val.length == 1) { + label += '0'; + } + label += val + '00'; + options.append($('<option />').attr('value', i*60*60*1000).text(label)); } - label += val + '00'; - options.append($('<option />').attr('value', i*60*60*1000).text(label)); - } - - options.bind('change', function(e) { - self.update(); - }); + options.bind('change', function(e) { + self.update(); + }); + } // Update the time ranges and redraw charts when the form is submitted this.ui.find('[name="action"]').bind('click', function(e) { self.update(); |