Tomato 1.28
[tomato/tomato-null.git] / release / src / router / www / status-devices.asp
blob14cb2e795f0a11e81412ff8ab327a6bdee789450
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Status: Device List</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.css'>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <style type='text/css'>
22 #dev-grid .co1 {
23 width: 10%;
25 #dev-grid .co2 {
26 width: 18%;
28 #dev-grid .co3 {
29 width: 17%;
31 #dev-grid .co4 {
32 width: 24%;
34 #dev-grid .co5 {
35 width: 8%;
36 text-align: right;
38 #dev-grid .co6 {
39 width: 8%;
40 text-align: center;
42 #dev-grid .co7 {
43 width: 15%;
44 text-align: right;
46 #dev-grid .header {
47 text-align: left;
49 </style>
51 <script type='text/javascript' src='debug.js'></script>
53 <script type='text/javascript'>
55 ipp = '<% lipp(); %>.';
56 //<% nvram('lan_ifname,wl_ifname,wl_mode,wl_radio'); %>
57 // <% devlist(); %>
59 list = [];
61 function find(mac, ip)
63 var e, i;
65 mac = mac.toUpperCase();
66 for (i = list.length - 1; i >= 0; --i) {
67 e = list[i];
68 if (((e.mac == mac) && ((e.ip == ip) || (e.ip == '') || (ip == null))) ||
69 ((e.mac == '00:00:00:00:00:00') && (e.ip == ip))) {
70 return e;
73 return null;
76 function get(mac, ip)
78 var e, i;
80 mac = mac.toUpperCase();
81 if ((e = find(mac, ip)) != null) {
82 if (ip) e.ip = ip;
83 return e;
86 e = {
87 mac: mac,
88 ip: ip || '',
89 ifname: '',
90 name: '',
91 rssi: '',
92 lease: ''
94 list.push(e);
96 return e;
100 var xob = null;
102 function _deleteLease(ip)
104 form.submitHidden('dhcpd.cgi', { remove: ip });
107 function deleteLease(a, ip)
109 if (xob) return;
110 if ((xob = new XmlHttp()) == null) {
111 _deleteLease(ip);
112 return;
115 a = E(a);
116 a.innerHTML = 'deleting...';
118 xob.onCompleted = function(text, xml) {
119 a.innerHTML = '...';
120 xob = null;
122 xob.onError = function() {
123 _deleteLease(ip);
126 xob.post('dhcpd.cgi', 'remove=' + ip);
129 function addStatic(n)
131 var e = list[n];
132 cookie.set('addstatic', [e.mac, e.ip, e.name.split(',')[0]].join(','), 1);
133 location.href = 'basic-static.asp';
136 function addWF(n)
138 var e = list[n];
139 cookie.set('addmac', [e.mac, e.name.split(',')[0]].join(','), 1);
140 location.href = 'basic-wfilter.asp';
144 var ref = new TomatoRefresh('update.cgi', 'exec=devlist', 0, 'status_devices_refresh');
146 ref.refresh = function(text)
148 eval(text);
149 dg.removeAllData();
150 dg.populate();
151 dg.resort();
152 E("noise").innerHTML = wlnoise;
156 var dg = new TomatoGrid();
158 dg.sortCompare = function(a, b) {
159 var col = this.sortColumn;
160 var ra = a.getRowData();
161 var rb = b.getRowData();
162 var r;
164 switch (col) {
165 case 2:
166 r = cmpIP(ra.ip, rb.ip);
167 break;
168 case 4:
169 r = cmpInt(ra.rssi, rb.rssi);
170 break;
171 case 5:
172 r = cmpInt(ra.qual, rb.qual);
173 break;
174 default:
175 r = cmpText(a.cells[col].innerHTML, b.cells[col].innerHTML);
177 if (r == 0) {
178 r = cmpIP(ra.ip, rb.ip);
179 if (r == 0) r = cmpText(ra.ifname, rb.ifname);
181 return this.sortAscending ? r : -r;
184 dg.populate = function()
186 var i, j;
187 var a, b, c, e;
189 list = [];
191 for (i = 0; i < list.length; ++i) {
192 list[i].ip = '';
193 list[i].ifname = '';
194 list[i].name = '';
195 list[i].rssi = '';
196 list[i].lease = '';
199 for (i = dhcpd_lease.length - 1; i >= 0; --i) {
200 a = dhcpd_lease[i];
201 e = get(a[2], a[1]);
202 e.lease = '<small><a href="javascript:deleteLease(\'L' + i + '\',\'' + a[1] + '\')" title="Delete Lease" id="L' + i + '">' + a[3] + '</a></small>';
203 e.name = a[0];
204 e.ifname = nvram.lan_ifname;
207 for (i = wldev.length - 1; i >= 0; --i) {
208 a = wldev[i];
209 if (a[0].indexOf('wds') == 0) {
210 e = get(a[1], '-');
211 e.ifname = a[0];
213 else {
214 e = get(a[1], null);
215 e.ifname = nvram.wl_ifname;
217 e.rssi = a[2];
220 for (i = arplist.length - 1; i >= 0; --i) {
221 a = arplist[i];
223 if ((e = get(a[1], a[0])) != null) {
224 if (e.ifname == '') e.ifname = a[2];
228 for (i = dhcpd_static.length - 1; i >= 0; --i) {
229 a = dhcpd_static[i].split('<');
230 if (a.length < 3) continue;
232 if (a[1].indexOf('.') == -1) a[1] = (ipp + a[1]);
234 c = a[0].split(',');
235 for (j = c.length - 1; j >= 0; --j) {
236 if ((e = find(c[j], a[1])) != null) break;
238 if (j < 0) continue;
240 if (e.name == '') {
241 e.name = a[2];
243 else {
244 b = e.name.toLowerCase();
245 c = a[2].toLowerCase();
246 if ((b.indexOf(c) == -1) && (c.indexOf(b) == -1)) {
247 if (e.name != '') e.name += ', ';
248 e.name += a[2];
253 for (i = list.length - 1; i >= 0; --i) {
254 e = list[i];
256 b = e.mac;
257 if (e.mac.match(/^(..):(..):(..)/)) {
258 b += '<br><small>' +
259 '<a href="http://standards.ieee.org/cgi-bin/ouisearch?' + RegExp.$1 + '-' + RegExp.$2 + '-' + RegExp.$3 + '" target="_new" title="OUI Search">[oui]</a> ' +
260 '<a href="javascript:addStatic(' + i + ')" title="Static Lease...">[static]</a>';
262 if (e.rssi != '') {
263 b += ' <a href="javascript:addWF(' + i + ')" title="Wireless Filter...">[wfilter]</a>';
265 b += '</small>';
267 else {
268 b = '';
271 if ((e.rssi !== '') && (wlnoise < 0)) {
272 e.qual = MAX(e.rssi - wlnoise, 0);
274 else {
275 e.qual = -1;
278 this.insert(-1, e, [
279 e.ifname, b, (e.ip == '-') ? '' : e.ip, e.name,
280 (e.rssi != 0) ? e.rssi + ' <small>dBm</small>' : '',
281 (e.qual < 0) ? '' : '<small>' + e.qual + '</small> <img src="bar' + MIN(MAX(Math.floor(e.qual / 10), 1), 6) + '.gif">',
282 e.lease], false);
286 dg.setup = function()
288 this.init('dev-grid', 'sort');
289 this.headerSet(['Interface', 'MAC Address', 'IP Address', 'Name', 'RSSI &nbsp; &nbsp; ', 'Quality', 'Lease &nbsp; &nbsp; ']);
290 this.populate();
291 this.sort(2);
294 function earlyInit()
296 dg.setup();
299 function init()
301 dg.recolor();
302 ref.initPage(3000, 3);
304 </script>
305 </head>
306 <body onload='init()'>
307 <table id='container' cellspacing=0>
308 <tr><td colspan=2 id='header'>
309 <div class='title'>Tomato</div>
310 <div class='version'>Version <% version(); %></div>
311 </td></tr>
312 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
313 <td id='content'>
314 <div id='ident'><% ident(); %></div>
316 <!-- / / / -->
318 <div class='section-title'>Device List</div>
319 <div class='section'>
320 <table id='dev-grid' class='tomato-grid' cellspacing=0></table>
321 <script type='text/javascript'>
322 if (nvram.wl_radio == '1') {
323 W('<div style="float:left"><b>Noise Floor:</b> <span id="noise">' + wlnoise + '</span> <small>dBm</small>');
324 if ((nvram.wl_mode == 'ap') || (nvram.wl_mode == 'wds')) {
325 W(' &nbsp; <input type="button" value="Measure" onclick="javascript:window.location=\'wlmnoise.cgi?_http_id=' + nvram.http_id + '\'">');
327 W('</div>');
329 </script>
331 </div>
333 <!-- / / / -->
335 </td></tr>
336 <tr><td id='footer' colspan=2><script type='text/javascript'>genStdRefresh(1,0,'ref.toggle()');</script></td></tr>
337 </table>
338 <script type='text/javascript'>earlyInit();</script>
339 </body>
340 </html>