1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
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.
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>
21 <script type='text/javascript' src='debug.js'
></script>
23 <style type='text/css'
>
40 #refreshb, #save-button
{
45 <script type='text/javascript'
>
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']);
56 wg
.populate = function()
63 var q
= nvram
.dhcpd_static
.split('>');
64 for (i
= 0; i
< q
.length
; ++i
) {
65 var e
= q
[i
].split('<');
66 if ((e
.length
== 3) || (e
.length
== 4)) {
67 var m
= e
[0].split(',');
68 for (j
= 0; j
< m
.length
; ++j
) {
69 s
.push([m
[j
], e
[1], e
[2]]);
74 // show entries in static dhcp list
75 for (i
= 0; i
< s
.length
; ++i
) {
78 for (j
= 0; j
< arplist
.length
; ++j
) {
79 if ((arplist
[j
][2] == nvram
.lan_ifname
) && (t
[0] == arplist
[j
][1])) {
80 active
= 'Active (In ARP)';
86 r
= this.insertData(-1, [t
[0], (t
[1].indexOf('.') != -1) ? t
[1] : ('<% lipp(); %>.' + t
[1]), active
, t
[2]]);
87 for (j
= 0; j
< 4; ++j
)
88 r
.cells
[j
].title
= 'Click to wake up';
92 // show anything else in ARP that is awake
93 for (i
= 0; i
< arplist
.length
; ++i
) {
94 if ((arplist
[i
][2] != nvram
.lan_ifname
) || (arplist
[i
][1].length
!= 17)) continue;
95 r
= this.insertData(-1, [arplist
[i
][1], arplist
[i
][0], 'Active (In ARP)', '']);
96 for (j
= 0; j
< 4; ++j
)
97 r
.cells
[j
].title
= 'Click to wake up';
102 wg
.onClick = function(cell
)
104 wake(PR(cell
).getRowData()[0]);
107 function verifyFields(focused
, quiet
)
112 e
.value
= e
.value
.replace(/[\t ]+/g, ' ');
118 E('refreshb').disabled
= x
;
119 E('wakeb').disabled
= x
;
127 if (!verifyFields(null, 1)) return;
128 mac
= E('_f_mac').value
;
129 cookie
.set('wakemac', mac
);
131 E('_mac').value
= mac
;
132 form
.submit('_fom', 1);
137 var refresher
= null;
138 var timer
= new TomatoTimer(refresh
);
143 if (!running
) return;
147 refresher
= new XmlHttp();
148 refresher
.onCompleted = function(text
, xml
) {
154 refresher
.onError = function(ex
) { alert(ex
); reloadPage(); }
155 refresher
.post('update.cgi', 'exec=arplist');
158 function refreshClick()
161 E('refreshb').value
= running
? 'Stop' : 'Refresh';
162 E('spin').style
.visibility
= running
? 'visible' : 'hidden';
163 if (running
) refresh();
173 <body onload='init()'
>
174 <form id='_fom' action='wakeup.cgi' method='post'
>
175 <table id='container' cellspacing=
0>
176 <tr><td colspan=
2 id='header'
>
177 <div class='title'
>Tomato
</div>
178 <div class='version'
>Version <%
version(); %></div>
180 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
182 <div id='ident'
><%
ident(); %></div>
186 <input type='hidden' name='_redirect' value='tools-wol.asp'
>
187 <input type='hidden' name='_nextwait' value='
1'
>
188 <input type='hidden' name='mac' value='' id='_mac'
>
190 <div class='section-title'
>Wake On LAN
</div>
191 <div class='section'
>
192 <table id='wol-grid' class='tomato-grid' cellspacing=
1></table>
193 <div style='float:right'
><img src='spin.gif' id='spin' style='vertical-align:middle;visibility:hidden'
> <input type='button' value='Refresh' onclick='refreshClick()' id='refreshb'
></div>
195 <div id='msg' style='visibility:hidden;background:#ffffa0;margin:auto;width:
50%;text-align:center;padding:
2px;border:
1px solid #fee'
></div>
196 <div class='section-title'
></div>
197 <div class='section'
>
198 <script type='text/javascript'
>
199 createFieldTable('', [
200 { title
: 'MAC Address List', name
: 'f_mac', type
: 'textarea', value
: cookie
.get('wakemac') || '' },
203 <div style='float:right'
><input type='button' value='Wake Up' onclick='wake(null)' id='save-button'
></div>
209 <tr><td id='footer' colspan=
2> </td></tr>
212 <script type='text/javascript'
>wg
.setup();wg
.populate();</script>