1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 05:27:58 +01:00

Replace template.map2 with an overloaded template.map

This commit is contained in:
Kris Maglione
2008-10-07 21:23:18 +00:00
parent 78d9d51434
commit c038e73471
4 changed files with 11 additions and 11 deletions

View File

@@ -931,7 +931,7 @@ liberator.Editor = function () //{{{
let list = let list =
<table> <table>
{ {
liberator.template.map2(abbrev, function (lhs, rhs) liberator.template.map(abbrev, function (lhs, rhs)
liberator.template.map(rhs, function (abbr) liberator.template.map(rhs, function (abbr)
searchFilter.indexOf(abbr[0]) < 0 ? undefined : searchFilter.indexOf(abbr[0]) < 0 ? undefined :
<tr> <tr>

View File

@@ -233,7 +233,7 @@ liberator.AutoCommands = function () //{{{
<td class="hl-Title" colspan="2">----- Auto Commands -----</td> <td class="hl-Title" colspan="2">----- Auto Commands -----</td>
</tr> </tr>
{ {
liberator.template.map2(cmds, function (event, items) liberator.template.map(cmds, function (event, items)
<tr> <tr>
<td class="hl-Title" colspan="2">{event}</td> <td class="hl-Title" colspan="2">{event}</td>
</tr> </tr>

View File

@@ -284,7 +284,7 @@ liberator.Options = function () //{{{
var str = var str =
<table> <table>
{ {
liberator.template.map2(liberator.globalVariables, function (i, value) { liberator.template.map(liberator.globalVariables, function (i, value) {
let prefix = typeof value == "number" ? "#" : let prefix = typeof value == "number" ? "#" :
typeof value == "function" ? "*" : typeof value == "function" ? "*" :
" "; " ";

View File

@@ -5,7 +5,12 @@ liberator.template = {
map: function (iter, fn, sep) map: function (iter, fn, sep)
{ {
if (iter.length) /* Kludge? */ if (fn.length > 1)
{
iter = Iterator(iter);
fn = function (x) fn.apply(null, x);
}
else if (iter.length) /* Kludge? */
iter = liberator.util.arrayIter(iter); iter = liberator.util.arrayIter(iter);
let ret = <></>; let ret = <></>;
let n = 0; let n = 0;
@@ -20,11 +25,6 @@ liberator.template = {
} }
return ret; return ret;
}, },
map2: function (iter, fn, sep)
{
// Could cause performance problems.
return this.map(Iterator(iter), function (x) fn.apply(null, x), sep);
},
maybeXML: function (xml) maybeXML: function (xml)
{ {
@@ -143,7 +143,7 @@ liberator.template = {
<th colspan="2">jump</th><th>title</th><th>URI</th> <th colspan="2">jump</th><th>title</th><th>URI</th>
</tr> </tr>
{ {
this.map2(elems, function (idx, val) this.map(elems, function (idx, val)
<tr> <tr>
<td class="indicator">{idx == index ? ">" : ""}</td> <td class="indicator">{idx == index ? ">" : ""}</td>
<td>{Math.abs(idx - index)}</td> <td>{Math.abs(idx - index)}</td>
@@ -207,7 +207,7 @@ liberator.template = {
this.map(iter, function (row) this.map(iter, function (row)
<tr> <tr>
{ {
liberator.template.map2(row, function (i, d) liberator.template.map(row, function (i, d)
<td style={style[i] || ""}>{d}</td>) <td style={style[i] || ""}>{d}</td>)
} }
</tr>) </tr>)