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

const moment = require("moment")
module.exports = class {
onCreate() {
this.state = {text: null, color: "color-menu", href: null, tooltip: null}
}
onInput(input) {
if (this.state != null) {
this.updateState(input)
}
}
updateState({kind, weak, value, updated}) {
this.state = {text: null, color: "color-menu", href: null, tooltip: null}
if (value == null || value == "") {
return
}
switch (kind) {
case "timestamp": {
const m = moment(value)
if (m.year() < 2) {
break
}
this.state.tooltip = m.format("YYYY-MM-DD HH:mm:ss")
this.state.text = `[${m.format("HH:mm")}]`
break
}
case "author": {
this.state.text = value
this.state.tooltip = "See all stories by " + value
this.state.href = `/story/by-author/${value}/`
break
}
default: {
this.state.color = "color-menu"
this.state.text = value
break
}
}
}
}