From 4846671b1d8931502ebdd87ce7fa85b02a44075f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 30 Mar 2013 03:39:50 -0500 Subject: query: more jquery ui tweaks --- python/gras/query/chart_factory.js | 32 ++++++++++++++++++-------------- python/gras/query/main.css | 4 ++-- python/gras/query/main.html | 6 +++--- python/gras/query/main.js | 18 ++++++++---------- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/python/gras/query/chart_factory.js b/python/gras/query/chart_factory.js index 2109976..0a7efbc 100644 --- a/python/gras/query/chart_factory.js +++ b/python/gras/query/chart_factory.js @@ -227,42 +227,45 @@ function gras_chart_factory_init(registry) $('#chart_type_selector').append(option); }); + //init chart overall gui controls + var overall_rate = $('#chart_update_rate').attr({size:3}); + overall_rate.spinner({ + min: 1, max: 10, step: 0.5, stop: function(event, ui){$(this).change();} + }); + var overall_active = $('#chart_active_state'); + overall_active.button(); + //callback for overall gui events function handle_gui_event() { registry.overall_active = overall_active.is(':checked'); - if (registry.overall_active) gras_query_stats(registry); - else window.clearInterval(registry.timeout_handle); registry.overall_rate = overall_rate.val(); gras_chart_save(registry); } - - //init chart overall gui controls - var overall_rate = $('#chart_update_rate').attr({size:3}); - overall_rate.spinner({ - min: 1, max: 10, stop: function(event, ui){$(this).change();} - }); overall_rate.change(handle_gui_event); - var overall_active = $('#chart_active_state'); overall_active.change(handle_gui_event); //block registry and checkboxes init $.getJSON('/blocks.json', function(data) { + var container = $('#chart_designer_blocks'); $.each(data.blocks, function(index, id) { registry.block_ids.push(id); - var container = $('#chart_designer_blocks'); + var cb_id = "chart_designer_blocks " + id; var div = $('
'); - $(div).append(''); + var label = $('
diff --git a/python/gras/query/main.js b/python/gras/query/main.js index a25979f..b17af63 100644 --- a/python/gras/query/main.js +++ b/python/gras/query/main.js @@ -3,7 +3,7 @@ **********************************************************************/ var GrasStatsRegistry = function() { - this.overall_rate = 2.0; + this.overall_rate = 3.0; this.overall_active = true; this.block_ids = new Array(); this.top_id = 'top'; @@ -38,21 +38,19 @@ var gras_query_stats = function(registry) { registry.online = true; gras_handle_offline(registry); - if (registry.overall_active) - { - gras_chart_factory_update(registry, response); + if (registry.overall_active) gras_chart_factory_update(registry, response); - registry.timeout_handle = window.setTimeout(function() - { - gras_query_stats(registry); - }, Math.round(1000/registry.overall_rate)); - } + var timeout = registry.overall_active? Math.round(1000/registry.overall_rate) : 1000; + window.setTimeout(function() + { + gras_query_stats(registry); + }, timeout); }, error: function() { registry.online = false; gras_handle_offline(registry); - registry.timeout_handle = window.setTimeout(function() + window.setTimeout(function() { gras_query_stats(registry); }, 1000); -- cgit