Revert "[fix](trx-frontend-http): normalize ft8 locator spacing"
This reverts commit 5aa9502e37.
This commit is contained in:
@@ -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 += `<span class="ft8-locator">[${grid}]</span>`;
|
||||
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); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user