1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 02:28:00 +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

@@ -4,7 +4,7 @@
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
// "use strict";
"use strict";
defineModule("buffer", {
exports: ["Buffer", "buffer"],
@@ -16,7 +16,7 @@ lazyRequire("io", ["io"]);
lazyRequire("finder", ["RangeFind"]);
lazyRequire("overlay", ["overlay"]);
lazyRequire("storage", ["File", "storage"]);
lazyRequire("template", ["template"]);
lazyRequire("template", ["template", "template_"]);
/**
* A class to manage the primary web content buffer. The name comes
@@ -888,8 +888,7 @@ var Buffer = Module("Buffer", {
showElementInfo: function showElementInfo(elem) {
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))
info += ", " + _("buffer.bookmarked");
let pageInfoText = <>{file.quote()} [{info}] {title}</>;
let pageInfoText = [file.quote(), " [", info, "] ", title].join("");
dactyl.echo(pageInfoText, commandline.FORCE_SINGLELINE);
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];
return template.table(title, action.call(self, true));
}, <br/>);
return template_.table(title, action.call(self, true));
}, ["br"]);
commandline.commandOutput(list);
},
@@ -1693,7 +1692,7 @@ var Buffer = Module("Buffer", {
function (file) {
let output = io.system(filename.substr(1), file);
commandline.command = command;
commandline.commandOutput(<span highlight="CmdOutput">{output}</span>);
commandline.commandOutput(["span", { highlight: "CmdOutput" }, output]);
});
if (/^>>/.test(filename)) {
@@ -2372,9 +2371,9 @@ Buffer.addPageInfoSection("e", "Search Engines", function (verbose) {
if (verbose)
for (let link in engines)
yield [link.title || /*L*/ "Engine " + n++,
<a xmlns={XHTML} href={link.href}
onclick="if (event.button == 0) { window.external.AddSearchProvider(this.href); return false; }"
highlight="URL">{link.href}</a>];
["a", { href: link.href, highlight: "URL",
onclick: "if (event.button == 0) { window.external.AddSearchProvider(this.href); return false; }" },
link.href]];
}
if (!verbose && nEngines)
@@ -2430,7 +2429,8 @@ Buffer.addPageInfoSection("f", "Feeds", function (verbose) {
nFeed++;
let type = feedTypes[feed.type] || "RSS";
if (verbose)
yield [feed.title, template.highlightURL(feed.href, true) + <span class="extra-info">&#xa0;({type})</span>];
yield [feed.title, [template.highlightURL(feed.href, true),
["span", { class: "extra-info" }, " (" + type + ")"]]];
}
}

View File

@@ -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) 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)
}),
@@ -1558,11 +1561,13 @@ var DOM = Class("DOM", {
if (isinstance(args, ["String", _]))
return doc.createTextNode(args);
if (isXML(args))
return DOM.fromXML(args, doc, nodes);
let [name, attr] = args;
attr = attr || {};
if (Array.isArray(name) || args.length == 0 || name == "") {
if (!isString(name) || args.length == 0 || name === "") {
var frag = doc.createDocumentFragment();
Array.forEach(args, function (arg) {
if (!isArray(arg[0]))

View File

@@ -918,7 +918,7 @@ unlet s:cpo_save
result.output += "\n" + _("io.shellReturn", result.returnValue);
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", {});
}, {

View File

@@ -751,7 +751,7 @@ var JavaScript = Module("javascript", {
message: Class.Memoize(function () {
default xml namespace = XHTML;
util.xmlToDom(<div highlight="REPL" key="rootNode"/>,
DOM.fromJSON(["div", { highlight: "REPL", key: "rootNode" }],
this.document, this);
return this.rootNode;

View File

@@ -2,7 +2,7 @@
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
/* use strict */
"use strict";
try {

View File

@@ -2,7 +2,7 @@
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
/* use strict */
"use strict";
defineModule("messages", {
exports: ["Messages", "messages", "_"],

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: