()
| 13549 | data = null; |
| 13550 | } |
| 13551 | |
| 13552 | if (!response.ok || (data && data.success === false)) { |
| 13553 | const errorMessage = data && (data.error || data.message) |
| 13554 | ? (data.error || data.message) |
| 13555 | : `Request failed (${response.status})`; |
| 13556 | throw new Error(errorMessage); |
| 13557 | } |
| 13558 | |
| 13559 | return data || { success: true }; |
| 13560 | } |
| 13561 | |
| 13562 | async function loadConnectData() { |
| 13563 | try { |
| 13564 | // Load Wi-Fi interfaces first so dropdowns are populated before status updates |
| 13565 | await loadWifiInterfaces(); |
| 13566 | |
| 13567 | // Refresh Wi-Fi and Bluetooth status in parallel to shorten the loading time |
| 13568 | console.log('Loading connect tab, refreshing connectivity status...'); |
| 13569 | await Promise.all([ |
| 13570 | refreshWifiStatus(), |
| 13571 | refreshEthernetStatus(), |
| 13572 | refreshBluetoothStatus() |
| 13573 | ]); |
| 13574 | } catch (error) { |
| 13575 | console.error('Error loading connect data:', error); |
| 13576 | } |
| 13577 | } |
| 13578 | |
| 13579 | async function loadFilesData() { |
| 13580 | try { |
| 13581 | displayDirectoryTree(); |
| 13582 | loadFiles('/'); |
| 13583 | // Don't automatically load images - user must click "Load Images" button |
| 13584 | } catch (error) { |
| 13585 | console.error('Error loading files data:', error); |
| 13586 | } |
| 13587 | } |
| 13588 | |
| 13589 | // ============================================================================ |
| 13590 | // PWNAGOTCHI VISIBILITY MANAGEMENT |
| 13591 | // ============================================================================ |
| 13592 | |
| 13593 | function arePwnFeaturesEnabled() { |
| 13594 | return localStorage.getItem('pwnagotchi-enabled') === 'true'; |
| 13595 | } |
| 13596 | |
| 13597 | function applyPwnVisibilityPreference(isEnabled) { |
| 13598 | const pwnSection = document.getElementById('pwnagotchi-section'); |
| 13599 | if (pwnSection) { |
| 13600 | pwnSection.style.display = isEnabled ? 'block' : 'none'; |
| 13601 | } |
| 13602 | updatePwnDiscoveredCard(pwnStatus); |
| 13603 |
nothing calls this directly
no test coverage detected