Replace form with div to avoid default button handling

This commit is contained in:
Matt
2025-12-14 08:23:32 +00:00
parent 2e36b44c7d
commit 1c29d37c6f
2 changed files with 15 additions and 19 deletions

View File

@@ -140,7 +140,7 @@
</div> </div>
<div class="card"> <div class="card">
<form id="configForm" class="controls"> <div class="controls">
<div> <div>
<label>Sample Rate (Hz)</label> <label>Sample Rate (Hz)</label>
<input type="number" id="sampleRate" value="10000" min="1" max="83333"> <input type="number" id="sampleRate" value="10000" min="1" max="83333">
@@ -171,9 +171,9 @@
</div> </div>
<div> <div>
<button id="resetBtn">Reset</button> <button id="resetBtn">Reset</button>
<button id="powerOff"><a style="text-decoration: none; color: inherit" href="/poweroff">Power off</a></button> <button id="powerOff">Power off</button>
</div> </div>
</form> </div>
</div> </div>
<div id="deltaPanel"></div> <div id="deltaPanel"></div>

View File

@@ -150,8 +150,6 @@ canvas.addEventListener('click', (event) => {
voltage, voltage,
time: timeOffset time: timeOffset
}; };
// draw(); // Removed: Animation loop handles this
} }
}); });
@@ -411,21 +409,19 @@ function setParams() {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload) body: JSON.stringify(payload)
}) }).then(res => {
.then(res => { if (res.ok) {
if (res.ok) { resetLowRateState();
resetLowRateState();
// Update active config // Update active config
activeConfig = { ...payload, desiredRate, trigger: parseInt(triggerLevel.value) || 2048 }; activeConfig = { ...payload, desiredRate, trigger: parseInt(triggerLevel.value) || 2048 };
// Save to localStorage // Save to localStorage
localStorage.setItem('esp32_adc_config', JSON.stringify(activeConfig)); localStorage.setItem('esp32_adc_config', JSON.stringify(activeConfig));
} else { } else {
alert('Error updating configuration'); alert('Error updating configuration');
} }
}) }).catch(err => alert('Network error: ' + err));
.catch(err => alert('Network error: ' + err));
}; };
// Load config from localStorage on startup // Load config from localStorage on startup
@@ -452,6 +448,6 @@ document.getElementById('resetBtn').addEventListener('click', () => {
localStorage.clear(); localStorage.clear();
window.location.reload(); window.location.reload();
}); });
document.getElementById('powerOff').addEventListener('click', () => window.location.href = "/poweroff");
setParams(); setParams();
connect(); connect();