-// Copyright (c) 2010-2011 by Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2010-2012 Kris Maglione <maglione.k@gmail.com>
//
// 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";
-Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("contexts", {
exports: ["Contexts", "Group", "contexts"],
require: ["services", "util"]
-}, this);
+});
-this.lazyRequire("overlay", ["overlay"]);
+lazyRequire("commands", ["ArgType", "CommandOption", "commands"]);
+lazyRequire("options", ["Option"]);
+lazyRequire("overlay", ["overlay"]);
+lazyRequire("storage", ["File"]);
+lazyRequire("template", ["template"]);
var Const = function Const(val) Class.Property({ enumerable: true, value: val });
var Group = Class("Group", {
init: function init(name, description, filter, persist) {
- const self = this;
-
this.name = name;
this.description = description;
this.filter = filter || this.constructor.defaultFilter;
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0,
}, {
- compileFilter: function (patterns, default_) {
+ compileFilter: function (patterns, default_ = false) {
if (arguments.length < 2)
default_ = false;
return update(siteFilter, {
toString: function () this.filters.join(","),
- toXML: function (modules) let (uri = modules && modules.buffer.uri)
+ toJSONXML: function (modules) let (uri = modules && modules.buffer.uri)
template.map(this.filters,
- function (f) <span highlight={uri && f(uri) ? "Filter" : ""}>{f}</span>,
- <>,</>),
+ function (f) ["span", { highlight: uri && f(uri) ? "Filter" : "" },
+ "toJSONXML" in f ? f.toJSONXML() : String(f)],
+ ","),
filters: Option.parse.sitelist(patterns)
});
Hives: Class("Hives", Class.Property, {
init: function init(name, constructor) {
const { contexts } = modules;
- const self = this;
if (this.Hive)
return {
enumerable: true,
- get: function () array(contexts.groups[self.name])
+ get: () => array(contexts.groups[this.name])
};
this.Hive = constructor;
return {
__proto__: frame,
filename: this.context.file[0] == "[" ? this.context.file
- : services.io.newFileURI(File(this.context.file)).spec,
+ : File(this.context.file).URI.spec,
lineNumber: this.context.line
};
return frame;
getDocs: function getDocs(context) {
try {
if (isinstance(context, ["Sandbox"])) {
- let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML && INFO.toXMLString()", context);
- return info && XML(info);
+ let info = "INFO" in context && Cu.evalInSandbox("this.INFO instanceof XML ? INFO.toXMLString() : this.INFO", context);
+ return /^</.test(info) ? XML(info) : info;
}
- if (typeof context.INFO == "xml")
+ if (DOM.isJSONXML(context.INFO))
+ return context.INFO;
+ if (typeof context.INFO == "xml" && config.haveGecko(null, "14.*"))
return context.INFO;
}
catch (e) {}
if (callable(params))
action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })");
else
- action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg).array);
+ action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg));
process = function (param) isObject(param) && param.valueOf ? param.valueOf() : param;
action.params = params;
action.makeParams = makeParams;
{
names: ["-description", "-desc", "-d"],
description: "A description of this group",
- default: ["User-defined group"],
+ default: "User-defined group",
type: CommandOption.STRING
},
{
names: ["-locations", "-locs", "-loc", "-l"],
- description: ["The URLs for which this group should be active"],
+ description: "The URLs for which this group should be active",
default: ["*"],
type: CommandOption.LIST
},
context.keys = {
active: function (group) group.filter(uri),
text: "name",
- description: function (g) <>{g.filter.toXML ? g.filter.toXML(modules) + <> </> : ""}{g.description || ""}</>
+ description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""]
};
context.completions = (active === undefined ? contexts.groupList : contexts.initializedGroups(active))
.slice(0, -1);
// catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
-// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: