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.
 
 
 
 

37 lines
857 B

const moment = require("moment")
module.exports = class {
onCreate(input) {
this.state = {
selectedChapter: "",
bullshit: 0,
}
}
onMount() {
this.state.selectedChapter = (window.location.hash||"#").slice(1)
// Marko is being silly and needs a state change to re-render
setInterval(() => {
this.state.bullshit++
if (this.state.bullshit > 10000) {
this.state.bullshit = 0
}
}, 250)
}
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
}
selectChapter(id) {
this.state.selectedChapter = id
}
}