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.
9 local olsrtools = require
"luci.tools.olsr"
12 if luci.http.formvalue(
"status") ==
"1" then
14 for k, link in ipairs(links) do
15 link.linkCost = tonumber(link.linkCost) or
0
16 if link.linkCost ==
4194304 then
19 local color = olsrtools.etx_color(link.linkCost)
20 local snr_color = olsrtools.snr_color(link.snr)
22 if link.defaultgw ==
1 then
23 defaultgw_color =
"#ffff99"
31 lq = string.format(
"%.3f", link.linkQuality),
32 nlq = string.format(
"%.3f",link.neighborLinkQuality),
33 cost = string.format(
"%.3f", link.linkCost),
38 snr_color = snr_color,
39 dfgcolor = defaultgw_color,
43 luci.http.prepare_content(
"application/json")
44 luci.http.write_json(rv)
51 <script type=
"text/javascript" src=
"<%=resource%>/cbi.js"></script>
52 <script type=
"text/javascript">//<![CDATA[
54 XHR.poll(
10 , '<%=REQUEST_URI%
>', { status:
1 },
57 var nt = document.getElementById('olsr_neigh_table');
61 for (var idx =
0; idx < info.length; idx++)
63 var neigh = info[idx];
65 if (neigh.proto == '
6') {
67 '
<div class=
"tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
68 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s"><a href=
"http://[%s]/cgi-bin-status.html">%s
</a></div>',
69 neigh.proto, neigh.dfgcolor, neigh.rip, neigh.rip
73 '
<div class=
"tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-%s">' +
74 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></div>',
75 neigh.proto, neigh.dfgcolor, neigh.rip, neigh.rip
80 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s"><a href=
"http://%s/cgi-bin-status.html">%s
</a></div>',
81 neigh.dfgcolor, neigh.hn, neigh.hn
85 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s">?
</div>',
90 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s">%s
</div>' +
91 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s">%s
</div>' +
92 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s">%s
</div>' +
93 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s">%s
</div>' +
94 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s">%s
</div>' +
95 '
<div class=
"td cbi-section-table-titles" style=
"background-color:%s" title=
"Signal: %s Noise: %s">%s
</div>' +
97 neigh.dfgcolor, neigh.ifn, neigh.dfgcolor, neigh.lip, neigh.dfgcolor, neigh.lq, neigh.dfgcolor, neigh.nlq, neigh.color, neigh.cost, neigh.snr_color, neigh.signal, neigh.noise, neigh.snr || '?'
108 <h2 name=
"content"><%:OLSR connections%
></h2>
110 <div id=
"togglebuttons"></div>
112 <fieldset class=
"cbi-section">
113 <legend><%:Overview of currently established OLSR connections%
></legend>
115 <div class=
"table cbi-section-table">
117 <div class=
"tr cbi-section-table-titles">
118 <div class=
"th cbi-section-table-cell"><%:Neighbour IP%
></div>
119 <div class=
"th cbi-section-table-cell"><%:Hostname%
></div>
120 <div class=
"th cbi-section-table-cell"><%:Interface%
></div>
121 <div class=
"th cbi-section-table-cell"><%:Local interface IP%
></div>
122 <div class=
"th cbi-section-table-cell">LQ
</div>
123 <div class=
"th cbi-section-table-cell">NLQ
</div>
124 <div class=
"th cbi-section-table-cell">ETX
</div>
125 <div class=
"th cbi-section-table-cell">SNR
</div>
129 <div class=
"tbody" id=
"olsr_neigh_table">
131 for k, link in ipairs(links) do
132 link.linkCost = tonumber(link.linkCost) or
0
133 if link.linkCost ==
4194304 then
137 color = olsrtools.etx_color(link.linkCost)
138 snr_color = olsrtools.snr_color(link.snr)
140 if link.snr ==
0 then
145 if link.defaultgw ==
1 then
146 defaultgw_color =
"#ffff99"
150 <div class=
"tr cbi-section-table-row cbi-rowstyle-<%=i%> proto-<%=link.proto%>">
151 <% if link.proto ==
"6" then %
>
152 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://[<%=link.remoteIP%>]/cgi-bin-status.html"><%=link.remoteIP%
></a></div>
154 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link.remoteIP%>/cgi-bin-status.html"><%=link.remoteIP%
></a></div>
156 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><a href=
"http://<%=link.hostname%>/cgi-bin-status.html"><%=link.hostname%
></a></div>
157 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=link.interface%
></div>
158 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=link.localIP%
></div>
159 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=string.format(
"%.3f", link.linkQuality)%
></div>
160 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=defaultgw_color%>"><%=string.format(
"%.3f", link.neighborLinkQuality)%
></div>
161 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=color%>"><%=string.format(
"%.3f", link.linkCost)%
></div>
162 <div class=
"td cbi-section-table-titles" style=
"background-color:<%=snr_color%>" title=
"Signal: <%=link.signal%> Noise: <%=link.noise%>"><%=link.snr%
></div>
171 <%+status-olsr/legend%
>
173 <%+status-olsr/common_js%
>