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 } }