diff --git a/docs/_javascript/preset_test.js b/docs/_javascript/preset_test.js index 4b68b6d6..1c759e75 100644 --- a/docs/_javascript/preset_test.js +++ b/docs/_javascript/preset_test.js @@ -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, diff --git a/docs/preset_test.md b/docs/preset_test.md index de62f91e..9bfe463a 100644 --- a/docs/preset_test.md +++ b/docs/preset_test.md @@ -1,9 +1,10 @@ -# Default temporary radio test · 910.1 MHz · September 21–23, 2026 +# Default temporary radio test · 910.1 MHz · September 21–23, 2026 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. 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. 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.
-

MeshCore · default 48-hour temporary preset test

+

MeshCore · default 48-hour temporary preset test

diff --git a/test/test_preset_test.js b/test/test_preset_test.js index 44edec6f..2ab1a97b 100644 --- a/test/test_preset_test.js +++ b/test/test_preset_test.js @@ -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, /