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