[feat](trx-frontend-http): persist settings and APRS state across refresh

Add localStorage persistence (trx_ prefix) for UI settings:
- Jog step, RX/TX volume (app.js)
- CW WPM, tone, threshold, auto-detect flags (cw.js)
- APRS decoded packets and running state (aprs.js)

APRS decoder auto-restarts on page refresh if it was active,
and all decoded packets plus map markers are restored from storage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
2026-02-08 22:05:44 +01:00
parent 3489a74855
commit 90d57a290e
3 changed files with 93 additions and 15 deletions
@@ -11,6 +11,16 @@ const cwWpmAutoCheck = document.getElementById("cw-wpm-auto");
const cwToneAutoCheck = document.getElementById("cw-tone-auto");
const CW_MAX_LINES = 200;
// Restore saved CW settings
cwWpmInput.value = loadSetting("cwWpm", 15);
cwToneInput.value = loadSetting("cwTone", 700);
cwThresholdInput.value = loadSetting("cwThreshold", 5);
cwThresholdVal.textContent = (cwThresholdInput.value / 100).toFixed(2);
cwWpmAutoCheck.checked = loadSetting("cwWpmAuto", true);
cwToneAutoCheck.checked = loadSetting("cwToneAuto", true);
cwWpmInput.readOnly = cwWpmAutoCheck.checked;
cwToneInput.readOnly = cwToneAutoCheck.checked;
let cwActive = false;
let cwWs = null;
let cwAudioCtx = null;
@@ -36,18 +46,25 @@ const MORSE_TABLE = {
// Update threshold display
cwThresholdInput.addEventListener("input", () => {
cwThresholdVal.textContent = (cwThresholdInput.value / 100).toFixed(2);
saveSetting("cwThreshold", Number(cwThresholdInput.value));
});
// Toggle readonly on WPM input based on Auto checkbox
cwWpmAutoCheck.addEventListener("change", () => {
cwWpmInput.readOnly = cwWpmAutoCheck.checked;
saveSetting("cwWpmAuto", cwWpmAutoCheck.checked);
});
// Toggle readonly on Tone input based on Auto checkbox
cwToneAutoCheck.addEventListener("change", () => {
cwToneInput.readOnly = cwToneAutoCheck.checked;
saveSetting("cwToneAuto", cwToneAutoCheck.checked);
});
// Save WPM/Tone when manually changed
cwWpmInput.addEventListener("change", () => { saveSetting("cwWpm", Number(cwWpmInput.value)); });
cwToneInput.addEventListener("change", () => { saveSetting("cwTone", Number(cwToneInput.value)); });
function createCwDecoder(sampleRate) {
let wpm = parseInt(cwWpmInput.value, 10) || 15;
let toneFreq = parseInt(cwToneInput.value, 10) || 700;
@@ -163,6 +180,7 @@ function createCwDecoder(sampleRate) {
if (Math.abs(detectedFreq - toneFreq) > TONE_SCAN_STEP) {
recomputeGoertzel(detectedFreq);
cwToneInput.value = detectedFreq;
saveSetting("cwTone", detectedFreq);
}
}
}
@@ -201,6 +219,7 @@ function createCwDecoder(sampleRate) {
if (newWpm !== wpm) {
wpm = newWpm;
cwWpmInput.value = wpm;
saveSetting("cwWpm", wpm);
}
}