modules/admin-full: template tweaks
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / wifi_status.htm
1 <%+cbi/valueheader%>
2
3 <script type="text/javascript"><![CDATA[
4         var iwxhr = new XHR();
5         (function() {
6                 iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "wireless_status", self.ifname)%>', null,
7                         function(x, iw)
8                         {
9                                 if (iw && (iw = iw[0]))
10                                 {
11                                         var is_assoc = (iw.bssid && iw.channel);
12                                         var p = (100 / iw.quality_max * iw.quality);
13                                         var q = is_assoc ? p : -1;
14
15                                         var icon;
16                                         if (q < 0)
17                                                 icon = "<%=resource%>/icons/signal-none.png";
18                                         else if (q == 0)
19                                                 icon = "<%=resource%>/icons/signal-0.png";
20                                         else if (q < 25)
21                                                 icon = "<%=resource%>/icons/signal-0-25.png";
22                                         else if (q < 50)
23                                                 icon = "<%=resource%>/icons/signal-25-50.png";
24                                         else if (q < 75)
25                                                 icon = "<%=resource%>/icons/signal-50-75.png";
26                                         else
27                                                 icon = "<%=resource%>/icons/signal-75-100.png";
28
29                                         var s = document.getElementById('<%=self.option%>-iw-signal');
30                                         if (s)
31                                                 s.innerHTML = String.format(
32                                                         '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" /><br />' +
33                                                         '<small>%d%%</small>', icon, iw.signal, iw.noise, p
34                                                 );
35
36                                         var d = document.getElementById('<%=self.option%>-iw-description');
37                                         if (d && is_assoc)
38                                                 d.innerHTML = String.format(
39                                                         '<strong><%:Mode%>:</strong> %s | ' +
40                                                         '<strong><%:SSID%>:</strong> %s<br />' +
41                                                         '<strong><%:BSSID%>:</strong> %s | ' +
42                                                         '<strong><%:Encryption%>:</strong> %s<br />' +
43                                                         '<strong><%:Channel%>:</strong> %d (%.3f GHz) | ' +
44                                                         '<strong><%:Tx-Power%>:</strong> %d dBm<br />' +
45                                                         '<strong><%:Signal%>:</strong> %d dBm | ' +
46                                                         '<strong><%:Noise%>:</strong> %d dBm<br />' +
47                                                         '<strong><%:Bit Rate%>:</strong> %.1f MBit/s | ' +
48                                                         '<strong><%:Country%>:</strong> %s',
49                                                                 iw.mode, iw.ssid, iw.bssid,
50                                                                 iw.encryption ? iw.encryption.description : '<%:None%>',
51                                                                 iw.channel, iw.frequency ? (iw.frequency / 1000) : 0,
52                                                                 iw.txpower, iw.signal, iw.noise,
53                                                                 iw.bitrate ? (iw.bitrate / 1000) : 0, iw.country
54                                                 );
55                                         else if (d)
56                                                 d.innerHTML = '<%:Wireless is disabled or not associated%>';
57                                 }
58                         }
59                 )
60
61                 window.setTimeout(arguments.callee, 5000);
62         })();
63 ]]></script>
64
65 <table>
66         <tr class="cbi-section-table">
67                 <td></td>
68                 <td class="cbi-value-field" style="width:16px; padding:3px" id="<%=self.option%>-iw-signal">
69                         <img src="<%=resource%>/icons/signal-none.png" title="<%:Not associated%>" /><br />
70                         <small>0%</small>
71                 </td>
72                 <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-iw-description">
73                         <em><%:Collecting data...%></em>
74                 </td>
75         </tr>
76 </table>
77
78 <%+cbi/valuefooter%>