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