diff options
Diffstat (limited to 'src/modules/Fridge.ts')
| -rw-r--r-- | src/modules/Fridge.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/modules/Fridge.ts b/src/modules/Fridge.ts index 79da4dc..c12bc53 100644 --- a/src/modules/Fridge.ts +++ b/src/modules/Fridge.ts @@ -1,24 +1,34 @@ import Chit, { ChitFromDb } from "Modules/Chit" +import WYSiWYG from "./WYSiWYG"; export default class Fridge { #chits: Chit[] = []; + //@ts-expect-error + #wysiwyg: WYSiWYG; - constructor() { + constructor(wysiwyg: WYSiWYG) { const f = sessionStorage.fridge; if (f === null) { location.href = "/" return; } + const cs = JSON.parse(f) as ChitFromDb[]; for (const c of cs) { - this.#chits.push(new Chit(this, c)) + this.#chits.push(new Chit(this, wysiwyg, c)); } + + + this.#wysiwyg = wysiwyg; } setChitZIAuto() { for (const c of this.#chits) c.div.style.zIndex = "auto" } + removeChit(ch: Chit) { + this.#chits = this.#chits.filter(c => c !== ch); + } // moveChit(coord: { top: number, left: number }) { // for (const c of this.#chits) { // if (c.isMoving) { @@ -35,7 +45,7 @@ export default class Fridge { // } createChit() { - this.#chits.push(new Chit(this)) + this.#chits.push(new Chit(this, this.#wysiwyg)) } get chits(): Chit[] { |
