1 requestAnimationFrame(function() {
2 document.querySelectorAll('[data-wifi-status]').forEach(function(container) {
3 var ifname = container.getAttribute('data-wifi-status'),
4 small = container.querySelector('small'),
5 info = container.querySelector('span');
7 L.poll(5, L.url('admin/network/wireless_status', ifname), null, function(xhr, iws) {
8 var iw = Array.isArray(iws) ? iws[0] : null;
12 var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && !iw.disabled);
14 var q = iw.disabled ? -1 : p;
18 icon = L.resource('icons/signal-none.png');
20 icon = L.resource('icons/signal-0.png');
22 icon = L.resource('icons/signal-0-25.png');
24 icon = L.resource('icons/signal-25-50.png');
26 icon = L.resource('icons/signal-50-75.png');
28 icon = L.resource('icons/signal-75-100.png');
30 L.dom.content(small, [
33 title: '%s: %d %s / %s: %d %s'.format(
34 _('Signal'), iw.signal, _('dBm'),
35 _('Noise'), iw.noise, _('dBm'))
37 '\u00a0', E('br'), '%d%%\u00a0'.format(p)
42 _('SSID'), '%h'.format(iw.ssid || '?'),
43 _('BSSID'), is_assoc ? iw.bssid : null,
44 _('Encryption'), is_assoc ? iw.encryption || _('None') : null,
45 _('Channel'), is_assoc ? '%d (%.3f %s)'.format(iw.channel, iw.frequency || 0, _('GHz')) : null,
46 _('Tx-Power'), is_assoc ? '%d %s'.format(iw.txpower, _('dBm')) : null,
47 _('Signal'), is_assoc ? '%d %s'.format(iw.signal, _('dBm')) : null,
48 _('Noise'), is_assoc ? '%d %s'.format(iw.noise, _('dBm')) : null,
49 _('Bitrate'), is_assoc ? '%.1f %s'.format(iw.bitrate || 0, _('Mbit/s')) : null,
50 _('Country'), is_assoc ? iw.country : null
51 ], [ ' | ', E('br'), E('br'), E('br'), E('br'), E('br'), ' | ', E('br'), ' | ' ]);
54 L.dom.append(info, E('em', iw.disabled ? _('Wireless is disabled') : _('Wireless is not associated')));