From d7d021729fead46edfe6db0c84b03beb39695f8e Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sun, 27 Aug 2023 11:35:28 +0200 Subject: [PATCH] fixing bug preventing documentation from loading --- src/Documentation.ts | 2 +- src/main.ts | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Documentation.ts b/src/Documentation.ts index 9f5f979..53014f4 100644 --- a/src/Documentation.ts +++ b/src/Documentation.ts @@ -74,7 +74,7 @@ Welcome to the Topos documentation. These pages are offering you an introduction ${makeExample( "Welcome! Eval to get started", - `mod([1/4,1/8,1/16].div(4)):: sound('sine') + `mod([1/4,1/8,1/16].div(8)):: sound('sine') .freq([100,50].div(16) + 50 * ($(1)%10)) .gain(0.5).room(0.9).size(0.9) .sustain(0.1).out() diff --git a/src/main.ts b/src/main.ts index 5d23c6c..c1a834a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -60,8 +60,6 @@ const bindings = Object.keys(classMap).map((key) => ({ replace: (match, p1) => `<${key} class="${classMap[key]}" ${p1}>`, })); -// Importing the documentation from separate files in the ./src/documentation/* folder - export class Editor { universes: Universes = template_universes; selected_universe: string; @@ -241,9 +239,12 @@ export class Editor { // ================================================================================ // Building the documentation - loadSamples().then(() => { - this.docs = documentation_factory(this); - }); + // loadSamples().then(() => { + // this.docs = documentation_factory(this); + // }); + let pre_loading = async () => { await loadSamples(); }; + pre_loading(); + this.docs = documentation_factory(this); // ================================================================================ // ================================================================================ @@ -553,9 +554,18 @@ export class Editor { "about", ].forEach((e) => { let name = `docs_` + e; - document.getElementById(name)!.addEventListener("click", () => { - this.currentDocumentationPane = e; - this.updateDocumentationContent(); + document.getElementById(name)!.addEventListener("click", async () => { + if (name !== "docs_samples") { + this.currentDocumentationPane = e; + this.updateDocumentationContent(); + } else { + console.log('Loading samples!'); + await loadSamples().then(() => { + this.docs = documentation_factory(this) + this.currentDocumentationPane = e; + this.updateDocumentationContent(); + }); + } }); });