(data)
| 3988 | el.innerHTML = '<span>🛡 Flagged by WiFi Defense:</span>' + name |
| 3989 | + `<span style="color:rgba(252,165,165,.8)">· ${state}</span>` |
| 3990 | + '<button onclick="wifiClearFlag()" class="ml-auto px-2 py-0.5 rounded bg-red-900/60 hover:bg-red-800 text-red-100" title="Clear the WIDS highlight">✕ dismiss</button>'; |
| 3991 | } else { |
| 3992 | // Plain inspection — blue "selected", no threat implication. |
| 3993 | el.className = 'flex flex-wrap items-center gap-2 mb-3 text-xs px-3 py-2 rounded-lg bg-blue-900/50 border border-blue-700 text-blue-200'; |
| 3994 | el.innerHTML = '<span>📶 Access Point selected:</span>' + name |
| 3995 | + `<span style="color:rgba(147,197,253,.85)">· ${state}</span>` |
| 3996 | + '<button onclick="wifiClearFlag()" class="ml-auto px-2 py-0.5 rounded bg-blue-900/50 border border-blue-700 text-blue-100" title="Clear the selection highlight">✕ dismiss</button>'; |
| 3997 | } |
| 3998 | } |
| 3999 | |
| 4000 | function wifiSelectAp(bssid) { |
| 4001 | if (_wifiState.selected !== bssid) _wifiState.radius = null; |
| 4002 | _wifiState.selected = bssid; |
| 4003 | wifiRender(); |
| 4004 | const iface = _wifiState.iface; |
| 4005 | // Prefill TX with the AP's advertised power (TPC report) when it has one. |
| 4006 | const ap = (_wifiState.data && _wifiState.data.aps || []).find(a => a.bssid === bssid); |
| 4007 | const txBox = document.getElementById('wifi-tx'); |
| 4008 | if (ap && ap.tx_power_dbm != null && !txBox._userset) txBox.value = ap.tx_power_dbm; |
| 4009 | txBox.onchange = () => { txBox._userset = true; if (_wifiState.selected) wifiSelectAp(_wifiState.selected); }; |
| 4010 | ['wifi-ple', 'wifi-rssi-offset', 'wifi-ant-gain', 'wifi-cable-loss'].forEach(id => { |
| 4011 | const el = document.getElementById(id); |
| 4012 | if (el && !el._wired) { |
| 4013 | el._wired = true; |
| 4014 | el.onchange = () => { |
| 4015 | // Typing n directly means the preset no longer matches → mark custom. |
| 4016 | if (id === 'wifi-ple') _wifiSyncEnvPreset(); |
| 4017 | if (_wifiState.selected) wifiSelectAp(_wifiState.selected); |
| 4018 | }; |
| 4019 | } |
| 4020 | }); |
| 4021 | const tx = txBox.value || 'auto'; |
| 4022 | const ple = document.getElementById('wifi-ple').value || 3.0; |
| 4023 | const rssiOffset = document.getElementById('wifi-rssi-offset').value || 0; |
| 4024 | const antGain = document.getElementById('wifi-ant-gain').value || 0; |
| 4025 | const cableLoss = document.getElementById('wifi-cable-loss').value || 0; |
| 4026 | const rssi0 = _wifiState.calRssi0 != null ? `&rssi0=${_wifiState.calRssi0}` : ''; |
| 4027 | // Hand back the row we're already showing so the server needn't re-scan |
| 4028 | // (a fresh scan can momentarily miss the AP → "bssid not found"). |
| 4029 | let known = ''; |
| 4030 | if (ap && ap.signal != null) { |
| 4031 | known = `&signal=${ap.signal}&freq=${ap.freq || ''}¢er_freq=${ap.center_freq || ''}` |
| 4032 | + `&band=${encodeURIComponent(ap.band || '')}&channel=${ap.channel != null ? ap.channel : ''}` |
| 4033 | + `&ssid=${encodeURIComponent(ap.ssid || '')}` |
| 4034 | + `&tx_measured=${ap.tx_power_dbm != null ? ap.tx_power_dbm : ''}`; |
| 4035 | } |
| 4036 | document.getElementById('wifi-radius-controls').style.display = 'flex'; |
| 4037 | document.getElementById('wifi-cal-details').style.display = 'block'; |
| 4038 | fetch(`/api/net/wifi/radius?interface=${encodeURIComponent(iface)}&bssid=${encodeURIComponent(bssid)}&tx=${tx}&ple=${ple}&rssi_offset=${rssiOffset}&antenna_gain=${antGain}&cable_loss=${cableLoss}${rssi0}${known}`) |
| 4039 | .then(r => r.json()).then(d => { |
| 4040 | if (d.error) { |
| 4041 | document.getElementById('wifi-radius-info').innerHTML = '<span class="text-amber-400">' + d.error + '</span>'; |
| 4042 | _wifiState.radius = null; _wifiFsRenderSide(); |
| 4043 | return; |
| 4044 | } |
| 4045 | // Kept for the full-screen inspector, which shows the same model. |
| 4046 | _wifiState.radius = d; |
| 4047 | _wifiFsRenderSide(); |
no test coverage detected