| 41 | * Called from main.ts on every FSM `transitioned` event. |
| 42 | */ |
| 43 | export function renderStatus(state: ConnectivityState): void { |
| 44 | const indicator = document.getElementById("status-indicator"); |
| 45 | const label = document.getElementById("status-label"); |
| 46 | |
| 47 | if (!indicator || !label) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | // Remove all state classes first, then apply the new one. |
| 52 | // This keeps the element clean regardless of what state we came from. |
| 53 | ALL_STATE_CLASSES.forEach(cls => { |
| 54 | indicator.classList.remove(cls); |
| 55 | }); |
| 56 | indicator.classList.add(`${STATE_CLASS_PREFIX}${state}`); |
| 57 | |
| 58 | label.textContent = STATE_LABELS[state]; |
| 59 | label.style.color = getStateColor(state); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Updates the check count display. Only meaningful when offline or checking. |