Project

General

Profile

« Previous | Next » 

Revision 27e6d494

Added by Steve Beaver almost 8 years ago

Use central refresh system for dyndns widget

View differences:

src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
116 116
			print('N/A ' . date("H:i:s"));
117 117
		}
118 118
	}
119

  
119 120
	exit;
120 121
} else if ($_POST['widgetkey']) {
121 122
	set_customwidgettitle($user_settings);
......
272 273

  
273 274
<script type="text/javascript">
274 275
//<![CDATA[
275
	function dyndns_getstatus_<?=$widgetkey_nodash?>() {
276
		scroll(0,0);
277
		var url = "/widgets/widgets/dyn_dns_status.widget.php";
278
		var pars = 'getdyndnsstatus=<?=$widgetkey?>';
279
		$.ajax(
280
			url,
281
			{
282
				type: 'get',
283
				data: pars,
284
				complete: dyndnscallback_<?=$widgetkey_nodash?>
285
			});
286 276

  
287
	}
288
	function dyndnscallback_<?=$widgetkey_nodash?>(transport) {
289
		// The server returns a string of statuses separated by vertical bars
290
		var responseStrings = transport.responseText.split("|");
291
		for (var count=0; count<responseStrings.length; count++) {
292
			var divlabel = '#widget-<?=$widgetkey?> #dyndnsstatus' + count;
293
			$(divlabel).prop('innerHTML',responseStrings[count]);
277
	events.push(function(){
278
		// --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
279

  
280
		// Callback function called by refresh system when data is retrieved
281
		function dyndnscallback_<?=$widgetkey_nodash?>(s) {
282
			// The server returns a string of statuses separated by vertical bars
283
			var responseStrings = s.split("|");
284
			for (var count=0; count<responseStrings.length; count++) {
285
				var divlabel = '#widget-<?=$widgetkey?> #dyndnsstatus' + count;
286
				$(divlabel).prop('innerHTML',responseStrings[count]);
287
			}
294 288
		}
295 289

  
296
		// Refresh the status every 5 minutes
297
		setTimeout('dyndns_getstatus_<?=$widgetkey_nodash?>()', 5*60*1000);
298
	}
299
	events.push(function(){
290
		// POST data to send via AJAX
291
		var postdata = {
292
			ajax: "ajax",
293
		 	getdyndnsstatus : "<?=$widgetkey?>"
294
		 };
295

  
296
		// Create an object defining the widget refresh AJAX call
297
		var dyndnsObject = new Object();
298
		dyndnsObject.name = "DynDNS";
299
		dyndnsObject.url = "/widgets/widgets/dyn_dns_status.widget.php";
300
		dyndnsObject.callback =  dyndnscallback_<?=$widgetkey_nodash?>;
301
		dyndnsObject.parms = postdata;
302
		dyndnsObject.freq = 1;
303

  
304
		// Register the AJAX object
305
		register_ajax(dyndnsObject);
306

  
307
		// ---------------------------------------------------------------------------------------------------
308

  
300 309
		set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
301 310
	});
302
	// Do the first status check 2 seconds after the dashboard opens
303
	setTimeout('dyndns_getstatus_<?=$widgetkey_nodash?>()', 2000);
311

  
304 312
//]]>
305 313
</script>
src/usr/local/www/widgets/widgets/system_information.widget.php
137 137
	header("Location: /index.php");
138 138
}
139 139

  
140
/*   Adding one second to the system widet update period
141
 *   will ensure that we update the GUI right after the stats are updated.
142
 */
143
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
144
$widgetperiod += 1000;
145

  
146 140
$filesystems = get_mounted_filesystems();
147 141

  
148 142
$skipsysinfoitems = explode(",", $user_settings['widgets'][$widgetkey]['filter']);
......
692 686
	versionObject.parms = postdata;
693 687
	versionObject.freq = 100;
694 688

  
695
	// Register the AJAX object
689
	//Register the AJAX object
696 690
	register_ajax(versionObject);
697 691
<?php endif; ?>
698 692
	// ---------------------------------------------------------------------------------------------------

Also available in: Unified diff