From 432e96ee2ee8768be6d7e96ebab553e18a0096aa Mon Sep 17 00:00:00 2001 From: Ruthenic Date: Thu, 22 Dec 2022 03:04:38 -0500 Subject: [PATCH] stupid hacky bullshit for my web interface --- src/classes/Chapter.ts | 17 ++++++++++++++--- src/classes/Work.ts | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/classes/Chapter.ts b/src/classes/Chapter.ts index 8cdc786..56ee18c 100644 --- a/src/classes/Chapter.ts +++ b/src/classes/Chapter.ts @@ -15,6 +15,7 @@ export default class Chapter { #summary!: string; #startNote!: string; #endNote!: string; + earlyName?: string; id!: Promise; workID!: Promise; name!: Promise; @@ -24,16 +25,26 @@ export default class Chapter { startNote!: Promise; endNote!: Promise; - constructor(workId: ID, id: ID, session: { - get: (path: string) => Promise; - }, DOMParser: DOMParser) { + constructor( + workId: ID, + id: ID, + session: { + get: (path: string) => Promise; + }, + DOMParser: DOMParser, + extraInfo: Record, + ) { this.#session = session; this.#workID = workId; this.#id = id; this.#DOMParser = DOMParser; + this.earlyName = extraInfo.name; return new Proxy(this, { get: async (target, prop) => { + if (prop === "earlyName") { + return this.earlyName; + } if (!this.isInited) { await target.init(); target.isInited = true; diff --git a/src/classes/Work.ts b/src/classes/Work.ts index 6bb72a4..2049ae6 100644 --- a/src/classes/Work.ts +++ b/src/classes/Work.ts @@ -124,6 +124,7 @@ export default class Work { this.id, this.#session, this.#DOMParser, + {}, ); this.chapters.push( newChapter, @@ -148,6 +149,7 @@ export default class Work { c.getAttribute("value") as string, this.#session, this.#DOMParser, + { name: c.innerText }, ); this.chapters.push( newChapter,