diff options
author | Steve Beaver <sbeaver@netgate.com> | 2017-08-15 15:25:34 -0400 |
---|---|---|
committer | Steve Beaver <sbeaver@netgate.com> | 2017-08-15 15:26:01 -0400 |
commit | 27e6d494698c898e6ef44cb72cb0e86b573efe63 (patch) | |
tree | 0d23e356651430b6483e406a7585fdefd2108df1 /src/usr/local/www | |
parent | e0e922da092c2f61826dadc37466d4912694f859 (diff) | |
download | pfsense-27e6d494698c898e6ef44cb72cb0e86b573efe63.zip pfsense-27e6d494698c898e6ef44cb72cb0e86b573efe63.tar.gz |
Use central refresh system for dyndns widget
Diffstat (limited to 'src/usr/local/www')
-rw-r--r-- | src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php | 56 | ||||
-rw-r--r-- | src/usr/local/www/widgets/widgets/system_information.widget.php | 8 |
2 files changed, 33 insertions, 31 deletions
diff --git a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php index ce40a99..19fe79c 100644 --- a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php +++ b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php @@ -116,6 +116,7 @@ if ($_REQUEST['getdyndnsstatus']) { print('N/A ' . date("H:i:s")); } } + exit; } else if ($_POST['widgetkey']) { set_customwidgettitle($user_settings); @@ -272,34 +273,41 @@ if (!function_exists('get_dyndns_service_text')) { <script type="text/javascript"> //<![CDATA[ - function dyndns_getstatus_<?=$widgetkey_nodash?>() { - scroll(0,0); - var url = "/widgets/widgets/dyn_dns_status.widget.php"; - var pars = 'getdyndnsstatus=<?=$widgetkey?>'; - $.ajax( - url, - { - type: 'get', - data: pars, - complete: dyndnscallback_<?=$widgetkey_nodash?> - }); - } - function dyndnscallback_<?=$widgetkey_nodash?>(transport) { - // The server returns a string of statuses separated by vertical bars - var responseStrings = transport.responseText.split("|"); - for (var count=0; count<responseStrings.length; count++) { - var divlabel = '#widget-<?=$widgetkey?> #dyndnsstatus' + count; - $(divlabel).prop('innerHTML',responseStrings[count]); + events.push(function(){ + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ + + // Callback function called by refresh system when data is retrieved + function dyndnscallback_<?=$widgetkey_nodash?>(s) { + // The server returns a string of statuses separated by vertical bars + var responseStrings = s.split("|"); + for (var count=0; count<responseStrings.length; count++) { + var divlabel = '#widget-<?=$widgetkey?> #dyndnsstatus' + count; + $(divlabel).prop('innerHTML',responseStrings[count]); + } } - // Refresh the status every 5 minutes - setTimeout('dyndns_getstatus_<?=$widgetkey_nodash?>()', 5*60*1000); - } - events.push(function(){ + // POST data to send via AJAX + var postdata = { + ajax: "ajax", + getdyndnsstatus : "<?=$widgetkey?>" + }; + + // Create an object defining the widget refresh AJAX call + var dyndnsObject = new Object(); + dyndnsObject.name = "DynDNS"; + dyndnsObject.url = "/widgets/widgets/dyn_dns_status.widget.php"; + dyndnsObject.callback = dyndnscallback_<?=$widgetkey_nodash?>; + dyndnsObject.parms = postdata; + dyndnsObject.freq = 1; + + // Register the AJAX object + register_ajax(dyndnsObject); + + // --------------------------------------------------------------------------------------------------- + set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); }); - // Do the first status check 2 seconds after the dashboard opens - setTimeout('dyndns_getstatus_<?=$widgetkey_nodash?>()', 2000); + //]]> </script> diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php index 26c9abb..8249ebd 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -137,12 +137,6 @@ if ($_REQUEST['getupdatestatus']) { header("Location: /index.php"); } -/* Adding one second to the system widet update period - * will ensure that we update the GUI right after the stats are updated. - */ -$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000; -$widgetperiod += 1000; - $filesystems = get_mounted_filesystems(); $skipsysinfoitems = explode(",", $user_settings['widgets'][$widgetkey]['filter']); @@ -692,7 +686,7 @@ events.push(function(){ versionObject.parms = postdata; versionObject.freq = 100; - // Register the AJAX object + //Register the AJAX object register_ajax(versionObject); <?php endif; ?> // --------------------------------------------------------------------------------------------------- |