trunk: s/ / /g
[project/luci.git] / applications / luci-upnp / luasrc / view / upnp_status.htm
1 <script type="text/javascript">//<![CDATA[
2         function upnp_delete_fwd(idx) {
3                 var dlxhr = new XHR();
4
5                 dlxhr.get('<%=luci.dispatcher.build_url("admin", "services", "upnp", "delete")%>/' + idx, null,
6                         function(x)
7                         {
8                                 var tb = document.getElementById('upnp_status_table');
9                                 if (tb && (idx < tb.rows.length))
10                                         tb.rows[0].parentNode.removeChild(tb.rows[idx]);
11                         }
12                 );
13         }
14
15         var stxhr = new XHR();
16         var update_status = function() {
17                 stxhr.get('<%=luci.dispatcher.build_url("admin", "services", "upnp", "status")%>', null,
18                         function(x, st)
19                         {
20                                 var tb = document.getElementById('upnp_status_table');
21                                 if (st && tb)
22                                 {
23                                         /* clear all rows */
24                                         while( tb.rows.length > 1 )
25                                                 tb.deleteRow(1);
26
27                                         for( var i = 0; i < st.length; i++ )
28                                         {
29                                                 var tr = tb.insertRow(-1);
30                                                         tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
31
32                                                 tr.insertCell(-1).innerHTML = st[i].proto;
33                                                 tr.insertCell(-1).innerHTML = st[i].extport;
34                                                 tr.insertCell(-1).innerHTML = st[i].intaddr;
35                                                 tr.insertCell(-1).innerHTML = st[i].intport;
36
37                                                 tr.insertCell(-1).innerHTML = String.format(
38                                                         '<input class="cbi-input-remove" type="button" value="<%:Delete Redirect%>" onclick="upnp_delete_fwd(%d)" />',
39                                                                 st[i].num
40                                                 );
41                                         }
42
43                                         if( tb.rows.length == 1 )
44                                         {
45                                                 var tr = tb.insertRow(-1);
46                                                         tr.className = 'cbi-section-table-row';
47
48                                                 var td = tr.insertCell(-1);
49                                                         td.colSpan = 5;
50                                                         td.innerHTML = '<em><br /><%:There are no active redirects.%></em>';
51                                         }
52                                 }
53
54                                 window.setTimeout(update_status, 5000);
55                         }
56                 )
57         };
58
59         update_status();
60 //]]></script>
61
62 <fieldset class="cbi-section">
63         <legend><%:Active UPnP Redirects%></legend>
64         <table class="cbi-section-table" id="upnp_status_table">
65                 <tr class="cbi-section-table-titles">
66                         <th class="cbi-section-table-cell"><%:Protocol%></th>
67                         <th class="cbi-section-table-cell"><%:External Port%></th>
68                         <th class="cbi-section-table-cell"><%:Client Address%></th>
69                         <th class="cbi-section-table-cell"><%:Client Port%></th>
70                         <th class="cbi-section-table-cell">&#160;</th>
71                 </tr>
72                 <tr class="cbi-section-table-row">
73                         <td colspan="5"><em><br /><%:Collecting data...%></em></td>
74                 </tr>
75         </table>
76 </fieldset>