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.

50 lines
1.5 KiB

  1. const {query} = require("../client")
  2. class Comment {
  3. /**
  4. * @param {string} id
  5. * @param {string} subject
  6. * @param {string} author
  7. * @param {string} characterName
  8. * @param {CommentCharacter} character
  9. * @param {string | number | Date} fictionalDate
  10. * @param {string | number | Date} createdDate
  11. * @param {string | number | Date} editedDate
  12. * @param {string} source
  13. */
  14. constructor(id, subject, author, characterName, character, fictionalDate, createdDate, editedDate, source) {
  15. this.id = id
  16. this.subject = subject
  17. this.author = author
  18. this.characterName = characterName
  19. this.character = character != null ? CommentCharacter.fromData(character) : null
  20. this.fictionalDate = fictionalDate != null ? new Date(fictionalDate) : null
  21. this.createdDate = new Date(createdDate)
  22. this.editedDate = new Date(editedDate)
  23. this.source = source
  24. }
  25. static fromData(data) {
  26. return new Comment(data.id, data.subject, data.author, data.characterName, data.character, data.fictionalDate, data.createdDate, data.editedDate, data.source)
  27. }
  28. }
  29. class CommentCharacter {
  30. /**
  31. * @param {string} id
  32. * @param {string} name
  33. * @param {string} author
  34. * @param {string} description
  35. */
  36. constructor(id, name, author, description) {
  37. this.id = id
  38. this.name = name
  39. this.author = author
  40. this.description = description
  41. }
  42. static fromData(data) {
  43. return new CommentCharacter(data.id, data.name, data.author, data.description)
  44. }
  45. }
  46. module.exports = {Comment, CommentCharacter}