diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/gras/query/chart_factory.js | 32 | ||||
-rw-r--r-- | python/gras/query/main.css | 4 | ||||
-rw-r--r-- | python/gras/query/main.html | 6 | ||||
-rw-r--r-- | 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 />'); - $(div).append('<label>' + id + '</label>'); + var label = $('<label />').text(id).attr({'for':cb_id}); var input = $('<input />').attr({ type: 'checkbox', - name: id + name: id, + id: cb_id, }); input.attr('checked', false); - $(div).append(input); - $(container).append(div); + div.append(input); + div.append(label); + container.append(div); }); + //container.buttonset(); //try to load last settings try{gras_chart_load(registry);}catch(e){} @@ -271,5 +274,6 @@ function gras_chart_factory_init(registry) overall_rate.val(registry.overall_rate); overall_active.attr('checked', registry.overall_active); handle_gui_event(); + gras_query_stats(registry); }); } diff --git a/python/gras/query/main.css b/python/gras/query/main.css index 2665e32..a428111 100644 --- a/python/gras/query/main.css +++ b/python/gras/query/main.css @@ -27,8 +27,8 @@ text-decoration:underline; #chart_designer_blocks input { -margin-right:10px; -margin-left:2px; +margin-right:2px; +margin-left:10px; } #charts_panel diff --git a/python/gras/query/main.html b/python/gras/query/main.html index 04e5a49..b64d53f 100644 --- a/python/gras/query/main.html +++ b/python/gras/query/main.html @@ -34,13 +34,13 @@ <td id="chart_designer_blocks" rowspan='2'></td> <td><select id="chart_type_selector" /></td> <td> - <label for="spinner">Updates/sec:</label> + <label for="chart_update_rate">Updates/sec:</label> <input id="chart_update_rate" type="spinner" /> </td> </tr> <tr> - <td><input type="submit" value="Create New Chart" id="chart_factory_button" /></td> - <td><label>Active?</label><input id="chart_active_state" type="checkbox" name="active" /></td> + <td><input type="button" value="Create New Chart" id="chart_factory_button" /></td> + <td><input id="chart_active_state" type="checkbox" /><label for="chart_active_state">Active</label></td> </tr> </table> </div> 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); |