refactor: route all decoders through plugin runtime

This commit is contained in:
sjg
2026-08-01 13:06:38 +02:00
parent 508cf2ba87
commit 9fef0ebc7b
19 changed files with 255 additions and 319 deletions
@@ -97,7 +97,7 @@
}
};
}
wsprWindow.onServerWsprBatch = function(messages) {
function onServerWsprBatch(messages) {
if (!Array.isArray(messages) || messages.length === 0) return;
if (wsprStatus) wsprStatus.textContent = "Receiving";
const normalized = [];
@@ -116,15 +116,11 @@
wsprMessageHistory = normalized.concat(wsprMessageHistory);
pruneWsprMessageHistory();
scheduleWsprHistoryRender();
};
wsprWindow.restoreWsprHistory = function(messages) {
const callback = wsprWindow.onServerWsprBatch;
if (typeof callback === "function") callback(messages);
};
wsprWindow.pruneWsprHistoryView = function() {
}
function pruneWsprHistoryView() {
pruneWsprMessageHistory();
renderWsprHistory();
};
}
function escapeWsprHtml(input) {
return input.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
}
@@ -205,12 +201,12 @@
const message = row.dataset.message || "";
row.style.display = message.includes(wsprFilterText) ? "" : "none";
}
wsprWindow.resetWsprHistoryView = function() {
function resetWsprHistoryView() {
if (wsprMessagesEl) wsprMessagesEl.innerHTML = "";
wsprMessageHistory = [];
renderWsprHistory();
if (wsprWindow.clearMapMarkersByType) wsprWindow.clearMapMarkersByType("wspr");
};
}
if (wsprFilterInput) {
wsprFilterInput.addEventListener("input", () => {
wsprFilterText = wsprFilterInput.value.trim().toUpperCase();
@@ -246,13 +242,13 @@
if (!await wsprWindow.trxUi.confirm({ title: "Clear WSPR history?", message: "All stored WSPR decodes will be permanently removed.", confirmLabel: "Clear history" })) return;
try {
await wsprWindow.postPath?.("/clear_wspr_decode");
wsprWindow.resetWsprHistoryView?.();
resetWsprHistoryView();
} catch (error) {
console.error("WSPR history clear failed", error);
}
})();
});
wsprWindow.onServerWspr = function(msg) {
function onServerWspr(msg) {
if (wsprStatus) wsprStatus.textContent = "Receiving";
const next = normalizeServerWsprMessage(msg);
if (next.grids.length > 0 && wsprWindow.mapAddLocator) {
@@ -262,5 +258,13 @@
});
}
addWsprMessage(next.history);
};
}
wsprWindow.trxPluginRuntime.registerDecoder({
id: "wspr",
onMessage: onServerWspr,
onBatch: onServerWsprBatch,
restore: onServerWsprBatch,
prune: pruneWsprHistoryView,
reset: resetWsprHistoryView
});
})();