From 0b37045254a4a126ee7104fef91d242c9a8aba21 Mon Sep 17 00:00:00 2001 From: BryanMurphy <123925276+BPMData@users.noreply.github.com> Date: Sat, 28 Nov 2026 01:09:47 -0500 Subject: [PATCH 1/3] Split main.js, step 0: setters for doc, ink data, language and save state Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 ++ app/index.html | 4 ++-- app/main.js | 39 +++++++++++++++++++++++++++------------ app/report/index.html | 2 +- app/sw.js | 12 ++++++------ app/version.json | 2 +- index.html | 2 +- overlay/ink_overlay.html | 2 +- 8 files changed, 41 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53fe4c4..f1dbb46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- **Tidier PDF app code** (v61, PDF app). app/main.js is split into smaller files. Nothing changes for teachers. + - **Plan for tidying the PDF app's code** (v60, docs only). `docs/plans/APP_MAIN_SPLIT.md` describes, step by step, how to split `app/main.js` into smaller files without changing anything the app does. Nothing changes for teachers yet. - **One email per report, for all four apps** (v59, report script and the report page's last screen). No more thank-you emails: the report page already says thank you once the report has gone through, so the email was a waste of Gmail's ~100 a day. People who leave an email now get just the one "here's what we changed" email when their issue is closed as completed, and that now works for AllAboard, AllHail and OverHeard reports too, not just OverBoard's. The report limits go up to 60 an hour and 70 a day (all four apps together). diff --git a/app/index.html b/app/index.html index 17657ad..396561d 100644 --- a/app/index.html +++ b/app/index.html @@ -5,7 +5,7 @@ OverBoard PDF - + @@ -47,7 +47,7 @@

Open again

Your PDF and your ink stay in this browser on this computer. Nothing is uploaded. Have a Word file? In Word, choose File → Save as PDF, then drop the PDF here. Have an HTML worksheet? Drop it here to get a _board.html copy you can write on. -
About OverBoard · Board not working? · v60

+
About OverBoard · Board not working? · v61

diff --git a/app/main.js b/app/main.js index 071a6f3..f50135e 100644 --- a/app/main.js +++ b/app/main.js @@ -46,6 +46,9 @@ const HIGHLIGHT_COLOR = '#fdd835'; // highlighter starts yellow; after that it r const HIGHLIGHT_W = 22; // starting highlighter width; the - / + buttons change it while the highlighter is on const HIGHLIGHT_STRENGTH = 50; // highlight strength in % (Highlighter ▾ slider, 10-100): 100 = the full color, 50 = halfway to white let tr = obT(obLang()); // OverBoard's words in the language picked in Settings (shared/strings.js); setLang() swaps it +function setTr(t) { + tr = t; +} const PEN_COLOR = '#e0218a'; // the pen starts Barbie pink (high visibility on the board) unless File ▸ Settings… picks another; the palette changes it const COVER_COLOR = '#111111'; // Highlighter ▾ Cover: an opaque stroke that hides answers (erase it to reveal them) /* ===================== */ @@ -133,8 +136,17 @@ const T = { /* ---------- the open document ---------- */ let doc = null; // { hash, name, pages, file, pdf, notebook } let D = null; // ink data: { v: 3, t, active, at, periods: { P1: [strokes] }, rot: { page: 90 | 180 | 270 } (Turn page) } +function setDoc(v) { + doc = v; +} +function setInkData(v) { + D = v; +} let saveTimer = null, dirty = false; +function setDirty(v) { + dirty = v; +} const viewer = new Viewer(pagesEl, { show: (P) => ink.show(P), @@ -634,8 +646,8 @@ async function openFile(file, handlePromise) { /* not ours */ } const fromPdf = inPdf && (!saved || (inPdf.t || 0) >= (saved.t || 0)); - D = fromPdf ? inPdf : saved || fresh(); - doc = { + setInkData(fromPdf ? inPdf : saved || fresh()); + setDoc({ hash, base, name: file.name, @@ -646,7 +658,7 @@ async function openFile(file, handlePromise) { linkOn: false, info: null, notebook: !!nb, - }; + }); document.body.classList.toggle('notebook', doc.notebook); addPageEl.hidden = !doc.notebook; store @@ -688,8 +700,8 @@ async function openFile(file, handlePromise) { loadOutline(pdf); } catch (e) { console.error(e); - doc = null; - D = null; + setDoc(null); + setInkData(null); if (!e || e.name !== 'PasswordException') dropPdfWorker(); document.body.classList.add('start'); bar.hidden = true; @@ -709,7 +721,7 @@ async function openFile(file, handlePromise) { async function closeDoc(showStart = true) { if (!doc) return; rememberOpen(null); // first, so a reload while this finishes doesn't reopen it - dirty = true; + setDirty(true); await writeNow(); await writePdf(); viewer.close(); @@ -718,11 +730,10 @@ async function closeDoc(showStart = true) { } catch (e) { /* already gone */ } - doc = null; - D = null; + setDoc(null); + setInkData(null); toc.hidden = true; - outline = []; - hasChapters = false; + clearChapters(); addPageEl.hidden = true; pageMenu.show(false); document.body.classList.remove('notebook'); @@ -895,6 +906,10 @@ const fitToolbar = () => /* ---------- chapters (PDF outline) ---------- */ let outline = []; // flat [{ button, page }] for marking the current chapter +function clearChapters() { + outline = []; + hasChapters = false; +} async function loadOutline(pdf) { const ul = $('ul', toc); ul.textContent = ''; @@ -1145,7 +1160,7 @@ function setLang(code) { } catch (e) { /* blocked */ } - tr = obT(code); + setTr(obT(code)); translateAll(); renderRecent(); timer.refresh(); @@ -1787,7 +1802,7 @@ async function importInk(file) { return; const has = Object.values(D.periods).some((l) => l.length); if (has && !confirm(tr('confirm_replace_ink', { f: file.name }))) return; - D = data; + setInkData(data); ink.setData(D); viewer.applyTurns(); refreshRedo(); diff --git a/app/report/index.html b/app/report/index.html index 647ac27..ba9b2d4 100644 --- a/app/report/index.html +++ b/app/report/index.html @@ -98,7 +98,7 @@

Is OverBoard not working on your board?

If something doesn't work the way the page asks, that's fine. That's exactly what I need to know. Just keep going.

Nothing is sent until you press Send at the very end, and you'll see everything first. No worksheets, PDFs or ink are ever included.

-

OverBoard v60

+

OverBoard v61

diff --git a/app/sw.js b/app/sw.js index d5f899c..44eb486 100644 --- a/app/sw.js +++ b/app/sw.js @@ -1,7 +1,7 @@ // ===== GENERATED by tools/build.py: every file the app needs, with the start of its SHA-256. Do not edit by hand. ===== -const VERSION = 'f7d570a4ef8d'; +const VERSION = '1ea20179f7ec'; const FILES = { - "../overlay/ink_overlay.html": "b19a861c912cbb4c", + "../overlay/ink_overlay.html": "7c160e292e47db57", "../shared/ink-core.js": "b65c19035e241559", "../shared/strings.js": "f2394bc536e6ec28", "../shared/toolbar.css": "e1e1905491edf8e6", @@ -17,14 +17,14 @@ const FILES = { "icons/icon-512.png": "46ca8bd2d6a32612", "icons/maskable-512.png": "c7d41ed2fa4ad874", "image.js": "a867d49b8c47a4a0", - "index.html": "fac8c0a6e92e1448", + "index.html": "4b037bbf59b6372e", "ink.js": "79d0b39c073d56dc", "libs.js": "3b92080779974cfa", - "main.js": "f6b5c9c39dfdea92", + "main.js": "521e23c7a87db87c", "manifest.json": "798bbad3d5e46dc6", "notebook.js": "ab3ff1706ec424b3", "offline.js": "e620a1ba2b6ea506", - "report/index.html": "61a7af1c0d94cd25", + "report/index.html": "b104fc895221db59", "store.js": "5487f91114ab7c30", "textlayer.js": "32d43c22f725a2d8", "vendor/pdf-lib@1.17.1/LICENSE.md": "f2c9fc00fdb66eb9", @@ -217,7 +217,7 @@ const FILES = { "vendor/pdfjs-dist@4.10.38/standard_fonts/LiberationSans-BoldItalic.ttf": "a224075ac17495ad", "vendor/pdfjs-dist@4.10.38/standard_fonts/LiberationSans-Italic.ttf": "832b4406dbef2362", "vendor/pdfjs-dist@4.10.38/standard_fonts/LiberationSans-Regular.ttf": "f8ace1f892b2bd9d", - "version.json": "6357dd9f0ebe11c5", + "version.json": "95019d569eec925c", "viewer.js": "f1e96f64aec11170" }; // ===== END GENERATED ===== diff --git a/app/version.json b/app/version.json index bde0858..bfd727e 100644 --- a/app/version.json +++ b/app/version.json @@ -1,5 +1,5 @@ { - "v": "b6934d09ddff", + "v": "d51ceb0821e8", "js": [ "embed.js", "export.js", diff --git a/index.html b/index.html index a4adfbc..dfd17a4 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@

Exit ticket

OverBoard · page 2 / 2 · Your ink saves in this browser only. Nothing is uploaded.
-