mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:58:00 +01:00
Frob some fnords.
This commit is contained in:
@@ -233,7 +233,7 @@ liberator.Bookmarks = function () //{{{
|
||||
var sh = getWebNavigation().sessionHistory;
|
||||
|
||||
let entries = [sh.getEntryAtIndex(i, false) for (i in liberator.util.range(0, sh.count))];
|
||||
let list = liberator.buffer.template.jumps(sh.index, entries);
|
||||
let list = liberator.template.jumps(sh.index, entries);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
{ argCount: "0" });
|
||||
@@ -482,7 +482,7 @@ liberator.Bookmarks = function () //{{{
|
||||
if (openItems)
|
||||
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
|
||||
|
||||
let list = liberator.buffer.template.bookmarks("title", (
|
||||
let list = liberator.template.bookmarks("title", (
|
||||
{
|
||||
url: item[0],
|
||||
title: item[1],
|
||||
@@ -767,7 +767,7 @@ liberator.History = function () //{{{
|
||||
}
|
||||
else
|
||||
{
|
||||
let list = liberator.buffer.template.bookmarks("title", (
|
||||
let list = liberator.template.bookmarks("title", (
|
||||
{
|
||||
title: item[1],
|
||||
url: item[0],
|
||||
@@ -942,7 +942,7 @@ liberator.QuickMarks = function () //{{{
|
||||
}
|
||||
|
||||
let items = ({title: mark, url: qmarks.get(mark)} for each (mark in marks));
|
||||
let list = liberator.buffer.template.bookmarks("QuickMark", items);
|
||||
let list = liberator.template.bookmarks("QuickMark", items);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1289,7 +1289,7 @@ liberator.Buffer = function () //{{{
|
||||
{
|
||||
let opt = options[option];
|
||||
if (opt && opt[0].length > 0)
|
||||
pageInfoText += br + liberator.buffer.template.table(opt[1], opt[0]);
|
||||
pageInfoText += br + liberator.template.table(opt[1], opt[0]);
|
||||
if (!br)
|
||||
br = "<br/>";
|
||||
}
|
||||
@@ -1297,117 +1297,6 @@ liberator.Buffer = function () //{{{
|
||||
liberator.echo(pageInfoText, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
template:
|
||||
{
|
||||
add: function (a, b) a + b,
|
||||
join: function (c) function (a, b) a + c + b,
|
||||
maybeXML: function (xml)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new XML(xml)
|
||||
}
|
||||
catch (e) {}
|
||||
return xml;
|
||||
},
|
||||
|
||||
generic: function (xml)
|
||||
{
|
||||
return (<>:{liberator.commandline.getCommand()}<br/></> + xml).toXMLString();
|
||||
},
|
||||
|
||||
bookmarks: function (header, items)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr align="left" class="hl-Title">
|
||||
<th>{header}</th><th>URL</th>
|
||||
</tr>
|
||||
{[
|
||||
<tr>
|
||||
<td>{liberator.util.clip(item.title, 50)}</td>
|
||||
<td style="width: 100%">
|
||||
<a href="#" class="hl-URL">{item.url}</a> 
|
||||
{
|
||||
(item.extra && item.extra.length) ?
|
||||
<span style="color: gray;">
|
||||
({
|
||||
[<>{e[0]}: <span style={"color: " + e[2]}>{e[1]}</span></>
|
||||
for each (e in item.extra)].reduce(this.join(<> </>))
|
||||
})
|
||||
</span>
|
||||
: ""
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
for each (item in items)].reduce(this.add, <></>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
jumps: function (index, elems)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr style="text-align: left;" class="hl-Title">
|
||||
<th colspan="2">jump</th><th>title</th><th>URI</th>
|
||||
</tr>
|
||||
{[
|
||||
<tr>
|
||||
<td>{idx == index ? <span style="color: blue;">{">"}</span> : ""}</td> <!-- } //vim :( -->
|
||||
<td>{Math.abs(idx - index)}</td>
|
||||
<td style="width: 250px; max-width: 500px; overflow: hidden;">{val.title}</td>
|
||||
<td><a href="#" class="hl-URL jump-list">{val.URI.spec}</a></td>
|
||||
</tr>
|
||||
for ([idx, val] in Iterator(elems))].reduce(this.add, <></>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
marks: function (marks)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr class="hl-Title" align="left">
|
||||
<th>mark</th>
|
||||
<th>line</th>
|
||||
<th>col</th>
|
||||
<th>file</th>
|
||||
</tr>
|
||||
{[
|
||||
<tr>
|
||||
<td>{mark[0]}</td>
|
||||
<td align="right">{Math.round(mark[1].position.y * 100)}%</td>
|
||||
<td align="right">{Math.round(mark[1].position.x * 100)}%</td>
|
||||
<td style="color: green;">{mark[1].location}</td>
|
||||
</tr>
|
||||
for each (mark in marks)].reduce(this.add, <></>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
table: function (title, data)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr>
|
||||
<th class="hl-Title" align="left" colspan="2">{title}</th>
|
||||
</tr>
|
||||
{
|
||||
[<tr>
|
||||
<td style="font-weight: bold; min-width: 150px">{datum[0]}</td>
|
||||
<td>{this.maybeXML(datum[1])}</td>
|
||||
</tr>
|
||||
for each (datum in data)].reduce(this.add, <></>)
|
||||
}
|
||||
</table>);
|
||||
}
|
||||
},
|
||||
|
||||
viewSelectionSource: function ()
|
||||
{
|
||||
// copied (and tuned somebit) from browser.jar -> nsContextMenu.js
|
||||
@@ -1812,7 +1701,7 @@ liberator.Marks = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
var list = liberator.buffer.template.marks(marks);
|
||||
var list = liberator.template.marks(marks);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
|
||||
@@ -1820,4 +1709,150 @@ liberator.Marks = function () //{{{
|
||||
//}}}
|
||||
}; //}}}
|
||||
|
||||
liberator.template = {
|
||||
add: function (a, b) a + b,
|
||||
join: function (c) function (a, b) a + c + b,
|
||||
|
||||
map: function (iter, fn, sep)
|
||||
{
|
||||
if (sep == undefined)
|
||||
sep = <></>;
|
||||
let ret = <></>;
|
||||
let n = 0;
|
||||
for each (let i in iter) {
|
||||
if (n++)
|
||||
ret += sep;
|
||||
ret += fn(i);
|
||||
}
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new XML(xml)
|
||||
}
|
||||
catch (e) {}
|
||||
return xml;
|
||||
},
|
||||
|
||||
generic: function (xml)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
return (<>:{liberator.commandline.getCommand()}<br/></> + xml).toXMLString();
|
||||
},
|
||||
|
||||
bookmarks: function (header, items)
|
||||
{
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr align="left" class="hl-Title">
|
||||
<th>{header}</th><th>URL</th>
|
||||
</tr>
|
||||
{
|
||||
this.map(items, function (item)
|
||||
<tr>
|
||||
<td>{liberator.util.clip(item.title, 50)}</td>
|
||||
<td style="width: 100%">
|
||||
<a href="#" class="hl-URL">{item.url}</a> 
|
||||
{
|
||||
!(item.extra && item.extra.length) ? "" :
|
||||
<span style="color: gray;">
|
||||
({
|
||||
liberator.template.map(item.extra, function (e)
|
||||
<>{e[0]}: <span style={"color: " + e[2]}>{e[1]}</span></>,
|
||||
<> </>)
|
||||
})
|
||||
</span>
|
||||
}
|
||||
</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
jumps: function (index, elems)
|
||||
{
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr style="text-align: left;" class="hl-Title">
|
||||
<th colspan="2">jump</th><th>title</th><th>URI</th>
|
||||
</tr>
|
||||
{
|
||||
this.map2(elems, function (idx, val)
|
||||
<tr>
|
||||
<td>{idx == index ? <span style="color: blue;">{">"}</span> : ""}</td> <!-- } //vim :( -->
|
||||
<td>{Math.abs(idx - index)}</td>
|
||||
<td style="width: 250px; max-width: 500px; overflow: hidden;">{val.title}</td>
|
||||
<td><a href="#" class="hl-URL jump-list">{val.URI.spec}</a></td>
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
marks: function (marks)
|
||||
{
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr class="hl-Title" align="left">
|
||||
<th>mark</th>
|
||||
<th>line</th>
|
||||
<th>col</th>
|
||||
<th>file</th>
|
||||
</tr>
|
||||
{
|
||||
this.map(marks, function (mark)
|
||||
<tr>
|
||||
<td>{mark[0]}</td>
|
||||
<td align="right">{Math.round(mark[1].position.y * 100)}%</td>
|
||||
<td align="right">{Math.round(mark[1].position.x * 100)}%</td>
|
||||
<td style="color: green;">{mark[1].location}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
options: function (title, opts)
|
||||
{
|
||||
return liberator.template.generic(
|
||||
<table>
|
||||
<tr class="hl-Title" align="left">
|
||||
<th>--- {title} ---</th>
|
||||
</tr>
|
||||
{
|
||||
liberator.template.map(opts, function (opt)
|
||||
<tr>
|
||||
<td>
|
||||
<span style={opt.isDefault ? "" : "font-weight: bold"}>{opt.pre}{opt.name}{opt.value}</span>
|
||||
{opt.isDefault || opt.default == null ? "" : <span style="color: gray"> (default: {opt.default})</span>}
|
||||
</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
table: function (title, data)
|
||||
{
|
||||
return this.generic(
|
||||
<table>
|
||||
<tr>
|
||||
<th class="hl-Title" align="left" colspan="2">{title}</th>
|
||||
</tr>
|
||||
{
|
||||
this.map(data, function(datum)
|
||||
<tr>
|
||||
<td style="font-weight: bold; min-width: 150px">{datum[0]}</td>
|
||||
<td>{this.maybeXML(datum[1])}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
}
|
||||
};
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -698,20 +698,20 @@ liberator.Commands = function () //{{{
|
||||
if (cmdlist.length > 0)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
var str = liberator.buffer.template.generic(
|
||||
var str = liberator.template.generic(
|
||||
<table>
|
||||
<tr class="hl-Title" align="left">
|
||||
<th>Name</th>
|
||||
<th>Args</th>
|
||||
<th>Definition</th>
|
||||
</tr>
|
||||
{[
|
||||
{
|
||||
liberator.template.map(cmdlist, function (cmd)
|
||||
<tr>
|
||||
<td>{cmd.name}</td>
|
||||
<td>*</td>
|
||||
<td>{cmd.replacementText || "function () { ... }"}</td>
|
||||
</tr>
|
||||
for each (cmd in cmdlist)].reduce(liberator.buffer.template.add, <></>)
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
|
||||
@@ -205,23 +205,21 @@ liberator.AutoCommands = function () //{{{
|
||||
let cmds = (item for (item in Iterator(autoCommands))
|
||||
if ((!auEvent || item[0] == auEvent) && item[1].length));
|
||||
|
||||
// Okay, maybe a bit scary. --Kris
|
||||
XML.prettyPrinting = false;
|
||||
var list = liberator.buffer.template.generic(
|
||||
var list = liberator.template.generic(
|
||||
<table>
|
||||
<tr>
|
||||
<td class="hl-Title" colspan="2">----- Auto Commands -----</td>
|
||||
</tr>
|
||||
{[
|
||||
{
|
||||
liberator.template.map2(cmds, function (event, items)
|
||||
<tr>
|
||||
<td class="hl-Title" colspan="2">{event}</td>
|
||||
</tr>
|
||||
+ [<tr>
|
||||
<td> {item[0]}</td>
|
||||
<td>{item[1]}</td>
|
||||
</tr>
|
||||
for each (item in items)].reduce(liberator.buffer.template.add)
|
||||
for ([event, items] in cmds)].reduce(liberator.buffer.template.add, <></>)
|
||||
+ liberator.template.map(items, function (item)
|
||||
<tr>
|
||||
<td> {item[0]}</td>
|
||||
<td>{item[1]}</td>
|
||||
</tr>))
|
||||
}
|
||||
</table>);
|
||||
|
||||
@@ -669,13 +667,13 @@ liberator.Events = function () //{{{
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
var str = <table>
|
||||
{[
|
||||
{
|
||||
liberator.template.map2(liberator.events.getMacros(args),
|
||||
function(macro, keys)
|
||||
<tr>
|
||||
<td>{macro}</td>
|
||||
<td>{keys}</td>
|
||||
</tr>
|
||||
for ([macro, keys] in Iterator(liberator.events.getMacros(args)))
|
||||
].reduce(liberator.buffer.template.add, <></>)
|
||||
</tr>)
|
||||
}
|
||||
</table>.toXMLString();
|
||||
liberator.echo(str, liberator.commandline.FORCE_MULTILINE);
|
||||
|
||||
@@ -317,12 +317,12 @@ liberator.IO = function () //{{{
|
||||
XML.prettyPrinting = false;
|
||||
var list =
|
||||
<table>
|
||||
{[
|
||||
{
|
||||
liberator.template.map2(scriptNames, function (i, name)
|
||||
<tr>
|
||||
<td style="text-align: right">{i+1}</td>
|
||||
<td>{name}</td>
|
||||
</tr>
|
||||
for ([i, name] in Iterator(striptNames))].reduce(liberator.buffer.template.add, <></>)
|
||||
</tr>)
|
||||
}
|
||||
</table>.toXMLString();
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
|
||||
@@ -276,12 +276,12 @@ const liberator = (function () //{{{
|
||||
// TODO: clicking on these should open the help
|
||||
XML.prettyPrinting = false;
|
||||
var usage = <table>
|
||||
{[
|
||||
{
|
||||
liberator.template.map(liberator.commands, function (command)
|
||||
<tr>
|
||||
<td class="hl-Title" style="padding-right: 20px">{command.name}</td>
|
||||
<td>{command.description}</td>
|
||||
</tr>
|
||||
for each (command in liberator.commands)].reduce(liberator.buffer.template.add)
|
||||
</tr>)
|
||||
}
|
||||
</table>.toXMLString();
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
@@ -428,8 +428,7 @@ const liberator = (function () //{{{
|
||||
var totalUnits = "msec";
|
||||
}
|
||||
|
||||
XML.prettyPrinting = false;
|
||||
var str = liberator.buffer.template.generic(
|
||||
var str = liberator.template.generic(
|
||||
<table>
|
||||
<tr class="hl-Title" align="left">
|
||||
<th colspan="3">Code execution summary</th>
|
||||
@@ -501,12 +500,12 @@ const liberator = (function () //{{{
|
||||
// TODO: clicking on these should open the help
|
||||
XML.prettyPrinting = false;
|
||||
var usage = <table>
|
||||
{[
|
||||
{
|
||||
liberator.template.add(liberator.mappings, function (mapping)
|
||||
<tr>
|
||||
<td class="hl-Title" style="padding-right: 20px"> {mapping.names[0]}</td>
|
||||
<td>{mapping.description}</td>
|
||||
</tr>
|
||||
for each (mapping in liberator.mappings)].reduce(liberator.buffer.template.add)
|
||||
</tr>)
|
||||
}
|
||||
</table>.toXMLString();
|
||||
|
||||
|
||||
@@ -419,15 +419,14 @@ liberator.Mappings = function () //{{{
|
||||
if (output[i]));
|
||||
XML.prettyPrinting = false;
|
||||
let list = <table>
|
||||
{[
|
||||
[
|
||||
{
|
||||
liberator.template.map(_maps, function (map)
|
||||
liberator.template.map(map.names, function (name)
|
||||
<tr>
|
||||
<td>{modeSign} {name}</td>
|
||||
<td>{map.noremap ? "*" : " "}</td>
|
||||
<td>{map.rhs || "function () { ... }"}</td>
|
||||
</tr>
|
||||
for each (name in map.names)].reduce(liberator.buffer.template.add)
|
||||
for each (map in _maps)].reduce(liberator.buffer.template.add)
|
||||
</tr>))
|
||||
}
|
||||
</table>
|
||||
|
||||
|
||||
@@ -240,27 +240,6 @@ liberator.Options = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
function echoOptions(title, opts) {
|
||||
XML.prettyPrinting = false;
|
||||
let list = liberator.buffer.template.generic(
|
||||
<table>
|
||||
<tr class="hl-Title" align="left">
|
||||
<th>--- {title} ---</th>
|
||||
</tr>
|
||||
{[
|
||||
<tr>
|
||||
<td>
|
||||
<span style={opt.isDefault ? "" : "font-weight: bold"}>{opt.pre}{opt.name}{opt.value}</span>
|
||||
{opt.isDefault || opt.default == null ? "" : <span style="color: gray"> (default: {opt.default})</span>}
|
||||
</td>
|
||||
</tr>
|
||||
for each (opt in opts)].reduce(liberator.buffer.template.add, <></>)
|
||||
}
|
||||
</table>);
|
||||
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
|
||||
//
|
||||
// firefox preferences which need to be changed to work well with vimperator
|
||||
//
|
||||
@@ -888,7 +867,8 @@ liberator.Options = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
echoOptions("Options", opts());
|
||||
let list = liberator.template.options("Options", opts());
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
listPrefs: function (onlyNonDefault, filter)
|
||||
@@ -921,7 +901,8 @@ liberator.Options = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
echoOptions(liberator.config.hostApplication + " Options", prefs());
|
||||
let list = liberator.template.options(liberator.config.hostApplication + " Options", prefs());
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
get store() liberator.storage.options,
|
||||
|
||||
@@ -711,7 +711,6 @@ liberator.Tabs = function () //{{{
|
||||
{
|
||||
// TODO: move this to liberator.tabs.get()
|
||||
|
||||
XML.prettyPrinting = false;
|
||||
let items = <></>;
|
||||
for (let [i, item] in Iterator(liberator.completion.buffer("")[1]))
|
||||
{
|
||||
@@ -732,7 +731,7 @@ liberator.Tabs = function () //{{{
|
||||
</tr>;
|
||||
}
|
||||
|
||||
let list = liberator.buffer.template.generic(<table>{items}</table>);
|
||||
let list = liberator.template.generic(<table>{items}</table>);
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user