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.
|
|
const moment = require("moment")
const {charactersApi} = require("../../../../../rpdata/api/Character")
module.exports = class { onCreate(input) { this.state = { error: null, loading: false, values: { newNick: "", } } }
change(key, ev) { this.state.values[key] = ev.target.value }
open() {
}
close() { this.emit("close") }
addNick() { if (this.state.loading) { return }
const input = {id: this.input.character.id, nick: this.state.values.newNick}
this.state.loading = true charactersApi.addNick(input).then((res) => { this.emit("nicks", res.nicks) this.state.values = {newNick: ""} }).catch(errs => { console.warn("Failed to add nick:", errs)
this.state.error = "Failed to add nick: " + errs[0].message }).then(() => { this.state.loading = false }) }
removeNick(nick) { if (this.state.loading) { return }
const input = {id: this.input.character.id, nick}
this.state.loading = true charactersApi.removeNick(input).then((res) => { this.emit("nicks", res.nicks) }).catch(errs => { console.warn("Failed to remove nick:", errs)
this.state.error = "Failed to remove nick: " + errs[0].message }).then(() => { this.state.loading = false }) } }
|