From f041daeda3b89a622070725efdb7d89537304bb8 Mon Sep 17 00:00:00 2001 From: Mark Wissink Date: Mon, 7 Sep 2026 08:27:06 -0400 Subject: [PATCH] More fix --- assets/sw.js | 24 +++++++++++++----------- assets/templates/reference.njk | 8 ++++++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/assets/sw.js b/assets/sw.js index 0903383..c9ebaff 100644 --- a/assets/sw.js +++ b/assets/sw.js @@ -434,8 +434,12 @@ router.get('/api/bookmark', () => bookmarkFragment('')); // straight in and processes no out-of-band elements -- and // when a worker first appears under a page boot.html // composed. -// chapter=ch3 the verses of that chapter, and land on the chapter. -// verse=v3_16 the same verses, that one selected, and land on the verse. +// at=ch3 the verses of that chapter, and land on the chapter. +// at=v3_16 the same verses, that one selected, and land on the verse. +// +// One parameter for both selects: at is the id of the element to land on, and +// ch3 and v3_16 are told apart by their shape. Which select it came from is +// not a second fact. // // Neither the book nor the anchor is in the URL, deliberately. Both come from // HX-Current-URL, which htmx sets from location.href on every request it @@ -467,19 +471,17 @@ router.get('/api/bookmark', () => bookmarkFragment('')); router.get('/api/reference', async (call) => { const params = call.url.searchParams; const page = call.currentUrl(); - // Which select the reader moved, if either did -- by whether the parameter - // is there, not by whether it says anything. A select posts an empty value - // when it has no options, and reading that as "no select moved" answers it - // with a whole picker: htmx swaps a
into a , which renders as nothing, and + // the select is then empty for good -- every change after that posts the + // same empty value and gets the same answer. // // An empty value is still an answerable question. It names no chapter, so it // gets chapter 1, which is what everything here does with an anchor it // cannot read. - const moved = params.has('verse') ? params.get('verse') - : params.has('chapter') ? params.get('chapter') - : null; + const moved = params.has('at') ? params.get('at') : null; // The address bar is the fallback, and only that: once a select has been // used it is the one saying where to go, and HX-Replace-Url has not caught diff --git a/assets/templates/reference.njk b/assets/templates/reference.njk index 0f25e19..c4f48b3 100644 --- a/assets/templates/reference.njk +++ b/assets/templates/reference.njk @@ -59,10 +59,14 @@ to know how a verse anchor is spelled -- including the worker, which reads the chapter back out of the id it sent. + Which is why both selects post under the same name. ch3 and v3_16 are + told apart by their shape, so a second name saying which select it came + from would only be repeating what the value already says. + hx-target is spelled out on both selects because the one on the div above is "this", and an inherited "this" would resolve to the select. #} {% include "verses.njk" %}