// Shared server status functionality for all pages async function updateServerStatus(statusElementId) { try { const response = await fetch('/api/server/status'); // Check for authentication redirect const contentType = response.headers.get('content-type'); if (contentType && contentType.includes('text/html')) { console.warn('Authentication required for server status'); // Silently fail for status updates, don't redirect automatically return; } if (!response.ok) { throw new Error('HTTP error! status: ' + response.status); } const status = await response.json(); updateStatusElement(statusElementId, status); } catch (error) { console.error('Failed to update server status:', error); // Show error state const statusElement = document.getElementById(statusElementId); if (statusElement) { statusElement.textContent = 'Error'; statusElement.className = 'status status-stopped'; } } } function updateStatusElement(elementId, status) { const statusElement = document.getElementById(elementId); if (statusElement) { const statusText = status.statusText || (status.isRunning ? 'running' : 'stopped'); statusElement.textContent = statusText.charAt(0).toUpperCase() + statusText.slice(1); statusElement.className = `status status-${statusText}`; } }