summaryrefslogtreecommitdiff
path: root/js/loadPage.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/loadPage.ts')
-rw-r--r--js/loadPage.ts32
1 files changed, 0 insertions, 32 deletions
diff --git a/js/loadPage.ts b/js/loadPage.ts
deleted file mode 100644
index ebf1f62..0000000
--- a/js/loadPage.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/// <reference path="initImages.ts" />
-
-async function loadPage(name: string) {
- console.log("loading page `" + name + "`")
-
- let url = `/html/${name}.html`;
- window.history.pushState("", "", url);
-
- let response = await fetch(url);
-
- if (!response.ok) {
- throw new Error(`unable to load page: \"${response.status}\"`);
- }
-
- let markup = await response.text();
-
- let parser = new DOMParser();
- let dom = parser.parseFromString(markup, "text/html");
-
- let title = document.getElementById("title")!;
- let body = document.getElementById("body")!;
- let page = document.getElementById("page")!;
-
- let new_title = dom.getElementById("title")!;
- let new_page = dom.getElementById("page")!;
-
- title.replaceWith(new_title);
- body.setAttribute("data-page", name);
- page.replaceWith(new_page);
-
- initImages();
-}