aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--services/nuldoc/nuldoc-src/commands/build.ts24
-rw-r--r--services/nuldoc/nuldoc-src/components/StaticScript.ts10
-rw-r--r--services/nuldoc/nuldoc-src/components/StaticStylesheet.ts13
-rw-r--r--services/nuldoc/nuldoc-src/pages/AboutPage.ts1
-rw-r--r--services/nuldoc/nuldoc-src/pages/SlidePage.ts1
-rw-r--r--services/nuldoc/public/blog/slide.js60
-rw-r--r--services/nuldoc/public/default/my-icon.js151
-rw-r--r--services/nuldoc/public/default/slide.js60
-rw-r--r--services/nuldoc/public/slides/my-icon.js151
-rw-r--r--services/nuldoc/static/_all/favicon.svg (renamed from services/nuldoc/static/favicon.svg)0
-rw-r--r--services/nuldoc/static/_all/style.css (renamed from services/nuldoc/static/style.css)0
-rw-r--r--services/nuldoc/static/about/my-icon.js (renamed from services/nuldoc/public/blog/my-icon.js)0
-rw-r--r--services/nuldoc/static/my-icon.js151
-rw-r--r--services/nuldoc/static/slide.js60
-rw-r--r--services/nuldoc/static/slides/pdf.min.mjs (renamed from services/nuldoc/static/pdf.min.mjs)0
-rw-r--r--services/nuldoc/static/slides/pdf.worker.min.mjs (renamed from services/nuldoc/static/pdf.worker.min.mjs)0
-rw-r--r--services/nuldoc/static/slides/slide.js (renamed from services/nuldoc/public/about/slide.js)0
17 files changed, 33 insertions, 649 deletions
diff --git a/services/nuldoc/nuldoc-src/commands/build.ts b/services/nuldoc/nuldoc-src/commands/build.ts
index 2a9295d..6185381 100644
--- a/services/nuldoc/nuldoc-src/commands/build.ts
+++ b/services/nuldoc/nuldoc-src/commands/build.ts
@@ -227,19 +227,19 @@ function collectTags(taggedPages: TaggedPage[]): [string, TaggedPage[]][] {
}
async function copyStaticFiles(config: Config) {
+ const staticDir = join(Deno.cwd(), config.locations.staticDir);
+
for (const site of Object.keys(config.sites)) {
- const globPattern = joinGlobs([
- Deno.cwd(),
- config.locations.staticDir,
- "*",
- ]);
- for await (const entry of expandGlob(globPattern)) {
- const src = entry.path;
- const dst = src.replace(
- config.locations.staticDir,
- join(config.locations.destDir, site),
- );
- await Deno.copyFile(src, dst);
+ const destDir = join(Deno.cwd(), config.locations.destDir, site);
+
+ // Copy files from static/_all/ to all sites
+ for await (const entry of expandGlob(join(staticDir, "_all", "*"))) {
+ await Deno.copyFile(entry.path, join(destDir, entry.name));
+ }
+
+ // Copy files from static/<site>/ to the corresponding site
+ for await (const entry of expandGlob(join(staticDir, site, "*"))) {
+ await Deno.copyFile(entry.path, join(destDir, entry.name));
}
}
}
diff --git a/services/nuldoc/nuldoc-src/components/StaticScript.ts b/services/nuldoc/nuldoc-src/components/StaticScript.ts
index b8dc95d..1a3431a 100644
--- a/services/nuldoc/nuldoc-src/components/StaticScript.ts
+++ b/services/nuldoc/nuldoc-src/components/StaticScript.ts
@@ -4,14 +4,20 @@ import { Element, script } from "../dom.ts";
import { calculateFileHash } from "./utils.ts";
export default async function StaticScript(
- { fileName, type, defer, config }: {
+ { site, fileName, type, defer, config }: {
+ site?: string;
fileName: string;
type?: string;
defer?: "true";
config: Config;
},
): Promise<Element> {
- const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
+ const filePath = join(
+ Deno.cwd(),
+ config.locations.staticDir,
+ site || "_all",
+ fileName,
+ );
const hash = await calculateFileHash(filePath);
const attrs: Record<string, string> = { src: `${fileName}?h=${hash}` };
if (type) attrs.type = type;
diff --git a/services/nuldoc/nuldoc-src/components/StaticStylesheet.ts b/services/nuldoc/nuldoc-src/components/StaticStylesheet.ts
index 065ee20..f2adb47 100644
--- a/services/nuldoc/nuldoc-src/components/StaticStylesheet.ts
+++ b/services/nuldoc/nuldoc-src/components/StaticStylesheet.ts
@@ -4,9 +4,18 @@ import { Element, link } from "../dom.ts";
import { calculateFileHash } from "./utils.ts";
export default async function StaticStylesheet(
- { fileName, config }: { fileName: string; config: Config },
+ { site, fileName, config }: {
+ site?: string;
+ fileName: string;
+ config: Config;
+ },
): Promise<Element> {
- const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
+ const filePath = join(
+ Deno.cwd(),
+ config.locations.staticDir,
+ site || "_all",
+ fileName,
+ );
const hash = await calculateFileHash(filePath);
return link({ rel: "stylesheet", href: `${fileName}?h=${hash}` });
}
diff --git a/services/nuldoc/nuldoc-src/pages/AboutPage.ts b/services/nuldoc/nuldoc-src/pages/AboutPage.ts
index 65a503d..5ae2ff5 100644
--- a/services/nuldoc/nuldoc-src/pages/AboutPage.ts
+++ b/services/nuldoc/nuldoc-src/pages/AboutPage.ts
@@ -51,6 +51,7 @@ export default async function AboutPage(
img({ src: "/favicon.svg" }),
),
await StaticScript({
+ site: "about",
fileName: "/my-icon.js",
defer: "true",
config,
diff --git a/services/nuldoc/nuldoc-src/pages/SlidePage.ts b/services/nuldoc/nuldoc-src/pages/SlidePage.ts
index 1c6709c..48e8037 100644
--- a/services/nuldoc/nuldoc-src/pages/SlidePage.ts
+++ b/services/nuldoc/nuldoc-src/pages/SlidePage.ts
@@ -89,6 +89,7 @@ export default async function SlidePage(
button({ id: "next", type: "button" }, "Next"),
),
await StaticScript({
+ site: "slides",
fileName: "/slide.js",
type: "module",
config,
diff --git a/services/nuldoc/public/blog/slide.js b/services/nuldoc/public/blog/slide.js
deleted file mode 100644
index 4c7a0de..0000000
--- a/services/nuldoc/public/blog/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);
-});
diff --git a/services/nuldoc/public/default/my-icon.js b/services/nuldoc/public/default/my-icon.js
deleted file mode 100644
index 48c556d..0000000
--- a/services/nuldoc/public/default/my-icon.js
+++ /dev/null
@@ -1,151 +0,0 @@
-const init = () => {
- const SIZE = 100;
- const DPR = globalThis.devicePixelRatio || 1;
- const FPS = 15;
-
- const colorBackground = "rgb(255, 255, 255)";
- const color蜜柑の果実 = "rgb(255, 165, 0)";
- const color蜜柑の内果皮 = "rgb(255, 255, 255)";
- const color蜜柑のじょうのう = "rgb(255, 255, 255)";
- const colorMosaic = [
- [255, 165, 0],
- [255, 140, 0],
- [255, 215, 0],
- [255, 205, 114],
- [255, 210, 127],
- [255, 192, 76],
- [255, 169, 12],
- [255, 228, 178],
- ];
- const colorEye = "rgb(0, 0, 0)";
-
- const container = document.getElementById("myIcon");
- const canvas = document.createElement("canvas");
- canvas.width = SIZE * DPR;
- canvas.height = SIZE * DPR;
- canvas.style.width = `${SIZE}px`;
- canvas.style.height = `${SIZE}px`;
- const ctx = canvas.getContext("2d");
- ctx.scale(DPR, DPR);
-
- let frameCount = 0;
-
- function randomChoice(xs) {
- return xs[(Math.random() * xs.length) | 0];
- }
-
- function roundRect(x, y, w, h, r) {
- ctx.beginPath();
- ctx.moveTo(x + r, y);
- ctx.lineTo(x + w - r, y);
- ctx.quadraticCurveTo(x + w, y, x + w, y + r);
- ctx.lineTo(x + w, y + h - r);
- ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
- ctx.lineTo(x + r, y + h);
- ctx.quadraticCurveTo(x, y + h, x, y + h - r);
- ctx.lineTo(x, y + r);
- ctx.quadraticCurveTo(x, y, x + r, y);
- ctx.closePath();
- ctx.fill();
- }
-
- function draw蜜柑() {
- // 果実、外果皮
- ctx.fillStyle = color蜜柑の果実;
- ctx.beginPath();
- ctx.arc(50, 50, 50, 0, Math.PI * 2);
- ctx.fill();
-
- // 内果皮
- ctx.strokeStyle = color蜜柑の内果皮;
- ctx.lineWidth = 4;
- ctx.beginPath();
- ctx.arc(50, 50, 45, 0, Math.PI * 2);
- ctx.stroke();
-
- // じょうのう
- ctx.strokeStyle = color蜜柑のじょうのう;
- ctx.lineWidth = 2;
- for (let t = 0; t < 10; t++) {
- ctx.save();
- ctx.translate(50, 50);
- ctx.rotate((t * Math.PI) / 5);
-
- ctx.beginPath();
- ctx.moveTo(0, -45);
- ctx.lineTo(0, 0);
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(0, -40);
- ctx.lineTo(-4, -45);
- ctx.lineTo(4, -45);
- ctx.closePath();
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(0, -20);
- ctx.lineTo(-3, 0);
- ctx.lineTo(3, 0);
- ctx.closePath();
- ctx.stroke();
-
- ctx.restore();
- }
- }
-
- function drawMosaic(f) {
- for (let dy = 0; dy < 10; dy++) {
- for (let dx = 0; dx < 10; dx++) {
- const y = dy * 10;
- const x = dx * 10;
- if (x < 50) {
- continue;
- }
- if ((x - 45) ** 2 + (y - 45) ** 2 > 55 ** 2) {
- continue;
- }
- if (Math.random() < 0.167 * f) {
- continue;
- }
-
- const [r, g, b] = randomChoice(colorMosaic);
- const a = 0.9 - f * 0.05;
- ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
- ctx.fillRect(x, y, 10, 10);
- }
- }
- }
-
- function drawEyes() {
- ctx.fillStyle = colorEye;
- roundRect(30, 35, 6, 25, 2);
- roundRect(64, 35, 6, 25, 2);
- }
-
- function mainLoop() {
- frameCount++;
- if (4 <= frameCount % 15) {
- setTimeout(mainLoop, 1000 / FPS);
- return;
- }
-
- ctx.fillStyle = colorBackground;
- ctx.fillRect(0, 0, SIZE, SIZE);
- ctx.clearRect(0, 0, SIZE, SIZE);
-
- draw蜜柑();
- drawMosaic(frameCount % 15);
- drawEyes();
-
- setTimeout(mainLoop, 1000 / FPS);
- }
-
- mainLoop();
- while (container.firstChild) {
- container.removeChild(container.firstChild);
- }
- container.appendChild(canvas);
-};
-
-document.addEventListener("DOMContentLoaded", init);
diff --git a/services/nuldoc/public/default/slide.js b/services/nuldoc/public/default/slide.js
deleted file mode 100644
index 4c7a0de..0000000
--- a/services/nuldoc/public/default/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);
-});
diff --git a/services/nuldoc/public/slides/my-icon.js b/services/nuldoc/public/slides/my-icon.js
deleted file mode 100644
index 48c556d..0000000
--- a/services/nuldoc/public/slides/my-icon.js
+++ /dev/null
@@ -1,151 +0,0 @@
-const init = () => {
- const SIZE = 100;
- const DPR = globalThis.devicePixelRatio || 1;
- const FPS = 15;
-
- const colorBackground = "rgb(255, 255, 255)";
- const color蜜柑の果実 = "rgb(255, 165, 0)";
- const color蜜柑の内果皮 = "rgb(255, 255, 255)";
- const color蜜柑のじょうのう = "rgb(255, 255, 255)";
- const colorMosaic = [
- [255, 165, 0],
- [255, 140, 0],
- [255, 215, 0],
- [255, 205, 114],
- [255, 210, 127],
- [255, 192, 76],
- [255, 169, 12],
- [255, 228, 178],
- ];
- const colorEye = "rgb(0, 0, 0)";
-
- const container = document.getElementById("myIcon");
- const canvas = document.createElement("canvas");
- canvas.width = SIZE * DPR;
- canvas.height = SIZE * DPR;
- canvas.style.width = `${SIZE}px`;
- canvas.style.height = `${SIZE}px`;
- const ctx = canvas.getContext("2d");
- ctx.scale(DPR, DPR);
-
- let frameCount = 0;
-
- function randomChoice(xs) {
- return xs[(Math.random() * xs.length) | 0];
- }
-
- function roundRect(x, y, w, h, r) {
- ctx.beginPath();
- ctx.moveTo(x + r, y);
- ctx.lineTo(x + w - r, y);
- ctx.quadraticCurveTo(x + w, y, x + w, y + r);
- ctx.lineTo(x + w, y + h - r);
- ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
- ctx.lineTo(x + r, y + h);
- ctx.quadraticCurveTo(x, y + h, x, y + h - r);
- ctx.lineTo(x, y + r);
- ctx.quadraticCurveTo(x, y, x + r, y);
- ctx.closePath();
- ctx.fill();
- }
-
- function draw蜜柑() {
- // 果実、外果皮
- ctx.fillStyle = color蜜柑の果実;
- ctx.beginPath();
- ctx.arc(50, 50, 50, 0, Math.PI * 2);
- ctx.fill();
-
- // 内果皮
- ctx.strokeStyle = color蜜柑の内果皮;
- ctx.lineWidth = 4;
- ctx.beginPath();
- ctx.arc(50, 50, 45, 0, Math.PI * 2);
- ctx.stroke();
-
- // じょうのう
- ctx.strokeStyle = color蜜柑のじょうのう;
- ctx.lineWidth = 2;
- for (let t = 0; t < 10; t++) {
- ctx.save();
- ctx.translate(50, 50);
- ctx.rotate((t * Math.PI) / 5);
-
- ctx.beginPath();
- ctx.moveTo(0, -45);
- ctx.lineTo(0, 0);
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(0, -40);
- ctx.lineTo(-4, -45);
- ctx.lineTo(4, -45);
- ctx.closePath();
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(0, -20);
- ctx.lineTo(-3, 0);
- ctx.lineTo(3, 0);
- ctx.closePath();
- ctx.stroke();
-
- ctx.restore();
- }
- }
-
- function drawMosaic(f) {
- for (let dy = 0; dy < 10; dy++) {
- for (let dx = 0; dx < 10; dx++) {
- const y = dy * 10;
- const x = dx * 10;
- if (x < 50) {
- continue;
- }
- if ((x - 45) ** 2 + (y - 45) ** 2 > 55 ** 2) {
- continue;
- }
- if (Math.random() < 0.167 * f) {
- continue;
- }
-
- const [r, g, b] = randomChoice(colorMosaic);
- const a = 0.9 - f * 0.05;
- ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
- ctx.fillRect(x, y, 10, 10);
- }
- }
- }
-
- function drawEyes() {
- ctx.fillStyle = colorEye;
- roundRect(30, 35, 6, 25, 2);
- roundRect(64, 35, 6, 25, 2);
- }
-
- function mainLoop() {
- frameCount++;
- if (4 <= frameCount % 15) {
- setTimeout(mainLoop, 1000 / FPS);
- return;
- }
-
- ctx.fillStyle = colorBackground;
- ctx.fillRect(0, 0, SIZE, SIZE);
- ctx.clearRect(0, 0, SIZE, SIZE);
-
- draw蜜柑();
- drawMosaic(frameCount % 15);
- drawEyes();
-
- setTimeout(mainLoop, 1000 / FPS);
- }
-
- mainLoop();
- while (container.firstChild) {
- container.removeChild(container.firstChild);
- }
- container.appendChild(canvas);
-};
-
-document.addEventListener("DOMContentLoaded", init);
diff --git a/services/nuldoc/static/favicon.svg b/services/nuldoc/static/_all/favicon.svg
index 923d78b..923d78b 100644
--- a/services/nuldoc/static/favicon.svg
+++ b/services/nuldoc/static/_all/favicon.svg
diff --git a/services/nuldoc/static/style.css b/services/nuldoc/static/_all/style.css
index 8a42363..8a42363 100644
--- a/services/nuldoc/static/style.css
+++ b/services/nuldoc/static/_all/style.css
diff --git a/services/nuldoc/public/blog/my-icon.js b/services/nuldoc/static/about/my-icon.js
index 48c556d..48c556d 100644
--- a/services/nuldoc/public/blog/my-icon.js
+++ b/services/nuldoc/static/about/my-icon.js
diff --git a/services/nuldoc/static/my-icon.js b/services/nuldoc/static/my-icon.js
deleted file mode 100644
index 48c556d..0000000
--- a/services/nuldoc/static/my-icon.js
+++ /dev/null
@@ -1,151 +0,0 @@
-const init = () => {
- const SIZE = 100;
- const DPR = globalThis.devicePixelRatio || 1;
- const FPS = 15;
-
- const colorBackground = "rgb(255, 255, 255)";
- const color蜜柑の果実 = "rgb(255, 165, 0)";
- const color蜜柑の内果皮 = "rgb(255, 255, 255)";
- const color蜜柑のじょうのう = "rgb(255, 255, 255)";
- const colorMosaic = [
- [255, 165, 0],
- [255, 140, 0],
- [255, 215, 0],
- [255, 205, 114],
- [255, 210, 127],
- [255, 192, 76],
- [255, 169, 12],
- [255, 228, 178],
- ];
- const colorEye = "rgb(0, 0, 0)";
-
- const container = document.getElementById("myIcon");
- const canvas = document.createElement("canvas");
- canvas.width = SIZE * DPR;
- canvas.height = SIZE * DPR;
- canvas.style.width = `${SIZE}px`;
- canvas.style.height = `${SIZE}px`;
- const ctx = canvas.getContext("2d");
- ctx.scale(DPR, DPR);
-
- let frameCount = 0;
-
- function randomChoice(xs) {
- return xs[(Math.random() * xs.length) | 0];
- }
-
- function roundRect(x, y, w, h, r) {
- ctx.beginPath();
- ctx.moveTo(x + r, y);
- ctx.lineTo(x + w - r, y);
- ctx.quadraticCurveTo(x + w, y, x + w, y + r);
- ctx.lineTo(x + w, y + h - r);
- ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
- ctx.lineTo(x + r, y + h);
- ctx.quadraticCurveTo(x, y + h, x, y + h - r);
- ctx.lineTo(x, y + r);
- ctx.quadraticCurveTo(x, y, x + r, y);
- ctx.closePath();
- ctx.fill();
- }
-
- function draw蜜柑() {
- // 果実、外果皮
- ctx.fillStyle = color蜜柑の果実;
- ctx.beginPath();
- ctx.arc(50, 50, 50, 0, Math.PI * 2);
- ctx.fill();
-
- // 内果皮
- ctx.strokeStyle = color蜜柑の内果皮;
- ctx.lineWidth = 4;
- ctx.beginPath();
- ctx.arc(50, 50, 45, 0, Math.PI * 2);
- ctx.stroke();
-
- // じょうのう
- ctx.strokeStyle = color蜜柑のじょうのう;
- ctx.lineWidth = 2;
- for (let t = 0; t < 10; t++) {
- ctx.save();
- ctx.translate(50, 50);
- ctx.rotate((t * Math.PI) / 5);
-
- ctx.beginPath();
- ctx.moveTo(0, -45);
- ctx.lineTo(0, 0);
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(0, -40);
- ctx.lineTo(-4, -45);
- ctx.lineTo(4, -45);
- ctx.closePath();
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(0, -20);
- ctx.lineTo(-3, 0);
- ctx.lineTo(3, 0);
- ctx.closePath();
- ctx.stroke();
-
- ctx.restore();
- }
- }
-
- function drawMosaic(f) {
- for (let dy = 0; dy < 10; dy++) {
- for (let dx = 0; dx < 10; dx++) {
- const y = dy * 10;
- const x = dx * 10;
- if (x < 50) {
- continue;
- }
- if ((x - 45) ** 2 + (y - 45) ** 2 > 55 ** 2) {
- continue;
- }
- if (Math.random() < 0.167 * f) {
- continue;
- }
-
- const [r, g, b] = randomChoice(colorMosaic);
- const a = 0.9 - f * 0.05;
- ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
- ctx.fillRect(x, y, 10, 10);
- }
- }
- }
-
- function drawEyes() {
- ctx.fillStyle = colorEye;
- roundRect(30, 35, 6, 25, 2);
- roundRect(64, 35, 6, 25, 2);
- }
-
- function mainLoop() {
- frameCount++;
- if (4 <= frameCount % 15) {
- setTimeout(mainLoop, 1000 / FPS);
- return;
- }
-
- ctx.fillStyle = colorBackground;
- ctx.fillRect(0, 0, SIZE, SIZE);
- ctx.clearRect(0, 0, SIZE, SIZE);
-
- draw蜜柑();
- drawMosaic(frameCount % 15);
- drawEyes();
-
- setTimeout(mainLoop, 1000 / FPS);
- }
-
- mainLoop();
- while (container.firstChild) {
- container.removeChild(container.firstChild);
- }
- container.appendChild(canvas);
-};
-
-document.addEventListener("DOMContentLoaded", init);
diff --git a/services/nuldoc/static/slide.js b/services/nuldoc/static/slide.js
deleted file mode 100644
index 4c7a0de..0000000
--- a/services/nuldoc/static/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);
-});
diff --git a/services/nuldoc/static/pdf.min.mjs b/services/nuldoc/static/slides/pdf.min.mjs
index 284b2df..284b2df 100644
--- a/services/nuldoc/static/pdf.min.mjs
+++ b/services/nuldoc/static/slides/pdf.min.mjs
diff --git a/services/nuldoc/static/pdf.worker.min.mjs b/services/nuldoc/static/slides/pdf.worker.min.mjs
index 1073dec..1073dec 100644
--- a/services/nuldoc/static/pdf.worker.min.mjs
+++ b/services/nuldoc/static/slides/pdf.worker.min.mjs
diff --git a/services/nuldoc/public/about/slide.js b/services/nuldoc/static/slides/slide.js
index 4c7a0de..4c7a0de 100644
--- a/services/nuldoc/public/about/slide.js
+++ b/services/nuldoc/static/slides/slide.js