The app was dark-only, with the chrome's colours hardcoded across style.css. Introduce a semantic token layer with three states: bare :root carries the dark palette (the original look, unchanged), a prefers-color-scheme block drives system mode, and [data-theme="light"] lets an explicit choice win against the OS. System is the default. Nothing is stored and no attribute is set until the user picks something, so the media query stays in charge — including an OS change made while the app is open, with no listener needed. The light palette is Open Color throughout, extending the --oc-* subset the compare view already used rather than adding a second scale. Document surfaces (.pdf-page, .image-info, …) are deliberately not themed — a page is white paper in both themes — and the format badges keep their meaning colours. Foreground tokens are set from measured contrast rather than by mirroring the dark ramp, because muted greys have to get darker in a light theme, not lighter: --fg-dim at gray-5 on gray-4 measured 1.39:1, effectively invisible. It is now dividers-only and never carries text. --fg-muted and --fg-faint both land on gray-7, since a light theme has far less headroom below the surface than a dark one has above it. Also: - localized theme selector (all 9 languages) beside the language one, with a pre-paint script in <head> so an explicit light choice cannot flash dark - the select chevron is tokenised as a whole image, since a custom property cannot be interpolated inside url() - the dropzone icon uses currentColor so it follows the accent - drop the duplicate toolbar separator shown when the format badge is hidden Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
248 lines
13 KiB
HTML
248 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title data-i18n="app.title">ReaderJS — Universal Document Viewer</title>
|
|
<link rel="stylesheet" href="/src/style.css" />
|
|
<script>
|
|
// Runs before first paint: style.css defaults to the dark palette, so an explicit
|
|
// light choice would otherwise flash dark for a frame. 'system' stores nothing and
|
|
// leaves the prefers-color-scheme block in charge, so there is nothing to apply.
|
|
try {
|
|
const t = localStorage.getItem('readerjs-theme')
|
|
if (t === 'light' || t === 'dark') document.documentElement.dataset.theme = t
|
|
} catch { /* storage blocked (e.g. sandboxed/embedded) */ }
|
|
</script>
|
|
<!-- WebODF is loaded on-demand by odf-renderer.js when an ODF file is opened -->
|
|
</head>
|
|
<body>
|
|
<div id="outerContainer">
|
|
|
|
<!-- Sidebar: page thumbnails -->
|
|
<div id="sidebarContainer">
|
|
<div id="sidebarToolbar">
|
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
|
|
<path d="M3,11H11V3H3M3,21H11V13H3M13,21H21V13H13M13,3V11H21V3" />
|
|
</svg>
|
|
<span class="sidebar-title" data-i18n="sidebar.pages">Pages</span>
|
|
</div>
|
|
<div id="sidebarContent">
|
|
<div id="thumbsContent"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main content -->
|
|
<div id="mainContainer">
|
|
|
|
<!-- Top toolbar -->
|
|
<div id="toolbarContainer">
|
|
<div id="toolbarLeft">
|
|
<button id="sidebarToggle" class="toolbar-btn" title="Toggle Sidebar" data-i18n-title="tip.sidebar">
|
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
|
|
<path d="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" />
|
|
</svg>
|
|
</button>
|
|
|
|
<div class="toolbar-separator"></div>
|
|
|
|
<button id="prevPage" class="toolbar-btn" title="Previous Page (←)" data-i18n-title="tip.prevPage" disabled>
|
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
|
|
<path d="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z" />
|
|
</svg>
|
|
</button>
|
|
|
|
<div id="pageNumberGroup">
|
|
<input id="pageNumber" type="number" value="1" min="1" max="1" title="Current Page" data-i18n-title="tip.currentPage" />
|
|
<span class="page-sep">/</span>
|
|
<span id="totalPages">—</span>
|
|
</div>
|
|
|
|
<button id="nextPage" class="toolbar-btn" title="Next Page (→)" data-i18n-title="tip.nextPage" disabled>
|
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
|
|
<path d="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="toolbarMiddle">
|
|
<button id="zoomOut" class="toolbar-btn" title="Zoom Out (Ctrl -)" data-i18n-title="tip.zoomOut">
|
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
|
|
<path d="M19,13H5V11H19V13Z" />
|
|
</svg>
|
|
</button>
|
|
|
|
<select id="scaleSelect" title="Zoom" data-i18n-title="tip.zoom">
|
|
<option value="auto" data-i18n="zoom.auto">Auto</option>
|
|
<option value="page-fit" data-i18n="zoom.pageFit">Page Fit</option>
|
|
<option value="page-width" data-i18n="zoom.pageWidth">Page Width</option>
|
|
<option value="page-height" data-i18n="zoom.fitHeight">Fit Height</option>
|
|
<option value="0.5">50%</option>
|
|
<option value="0.75">75%</option>
|
|
<option value="1" selected>100%</option>
|
|
<option value="1.25">125%</option>
|
|
<option value="1.5">150%</option>
|
|
<option value="2">200%</option>
|
|
<option value="3">300%</option>
|
|
</select>
|
|
|
|
<button id="zoomIn" class="toolbar-btn" title="Zoom In (Ctrl +)" data-i18n-title="tip.zoomIn">
|
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
|
|
<path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="toolbarRight">
|
|
<select id="compareModeSelect" class="compare-only" title="Compare view" data-i18n-title="compare.badge">
|
|
<option value="side-by-side" data-i18n="compare.modeSideBySide">Side by side</option>
|
|
<option value="unified" data-i18n="compare.modeUnified">Unified</option>
|
|
<option value="inline" data-i18n="compare.modeInline">Inline</option>
|
|
</select>
|
|
<select id="langSelect" title="Language" data-i18n-title="tip.language">
|
|
<option value="en">English</option>
|
|
<option value="pl">Polski</option>
|
|
<option value="es">Español</option>
|
|
<option value="fr">Français</option>
|
|
<option value="de">Deutsch</option>
|
|
<option value="pt">Português</option>
|
|
<option value="zh">中文</option>
|
|
<option value="ja">日本語</option>
|
|
<option value="ru">Русский</option>
|
|
</select>
|
|
|
|
<select id="themeSelect" title="Theme" data-i18n-title="tip.theme">
|
|
<option value="system" data-i18n="theme.system">System</option>
|
|
<option value="light" data-i18n="theme.light">Light</option>
|
|
<option value="dark" data-i18n="theme.dark">Dark</option>
|
|
</select>
|
|
|
|
<div class="toolbar-separator"></div>
|
|
|
|
<span id="formatBadge" class="hidden"></span>
|
|
|
|
<div class="toolbar-separator"></div>
|
|
|
|
<button id="printBtn" class="toolbar-btn" title="Print (Ctrl+P)" data-i18n-title="tip.print">
|
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
|
|
<path d="M18,3H6V7H18M19,12A1,1 0 0,1 18,11A1,1 0 0,1 19,10A1,1 0 0,1 20,11A1,1 0 0,1 19,12M16,19H8V14H16M19,8H5A3,3 0 0,0 2,11V17H6V21H18V17H22V11A3,3 0 0,0 19,8Z" />
|
|
</svg>
|
|
</button>
|
|
|
|
<label class="toolbar-btn" for="fileInput" title="Open File" data-i18n-title="tip.openFile">
|
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
|
|
<path d="M10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6H12L10,4Z" />
|
|
</svg>
|
|
</label>
|
|
<input id="fileInput" type="file"
|
|
accept=".pdf,.ps,.eps,.epsf,.djvu,.djv,.odt,.ods,.odp,.odg,.odm,.odf,.rtf,.doc,.docx,.mht,.mhtml,.chm,.pptx,.xlsx,.xls,.xlsm,.xlsb,.csv,.tsv,.js,.mjs,.cjs,.jsx,.ts,.tsx,.json,.jsonc,.xml,.html,.htm,.yaml,.yml,.css,.scss,.less,.py,.java,.c,.h,.cpp,.cc,.hpp,.cs,.go,.rs,.rb,.php,.sh,.bash,.sql,.kt,.swift,.toml,.ini,.diff,.md,.markdown,.txt,.text,.log,.png,.jpg,.jpeg,.gif,.webp,.avif,.bmp,.svg,.ico,.tif,.tiff,.cbz,.cbr,.cbt,.epub,.mobi,.azw3,.azw,.kf8,.fb2,.fbz"
|
|
aria-label="Open document file" data-i18n-aria="aria.openFile" />
|
|
|
|
<button id="compareBtn" class="toolbar-btn" title="Compare two files…" data-i18n-title="compare.openTwo">
|
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor">
|
|
<path d="M21 3C21.53 3 22.04 3.21 22.41 3.59C22.79 3.96 23 4.47 23 5V15C23 15.53 22.79 16.04 22.41 16.41C22.04 16.79 21.53 17 21 17H7C6.47 17 5.96 16.79 5.59 16.41C5.21 16.04 5 15.53 5 15V5C5 4.47 5.21 3.96 5.59 3.59C5.96 3.21 6.47 3 7 3H21M3 19H18V21H3C2.47 21 1.96 20.79 1.59 20.41C1.21 20.04 1 19.53 1 19V8H3V19Z" />
|
|
</svg>
|
|
</button>
|
|
<input id="compareInput" type="file" class="hidden" multiple
|
|
accept=".pdf,.djvu,.djv,.epub,.mobi,.azw3,.azw,.kf8,.fb2,.fbz,.txt,.text,.log,.md,.markdown,.csv,.tsv,.docx,.doc,.rtf,.odt,.ods,.odp,.odg,.xlsx,.xls,.xlsm,.xlsb,.js,.ts,.json,.xml,.yaml,.yml,.py,.java,.c,.cpp,.cs,.go,.rs,.rb,.php,.sh,.sql,.html,.css" aria-hidden="true" />
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Loading bar -->
|
|
<div id="loadingBar" class="hidden">
|
|
<div id="loadingBarProgress"></div>
|
|
</div>
|
|
|
|
<!-- Error bar -->
|
|
<div id="errorBar" class="hidden" role="alert">
|
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" style="flex-shrink:0">
|
|
<path d="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
|
|
</svg>
|
|
<span id="errorMsg"></span>
|
|
<button id="errorClose" aria-label="Dismiss" data-i18n-aria="aria.dismiss">
|
|
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
|
|
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Viewer -->
|
|
<div id="viewerContainer">
|
|
|
|
<!-- Drop zone (shown when no file loaded) -->
|
|
<div id="dropzone">
|
|
<div id="dropzoneContent">
|
|
<div id="dropzoneIcon">
|
|
<svg viewBox="0 0 24 24" width="72" height="72" fill="currentColor">
|
|
<path d="M11 20H6.5Q4.22 20 2.61 18.43 1 16.85 1 14.58 1 12.63 2.17 11.1 3.35 9.57 5.25 9.15 5.88 6.85 7.75 5.43 9.63 4 12 4 14.93 4 16.96 6.04 19 8.07 19 11 20.73 11.2 21.86 12.5 23 13.78 23 15.5 23 17.38 21.69 18.69 20.38 20 18.5 20H13V12.85L14.6 14.4L16 13L12 9L8 13L9.4 14.4L11 12.85Z" />
|
|
</svg>
|
|
</div>
|
|
<h2 data-i18n="dropzone.title">Open a Document</h2>
|
|
<p><span data-i18n="dropzone.drop">Drop a file here, or</span> <label for="fileInput" data-i18n="dropzone.browse">browse</label></p>
|
|
<div class="format-tags">
|
|
<span class="format-tag tag-pdf">PDF</span>
|
|
<span class="format-tag tag-ps">PS</span>
|
|
<span class="format-tag tag-djvu">DJVU</span>
|
|
<span class="format-tag tag-odf">ODT</span>
|
|
<span class="format-tag tag-odf">ODS</span>
|
|
<span class="format-tag tag-odf">ODP</span>
|
|
<span class="format-tag tag-rtf">RTF</span>
|
|
<span class="format-tag tag-doc">DOC</span>
|
|
<span class="format-tag tag-docx">DOCX</span>
|
|
<span class="format-tag tag-mhtml">MHTML</span>
|
|
<span class="format-tag tag-chm">CHM</span>
|
|
<span class="format-tag tag-pptx">PPTX</span>
|
|
<span class="format-tag tag-xlsx">XLSX</span>
|
|
<span class="format-tag tag-md">MD</span>
|
|
<span class="format-tag tag-txt">TXT</span>
|
|
<span class="format-tag tag-csv">CSV</span>
|
|
<span class="format-tag tag-code">JSON</span>
|
|
<span class="format-tag tag-code">XML</span>
|
|
<span class="format-tag tag-code">YAML</span>
|
|
<span class="format-tag tag-image">JPG</span>
|
|
<span class="format-tag tag-image">PNG</span>
|
|
<span class="format-tag tag-image">TIFF</span>
|
|
<span class="format-tag tag-image">EXIF</span>
|
|
<span class="format-tag tag-comic">CBZ</span>
|
|
<span class="format-tag tag-comic">CBR</span>
|
|
<span class="format-tag tag-comic">CBT</span>
|
|
<span class="format-tag tag-epub">EPUB</span>
|
|
<span class="format-tag tag-epub">MOBI</span>
|
|
<span class="format-tag tag-epub">AZW3</span>
|
|
<span class="format-tag tag-epub">FB2</span>
|
|
</div>
|
|
<div class="powered-by">
|
|
<span data-i18n="dropzone.poweredBy">Powered by</span>
|
|
<a href="https://github.com/mozilla/pdf.js" target="_blank" rel="noopener">PDF.js</a>
|
|
· <a href="https://github.com/Alpaq92/dejaview" target="_blank" rel="noopener">DejaView</a>
|
|
· <a href="https://github.com/Alpaq92/JSDoc" target="_blank" rel="noopener">JSDoc</a>
|
|
· <a href="https://github.com/tbluemel/rtf.js" target="_blank" rel="noopener">RTF.js</a>
|
|
· <a href="https://github.com/mwilliamson/mammoth.js" target="_blank" rel="noopener">mammoth.js</a>
|
|
· <a href="https://github.com/gptsci/pptxviewjs" target="_blank" rel="noopener">PptxViewJS</a>
|
|
· <a href="https://sheetjs.com/" target="_blank" rel="noopener">SheetJS</a>
|
|
· <a href="https://www.papaparse.com/" target="_blank" rel="noopener">Papa Parse</a>
|
|
· <a href="https://highlightjs.org/" target="_blank" rel="noopener">highlight.js</a>
|
|
· <a href="https://github.com/markedjs/marked" target="_blank" rel="noopener">marked</a>
|
|
· <a href="https://github.com/Stuk/jszip" target="_blank" rel="noopener">JSZip</a>
|
|
· <a href="https://github.com/nika-begiashvili/libarchivejs" target="_blank" rel="noopener">libarchive.js</a>
|
|
· <a href="https://github.com/johnfactotum/foliate-js" target="_blank" rel="noopener">foliate-js</a>
|
|
· <a href="https://github.com/photopea/UTIF.js" target="_blank" rel="noopener">UTIF.js</a>
|
|
· <a href="https://github.com/MikeKovarik/exifr" target="_blank" rel="noopener">exifr</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Document render target -->
|
|
<div id="docContainer" class="hidden"></div>
|
|
|
|
</div><!-- /viewerContainer -->
|
|
</div><!-- /mainContainer -->
|
|
</div><!-- /outerContainer -->
|
|
|
|
<!-- Print layer: populated by PDF renderer before window.print() -->
|
|
<div id="printLayer" aria-hidden="true"></div>
|
|
|
|
<script type="module" src="/src/main.js"></script>
|
|
</body>
|
|
</html>
|