summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/widgets/widgets/ntp_status.widget.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www/widgets/widgets/ntp_status.widget.php')
-rw-r--r--src/usr/local/www/widgets/widgets/ntp_status.widget.php44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/usr/local/www/widgets/widgets/ntp_status.widget.php b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
index 9f0e964..4be7074 100644
--- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
@@ -227,30 +227,34 @@ setInterval(function() {
<?php if ($widget_first_instance): ?>
<script type="text/javascript">
//<![CDATA[
- function ntp_getstatus() {
- var url = "/widgets/widgets/ntp_status.widget.php";
- var pars = 'updateme=yes';
- $.ajax(
- url,
- {
- type: 'get',
- data: pars,
- complete: ntpstatuscallback
- });
- }
- function ntpstatuscallback(transport) {
- // The server returns formatted html code
- var responseStringNtp = transport.responseText
- $('[id="ntpstatus"]').prop('innerHTML',responseStringNtp);
+events.push(function(){
+ // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
- // Refresh the status at the configured interval
- setTimeout('ntp_getstatus()', "<?=$widgetperiod?>");
+ // Callback function called by refresh system when data is retrieved
+ function ntp_callback(s) {
+ $('[id="ntpstatus"]').prop('innerHTML', s);
}
- // 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(ntp_getstatus, Math.floor((Math.random() * 10000) + 1000));
+ // POST data to send via AJAX
+ var postdata = {
+ ajax: "ajax",
+ updateme : "yes"
+ };
+
+ // Create an object defining the widget refresh AJAX call
+ var ntpObject = new Object();
+ ntpObject.name = "NTP";
+ ntpObject.url = "/widgets/widgets/ntp_status.widget.php";
+ ntpObject.callback = ntp_callback;
+ ntpObject.parms = postdata;
+ ntpObject.freq = 4;
+
+ // Register the AJAX object
+ register_ajax(ntpObject);
+
+ // ---------------------------------------------------------------------------------------------------
+});
//]]>
</script>
OpenPOWER on IntegriCloud