Files
longhikes/web/assets/prefs.js
T
swaitsandClaude Fable 5.2 46dc81523c
Mirror to forge / mirror (push) Canceled after 0s
Validate / validate (push) Canceled after 0s
Validate / site (push) Canceled after 0s
Validate / deploy (push) Canceled after 0s
Add saved trails, and move the units and theme switches to the header
A visitor can save trails with a star on every list row and a Save
button on each trail page. The list is kept in localStorage (lh-saved)
and shown at /saved/, with a map of only those trails and a link that
carries the list in its address (/saved/?t=id,id) so it can be
bookmarked or sent to another device or person. A list opened from a
link never overwrites the visitor's own; "Save these" adds to it. The
page is noindex and left out of the sitemap.

The miles/km switch and the auto/light/dark choice move from the footer
to the header on every page, beside a Saved link that shows the count.
They are hidden without JavaScript.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-15 16:01:29 -07:00

19 lines
965 B
JavaScript

/* Runs in <head>, before first paint: marks that JavaScript runs, and applies the
reader's saved theme, length order and base map. Saved by app.js (the units
switch and theme menu in the header, and the Outdoor / Plain switch on a
trail map). The theme menu's button shows the theme from html[data-theme],
so it is right from the first paint too. */
(function () {
'use strict';
var root = document.documentElement;
root.classList.add('js');
try {
var theme = localStorage.getItem('lh-theme');
var units = localStorage.getItem('lh-units');
var basemap = localStorage.getItem('lh-basemap');
if (theme === 'light' || theme === 'dark') root.dataset.theme = theme;
if (units === 'km') root.dataset.units = 'km'; /* anything else, an old 'mi' included, is miles */
if (basemap === 'plain') root.dataset.basemap = 'plain'; /* anything else is the outdoor map */
} catch (e) { /* storage blocked: defaults apply */ }
})();