upnp_status.htm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script type="text/javascript">//<![CDATA[
  2. function upnp_delete_fwd(idx) {
  3. XHR.get('<%=luci.dispatcher.build_url("admin", "services", "upnp", "delete")%>/' + idx, null,
  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, '<%=luci.dispatcher.build_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 = String.format(
  30. '<input class="cbi-button cbi-input-remove" type="button" value="<%:Delete Redirect%>" onclick="upnp_delete_fwd(%d)" />',
  31. st[i].num
  32. );
  33. }
  34. if( tb.rows.length == 1 )
  35. {
  36. var tr = tb.insertRow(-1);
  37. tr.className = 'cbi-section-table-row';
  38. var td = tr.insertCell(-1);
  39. td.colSpan = 5;
  40. td.innerHTML = '<em><br /><%:There are no active redirects.%></em>';
  41. }
  42. }
  43. }
  44. );
  45. //]]></script>
  46. <fieldset class="cbi-section">
  47. <legend><%:Active UPnP Redirects%></legend>
  48. <table class="cbi-section-table" id="upnp_status_table">
  49. <tr class="cbi-section-table-titles">
  50. <th class="cbi-section-table-cell"><%:Protocol%></th>
  51. <th class="cbi-section-table-cell"><%:External Port%></th>
  52. <th class="cbi-section-table-cell"><%:Client Address%></th>
  53. <th class="cbi-section-table-cell"><%:Client Port%></th>
  54. <th class="cbi-section-table-cell">&#160;</th>
  55. </tr>
  56. <tr class="cbi-section-table-row">
  57. <td colspan="5"><em><br /><%:Collecting data...%></em></td>
  58. </tr>
  59. </table>
  60. </fieldset>