Add null checks for legacy WiFi UI elements

- Add null checks in updateChannelRecommendation for removed elements
- Add null checks in updateProbeAnalysis for counter elements
- Prevents TypeError when legacy functions run with v2 layout

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-21 22:35:57 +00:00
parent 1d30ea2708
commit 0ca3066cfc
+19 -11
View File
@@ -4250,21 +4250,26 @@
} }
}); });
// Update UI with more context // Update UI with more context (with null checks for v2 layout)
document.getElementById('rec24Channel').textContent = best24; const rec24El = document.getElementById('rec24Channel');
const rec24ReasonEl = document.getElementById('rec24Reason');
const rec5El = document.getElementById('rec5Channel');
const rec5ReasonEl = document.getElementById('rec5Reason');
if (rec24El) rec24El.textContent = best24;
if (totalNetworks === 0) { if (totalNetworks === 0) {
document.getElementById('rec24Reason').textContent = '(no networks detected)'; if (rec24ReasonEl) rec24ReasonEl.textContent = '(no networks detected)';
} else { } else {
const usage = channelUsage24.map(c => `CH${c.channel}:${Math.round(c.count)}`).join(', '); const usage = channelUsage24.map(c => `CH${c.channel}:${Math.round(c.count)}`).join(', ');
document.getElementById('rec24Reason').textContent = if (rec24ReasonEl) rec24ReasonEl.textContent =
minCount24 === 0 ? '(clear)' : `(${Math.round(minCount24)} interference) [${usage}]`; minCount24 === 0 ? '(clear)' : `(${Math.round(minCount24)} interference) [${usage}]`;
} }
document.getElementById('rec5Channel').textContent = best5; if (rec5El) rec5El.textContent = best5;
if (totalNetworks === 0) { if (totalNetworks === 0) {
document.getElementById('rec5Reason').textContent = '(no networks detected)'; if (rec5ReasonEl) rec5ReasonEl.textContent = '(no networks detected)';
} else { } else {
document.getElementById('rec5Reason').textContent = if (rec5ReasonEl) rec5ReasonEl.textContent =
minCount5 === 0 ? `(clear, ${channels5g.length - used5g} unused)` : `(${minCount5} networks)`; minCount5 === 0 ? `(clear, ${channels5g.length - used5g} unused)` : `(${minCount5} networks)`;
} }
} }
@@ -4864,10 +4869,13 @@
}); });
}); });
// Update counters // Update counters (with null checks for v2 layout)
document.getElementById('probeClientCount').textContent = clientsWithProbes.length; const probeClientEl = document.getElementById('probeClientCount');
document.getElementById('probeSSIDCount').textContent = allProbes.size; const probeSSIDEl = document.getElementById('probeSSIDCount');
document.getElementById('probePrivacyCount').textContent = privacyLeaks; const probePrivacyEl = document.getElementById('probePrivacyCount');
if (probeClientEl) probeClientEl.textContent = clientsWithProbes.length;
if (probeSSIDEl) probeSSIDEl.textContent = allProbes.size;
if (probePrivacyEl) probePrivacyEl.textContent = privacyLeaks;
if (clientsWithProbes.length === 0) { if (clientsWithProbes.length === 0) {
list.innerHTML = '<div style="color: var(--text-dim);">Waiting for client probe requests...</div>'; list.innerHTML = '<div style="color: var(--text-dim);">Waiting for client probe requests...</div>';