treewide: always include cbi.js
[project/luci.git] / applications / luci-app-olsr / luasrc / view / status-olsr / hna.htm
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 <%
9 local i = 1
10
11 if luci.http.formvalue("status") == "1" then
12 local rv = {}
13 for k, hna in ipairs(hna) do
14 rv[#rv+1] = {
15 proto = hna["proto"],
16 destination = hna["destination"],
17 genmask = hna["genmask"],
18 gateway = hna["gateway"],
19 hostname = hna["hostname"],
20 validityTime = hna["validityTime"]
21 }
22 end
23 luci.http.prepare_content("application/json")
24 luci.http.write_json(rv)
25 return
26 end
27 %>
28
29 <%+header%>
30
31 <script type="text/javascript">//<![CDATA[
32 XHR.poll(10, '<%=REQUEST_URI%>', { status: 1 },
33 function(x, info)
34 {
35 var hnadiv = document.getElementById('olsrd_hna');
36 if (hnadiv)
37 {
38 var s = '';
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
50 if (hna.validityTime != undefined) {
51 validity = hna.validityTime + 's'
52 } else {
53 validity = '-'
54 }
55
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
62 s += String.format(
63 '<div class="td cbi-section-table-cell">%s</div>' +
64 '<div class="td cbi-section-table-cell">%s</div>' +
65 '<div class="td cbi-section-table-cell">%s</div>', hna.destination + '/' + hna.genmask, linkgw + hostname, validity
66 )
67 s += '</div>'
68 }
69 hnadiv.innerHTML = s;
70 }
71 }
72 );
73 //]]></script>
74
75 <h2 name="content"><%:Active host net announcements%></h2>
76
77 <div id="togglebuttons"></div>
78 <fieldset class="cbi-section">
79
80 <legend><%:Overview of currently active OLSR host net announcements%></legend>
81 <div class="table cbi-section-table">
82 <div class="thead">
83 <div class="tr cbi-section-table-titles">
84 <div class="th cbi-section-table-cell"><%:Announced network%></div>
85 <div class="th cbi-section-table-cell"><%:OLSR gateway%></div>
86 <div class="th cbi-section-table-cell"><%:Validity Time%></div>
87 </div>
88
89 </div>
90 <div class="tbody" id="olsrd_hna">
91 <% for k, route in ipairs(hna) do %>
92
93 <div class="tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=hna[k].proto%>">
94 <div class="td cbi-section-table-cell"><%=hna[k].destination%>/<%=hna[k].genmask%> </div>
95 <div class="td cbi-section-table-cell">
96 <% if hna[k].proto == '6' then %>
97 <a href="http://[<%=hna[k].gateway%>]/cgi-bin-status.html"><%=hna[k].gateway%></a>
98 <% else %>
99 <a href="http://<%=hna[k].gateway%>/cgi-bin-status.html"><%=hna[k].gateway%></a>
100 <% end %>
101 <% if hna[k].hostname then %>
102 / <a href="http://<%=hna[k].hostname%>/cgi-bin-status.html"><%=hna[k].hostname%></a>
103 <% end %>
104 </div>
105 <% if hna[k].validityTime then
106 validity = hna[k].validityTime .. 's'
107 else
108 validity = '-'
109 end %>
110
111 <div class="td cbi-section-table-cell"><%=validity%></div>
112 </div>
113
114 <% i = ((i % 2) + 1)
115 end %>
116 </div>
117 </div>
118 </fieldset>
119
120 <%+status-olsr/common_js%>
121 <%+footer%>