From da316ccc964806ea57c16119c4578b96640b779f Mon Sep 17 00:00:00 2001 From: Zack Orndorff Date: Sun, 16 Mar 2025 22:39:02 -0400 Subject: [PATCH 1/2] Allow narrowing a pileup by querying with a number For example, if you hear a garble of CW but manage to pick out a 4 in the cacophony, you can respond with "4?" and only callsigns containing 4 should call back. --- src/js/util.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/js/util.js b/src/js/util.js index 0a80c20..8e44ffa 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -40,6 +40,11 @@ export function compareStrings(source, query) { // console.log("Partial: Criterion 5"); return 'partial'; } + // Check Criterion 6 (Single Number Matches Call Region) + if (criterion6(source, query)) { + // console.log("Partial: Criterion 6"); + return 'partial'; + } // If none of the criteria are met // console.log("None"); return 'none'; @@ -224,6 +229,47 @@ export function compareStrings(source, query) { return true; } + + /** + * Criterion 6: Single Number Matches Call Region + * + * - **Conditions:** + * - The query must be a single digit character + * - The callsign must have only a single number + * - They must match + * + * - **Examples:** + * - Source: "AB6ZZ", Query: "6" + * => "AB6ZZ" contains one number, "6". + * => "6" is a single digit + * => "6" matches "6" + * + * @param {string} source + * @param {string} query + * @returns boolean + */ + function criterion6(source, query) { + // The query must be a single digit character + if (!isdigit(query)) { + return false; + } + + // The source must contain exactly one digit + let digits = 0; + let source_digit; + for (const ch of source) { + if (isdigit(ch)) { + digits++; + source_digit = ch; + } + } + if (digits != 1) { + return false; + } + + // They must match + return source_digit === query; + } } // function runCompareStringTestCase(source, query, expectedResult) { @@ -650,3 +696,16 @@ function updateSummaryRow(tableName, extra = null) { export function updateActiveStations(numStations) { document.getElementById('activeStations').textContent = numStations; } + +/** + * Checks if provided string is a single digit character + * + * @param {string} ch - The prospective digit + * @returns {boolean} + */ +export function isdigit(ch) { + if (ch.length !== 1) { + return false; + } + return '1234567890'.includes(ch); +} From 3d94ed7ab598b9375571b35955d0dd1cd1215919 Mon Sep 17 00:00:00 2001 From: Zack Orndorff Date: Sun, 16 Mar 2025 23:18:38 -0400 Subject: [PATCH 2/2] Update Getting Started docs for querying by number --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index b5617aa..3059312 100644 --- a/src/index.html +++ b/src/index.html @@ -1089,7 +1089,7 @@ >Use partial matches to single out stations in a pileup. E.g., for W6NYC, all of the following will - get a reply back: 'W?', 'W6?', 'W6NC', 'NYC'.


Note that more than one station may reply if they match your partial pattern!