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.
 
 
 
 

52 lines
1.0 KiB

const moment = require("moment")
module.exports = class {
onCreate({kind, value, updated}) {
this.state = {text: null, color: "color-menu", tooltip: null}
if (value == null || value == "") {
return
}
switch (kind) {
case "date": {
const m = moment(value)
if (m.year() < 2) {
break
}
const dateStr = m.format("MMM D, YYYY")
this.state.text = dateStr
if (updated != null && Date.parse(updated) > Date.parse(value)) {
const m2 = moment(updated)
this.state.tooltip = "Originally posted: " + dateStr
this.state.text = m2.format("MMM D, YYYY") + " *"
}
break
}
case "tag": {
this.state.color = `color-tag-${value.kind.toLowerCase()}`
this.state.text = value.name
break
}
case "author": {
this.state.text = value
break
}
default: {
this.state.color = "color-menu"
this.state.text = value
break
}
}
}
}