This commit is contained in:
mark committed 2026-09-07 08:27:06 -04:00
1 parent d74385ca3c
commit f041daeda3
2 files changed
+19 -13

No files matched your search

+13 -11
View File
@@ -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 <div> into a <select>, 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.
// Set when a select was moved -- 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 <div> into a <select>, 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
+6 -2
View File
@@ -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. #}
<select class="reference-chapter form-select form-select-sm"
id="reference-chapter" name="chapter"
id="reference-chapter" name="at"
hx-get="api/reference" hx-target="#reference-verse"
hx-swap="innerHTML">
{%- for chapter in reference.chapters %}
@@ -76,7 +80,7 @@
has something to hang the scroll on -- and so the option the reader chose
comes back marked selected instead of being reset by the swap. #}
<select class="reference-verse form-select form-select-sm"
id="reference-verse" name="verse"
id="reference-verse" name="at"
hx-get="api/reference" hx-target="this" hx-swap="innerHTML">
{% include "verses.njk" %}
</select>