diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/ft8.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/ft8.js index b2e72c7..b9622ef 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/ft8.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/ft8.js @@ -29,32 +29,30 @@ function addFt8Message(msg) { } function renderFt8Message(message) { - const normalized = normalizeSpaces(message); const gridRegex = /[A-R]{2}\\d{2}(?:[A-X]{2})?/gi; let out = ""; let lastIdx = 0; - for (const match of normalized.matchAll(gridRegex)) { + for (const match of message.matchAll(gridRegex)) { const idx = match.index ?? 0; const grid = match[0].toUpperCase(); - const prev = idx > 0 ? normalized[idx - 1] : ""; - const next = idx + grid.length < normalized.length ? normalized[idx + grid.length] : ""; + const prev = idx > 0 ? message[idx - 1] : ""; + const next = idx + grid.length < message.length ? message[idx + grid.length] : ""; if (isAlphaNum(prev) || isAlphaNum(next)) continue; - out += escapeHtml(normalized.slice(lastIdx, idx)); + out += escapeHtml(message.slice(lastIdx, idx)); out += `[${grid}]`; lastIdx = idx + grid.length; } - out += escapeHtml(normalized.slice(lastIdx)); + out += escapeHtml(message.slice(lastIdx)); return out; } function extractFirstGrid(message) { - const normalized = normalizeSpaces(message); 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 grid = match[0].toUpperCase(); - const prev = idx > 0 ? normalized[idx - 1] : ""; - const next = idx + grid.length < normalized.length ? normalized[idx + grid.length] : ""; + const prev = idx > 0 ? message[idx - 1] : ""; + const next = idx + grid.length < message.length ? message[idx + grid.length] : ""; if (isAlphaNum(prev) || isAlphaNum(next)) continue; return grid; } @@ -73,10 +71,6 @@ function isAlphaNum(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 () => { try { await postPath("/toggle_ft8_decode"); } catch (e) { console.error("FT8 toggle failed", e); } });