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
600 B

module.exports = class {
onCreate(input) {
this.state = {
story: input.story
}
}
updateChapter(id, data) {
const index = this.state.story.chapters.findIndex(ch => ch.id === id)
if (index === -1) {
return
}
for (const key in data) {
if (!data.hasOwnProperty(key)) {
continue
}
this.state.story.chapters[index][key] = data[key]
}
}
removeChapter(id) {
const index = this.state.story.chapters.findIndex(ch => ch.id === id)
if (index === -1) {
return
}
this.state.story.chapters.splice(index, 1)
}
}