From 67dd6c11a4668673c0daac09bacf58685b80f1bf Mon Sep 17 00:00:00 2001 From: Steve Beaver Date: Wed, 9 Aug 2017 10:50:19 -0400 Subject: dd system information widget to central refresh system Add ability for a widget to specify how often it wants to be updated --- src/usr/local/www/index.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/usr/local/www/index.php') diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index e14f2a3..8a1b997 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -572,6 +572,7 @@ function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) { var ajaxspecs = new Array(); // Array to hold widget refresh specifications (objects ) var ajaxidx = 0; var ajaxmutex = false; +var ajaxcntr = 0; // Add a widget refresh object to the array list function register_ajax(ws) { @@ -661,9 +662,20 @@ events.push(function() { // results back to the widget's callback function function executewidget() { if (ajaxspecs.length > 0) { + var freq = ajaxspecs[ajaxidx].freq; // widget can specifify it should be called freq times around hte loop + if (!ajaxmutex) { - make_ajax_call(ajaxspecs[ajaxidx]); - ajaxidx = ++ajaxidx % ajaxspecs.length; + if ((ajaxcntr % freq) === 0) { + make_ajax_call(ajaxspecs[ajaxidx]); + } + + if (++ajaxidx >= ajaxspecs.length) { + ajaxidx = 0; + + if (++ajaxcntr >= 4096) { + ajaxcntr = 0; + } + } } setTimeout(function() { executewidget(); }, 2000); -- cgit v1.1