Initial Commit

This commit is contained in:
2018-09-13 21:15:47 +02:00
commit 09f406cba7
84 changed files with 6920 additions and 0 deletions
@@ -0,0 +1,40 @@
const moment = require("moment")
module.exports = class {
onCreate(input) {
this.state = {
chapterTitles: {},
fdateLink: "",
fdate: "",
selectedChapter: ""
}
}
onMount() {
this.state.selectedChapter = (window.location.hash||"#").slice(1)
}
onInput(input) {
if (input.story.fictionalDate && input.story.fictionalDate.getUTCFullYear() > 10) {
const fdate = input.story.fictionalDate
this.state.fdateLink = `/story/by-month/${moment(fdate).format("YYYY-MM")}`
this.state.fdate = moment(fdate).format("MMM D, YYYY")
}
for (const chapter of input.story.chapters) {
let title = "Chapter " + 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")
}
this.state.chapterTitles[chapter.id] = title
}
}
selectChapter(id) {
this.state.selectedChapter = id
}
}
@@ -0,0 +1,9 @@
<menu user=input.user>
<if(input.story.chapters.length > 1)>
<menu-header>${input.story.name}</menu-header>
<for(chapter in input.story.chapters | status-var=loop)>
<menu-link on-click("selectChapter", chapter.id) href=("#" + chapter.id) selected=(state.selectedChapter === chapter.id) icon=(loop.getIndex()+1)>${state.chapterTitles[chapter.id]}</menu-link>
</for>
<menu-gap />
</if>
</menu>