]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/html/themes/ipfire-new/include/js/refreshInetInfo.js
New theme for the IPFire web user interface
[people/teissler/ipfire-2.x.git] / html / html / themes / ipfire-new / include / js / refreshInetInfo.js
1 /* refreshInetInfo.js
2 * functions for retrieving status information via jQuery
3 * Modified: March 6th, 2013 by michael@koehler.tk
4 * Authors: IPFire Team (info@ipfire.org)
5 Kay-Michael Köhler (michael@koehler.tk)
6 * Visit http://www.ipfire.org/
7 */
8
9 var t_current;
10 var t_last = 0;
11 var rxb_current;
12 var rxb_last = 0;
13 var txb_current;
14 var txb_last = 0;
15
16 $(document).ready(function(){
17 refreshInetInfo();
18 });
19
20 function refreshInetInfo() {
21 $.ajax({
22 url: '/cgi-bin/speed.cgi',
23 success: function(xml){
24
25 t_current = new Date();
26 var t_diff = t_current - t_last;
27
28 rxb_current = $("rxb",xml).text();
29 var rxb_diff = rxb_current - rxb_last;
30 rxb_last = rxb_current;
31
32 var rx_kbs = rxb_diff/t_diff;
33 rx_kbs = Math.round(rx_kbs*10)/10;
34
35 txb_current = $("txb",xml).text();
36 var txb_diff = txb_current - txb_last;
37 txb_last = txb_current;
38
39 var tx_kbs = txb_diff/t_diff;
40 tx_kbs = Math.round(tx_kbs*10)/10;
41
42 if (t_last != 0) {
43 $("#rx_kbs").text(rx_kbs + ' kb/s');
44 $("#tx_kbs").text(tx_kbs + ' kb/s');
45 if ($("#bandwidthCalculationContainer").css('display') == 'none')
46 $("#bandwidthCalculationContainer").css('display','block');
47 }
48
49 t_last = t_current;
50 }
51 });
52 window.setTimeout("refreshInetInfo()", 2000);
53 }