()
| 1959 | }); |
| 1960 | } |
| 1961 | |
| 1962 | function _wifiHitTest(canvas, x, y) { |
| 1963 | const hits = (canvas && canvas._wifiHits) || []; |
| 1964 | if (!_wifiState.data) return null; |
| 1965 | // Reverse: hits are pushed weakest-first, so the last match is the one |
| 1966 | // drawn on top at this pixel. |
| 1967 | for (let i = hits.length - 1; i >= 0; i--) { |
| 1968 | const h = hits[i]; |
| 1969 | if (x >= h.x0 && x <= h.x1 && y >= h.y0 && y <= h.y1) return h; |
| 1970 | } |
| 1971 | return null; |
| 1972 | } |
| 1973 | |
| 1974 | // "ch 6.4 · 2437 MHz · −72 dBm" for the cursor position — a spectrum-analyzer |
| 1975 | // style marker readout. |
| 1976 | function _wifiCursorReadout(canvas, x, y) { |
| 1977 | const g = canvas && canvas._wifiGeom; |
| 1978 | if (!g || x < g.padL || x > g.W - g.padR || y < g.padT || y > g.H - g.padB) return ''; |
| 1979 | const band = g.bands.find(b => x >= g.ranges[b].x0 && x <= g.ranges[b].x1); |
| 1980 | const dbm = Math.round(g.dbmFor(y)); |
| 1981 | if (!band) return `${dbm} dBm`; |
| 1982 | const ch = g.chFor(band, x); |
| 1983 | const mhz = band === '2.4' ? Math.round(2407 + ch * 5) |
| 1984 | : band === '6' ? Math.round(5950 + ch * 5) : Math.round(5000 + ch * 5); |
| 1985 | return `${band} GHz · ch ${ch.toFixed(1)} · ${mhz} MHz · ${dbm} dBm`; |
| 1986 | } |
| 1987 | |
| 1988 | function _wifiTipHtml(a) { |
| 1989 | const col = _wifiSignalColor(a.signal); |
| 1990 | const issue = (a.security_findings || []).length; |
| 1991 | return `<div><b>${_esc(a.ssid) || '<i>hidden</i>'}</b>${_wifiGenBadge(a.standard)}</div> |
| 1992 | <div class="k" style="font-family:ui-monospace,monospace">${_esc(a.bssid)}</div> |
| 1993 | <div><span class="k">${_esc(a.vendor) || 'unknown vendor'}</span></div> |
| 1994 | <div><b style="color:${col}">${a.signal} dBm</b>${a.snr != null ? ' <span class="k">SNR ' + a.snr + ' dB</span>' : ''} |
| 1995 | · ${a.band} GHz ch ${a.channel} · ${a.width} MHz${a.dfs ? ' <span style="color:#a78bfa">◆DFS</span>' : ''}</div> |
| 1996 | <div><span class="k">${_esc(a.security)}</span>${a.channel_util != null ? ' <span class="k">· util ' + a.channel_util + '%</span>' : ''}</div> |
| 1997 | ${issue ? `<div style="color:#fbbf24">⚠ ${_esc(a.security_findings.join('; '))}</div>` : ''} |
| 1998 | <div class="k" style="margin-top:3px">click to inspect</div>`; |
| 1999 | } |
| 2000 | |
| 2001 | function _wifiFillIfaces() { |
| 2002 | fetch('/api/net/wifi/interfaces').then(r => r.json()).then(d => { |
| 2003 | const sel = document.getElementById('wifi-iface'); |
| 2004 | const ifs = (d && d.interfaces) || []; |
nothing calls this directly
no test coverage detected