1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-05 21:54:12 +01:00

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-11-28 17:49:04 -08:00
parent 8d1d33aeeb
commit d1e9701749
7 changed files with 60 additions and 21 deletions

View File

@@ -6,7 +6,7 @@
let global = this;
defineModule("template", {
exports: ["Binding", "Template", "template"],
exports: ["Binding", "Template", "template", "template_"],
require: ["util"]
});
@@ -553,6 +553,40 @@ var Template = Module("Template", {
}
});
var Template_ = Module("Template_", {
map: function map(iter, func, sep, interruptable) {
if (typeof iter.length == "number") // FIXME: Kludge?
iter = array.iterValues(iter);
let res = [];
let n = 0;
for each (let i in Iterator(iter)) {
let val = func(i, n);
if (val == undefined)
continue;
if (n++ && sep)
res.push(sep);
if (interruptable && n % interruptable == 0)
util.threadYield(true, true);
res.push(val);
}
return res;
},
table: function table(title, data, indent) {
let table = ["table", {},
["tr", { highlight: "Title", align: "left" },
["th", { colspan: "2" }, title]],
this.map(data, function (datum)
["tr", {},
["td", { style: "font-weight: bold; min-width: 150px; padding-left: " + (indent || "2ex") }, datum[0]],
["td", {}, datum[1]]])];
if (table[3].length)
return table;
},
});
endModule();
// vim: set fdm=marker sw=4 ts=4 et ft=javascript: