upnp_status.htm 2.1 KB

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