diff options
Diffstat (limited to 'src/usr/local/www/widgets/widgets/interface_statistics.widget.php')
-rw-r--r-- | src/usr/local/www/widgets/widgets/interface_statistics.widget.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php index 32c2365..43e20b3 100644 --- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php +++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php @@ -297,7 +297,7 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey); <script type="text/javascript"> //<![CDATA[ - +/* function get_if_stats_<?=$widgetkey_nodash?>() { var ajaxRequest; @@ -315,16 +315,38 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey); setTimeout(get_if_stats_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>"); }); } +*/ + events.push(function() { + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ + + // Callback function called by refresh system when data is retrieved + function interface_statistics_callback(s) { + $('#<?=$widgetkey?>-iftbl').html(s); + } + + // POST data to send via AJAX + var postdata = { + ajax : "ajax", + widgetkey :"<?=$widgetkey?>" + }; + + // Create an object defining the widget refresh AJAX call + var ifstatObject = new Object(); + ifstatObject.name = "IFstats"; + ifstatObject.url = "/widgets/widgets/interface_statistics.widget.php"; + ifstatObject.callback = interface_statistics_callback; + ifstatObject.parms = postdata; + ifstatObject.freq = 1; + + // Register the AJAX object + register_ajax(ifstatObject); - events.push(function(){ + // --------------------------------------------------------------------------------------------------- // Note: This manages all settings checkboxes with id starting with "show" // (i.e. both the interface and stats item selection groups) // using a single All/None button set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); - // Start polling for updates some small random number of seconds from now (so that all the widgets don't - // hit the server at exactly the same time) - setTimeout(get_if_stats_<?=$widgetkey_nodash?>, Math.floor((Math.random() * 10000) + 1000)); }); //]]> </script> |