fix(docs): reflect preset URL in page header

This commit is contained in:
mikecarper
2026-09-20 16:40:49 -07:00
parent ba153b758d
commit 968e5240ac
3 changed files with 81 additions and 10 deletions
+58
View File
@@ -212,6 +212,48 @@
});
}
function isDefaultPreset(config) {
return (
config.startMs === parseTimestamp(DEFAULTS.start, "start") &&
config.endMs === parseTimestamp(DEFAULTS.end, "end") &&
config.freq === Number(DEFAULTS.freq) &&
config.bw === Number(DEFAULTS.bw) &&
config.sf === Number(DEFAULTS.sf) &&
config.cr === Number(DEFAULTS.cr) &&
config.tx === Number(DEFAULTS.tx)
);
}
function presetDurationText(config) {
const hours = (config.endMs - config.startMs) / (60 * 60 * 1000);
if (Number.isInteger(hours)) return hours + (hours === 1 ? " hour" : " hours");
return formatCountdown(config.endMs - config.startMs);
}
function presetDurationLabel(config) {
const hours = (config.endMs - config.startMs) / (60 * 60 * 1000);
if (Number.isInteger(hours)) return hours + "-hour";
return presetDurationText(config);
}
function presetPageTitle(config) {
return (isDefaultPreset(config) ? "Default temporary" : "Temporary") +
" radio test · " + config.freqText + " MHz";
}
function presetPageSummary(config) {
return "The " + (isDefaultPreset(config) ? "default" : "configured") +
" window is " + formatZoned(config.startMs, config.tz) + " through " +
formatZoned(config.endMs, config.tz) + " (" + presetDurationText(config) +
"), using " + config.freqText + " MHz, " + config.bwText + " kHz, SF" +
config.sf + ", CR" + config.cr + ", " + config.txText + " dBm.";
}
function presetEyebrow(config) {
return "MeshCore · " + (isDefaultPreset(config) ? "default " : "") +
presetDurationLabel(config) + " temporary preset test";
}
function phaseAt(config, nowMs) {
if (nowMs < config.startMs) return "before";
if (nowMs < config.endMs) return "active";
@@ -475,6 +517,13 @@
});
}
function setPageText(selector, value) {
if (!global.document) return;
global.document.querySelectorAll(selector).forEach(function (element) {
element.textContent = value;
});
}
function setCommand(root, name, value) {
setText(root, '[data-command="' + name + '"]', value);
root.querySelectorAll('[data-copy-command="' + name + '"]').forEach(function (button) {
@@ -676,6 +725,9 @@
return;
}
setPageText('[data-role="preset-test-page-title"]', presetPageTitle(config));
setPageText('[data-role="preset-test-page-summary"]', presetPageSummary(config));
setText(root, '[data-role="preset-test-eyebrow"]', presetEyebrow(config));
setText(root, '[data-field="freq-display"]', config.freq.toFixed(3));
setText(root, '[data-field="bw-display"]', config.bwText);
setText(root, '[data-field="sf"]', String(config.sf));
@@ -880,6 +932,12 @@
PresetTestError: PresetTestError,
configFromSearch: configFromSearch,
configFromGenerator: configFromGenerator,
isDefaultPreset: isDefaultPreset,
presetDurationText: presetDurationText,
presetDurationLabel: presetDurationLabel,
presetPageTitle: presetPageTitle,
presetPageSummary: presetPageSummary,
presetEyebrow: presetEyebrow,
validateTimeZone: validateTimeZone,
browserTimeZone: browserTimeZone,
supportedTimeZones: supportedTimeZones,
+6 -5
View File
@@ -1,9 +1,10 @@
# Default temporary radio test · 910.1 MHz · September 21–23, 2026
# <span data-role="preset-test-page-title">Default temporary radio test · 910.1 MHz · September 21–23, 2026</span>
Use this page to join the shared temporary radio test without overwriting the
node's saved primary radio settings. The default window is **Monday,
September 21, 2026 at 5:00 PM through Wednesday, September 23 at 5:00 PM
Pacific time** (48 hours), using **910.1 MHz, 500 kHz, SF8, CR7**.
node's saved primary radio settings. <span data-role="preset-test-page-summary">The
default window is <strong>Monday, September 21, 2026 at 5:00 PM through
Wednesday, September 23 at 5:00 PM Pacific time</strong> (48 hours), using
<strong>910.1 MHz, 500 kHz, SF8, CR7</strong>.</span>
The page reads the complete test definition from its URL. Change the query
parameters to reuse it for a different window, display time zone, or radio
@@ -14,7 +15,7 @@ tuple; no source edit is required.
<div data-role="content">
<section class="preset-test-hero" aria-labelledby="preset-test-title">
<p class="preset-test-eyebrow">MeshCore · default 48-hour temporary preset test</p>
<p class="preset-test-eyebrow" data-role="preset-test-eyebrow">MeshCore · default 48-hour temporary preset test</p>
<div class="preset-test-hero-row">
<div>
<h2 id="preset-test-title">
+17 -5
View File
@@ -5,11 +5,9 @@ const fs = require("fs");
const tool = require("../docs/_javascript/preset_test.js");
const pageSource = fs.readFileSync("docs/preset_test.md", "utf8");
assert.match(
pageSource,
/^# Default temporary radio test · 910\.1 MHz · September 21–23, 2026$/m
);
assert.match(pageSource, /MeshCore · default 48-hour temporary preset test/);
assert.match(pageSource, /data-role="preset-test-page-title"/);
assert.match(pageSource, /data-role="preset-test-page-summary"/);
assert.match(pageSource, /data-role="preset-test-eyebrow"/);
assert.match(pageSource, /data-role="timezone-map"/);
assert.match(pageSource, /type="hidden" name="tz"/);
assert.doesNotMatch(pageSource, /<select name="tz"/);
@@ -47,6 +45,20 @@ assert.strictEqual(defaults.sf, 8);
assert.strictEqual(defaults.cr, 7);
assert.strictEqual(defaults.tx, 22);
assert.strictEqual(defaults.tz, config.tz);
assert.strictEqual(tool.isDefaultPreset(defaults), true);
assert.strictEqual(tool.presetPageTitle(defaults), "Default temporary radio test · 910.1 MHz");
assert.match(tool.presetPageSummary(defaults), /910\.1 MHz, 500 kHz, SF8, CR7, 22 dBm/);
assert.strictEqual(tool.presetEyebrow(defaults), "MeshCore · default 48-hour temporary preset test");
const requestedLink = tool.configFromSearch(
"?start=2026-09-22T00:00:00.000Z&end=2026-09-24T00:00:00.000Z" +
"&tz=America%2FLos_Angeles&freq=911.3&bw=500&sf=8&cr=7&tx=22"
);
assert.strictEqual(tool.isDefaultPreset(requestedLink), false);
assert.strictEqual(tool.presetPageTitle(requestedLink), "Temporary radio test · 911.3 MHz");
assert.match(tool.presetPageSummary(requestedLink), /911\.3 MHz, 500 kHz, SF8, CR7, 22 dBm/);
assert.doesNotMatch(tool.presetPageSummary(requestedLink), /910\.1 MHz/);
assert.strictEqual(tool.presetEyebrow(requestedLink), "MeshCore · 48-hour temporary preset test");
const browserZoneFallback = tool.configFromSearch("", "America/New_York");
assert.strictEqual(browserZoneFallback.tz, "America/New_York");