+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript"><![CDATA[
+ var iwxhr = new XHR();
+ var wifidevs = <%=luci.http.write_json(netdevs)%>;
+ var arptable = <%=luci.http.write_json(arpcache)%>;
+
+ (function() {
+ iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "wireless_status", table.concat(netlist, ","))%>', null,
+ function(x)
+ {
+ var st = x.responseText ? eval('(' + x.responseText + ')') : null;
+ if (st)
+ {
+ var assoctable = document.getElementById('iw-assoclist');
+ if (assoctable)
+ while (assoctable.rows.length > 1)
+ assoctable.rows[1].parentNode.removeChild(assoctable.rows[1]);
+
+ for( var i = 0; i < st.length; i++ )
+ {
+ var iw = st[i];
+ var p = (100 / iw.quality_max * iw.quality);
+ var q = (iw.bssid && iw.channel) ? p : -1;
+
+ var icon;
+ if (q < 0)
+ icon = "<%=resource%>/icons/signal-none.png";
+ else if (q == 0)
+ icon = "<%=resource%>/icons/signal-0.png";
+ else if (q < 25)
+ icon = "<%=resource%>/icons/signal-0-25.png";
+ else if (q < 50)
+ icon = "<%=resource%>/icons/signal-25-50.png";
+ else if (q < 75)
+ icon = "<%=resource%>/icons/signal-50-75.png";
+ else
+ icon = "<%=resource%>/icons/signal-75-100.png";
+
+ var sig = document.getElementById(iw.id + '-iw-signal');
+ if (sig)
+ sig.innerHTML = String.format(
+ '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" /><br />' +
+ '<small>%d%%</small>', icon, iw.signal, iw.noise, p
+ );
+
+ var info = document.getElementById(iw.id + '-iw-status');
+ if (info)
+ info.innerHTML = String.format(
+ '<strong><%:SSID%>:</strong> %s | ' +
+ '<strong><%:Mode%>:</strong> %s<br />' +
+ '<strong><%:BSSID%>:</strong> %s | ' +
+ '<strong><%:Encryption%>:</strong> %s',
+ iw.ssid, iw.mode, iw.bssid,
+ iw.encryption ? iw.encryption.description : '<%:None%>'
+ );
+
+ var dev = document.getElementById(wifidevs[iw.id] + '-iw-devinfo');
+ if (dev)
+ dev.innerHTML = String.format(
+ '<strong><%:Channel%>:</strong> %s (%s GHz) | ' +
+ '<strong><%:Bitrate%>:</strong> %s Mb/s',
+ iw.channel ? iw.channel : '?',
+ iw.frequency ? iw.frequency / 1000 : '?',
+ iw.bitrate ? iw.bitrate / 1000 : '?'
+ );
+
+ if (assoctable)
+ {
+ var assoclist = [ ];
+ for( var bssid in iw.assoclist )
+ {
+ assoclist.push(iw.assoclist[bssid]);
+ assoclist[assoclist.length-1].bssid = bssid;
+ }
+
+ assoclist.sort(function(a, b) { a.bssid < b.bssid });
+
+ for( var j = 0; j < assoclist.length; j++ )
+ {
+ var tr = document.createElement('tr');
+ tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((j % 2) + (i % 2));
+
+ var icon;
+ var q = (-1 * (assoclist[j].noise - assoclist[j].signal)) / 5;
+ if (q < 1)
+ icon = "<%=resource%>/icons/signal-0.png";
+ else if (q < 2)
+ icon = "<%=resource%>/icons/signal-0-25.png";
+ else if (q < 3)
+ icon = "<%=resource%>/icons/signal-25-50.png";
+ else if (q < 4)
+ icon = "<%=resource%>/icons/signal-50-75.png";
+ else
+ icon = "<%=resource%>/icons/signal-75-100.png";
+
+ tr.innerHTML = String.format(
+ '<td class="cbi-value-field">' +
+ '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" />' +
+ '</td>' +
+ '<td class="cbi-value-field">%s</td>' +
+ '<td class="cbi-value-field">%s</td>' +
+ '<td class="cbi-value-field">%s</td>' +
+ '<td class="cbi-value-field">%d dBm</td>' +
+ '<td class="cbi-value-field">%d dBm</td>',
+ icon,
+ assoclist[j].signal, assoclist[j].noise,
+ iw.ssid ? iw.ssid : '?',
+ assoclist[j].bssid,
+ arptable[assoclist[j].bssid]
+ ? arptable[assoclist[j].bssid] : '?',
+ assoclist[j].signal, assoclist[j].noise
+ );
+
+ assoctable.rows[0].parentNode.appendChild(tr);
+ }
+ }
+ }
+
+ if (assoctable && assoctable.rows.length == 1)
+ {
+ var tr = document.createElement('tr');
+ tr.className = 'cbi-section-table-row';
+
+ tr.innerHTML = '<td class="cbi-value-field" colspan="6"><br /><em><%:No information available%></em></td>';
+
+ assoctable.rows[0].parentNode.appendChild(tr);
+ }
+ }
+ }
+ )
+
+ window.setTimeout(arguments.callee, 5000);
+ })();
+]]></script>
+