a story
This commit is contained in:
parent
d2aef1d7a1
commit
782758f7e7
7 changed files with 509 additions and 198 deletions
|
@ -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";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue