]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/html/themes/ipfire-new/include/js/refreshInetInfo.js
f17b50a9a72ad4e357389495271f698e1ed1b35b
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/
16 $(document
).ready(function(){
20 function refreshInetInfo() {
22 url
: '/cgi-bin/speed.cgi',
23 success: function(xml
) {
24 t_current
= new Date();
25 var t_diff
= t_current
- t_last
;
27 rxb_current
= $("rxb", xml
).text();
28 var rxb_diff
= rxb_current
- rxb_last
;
29 rxb_last
= rxb_current
;
31 var rx_bits
= rxb_diff
* 1024 / t_diff
;
32 var rx_fmt
= format_bytes(rx_bits
);
34 txb_current
= $("txb", xml
).text();
35 var txb_diff
= txb_current
- txb_last
;
36 txb_last
= txb_current
;
38 var tx_bits
= txb_diff
* 1024 / t_diff
;
39 var tx_fmt
= format_bytes(tx_bits
);
42 $("#rx_kbs").text(rx_fmt
);
43 $("#tx_kbs").text(tx_fmt
);
50 window
.setTimeout("refreshInetInfo()", 2000);
53 function format_bytes(bytes
) {
54 var units
= ["Bit/s", "kBit/s", "MBit/s", "GBit/s", "TBit/s"];
57 for (var i
= 1; i
< units
.length
; i
++) {
66 bytes
= bytes
.toFixed(2);
68 return bytes
+ " " + unit
;