async function saveTable() { const rows = []; const rowCount = document.querySelectorAll('tbody tr').length; for (let i = 0; i < rowCount; i++) { const bezeichnung = document.querySelector(`input[data-row='${i}'][data-field='bezeichnung']`).value; const adresse = document.querySelector(`input[data-row='${i}'][data-field='adresse']`).value; const type = document.querySelector(`input[data-row='${i}'][data-field='type']`).value; const faktor = document.querySelector(`input[data-row='${i}'][data-field='faktor']`).value; const mqtt = document.querySelector(`input[data-row='${i}'][data-field='mqtt']`).checked; const influxdb = document.querySelector(`input[data-row='${i}'][data-field='influxdb']`).checked; rows.push({ bezeichnung, adresse, type, faktor, mqtt, influxdb }); } try { const response = await fetch('/api/save', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ rows: rows }) }); const messageDiv = document.getElementById('message'); if (response.ok) { messageDiv.className = 'message success'; messageDiv.textContent = '✓ Erfolgreich gespeichert!'; } else { messageDiv.className = 'message error'; messageDiv.textContent = '✗ Fehler beim Speichern!'; } setTimeout(() => { messageDiv.style.display = 'none'; }, 3000); } catch (error) { const messageDiv = document.getElementById('message'); messageDiv.className = 'message error'; messageDiv.textContent = '✗ Verbindungsfehler!'; } }