hna.htm 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <%#
  2. Copyright 2008 Steven Barth <steven@midlink.org>
  3. Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
  4. Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
  5. Licensed to the public under the Apache License 2.0.
  6. -%>
  7. <%
  8. local i = 1
  9. if luci.http.formvalue("status") == "1" then
  10. local rv = {}
  11. for k, hna in ipairs(hna) do
  12. rv[#rv+1] = {
  13. proto = hna["proto"],
  14. destination = hna["destination"],
  15. genmask = hna["genmask"],
  16. gateway = hna["gateway"],
  17. hostname = hna["hostname"],
  18. validityTime = hna["validityTime"]
  19. }
  20. end
  21. luci.http.prepare_content("application/json")
  22. luci.http.write_json(rv)
  23. return
  24. end
  25. %>
  26. <%+header%>
  27. <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
  28. <script type="text/javascript">//<![CDATA[
  29. XHR.poll(10, '<%=REQUEST_URI%>', { status: 1 },
  30. function(x, info)
  31. {
  32. var hnadiv = document.getElementById('olsrd_hna');
  33. if (hnadiv)
  34. {
  35. var s = '';
  36. for (var idx = 0; idx < info.length; idx++)
  37. {
  38. var hna = info[idx];
  39. var linkgw = ''
  40. s += '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + hna.proto + '">'
  41. if (hna.proto == '6') {
  42. linkgw = '<a href="http://[' + hna.gateway + ']/cgi-bin-status.html">' + hna.gateway + '</a>'
  43. } else {
  44. linkgw = '<a href="http://' + hna.gateway + '/cgi-bin-status.html">' + hna.gateway + '</a>'
  45. }
  46. if (hna.validityTime != undefined) {
  47. validity = hna.validityTime + 's'
  48. } else {
  49. validity = '-'
  50. }
  51. if (hna.hostname != undefined) {
  52. hostname = ' / <a href="http://' + hna.hostname + '/cgi-bin-status.html">' + hna.hostname + '</a>'
  53. } else {
  54. hostname = ''
  55. }
  56. s += String.format(
  57. '<td class="cbi-section-table-cell">%s</td>' +
  58. '<td class="cbi-section-table-cell">%s</td>' +
  59. '<td class="cbi-section-table-cell">%s</td>', hna.destination + '/' + hna.genmask, linkgw + hostname, validity
  60. )
  61. s += '</tr>'
  62. }
  63. hnadiv.innerHTML = s;
  64. }
  65. }
  66. );
  67. //]]></script>
  68. <h2><a id="content" name="content"><%:Active host net announcements%></a></h2>
  69. <div id="togglebuttons"></div>
  70. <fieldset class="cbi-section">
  71. <legend><%:Overview of currently active OLSR host net announcements%></legend>
  72. <table class="cbi-section-table">
  73. <thead>
  74. <tr class="cbi-section-table-titles">
  75. <th class="cbi-section-table-cell"><%:Announced network%></th>
  76. <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
  77. <th class="cbi-section-table-cell"><%:Validity Time%></th>
  78. </tr>
  79. </thead>
  80. <tbody id="olsrd_hna">
  81. <% for k, route in ipairs(hna) do %>
  82. <tr class="cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=hna[k].proto%>">
  83. <td class="cbi-section-table-cell"><%=hna[k].destination%>/<%=hna[k].genmask%> </td>
  84. <td class="cbi-section-table-cell">
  85. <% if hna[k].proto == '6' then %>
  86. <a href="http://[<%=hna[k].gateway%>]/cgi-bin-status.html"><%=hna[k].gateway%></a>
  87. <% else %>
  88. <a href="http://<%=hna[k].gateway%>/cgi-bin-status.html"><%=hna[k].gateway%></a>
  89. <% end %>
  90. <% if hna[k].hostname then %>
  91. / <a href="http://<%=hna[k].hostname%>/cgi-bin-status.html"><%=hna[k].hostname%></a>
  92. <% end %>
  93. </td>
  94. <% if hna[k].validityTime then
  95. validity = hna[k].validityTime .. 's'
  96. else
  97. validity = '-'
  98. end %>
  99. <td class="cbi-section-table-cell"><%=validity%></td>
  100. </tr>
  101. <% i = ((i % 2) + 1)
  102. end %>
  103. </tbody>
  104. </table>
  105. </fieldset>
  106. <%+status-olsr/common_js%>
  107. <%+footer%>