Revert "[fix](trx-frontend-http): normalize ft8 locator spacing"

This reverts commit 5aa9502e37.
This commit is contained in:
2026-02-09 22:15:00 +01:00
parent 5aa9502e37
commit a8f7e9c8de
@@ -29,32 +29,30 @@ function addFt8Message(msg) {
} }
function renderFt8Message(message) { function renderFt8Message(message) {
const normalized = normalizeSpaces(message);
const gridRegex = /[A-R]{2}\\d{2}(?:[A-X]{2})?/gi; const gridRegex = /[A-R]{2}\\d{2}(?:[A-X]{2})?/gi;
let out = ""; let out = "";
let lastIdx = 0; let lastIdx = 0;
for (const match of normalized.matchAll(gridRegex)) { for (const match of message.matchAll(gridRegex)) {
const idx = match.index ?? 0; const idx = match.index ?? 0;
const grid = match[0].toUpperCase(); const grid = match[0].toUpperCase();
const prev = idx > 0 ? normalized[idx - 1] : ""; const prev = idx > 0 ? message[idx - 1] : "";
const next = idx + grid.length < normalized.length ? normalized[idx + grid.length] : ""; const next = idx + grid.length < message.length ? message[idx + grid.length] : "";
if (isAlphaNum(prev) || isAlphaNum(next)) continue; if (isAlphaNum(prev) || isAlphaNum(next)) continue;
out += escapeHtml(normalized.slice(lastIdx, idx)); out += escapeHtml(message.slice(lastIdx, idx));
out += `<span class="ft8-locator">[${grid}]</span>`; out += `<span class="ft8-locator">[${grid}]</span>`;
lastIdx = idx + grid.length; lastIdx = idx + grid.length;
} }
out += escapeHtml(normalized.slice(lastIdx)); out += escapeHtml(message.slice(lastIdx));
return out; return out;
} }
function extractFirstGrid(message) { function extractFirstGrid(message) {
const normalized = normalizeSpaces(message);
const gridRegex = /[A-R]{2}\\d{2}(?:[A-X]{2})?/gi; const gridRegex = /[A-R]{2}\\d{2}(?:[A-X]{2})?/gi;
for (const match of normalized.matchAll(gridRegex)) { for (const match of message.matchAll(gridRegex)) {
const idx = match.index ?? 0; const idx = match.index ?? 0;
const grid = match[0].toUpperCase(); const grid = match[0].toUpperCase();
const prev = idx > 0 ? normalized[idx - 1] : ""; const prev = idx > 0 ? message[idx - 1] : "";
const next = idx + grid.length < normalized.length ? normalized[idx + grid.length] : ""; const next = idx + grid.length < message.length ? message[idx + grid.length] : "";
if (isAlphaNum(prev) || isAlphaNum(next)) continue; if (isAlphaNum(prev) || isAlphaNum(next)) continue;
return grid; return grid;
} }
@@ -73,10 +71,6 @@ function isAlphaNum(ch) {
return /[A-Za-z0-9]/.test(ch); return /[A-Za-z0-9]/.test(ch);
} }
function normalizeSpaces(input) {
return input.replace(/[\\u00A0\\u2000-\\u200B\\u202F\\u205F\\u3000]/g, " ");
}
document.getElementById("ft8-decode-toggle-btn").addEventListener("click", async () => { document.getElementById("ft8-decode-toggle-btn").addEventListener("click", async () => {
try { await postPath("/toggle_ft8_decode"); } catch (e) { console.error("FT8 toggle failed", e); } try { await postPath("/toggle_ft8_decode"); } catch (e) { console.error("FT8 toggle failed", e); }
}); });