mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 02:17:59 +01:00
Death to E4X and stuff.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
// "use strict";
|
"use strict";
|
||||||
|
|
||||||
defineModule("buffer", {
|
defineModule("buffer", {
|
||||||
exports: ["Buffer", "buffer"],
|
exports: ["Buffer", "buffer"],
|
||||||
@@ -16,7 +16,7 @@ lazyRequire("io", ["io"]);
|
|||||||
lazyRequire("finder", ["RangeFind"]);
|
lazyRequire("finder", ["RangeFind"]);
|
||||||
lazyRequire("overlay", ["overlay"]);
|
lazyRequire("overlay", ["overlay"]);
|
||||||
lazyRequire("storage", ["File", "storage"]);
|
lazyRequire("storage", ["File", "storage"]);
|
||||||
lazyRequire("template", ["template"]);
|
lazyRequire("template", ["template", "template_"]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to manage the primary web content buffer. The name comes
|
* A class to manage the primary web content buffer. The name comes
|
||||||
@@ -888,8 +888,7 @@ var Buffer = Module("Buffer", {
|
|||||||
showElementInfo: function showElementInfo(elem) {
|
showElementInfo: function showElementInfo(elem) {
|
||||||
let { dactyl } = this.modules;
|
let { dactyl } = this.modules;
|
||||||
|
|
||||||
XML.ignoreWhitespace = XML.prettyPrinting = false;
|
dactyl.echo(["", /*L*/"Element:", ["br"], util.objectToString(elem, true)]);
|
||||||
dactyl.echo(<><!--L-->Element:<br/>{util.objectToString(elem, true)}</>);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -918,15 +917,15 @@ var Buffer = Module("Buffer", {
|
|||||||
if (bookmarkcache.isBookmarked(this.URL))
|
if (bookmarkcache.isBookmarked(this.URL))
|
||||||
info += ", " + _("buffer.bookmarked");
|
info += ", " + _("buffer.bookmarked");
|
||||||
|
|
||||||
let pageInfoText = <>{file.quote()} [{info}] {title}</>;
|
let pageInfoText = [file.quote(), " [", info, "] ", title].join("");
|
||||||
dactyl.echo(pageInfoText, commandline.FORCE_SINGLELINE);
|
dactyl.echo(pageInfoText, commandline.FORCE_SINGLELINE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let list = template.map(sections || options["pageinfo"], function (option) {
|
let list = template_.map(sections || options["pageinfo"], function (option) {
|
||||||
let { action, title } = Buffer.pageInfo[option];
|
let { action, title } = Buffer.pageInfo[option];
|
||||||
return template.table(title, action.call(self, true));
|
return template_.table(title, action.call(self, true));
|
||||||
}, <br/>);
|
}, ["br"]);
|
||||||
|
|
||||||
commandline.commandOutput(list);
|
commandline.commandOutput(list);
|
||||||
},
|
},
|
||||||
@@ -1693,7 +1692,7 @@ var Buffer = Module("Buffer", {
|
|||||||
function (file) {
|
function (file) {
|
||||||
let output = io.system(filename.substr(1), file);
|
let output = io.system(filename.substr(1), file);
|
||||||
commandline.command = command;
|
commandline.command = command;
|
||||||
commandline.commandOutput(<span highlight="CmdOutput">{output}</span>);
|
commandline.commandOutput(["span", { highlight: "CmdOutput" }, output]);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (/^>>/.test(filename)) {
|
if (/^>>/.test(filename)) {
|
||||||
@@ -2372,9 +2371,9 @@ Buffer.addPageInfoSection("e", "Search Engines", function (verbose) {
|
|||||||
if (verbose)
|
if (verbose)
|
||||||
for (let link in engines)
|
for (let link in engines)
|
||||||
yield [link.title || /*L*/ "Engine " + n++,
|
yield [link.title || /*L*/ "Engine " + n++,
|
||||||
<a xmlns={XHTML} href={link.href}
|
["a", { href: link.href, highlight: "URL",
|
||||||
onclick="if (event.button == 0) { window.external.AddSearchProvider(this.href); return false; }"
|
onclick: "if (event.button == 0) { window.external.AddSearchProvider(this.href); return false; }" },
|
||||||
highlight="URL">{link.href}</a>];
|
link.href]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!verbose && nEngines)
|
if (!verbose && nEngines)
|
||||||
@@ -2430,7 +2429,8 @@ Buffer.addPageInfoSection("f", "Feeds", function (verbose) {
|
|||||||
nFeed++;
|
nFeed++;
|
||||||
let type = feedTypes[feed.type] || "RSS";
|
let type = feedTypes[feed.type] || "RSS";
|
||||||
if (verbose)
|
if (verbose)
|
||||||
yield [feed.title, template.highlightURL(feed.href, true) + <span class="extra-info"> ({type})</span>];
|
yield [feed.title, [template.highlightURL(feed.href, true),
|
||||||
|
["span", { class: "extra-info" }, " (" + type + ")"]]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1384,9 +1384,12 @@ var DOM = Class("DOM", {
|
|||||||
? function (elem, dir) services.dactyl.getScrollable(elem) & (dir ? services.dactyl["DIRECTION_" + dir.toUpperCase()] : ~0)
|
? function (elem, dir) services.dactyl.getScrollable(elem) & (dir ? services.dactyl["DIRECTION_" + dir.toUpperCase()] : ~0)
|
||||||
: function (elem, dir) true),
|
: function (elem, dir) true),
|
||||||
|
|
||||||
isJSONXML: function isJSONXML(val) isArray(val) && (isString(val[0]) || isArray(val[0])) || isObject(val) && "toDOM" in val,
|
isJSONXML: function isJSONXML(val) isArray(val) && isinstance(val[0], ["String", "Array", "XML", DOM.DOMString])
|
||||||
|
|| isObject(val) && "toDOM" in val,
|
||||||
|
|
||||||
|
DOMString: function DOMString(val) ({
|
||||||
|
__proto__: DOMString.prototype,
|
||||||
|
|
||||||
DOMString: function (val) ({
|
|
||||||
toDOM: function toDOM(doc) doc.createTextNode(val)
|
toDOM: function toDOM(doc) doc.createTextNode(val)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1558,11 +1561,13 @@ var DOM = Class("DOM", {
|
|||||||
|
|
||||||
if (isinstance(args, ["String", _]))
|
if (isinstance(args, ["String", _]))
|
||||||
return doc.createTextNode(args);
|
return doc.createTextNode(args);
|
||||||
|
if (isXML(args))
|
||||||
|
return DOM.fromXML(args, doc, nodes);
|
||||||
|
|
||||||
let [name, attr] = args;
|
let [name, attr] = args;
|
||||||
attr = attr || {};
|
attr = attr || {};
|
||||||
|
|
||||||
if (Array.isArray(name) || args.length == 0 || name == "") {
|
if (!isString(name) || args.length == 0 || name === "") {
|
||||||
var frag = doc.createDocumentFragment();
|
var frag = doc.createDocumentFragment();
|
||||||
Array.forEach(args, function (arg) {
|
Array.forEach(args, function (arg) {
|
||||||
if (!isArray(arg[0]))
|
if (!isArray(arg[0]))
|
||||||
|
|||||||
@@ -918,7 +918,7 @@ unlet s:cpo_save
|
|||||||
result.output += "\n" + _("io.shellReturn", result.returnValue);
|
result.output += "\n" + _("io.shellReturn", result.returnValue);
|
||||||
|
|
||||||
modules.commandline.command = args.commandName.replace("run", "$& ") + arg;
|
modules.commandline.command = args.commandName.replace("run", "$& ") + arg;
|
||||||
modules.commandline.commandOutput(<span highlight="CmdOutput">{result.output}</span>);
|
modules.commandline.commandOutput(["span", { highlight: "CmdOutput" }, result.output]);
|
||||||
|
|
||||||
modules.autocommands.trigger("ShellCmdPost", {});
|
modules.autocommands.trigger("ShellCmdPost", {});
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -751,7 +751,7 @@ var JavaScript = Module("javascript", {
|
|||||||
|
|
||||||
message: Class.Memoize(function () {
|
message: Class.Memoize(function () {
|
||||||
default xml namespace = XHTML;
|
default xml namespace = XHTML;
|
||||||
util.xmlToDom(<div highlight="REPL" key="rootNode"/>,
|
DOM.fromJSON(["div", { highlight: "REPL", key: "rootNode" }],
|
||||||
this.document, this);
|
this.document, this);
|
||||||
|
|
||||||
return this.rootNode;
|
return this.rootNode;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
/* use strict */
|
"use strict";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
/* use strict */
|
"use strict";
|
||||||
|
|
||||||
defineModule("messages", {
|
defineModule("messages", {
|
||||||
exports: ["Messages", "messages", "_"],
|
exports: ["Messages", "messages", "_"],
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
let global = this;
|
let global = this;
|
||||||
defineModule("template", {
|
defineModule("template", {
|
||||||
exports: ["Binding", "Template", "template"],
|
exports: ["Binding", "Template", "template", "template_"],
|
||||||
require: ["util"]
|
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();
|
endModule();
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
|
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
|
||||||
|
|||||||
Reference in New Issue
Block a user