MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / www / status-data.jsx
blobe942328d3137a252393fb73c3c1757015ef717e7
1 /*
2         Tomato GUI
3         Copyright (C) 2006-2010 Jonathan Zarate
4         http://www.polarcloud.com/tomato/
6         For use with Tomato Firmware only.
7         No part of this file may be used without permission.
8 */
10 //<% nvram("ppp_get_ip,pptp_server_ip,router_name,wan_domain,wan_gateway,wan_gateway_get,wan_get_domain,wan_hostname,wan_hwaddr,wan_ipaddr,wan_netmask,wan_proto,wan_run_mtu,et0macaddr,lan_proto,lan_ipaddr,dhcp_start,dhcp_num,dhcpd_startip,dhcpd_endip,lan_netmask,wl_security_mode,wl_crypto,wl_mode,wl_wds_enable,wl_hwaddr,wl_net_mode,wl_radio,wl_channel,lan_gateway,wl_ssid,t_model_name,t_features,pptp_dhcp"); %>
11 //<% uptime(); %>
12 //<% sysinfo(); %>
13 //<% wlstats(); %>
15 stats = { };
17 do {
18         var a, b, i;
20         if (typeof(last_wan_proto) == 'undefined') {
21                 last_wan_proto = nvram.wan_proto;
22         }
23         else if (last_wan_proto != nvram.wan_proto) {
24                 reloadPage();
25         }
26         stats.flashsize = sysinfo.flashsize+'MB';
27         stats.cpumhz = sysinfo.cpuclk+'MHz';
28         stats.systemtype = sysinfo.systemtype;
29         stats.cpuload = ((sysinfo.loads[0] / 65536.0).toFixed(2) + '<small> / </small> ' +
30                 (sysinfo.loads[1] / 65536.0).toFixed(2) + '<small> / </small>' +
31                 (sysinfo.loads[2] / 65536.0).toFixed(2));
32         stats.uptime = sysinfo.uptime_s;
34         a = sysinfo.totalram;
35         b = sysinfo.totalfreeram;
36         stats.memory = scaleSize(a) + ' / ' + scaleSize(b) + ' <small>(' + (b / a * 100.0).toFixed(2) + '%)</small>';
37         if (sysinfo.totalswap > 0) {
38                 a = sysinfo.totalswap;
39                 b = sysinfo.freeswap;
40                 stats.swap = scaleSize(a) + ' / ' + scaleSize(b) + ' <small>(' + (b / a * 100.0).toFixed(2) + '%)</small>';
41         } else
42                 stats.swap = '';
44         stats.time = '<% time(); %>';
45         stats.wanup = '<% wanup(); %>' == '1';
46         stats.wanuptime = '<% link_uptime(); %>';
47         stats.wanlease = '<% dhcpc_time(); %>';
49         //<% dns(); %>
50         stats.dns = dns.join(', ');
52         stats.wanip = nvram.wan_ipaddr;
53         stats.wannetmask = nvram.wan_netmask;
54         stats.wangateway = nvram.wan_gateway_get;
55         if (stats.wangateway == '0.0.0.0' || stats.wangateway == '')
56                 stats.wangateway = nvram.wan_gateway;
58         switch (nvram.wan_proto) {
59         case 'pptp':
60         case 'l2tp':
61                 if (stats.wanup) {
62                         stats.wanip = nvram.ppp_get_ip;
63                         if (nvram.pptp_dhcp == '1') {
64                                 if (nvram.wan_ipaddr != '' && nvram.wan_ipaddr != '0.0.0.0' && nvram.wan_ipaddr != stats.wanip)
65                                         stats.wanip += '&nbsp;&nbsp;<small>(DHCP: ' + nvram.wan_ipaddr + ')</small>';
66                                 if (nvram.wan_gateway != '' && nvram.wan_gateway != '0.0.0.0' && nvram.wan_gateway != stats.wangateway)
67                                         stats.wangateway += '&nbsp;&nbsp;<small>(DHCP: ' + nvram.wan_gateway + ')</small>';
68                         }
69                         if (stats.wannetmask == '0.0.0.0')
70                                 stats.wannetmask = '255.255.255.255';
71                 }
72                 else {
73                         if (nvram.wan_proto == 'pptp')
74                                 stats.wangateway = nvram.pptp_server_ip;
75                 }
76                 break;
77         default:
78                 if (!stats.wanup) {
79                         stats.wanip = '0.0.0.0';
80                         stats.wannetmask = '0.0.0.0';
81                         stats.wangateway = '0.0.0.0';
82                 }
83         }
85 /* IPV6-BEGIN */
86         stats.ip6_wan = ((typeof(sysinfo.ip6_wan) != 'undefined') ? sysinfo.ip6_wan : '') + '';
87         stats.ip6_lan = ((typeof(sysinfo.ip6_lan) != 'undefined') ? sysinfo.ip6_lan : '') + ''
88         stats.ip6_lan_ll = ((typeof(sysinfo.ip6_lan_ll) != 'undefined') ? sysinfo.ip6_lan_ll : '') + ''
89 /* IPV6-END */
91         stats.wanstatus = '<% wanstatus(); %>';
92         if (stats.wanstatus != 'Connected') stats.wanstatus = '<b>' + stats.wanstatus + '</b>';
94         stats.channel = [];
95         stats.interference = [];
96         stats.qual = [];
98         for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
99                 u = wl_unit(uidx);
101                 a = i = wlstats[uidx].channel * 1;
102                 if (i < 0) i = -i;
103                 stats.channel.push('<a href="tools-survey.asp">' + ((i) ? i + '' : 'Auto') +
104                         ((wlstats[uidx].mhz) ? ' - ' + (wlstats[uidx].mhz / 1000.0).toFixed(3) + ' <small>GHz</small>' : '') + '</a>' +
105                         ((a < 0) ? ' <small>(scanning...)</small>' : ''));
106                 stats.interference.push((wlstats[uidx].intf >= 0) ? ((wlstats[uidx].intf) ? 'Severe' : 'Acceptable') : '');
108                 a = wlstats[uidx].nbw * 1;
109                 wlstats[uidx].nbw = (a > 0) ? (a + ' <small>MHz</small>') : 'Auto';
111                 if (wlstats[uidx].radio) {
112                         a = wlstats[uidx].rate * 1;
113                         if (a > 0)
114                                 wlstats[uidx].rate = Math.floor(a / 2) + ((a & 1) ? '.5' : '') + ' <small>Mbps</small>';
115                         else
116                                 wlstats[uidx].rate = '-';
118                         if (wlstats[uidx].client) {
119                                 if (wlstats[uidx].rssi == 0) a = 0;
120                                         else a = MAX(wlstats[uidx].rssi - wlstats[uidx].noise, 0);
121                                 stats.qual.push(a + ' <img src="bar' + MIN(MAX(Math.floor(a / 10), 1), 6) + '.gif">');
122                         }
123                         else {
124                                 stats.qual.push('');
125                         }
126                         wlstats[uidx].noise += ' <small>dBm</small>';
127                         wlstats[uidx].rssi += ' <small>dBm</small>';
128                 }
129                 else {
130                         wlstats[uidx].rate = '';
131                         wlstats[uidx].noise = '';
132                         wlstats[uidx].rssi = '';
133                         stats.qual.push('');
134                 }
135         }
136 } while (0);