2
0

hna.htm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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">//<![CDATA[
  28. XHR.poll(10, '<%=REQUEST_URI%>', { status: 1 },
  29. function(x, info)
  30. {
  31. var hnadiv = document.getElementById('olsrd_hna');
  32. if (hnadiv)
  33. {
  34. var s = '<div class="tr cbi-section-table-titles">' +
  35. '<div class="th cbi-section-table-cell"><%:Announced network%></div>' +
  36. '<div class="th cbi-section-table-cell"><%:OLSR gateway%></div>' +
  37. '<div class="th cbi-section-table-cell"><%:Validity Time%></div>' +
  38. '</div>';
  39. for (var idx = 0; idx < info.length; idx++)
  40. {
  41. var hna = info[idx];
  42. var linkgw = ''
  43. s += '<div class="tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + hna.proto + '">'
  44. if (hna.proto == '6') {
  45. linkgw = '<a href="http://[' + hna.gateway + ']/cgi-bin-status.html">' + hna.gateway + '</a>'
  46. } else {
  47. linkgw = '<a href="http://' + hna.gateway + '/cgi-bin-status.html">' + hna.gateway + '</a>'
  48. }
  49. var validity;
  50. if (hna.validityTime != undefined) {
  51. validity = hna.validityTime + 's'
  52. } else {
  53. validity = '-'
  54. }
  55. var hostname;
  56. if (hna.hostname != undefined) {
  57. hostname = ' / <a href="http://' + hna.hostname + '/cgi-bin-status.html">' + hna.hostname + '</a>'
  58. } else {
  59. hostname = ''
  60. }
  61. s += String.format(
  62. '<div class="td cbi-section-table-cell left">%s</div>' +
  63. '<div class="td cbi-section-table-cell left">%s</div>' +
  64. '<div class="td cbi-section-table-cell left">%s</div>', hna.destination + '/' + hna.genmask, linkgw + hostname, validity
  65. )
  66. s += '</div>'
  67. }
  68. hnadiv.innerHTML = s;
  69. }
  70. }
  71. );
  72. //]]></script>
  73. <h2 name="content"><%:Active host net announcements%></h2>
  74. <div id="togglebuttons"></div>
  75. <fieldset class="cbi-section">
  76. <legend><%:Overview of currently active OLSR host net announcements%></legend>
  77. <div class="table cbi-section-table" id="olsrd_hna">
  78. <div class="tr cbi-section-table-titles">
  79. <div class="th cbi-section-table-cell"><%:Announced network%></div>
  80. <div class="th cbi-section-table-cell"><%:OLSR gateway%></div>
  81. <div class="th cbi-section-table-cell"><%:Validity Time%></div>
  82. </div>
  83. <% for k, route in ipairs(hna) do %>
  84. <div class="tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=hna[k].proto%>">
  85. <div class="td cbi-section-table-cell left"><%=hna[k].destination%>/<%=hna[k].genmask%> </div>
  86. <div class="td cbi-section-table-cell left">
  87. <% if hna[k].proto == '6' then %>
  88. <a href="http://[<%=hna[k].gateway%>]/cgi-bin-status.html"><%=hna[k].gateway%></a>
  89. <% else %>
  90. <a href="http://<%=hna[k].gateway%>/cgi-bin-status.html"><%=hna[k].gateway%></a>
  91. <% end %>
  92. <% if hna[k].hostname then %>
  93. / <a href="http://<%=hna[k].hostname%>/cgi-bin-status.html"><%=hna[k].hostname%></a>
  94. <% end %>
  95. </div>
  96. <% if hna[k].validityTime then
  97. validity = hna[k].validityTime .. 's'
  98. else
  99. validity = '-'
  100. end %>
  101. <div class="td cbi-section-table-cell left"><%=validity%></div>
  102. </div>
  103. <% i = ((i % 2) + 1)
  104. end %>
  105. </div>
  106. </fieldset>
  107. <%+status-olsr/common_js%>
  108. <%+footer%>