logs, logs-content: Added basic view of logs and added characters to logs
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<if(state.text != null && state.text != "")>
|
||||
<div class=["post-meta", input.kind, state.color, input.weak ? "weak" : null] title=state.tooltip>
|
||||
<a if(state.href != null) href=state.href>${state.text}</a>
|
||||
<span else>${state.text}</span>
|
||||
</div>
|
||||
</if>
|
||||
@@ -0,0 +1,20 @@
|
||||
div.post-meta {
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
padding-right: 1em;
|
||||
margin: 0;
|
||||
|
||||
user-select: none;
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
border-bottom: 0.25px dotted;
|
||||
}
|
||||
a:hover {
|
||||
border-bottom: 0.5px solid;
|
||||
}
|
||||
}
|
||||
|
||||
div.post-meta.weak {
|
||||
opacity: 0.5;
|
||||
}
|
||||
Reference in New Issue
Block a user