make eslint happier

This commit is contained in:
Nils Schneider 2015-03-30 03:20:43 +02:00
parent c4db68b31f
commit 1f8cb5203e
5 changed files with 103 additions and 101 deletions

View file

@ -1,13 +1,13 @@
define(function () {
return function (config, el, router, d) {
var h2 = document.createElement("h2")
a1 = document.createElement("a")
var a1 = document.createElement("a")
a1.href = "#"
a1.onclick = router.node(d.source.node)
a1.textContent = d.source.node.nodeinfo.hostname
h2.appendChild(a1)
h2.appendChild(document.createTextNode(" "))
a2 = document.createElement("a")
var a2 = document.createElement("a")
a2.href = "#"
a2.onclick = router.node(d.target.node)
a2.textContent = d.target.node.nodeinfo.hostname

View file

@ -1,7 +1,7 @@
define(["infobox/link", "infobox/node"], function (Link, Node) {
return function (config, sidebar, router) {
var self = this
el = undefined
var el
function destroy() {
if (el && el.parentNode) {

View file

@ -1,4 +1,101 @@
define(["moment", "tablesort", "tablesort.numeric"], function (moment, Tablesort) {
function showFirmware(d) {
var release = dictGet(d.nodeinfo, ["software", "firmware", "release"])
var base = dictGet(d.nodeinfo, ["software", "firmware", "base"])
if (release === null || base === null)
return undefined
return release + " / " + base
}
function showUptime(d) {
if (!("uptime" in d.statistics))
return undefined
return moment.duration(d.statistics.uptime, "seconds").humanize()
}
function showFirstseen(d) {
if (!("firstseen" in d))
return undefined
return d.firstseen.fromNow(true)
}
function showClients(d) {
if (!d.flags.online)
return undefined
return function (el) {
el.appendChild(document.createTextNode(d.statistics.clients > 0 ? d.statistics.clients : "keine"))
el.appendChild(document.createElement("br"))
var span = document.createElement("span")
span.classList.add("clients")
span.textContent = " ".repeat(d.statistics.clients)
el.appendChild(span)
}
}
function showIPs(d) {
var ips = dictGet(d.nodeinfo, ["network", "addresses"])
if (ips === null)
return undefined
ips.sort()
return function (el) {
ips.forEach( function (ip, i) {
var link = !ip.startsWith("fe80:")
if (i > 0)
el.appendChild(document.createElement("br"))
if (link) {
var a = document.createElement("a")
a.href = "http://[" + ip + "]/"
a.textContent = ip
el.appendChild(a)
} else
el.appendChild(document.createTextNode(ip))
})
}
}
function showBar(className, v) {
var span = document.createElement("span")
span.classList.add("bar")
span.classList.add(className)
var bar = document.createElement("span")
bar.style.width = (v * 100) + "%"
span.appendChild(bar)
var label = document.createElement("label")
label.textContent = (Math.round(v * 100)) + " %"
span.appendChild(label)
return span
}
function showRAM(d) {
if (!("memory_usage" in d.statistics))
return undefined
return function (el) {
el.appendChild(showBar("memory-usage", d.statistics.memory_usage))
}
}
function showAutoupdate(d) {
var au = dictGet(d.nodeinfo, ["software", "autoupdater"])
if (!au)
return undefined
return au.enabled ? "aktiviert (" + au.branch + ")" : "deaktiviert"
}
return function(config, el, router, d) {
var h2 = document.createElement("h2")
h2.textContent = d.nodeinfo.hostname
@ -104,102 +201,5 @@ define(["moment", "tablesort", "tablesort.numeric"], function (moment, Tablesort
el.appendChild(table)
}
function showFirmware(d) {
var release = dictGet(d.nodeinfo, ["software", "firmware", "release"])
var base = dictGet(d.nodeinfo, ["software", "firmware", "base"])
if (release === null || base === null)
return
return release + " / " + base
}
function showUptime(d) {
if (!("uptime" in d.statistics))
return
return moment.duration(d.statistics.uptime, "seconds").humanize()
}
function showFirstseen(d) {
if (!("firstseen" in d))
return
return d.firstseen.fromNow(true)
}
function showClients(d) {
if (!d.flags.online)
return
return function (el) {
el.appendChild(document.createTextNode(d.statistics.clients > 0 ? d.statistics.clients : "keine"))
el.appendChild(document.createElement("br"))
var span = document.createElement("span")
span.classList.add("clients")
span.textContent = " ".repeat(d.statistics.clients)
el.appendChild(span)
}
}
function showIPs(d) {
var ips = dictGet(d.nodeinfo, ["network", "addresses"])
if (ips === null)
return
ips.sort()
return function (el) {
ips.forEach( function (ip, i) {
var link = !ip.startsWith("fe80:")
if (i > 0)
el.appendChild(document.createElement("br"))
if (link) {
var a = document.createElement("a")
a.href = "http://[" + ip + "]/"
a.textContent = ip
el.appendChild(a)
} else
el.appendChild(document.createTextNode(ip))
})
}
}
function showRAM(d) {
if (!("memory_usage" in d.statistics))
return
return function (el) {
el.appendChild(showBar("memory-usage", d.statistics.memory_usage))
}
}
function showBar(className, v) {
var span = document.createElement("span")
span.classList.add("bar")
span.classList.add(className)
var bar = document.createElement("span")
bar.style.width = (v * 100) + "%"
span.appendChild(bar)
var label = document.createElement("label")
label.textContent = (Math.round(v * 100)) + " %"
span.appendChild(label)
return span
}
function showAutoupdate(d) {
var au = dictGet(d.nodeinfo, ["software", "autoupdater"])
if (!au)
return
return au.enabled ? "aktiviert (" + au.branch + ")" : "deaktiviert"
}
}
})

View file

@ -23,6 +23,8 @@
"node": true
},
"globals": {
"attributeEntry": false,
"dictGet": false,
"getJSON": false,
"has_location": false,
"limit": false,

View file

@ -23,7 +23,7 @@ module.exports = function (grunt) {
}
},
sources: {
src: ["app.js", "!Gruntfile.js", "lib/*.js"]
src: ["app.js", "!Gruntfile.js", "lib/**/*.js"]
},
grunt: {
src: ["Gruntfile.js", "tasks/*.js"]