hopglass/lib/filters/genericnode.js

33 lines
645 B
JavaScript
Raw Normal View History

2015-07-08 00:36:57 +02:00
define(["filters/nodefilter"], function (nodefilter) {
return function (name, key, value, f) {
function run(d) {
var o = dictGet(d, key.slice(0))
if (f)
o = f(o)
return o === value
}
function setRefresh() {
}
function render(el) {
var label = document.createElement("label")
label.textContent = name + " "
var strong = document.createElement("strong")
strong.textContent = value
label.appendChild(strong)
el.appendChild(label)
}
return { run: nodefilter(run),
setRefresh: setRefresh,
render: render
}
}
})