From be6a9a53cfc620df3b79591f846c9f159b271247 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Fri, 31 Dec 2010 11:31:48 +0000 Subject: a summary page and back buttons --- jarmon/jarmon.js | 93 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 33 deletions(-) diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js index 1c5c3eb..6bd8d23 100644 --- a/jarmon/jarmon.js +++ b/jarmon/jarmon.js @@ -692,41 +692,43 @@ jarmon.Chart.fromRecipe = function(recipes, templateFactory, downloader) { **/ jarmon.ChartConfig = function($tpl) { this.$tpl = $tpl; - this.rrdUrl = ''; - this.dsName = ''; - this.dsLabel = ''; - this.dsUnit = ''; + this.data = { + rrdUrl: '', + dsName: '', + dsLabel: '', + dsUnit:'' + }; }; jarmon.ChartConfig.prototype.drawRrdUrlForm = function() { var self = this; this.$tpl.empty(); - var $f = $('
'); - - $('
').append( - $('

').text('Enter the URL of an RRD file'), - $('

').append( + $('

').text('Enter the URL of an RRD file'), + $('

', {class: 'next'}) ) - ).appendTo($f); - - $f.submit( + ).submit( function(e) { - self.rrdUrl = this['rrd_url'].value; + self.data.rrdUrl = this['rrd_url'].value; $placeholder = $(this).find('.next').empty(); - var rq = new jarmon.RrdQueryRemote(self.rrdUrl); - rq.getDSNames().addCallback( + new jarmon.RrdQueryRemote(self.data.rrdUrl).getDSNames().addCallback( function($placeholder, dsNames) { if(dsNames.length > 1) { - $('

').text('The RRD file contains multiple data sources. Choose one:').appendTo($placeholder); + $('

').text( + 'The RRD file contains multiple data sources. \ + Choose one:').appendTo($placeholder); + $(dsNames).map( function(i, el) { return $('', { @@ -735,13 +737,13 @@ jarmon.ChartConfig.prototype.drawRrdUrlForm = function() { } ).click( function(e) { - self.dsName = this.value; + self.data.dsName = this.value; self.drawDsLabelForm(); } ); }).appendTo($placeholder); } else { - self.dsName = dsNames[0]; + self.data.dsName = dsNames[0]; self.drawDsLabelForm(); } }, $placeholder @@ -752,9 +754,7 @@ jarmon.ChartConfig.prototype.drawRrdUrlForm = function() { ); return false; } - ); - - $f.appendTo(this.$tpl); + ).appendTo(this.$tpl); } jarmon.ChartConfig.prototype.drawDsLabelForm = function() { @@ -765,34 +765,61 @@ jarmon.ChartConfig.prototype.drawDsLabelForm = function() { $('

').text('Choose a label and unit for this data source.'), $('

').append( $('