diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-06-27 23:39:31 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-06-27 23:39:31 +0900 |
| commit | 674fe965550444db87edc7937ff6932e1a918d9d (patch) | |
| tree | e8a80dd958d3e082485286bf5785a7992b6e6b0e /vhosts/blog/public/slide.js | |
| parent | fe4d1d625b53796c5f20399790e5ff8c7a7e1608 (diff) | |
| download | nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.tar.gz nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.tar.zst nsfisis.dev-674fe965550444db87edc7937ff6932e1a918d9d.zip | |
feat(meta): rename vhosts/ directory to services/
Diffstat (limited to 'vhosts/blog/public/slide.js')
| -rw-r--r-- | vhosts/blog/public/slide.js | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/vhosts/blog/public/slide.js b/vhosts/blog/public/slide.js deleted file mode 100644 index 4c7a0de8..00000000 --- a/vhosts/blog/public/slide.js +++ /dev/null @@ -1,60 +0,0 @@ -import { GlobalWorkerOptions, getDocument } from "/pdf.min.mjs"; - -document.addEventListener("DOMContentLoaded", async () => { - GlobalWorkerOptions.workerSrc = "/pdf.worker.min.mjs"; - - const canvas = document.getElementById("slide"); - const ctx = canvas.getContext("2d"); - const url = canvas.dataset.slideLink; - - let pageNum = 1; - let pageNumPending = null; - let pageRendering = false; - let doc = null; - - const renderPage = async (num) => { - pageRendering = true; - const page = await doc.getPage(num); - - const viewport = page.getViewport({ scale: 1.0 }); - canvas.height = viewport.height; - canvas.width = viewport.width; - - // TODO: error handling - await page.render({ - canvasContext: ctx, - viewport: viewport, - }); - - pageRendering = false; - if (pageNumPending !== null) { - renderPage(pageNumPending); - pageNumPending = null; - } - }; - - const queueRenderPage = (num) => { - if (pageRendering) { - pageNumPending = num; - } else { - renderPage(num); - } - }; - - const prev = document.getElementById("prev"); - prev.addEventListener("click", () => { - if (pageNum <= 1) return; - pageNum--; - queueRenderPage(pageNum); - }); - const next = document.getElementById("next"); - next.addEventListener("click", () => { - if (pageNum >= doc.numPages) return; - pageNum++; - queueRenderPage(pageNum); - }); - - // TODO: error handling - doc = await getDocument(url).promise; - queueRenderPage(pageNum); -}); |
