Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / www / tools-wol.asp
blob9fb9a511edbd79dff29cbba7cb2f8b99b1739267
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(); %>] Tools: WOL</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 <script type='text/javascript' src='debug.js'></script>
23 <style type='text/css'>
24 #wol-grid .co1 {
25 width: 15%;
27 #wol-grid .co2 {
28 width: 15%;
30 #wol-grid .co3 {
31 width: 25%;
33 #wol-grid .co4 {
34 width: 45%;
36 textarea {
37 width: 99%;
38 height: 8em;
40 #refreshb, #save-button {
41 width: 90px;
43 </style>
45 <script type='text/javascript'>
47 // <% arplist(); %>
48 // <% nvram('dhcpd_static,lan_ifname'); %>
50 var wg = new TomatoGrid();
51 wg.setup = function() {
52 this.init('wol-grid', 'sort');
53 this.headerSet(['MAC Address', 'IP Address', 'Status', 'Name']);
54 this.sort(3);
56 wg.sortCompare = function(a, b) {
57 var da = a.getRowData();
58 var db = b.getRowData();
59 var r = 0;
60 var c = this.sortColumn;
61 if (c == 1)
62 r = cmpIP(da[c], db[c]);
63 else
64 r = cmpText(da[c], db[c]);
65 return this.sortAscending ? r : -r;
67 wg.populate = function()
69 var i, j, r, s;
71 this.removeAllData();
73 s = [];
74 var q = nvram.dhcpd_static.split('>');
75 for (i = 0; i < q.length; ++i) {
76 var e = q[i].split('<');
77 if ((e.length == 3) || (e.length == 4)) {
78 var m = e[0].split(',');
79 for (j = 0; j < m.length; ++j) {
80 s.push([m[j], e[1], e[2]]);
85 // show entries in static dhcp list
86 for (i = 0; i < s.length; ++i) {
87 var t = s[i];
88 var active = '-';
89 for (j = 0; j < arplist.length; ++j) {
90 if ((arplist[j][2] == nvram.lan_ifname) && (t[0] == arplist[j][1])) {
91 active = 'Active (In ARP)';
92 arplist[j][1] = '!';
93 break;
96 if (t.length == 3) {
97 r = this.insertData(-1, [t[0], (t[1].indexOf('.') != -1) ? t[1] : ('<% lipp(); %>.' + t[1]), active, t[2]]);
98 for (j = 0; j < 4; ++j)
99 r.cells[j].title = 'Click to wake up';
103 // show anything else in ARP that is awake
104 for (i = 0; i < arplist.length; ++i) {
105 if ((arplist[i][2] != nvram.lan_ifname) || (arplist[i][1].length != 17)) continue;
106 r = this.insertData(-1, [arplist[i][1], arplist[i][0], 'Active (In ARP)', '']);
107 for (j = 0; j < 4; ++j)
108 r.cells[j].title = 'Click to wake up';
111 this.resort(2);
113 wg.onClick = function(cell)
115 wake(PR(cell).getRowData()[0]);
118 function verifyFields(focused, quiet)
120 var e;
122 e = E('_f_mac');
123 e.value = e.value.replace(/[\t ]+/g, ' ');
124 return 1;
127 function spin(x)
129 E('refreshb').disabled = x;
130 E('wakeb').disabled = x;
133 var waker = null;
135 function wake(mac)
137 if (!mac) {
138 if (!verifyFields(null, 1)) return;
139 mac = E('_f_mac').value;
140 cookie.set('wakemac', mac);
142 E('_mac').value = mac;
143 form.submit('_fom', 1);
148 var refresher = null;
149 var timer = new TomatoTimer(refresh);
150 var running = 0;
152 function refresh()
154 if (!running) return;
156 timer.stop();
158 refresher = new XmlHttp();
159 refresher.onCompleted = function(text, xml) {
160 eval(text);
161 wg.populate();
162 timer.start(5000);
163 refresher = null;
165 refresher.onError = function(ex) { alert(ex); reloadPage(); }
166 refresher.post('update.cgi', 'exec=arplist');
169 function refreshClick()
171 running ^= 1;
172 E('refreshb').value = running ? 'Stop' : 'Refresh';
173 E('spin').style.visibility = running ? 'visible' : 'hidden';
174 if (running) refresh();
177 function init()
179 wg.recolor();
181 </script>
183 </head>
184 <body onload='init()'>
185 <form id='_fom' action='wakeup.cgi' method='post'>
186 <table id='container' cellspacing=0>
187 <tr><td colspan=2 id='header'>
188 <div class='title'>Tomato</div>
189 <div class='version'>Version <% version(); %></div>
190 </td></tr>
191 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
192 <td id='content'>
193 <div id='ident'><% ident(); %></div>
195 <!-- / / / -->
197 <input type='hidden' name='_redirect' value='tools-wol.asp'>
198 <input type='hidden' name='_nextwait' value='1'>
199 <input type='hidden' name='mac' value='' id='_mac'>
201 <div class='section-title'>Wake On LAN</div>
202 <div class='section'>
203 <table id='wol-grid' class='tomato-grid' cellspacing=1></table>
204 <div style='float:right'><img src='spin.gif' id='spin' style='vertical-align:middle;visibility:hidden'> &nbsp; <input type='button' value='Refresh' onclick='refreshClick()' id='refreshb'></div>
205 </div>
206 <div id='msg' style='visibility:hidden;background:#ffffa0;margin:auto;width:50%;text-align:center;padding:2px;border:1px solid #fee'></div>
207 <div class='section-title'></div>
208 <div class='section'>
209 <script type='text/javascript'>
210 createFieldTable('', [
211 { title: 'MAC Address List', name: 'f_mac', type: 'textarea', value: cookie.get('wakemac') || '' },
213 </script>
214 <div style='float:right'><input type='button' value='Wake Up' onclick='wake(null)' id='save-button'></div>
215 </div>
217 <!-- / / / -->
219 </td></tr>
220 <tr><td id='footer' colspan=2>&nbsp;</td></tr>
221 </table>
222 </form>
223 <script type='text/javascript'>wg.setup();wg.populate();</script>
224 </body>
225 </html>