The frontend/UI server, written in JS using the MarkoJS library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
698 B

const moment = require("moment")
module.exports = class {
onCreate(input) {
this.state = {
selectedChapter: "",
}
}
onMount() {
this.state.selectedChapter = (window.location.hash||"#").slice(1)
}
chapterTitle(chapter) {
let title = "Chapter " + (this.input.story.chapters.indexOf(chapter) + 1)
if (chapter.title) {
title = chapter.title
} else if (chapter.fictionalDate && chapter.fictionalDate.getUTCFullYear() > 1) {
title = moment(chapter.fictionalDate).format("MMM D, YYYY")
}
return title
}
select(kind, id) {
if (kind === "chapter") {
this.state.selectedChapter = id
}
this.emit("select", kind, id)
}
}