// Configuration management functions let currentConfigJSON = null; let configMeta = null; let configEditor = null; // Initialize config section async function initConfigSection() { try { await loadConfiguration(); } catch (error) { console.error('Failed to load configuration:', error); showNotification('Ошибка загрузки конфигурации', 'error'); } } // Load current configuration async function loadConfiguration() { try { const response = await fetch('/api/config/get', { method: 'GET', credentials: 'same-origin' }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); currentConfigJSON = data.config_json; configMeta = { path: data.config_path, format: data.config_format }; renderConfigEditor(); updateConfigStatus(); } catch (error) { console.error('Error loading configuration:', error); throw error; } } // Render configuration editor with JSON syntax highlighting function renderConfigEditor() { const configSection = document.getElementById('config-section'); const configEditor = `

Файл конфигурации

${configMeta.path} ${configMeta.format.toUpperCase()}
JSON Конфигурация
Обновить
Форматировать
Проверить
Сохранить
Сохранить и перезапустить
`; configSection.innerHTML = configEditor; updateTexts(); initJSONEditor(); }