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 // straight in and processes no out-of-band elements -- and
// when a worker first appears under a page boot.html // when a worker first appears under a page boot.html
// composed. // composed.
// chapter=ch3 the verses of that chapter, and land on the chapter. // at=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=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 // 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 // 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) => { router.get('/api/reference', async (call) => {
const params = call.url.searchParams; const params = call.url.searchParams;
const page = call.currentUrl(); const page = call.currentUrl();
// Which select the reader moved, if either did -- by whether the parameter // Set when a select was moved -- by whether the parameter is there, not by
// is there, not by whether it says anything. A select posts an empty value // whether it says anything. A select posts an empty value when it has no
// when it has no options, and reading that as "no select moved" answers it // options, and reading that as "no select moved" answers it with a whole
// with a whole picker: htmx swaps a <div> into a <select>, which renders as // picker: htmx swaps a <div> into a <select>, which renders as nothing, and
// nothing, and the select is then empty for good -- every change after that // the select is then empty for good -- every change after that posts the
// posts the same empty value and gets the same answer. // same empty value and gets the same answer.
// //
// An empty value is still an answerable question. It names no chapter, so it // 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 // gets chapter 1, which is what everything here does with an anchor it
// cannot read. // cannot read.
const moved = params.has('verse') ? params.get('verse') const moved = params.has('at') ? params.get('at') : null;
: params.has('chapter') ? params.get('chapter')
: null;
// The address bar is the fallback, and only that: once a select has been // 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 // 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 to know how a verse anchor is spelled -- including the worker, which
reads the chapter back out of the id it sent. 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 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. #} is "this", and an inherited "this" would resolve to the select. #}
<select class="reference-chapter form-select form-select-sm" <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-get="api/reference" hx-target="#reference-verse"
hx-swap="innerHTML"> hx-swap="innerHTML">
{%- for chapter in reference.chapters %} {%- for chapter in reference.chapters %}
@@ -76,7 +80,7 @@
has something to hang the scroll on -- and so the option the reader chose 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. #} comes back marked selected instead of being reset by the swap. #}
<select class="reference-verse form-select form-select-sm" <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"> hx-get="api/reference" hx-target="this" hx-swap="innerHTML">
{% include "verses.njk" %} {% include "verses.njk" %}
</select> </select>