This commit is contained in:
りき萌 2023-08-20 18:37:00 +02:00
parent d2aef1d7a1
commit 782758f7e7
7 changed files with 509 additions and 198 deletions

View file

@ -36,7 +36,12 @@ class LinkedBranch extends HTMLLIElement {
this.state = "loading";
fetch(`/${this.linkedTree}.html`)
.then(request => request.text())
.then(response => {
if (response.status == 404) {
throw `Hmm, seems like the tree "${this.linkedTree}" does not exist.`;
}
return response.text();
})
.then(text => {
let parser = new DOMParser();
let linkedDocument = parser.parseFromString(text, "text/html");
@ -49,9 +54,12 @@ class LinkedBranch extends HTMLLIElement {
for (let i = 0; i < ul.childNodes.length; ++i) {
this.innerUL.appendChild(ul.childNodes[i]);
}
this.state = "loaded";
})
.catch(error => {
this.loadingText.innerText = error.toString();
this.state = "error";
});
}
}