Tomato 1.28
[tomato.git] / release / src / router / www / status-data.jsx
blob7260db22d17f90363f4ba8c8c8fe5c2ec9c1b7ea
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("l2tp_get_ip,pptp_get_ip,pptp_server_ip,router_name,wan_domain,wan_gateway,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,security_mode2,wl_crypto,wl_mode,wds_enable,wl0_hwaddr,wl_net_mode,wl_radio,wl_channel,lan_gateway,wl_ssid,t_model_name"); %>
11 //<% uptime(); %>
12 //<% sysinfo(); %>
13 //<% wlradio(); %>
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         }
27         stats.cpuload = ((sysinfo.loads[0] / 65536.0).toFixed(2) + '<small> / </small> ' +
28                 (sysinfo.loads[1] / 65536.0).toFixed(2) + '<small> / </small>' +
29                 (sysinfo.loads[2] / 65536.0).toFixed(2));
30         stats.uptime = sysinfo.uptime_s;
32         a = sysinfo.totalram + sysinfo.totalswap;
33         b = sysinfo.totalfreeram + sysinfo.freeswap;
34         stats.memory = scaleSize(a) + ' / ' + scaleSize(b) + ' <small>(' + (b / a * 100.0).toFixed(2) + '%)</small>';
36         stats.time = '<% time(); %>';
37         stats.wanup = '<% wanup(); %>' == '1';
38         stats.wanuptime = '<% link_uptime(); %>';
39         stats.wanlease = '<% dhcpc_time(); %>';
41         //<% dns(); %>
42         stats.dns = dns.join(', ');
44         stats.wanip = nvram.wan_ipaddr;
45         stats.wannetmask = nvram.wan_netmask;
46         stats.wangateway = nvram.wan_gateway;
48         switch (nvram.wan_proto) {
49         case 'pptp':
50                 if (stats.wanup) {
51                         stats.wanip = nvram.pptp_get_ip;
52                         stats.wannetmask = '255.255.255.255';
53                 }
54                 else {
55                         stats.wangateway = nvram.pptp_server_ip;
56                 }
57                 break;
58         case 'l2tp':
59                 if (stats.wanup) {
60                         stats.wanip = nvram.l2tp_get_ip;
61                         stats.wannetmask = '255.255.255.255';
62                 }
63                 break;
64         default:
65                 if (!stats.wanup) {
66                         stats.wanip = '0.0.0.0';
67                         stats.wannetmask = '0.0.0.0';
68                         stats.wangateway = '0.0.0.0';
69                 }
70         }
72         stats.wanstatus = '<% wanstatus(); %>';
73         if (stats.wanstatus != 'Connected') stats.wanstatus = '<b>' + stats.wanstatus + '</b>';
75         a = i = '<% wlchannel(); %>' * 1;
76         if (i < 0) i = -i;
77         if ((i >= 1) && (i <= 14)) {
78                 stats.channel = '<a href="tools-survey.asp">' + i + ' - ' + ghz[i - 1] + ' <small>GHz</small></a>'
79                 if (a < 0) stats.channel += ' <small>(scanning...)</small>';
80         }
81         else if (i == 0) {
82                 stats.channel = 'Auto';
83         }
84         else {
85                 stats.channel = '-';
86         }
88         wlcrssi = wlnoise = stats.qual = '';
89         isClient = ((nvram.wl_mode == 'wet') || (nvram.wl_mode == 'sta'));
90         if (wlradio) {
91                 if (isClient) {
92                         //<% wlnoise(); %>
93                         //<% wlcrssi(); %>
94                         if (wlcrssi == 0) a = 0;
95                                 else a = MAX(wlcrssi - wlnoise, 0);
96                         stats.qual = a + ' <img src="bar' + MIN(MAX(Math.floor(a / 10), 1), 6) + '.gif">';
97                 }
98                 wlnoise += ' <small>dBm</small>';
99                 wlcrssi += ' <small>dBm</small>';
100         }
101 } while (0);