diff --git a/src/llm/web/pdf.html b/src/llm/web/pdf.html index de062e7..77c2f07 100644 --- a/src/llm/web/pdf.html +++ b/src/llm/web/pdf.html @@ -186,6 +186,7 @@ pdfjs = null; } + async function show() { // ── file list ── let files = []; try { @@ -211,11 +212,7 @@ } if (files.length > 1) sel.hidden = false; const current = files.find(f => f.name === wantFile) || files.find(f => f.renderable) || files[0]; - // the "done:" throws below end this module on purpose once a non-PDF - // pane is up; keep the console quiet about them - window.addEventListener('unhandledrejection', ev => { - if (ev.reason && /^done: /.test(String(ev.reason.message || ev.reason))) ev.preventDefault(); - }); + sel.value = current.name; const fileUrl = '/pdf/' + encodeURIComponent(key) + '/file?name=' + encodeURIComponent(current.name); $('download').href = fileUrl; @@ -351,7 +348,7 @@ const find = domFind(pre); nav.goTo(1, false); seedFind(find); - throw new Error('done: text'); // the module's PDF path below must not run + return; } // ── Word (.docx) via docx-preview: sections become pages; zoom scales @@ -414,7 +411,7 @@ const hashPage = parseInt((location.hash.match(/page=(\d+)/) || [])[1] || '0', 10); nav.goTo(hashPage || wantPage, false); seedFind(find); - throw new Error('done: docx'); // stop before the PDF path + return; } if (!pdfjs) { @@ -666,6 +663,8 @@ $('find').value = probe; runFind(probe); } + } + show().catch(e => console.warn('viewer:', e && e.message || e));