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.

36 lines
857 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. bullshit: 0,
  7. }
  8. }
  9. onMount() {
  10. this.state.selectedChapter = (window.location.hash||"#").slice(1)
  11. // Marko is being silly and needs a state change to re-render
  12. setInterval(() => {
  13. this.state.bullshit++
  14. if (this.state.bullshit > 10000) {
  15. this.state.bullshit = 0
  16. }
  17. }, 250)
  18. }
  19. chapterTitle(chapter) {
  20. let title = "Chapter " + this.input.story.chapters.indexOf(chapter) + 1
  21. if (chapter.title) {
  22. title = chapter.title
  23. } else if (chapter.fictionalDate && chapter.fictionalDate.getUTCFullYear() > 1) {
  24. title = moment(chapter.fictionalDate).format("MMM D, YYYY")
  25. }
  26. return title
  27. }
  28. selectChapter(id) {
  29. this.state.selectedChapter = id
  30. }
  31. }