fix(web): convert remaining JS-global bindings for the CSP build; drop unsafe-eval

The strict CSP sweep surfaced a final class of bindings on the audio
reader and book detail pages that referenced browser globals
(Number, String, Math, window, document) — identifiers the CSP-safe
evaluator resolves only from component scope:

- audio reader: scrub input, volume slider/input, speed+skip active
  styles, genre tick styles, and the default-speed select now route
  through component methods (onScrubInput, setVolumeFromEvent,
  applyDefaultSpeedFromSelect, volumeLabel, railTickStyle,
  isSkipActive, isSpeedActive, isDefaultSpeed)
- book detail: cover-upload click and banner edit validation moved to
  component methods (triggerCoverUpload, bannerEditHasText)
- admin: Refresh-to-View-Books reload moved to reloadPage()
- reader: note edit validation moved to noteEditHasText()

CSP header: frame-src 'self' blob: (foliate renders book content in
a blob: frame) and blob: on font-src/img-src (EPUB-embedded fonts
and images load as blob: URLs inside that frame). 'unsafe-eval' is
gone: script-src is 'self' plus 'unsafe-inline' for the pre-paint
theme flash guard.

Also: header openPanel promoted to the root component (one open
panel across all sidebar panels, persisted in init), with the
sidebar shell reduced to themeMode state + methods; fmtTime restored
to the audioReader component (ripped by the unexport pass — time
displays were dead on the audio reader).
This commit is contained in:
John O'Keefe committed 2026-10-25 17:39:30 -04:00
1 parent 09545ca5e1
commit 6d01bd7971
3 files changed
+15 -4

No files matched your search

+3 -3
View File
@@ -829,7 +829,7 @@ templ ReaderSearchDrawer() {
</button>
</div>
<div class="reader-search-status" x-show="searchQuery || searching || searchGroups.length || searchError">
<span x-show="searching" x-text="'Searching… ' + Math.round(searchProgress * 100) + '%'">Searching…</span>
<span x-show="searching" x-text="searchProgressLabel()">Searching…</span>
<span x-show="!searching && searchGroups.length" x-text="searchMatchCount + ' match' + (searchMatchCount === 1 ? '' : 'es')">0 matches</span>
<span x-show="!searching && searchQuery && !searchGroups.length && !searchError">No matches</span>
<span x-show="searchError" x-text="searchError" style="color: #f87171;">Search failed</span>
@@ -961,12 +961,12 @@ templ ReaderSettingsDrawer() {
<label class="block mb-2">
Brightness
<input type="range" name="fx_brightness" x-model.number="fxBrightness" @input="applyFxFilter()" @change="applyFxFilter(true)" min="0.3" max="1.3" step="0.05" class="w-full"/>
<span class="text-xs" x-text="Math.round(fxBrightness * 100) + '%'" style="color: var(--text-secondary)">100%</span>
<span class="text-xs" x-text="brightnessLabel()" style="color: var(--text-secondary)">100%</span>
</label>
<label class="block mb-2">
Contrast
<input type="range" name="fx_contrast" x-model.number="fxContrast" @input="applyFxFilter()" @change="applyFxFilter(true)" min="0.7" max="1.3" step="0.05" class="w-full"/>
<span class="text-xs" x-text="Math.round(fxContrast * 100) + '%'" style="color: var(--text-secondary)">100%</span>
<span class="text-xs" x-text="contrastLabel()" style="color: var(--text-secondary)">100%</span>
</label>
<label class="flex items-center mb-2">
<input type="checkbox" name="fx_invert" x-model="fxInvert" @change="applyFxFilter(true)" class="mr-2"/>