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.1 KiB

module.exports = class {
onCreate(input) {
this.state = {
shortName: "",
name: "",
text: "",
}
this.updatePost(input)
}
onInput(input) {
if (this.state == null) {
return
}
this.updatePost(input)
}
updatePost(input) {
this.state.shortName = input.post.nick.split("_").shift()
this.state.name = input.post.nick
this.state.text = input.post.text.replace(/\x02/g, "**")
if (input.post.kind === "text" && !this.state.text.includes("\"")) {
this.state.text = '"' + this.state.text + '"'
}
if (!input.post.nick.startsWith("=")) {
const postNick = input.post.nick.replace("'s", "").replace("s'", "s")
for (const character of input.characters) {
for (const nick of character.nicks) {
if (nick === postNick) {
this.state.shortName = character.shortName
return
}
}
}
}
}
kindClass(prefix) {
if (this.input.post == null) {
return
}
return `${prefix}${this.input.post.kind.replace(".", "-")}`
}
}