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.

31 lines
702 B

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. const moment = require("moment")
  2. module.exports = class {
  3. onCreate(input) {
  4. this.state = {
  5. selectedChapter: "",
  6. }
  7. }
  8. onMount() {
  9. this.state.selectedChapter = (window.location.hash||"#").slice(1)
  10. }
  11. chapterTitle(chapter) {
  12. let title = "Chapter " + (this.input.story.chapters.indexOf(chapter) + 1)
  13. if (chapter.title) {
  14. title = chapter.title
  15. } else if (chapter.fictionalDate && chapter.fictionalDate.getUTCFullYear() > 1) {
  16. title = moment.utc(chapter.fictionalDate).format("MMM D, YYYY")
  17. }
  18. return title
  19. }
  20. select(kind, id) {
  21. if (kind === "chapter") {
  22. this.state.selectedChapter = id
  23. }
  24. this.emit("select", kind, id)
  25. }
  26. }