1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-27 06:53:31 +01:00

Hello strange new syntax. Can we be friends?

This commit is contained in:
Kris Maglione
2013-08-21 22:55:55 -07:00
parent e5864bfd23
commit c89f3e0df5
21 changed files with 106 additions and 134 deletions

View File

@@ -167,11 +167,11 @@ var CommandWidgets = Class("CommandWidgets", {
function get(prefix, map, id) (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id)); function get(prefix, map, id) (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id));
this.active.__defineGetter__(obj.name, function () self.activeGroup[obj.name][obj.name]); this.active.__defineGetter__(obj.name, () => this.activeGroup[obj.name][obj.name]);
this.activeGroup.__defineGetter__(obj.name, function () self.getGroup(obj.name)); this.activeGroup.__defineGetter__(obj.name, () => this.getGroup(obj.name));
memoize(this.statusbar, obj.name, function () get("dactyl-statusline-field-", statusline.widgets, (obj.id || obj.name))); memoize(this.statusbar, obj.name, () => get("dactyl-statusline-field-", statusline.widgets, (obj.id || obj.name)));
memoize(this.commandbar, obj.name, function () get("dactyl-", {}, (obj.id || obj.name))); memoize(this.commandbar, obj.name, () => get("dactyl-", {}, (obj.id || obj.name)));
if (!(obj.noValue || obj.getValue)) { if (!(obj.noValue || obj.getValue)) {
Object.defineProperty(this, obj.name, Modes.boundProperty({ Object.defineProperty(this, obj.name, Modes.boundProperty({
@@ -504,8 +504,6 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
*/ */
var CommandLine = Module("commandline", { var CommandLine = Module("commandline", {
init: function init() { init: function init() {
const self = this;
this._callbacks = {}; this._callbacks = {};
memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true })); memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true }));
@@ -777,13 +775,12 @@ var CommandLine = Module("commandline", {
highlightGroup = highlightGroup || this.HL_NORMAL; highlightGroup = highlightGroup || this.HL_NORMAL;
let self = this; let appendToMessages = (data) => {
function appendToMessages(data) {
let message = isObject(data) && !DOM.isJSONXML(data) ? data : { message: data }; let message = isObject(data) && !DOM.isJSONXML(data) ? data : { message: data };
// Make sure the memoized message property is an instance property. // Make sure the memoized message property is an instance property.
message.message; message.message;
self._messageHistory.add(update({ highlight: highlightGroup }, message)); this._messageHistory.add(update({ highlight: highlightGroup }, message));
return message.message; return message.message;
} }
@@ -802,7 +799,7 @@ var CommandLine = Module("commandline", {
if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isinstance(data, [_, "String"])) && !(flags & this.FORCE_SINGLELINE)) if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isinstance(data, [_, "String"])) && !(flags & this.FORCE_SINGLELINE))
action = mow.closure.echo; action = mow.closure.echo;
let checkSingleLine = function () action == self._echoLine; let checkSingleLine = () => action == this._echoLine;
if (forceSingle) { if (forceSingle) {
this._lastEcho = null; this._lastEcho = null;

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// 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.

View File

@@ -250,18 +250,17 @@ var KeyProcessor = Class("KeyProcessor", {
}, },
execute: function execute(map, args) execute: function execute(map, args)
let (self = this) () => {
function execute() { if (this.preExecute)
if (self.preExecute) this.preExecute.apply(this, args);
self.preExecute.apply(self, args);
args.self = self.main.params.mappingSelf || self.main.mappingSelf || map; args.self = this.main.params.mappingSelf || this.main.mappingSelf || map;
let res = map.execute.call(map, args); let res = map.execute.call(map, args);
if (self.postExecute) if (this.postExecute)
self.postExecute.apply(self, args); this.postExecute.apply(this, args);
return res; return res;
}, },
onKeyPress: function onKeyPress(event) { onKeyPress: function onKeyPress(event) {
if (event.skipmap) if (event.skipmap)

View File

@@ -123,8 +123,7 @@ var Map = Class("Map", {
contexts.context, contexts.context,
args); args);
let self = this; let repeat = () => this.action(args);
function repeat() self.action(args)
if (this.names[0] != ".") // FIXME: Kludge. if (this.names[0] != ".") // FIXME: Kludge.
mappings.repeat = repeat; mappings.repeat = repeat;

View File

@@ -211,9 +211,8 @@ var Addon = Class("Addon", {
}, },
update: function callee() { update: function callee() {
let self = this; let update = (key, xml) => {
function update(key, xml) { let node = this.nodes[key];
let node = self.nodes[key];
while (node.firstChild) while (node.firstChild)
node.removeChild(node.firstChild); node.removeChild(node.firstChild);

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2009-2013 Kris Maglione <maglione.k@gmail.com>
// //
// 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.
@@ -953,14 +953,13 @@ Class.prototype = {
* @returns {nsITimer} The timer which backs this timeout. * @returns {nsITimer} The timer which backs this timeout.
*/ */
timeout: function timeout(callback, timeout) { timeout: function timeout(callback, timeout) {
const self = this; let timeout_notify = (timer) => {
function timeout_notify(timer) { if (this.stale ||
if (self.stale ||
util.rehashing && !isinstance(Cu.getGlobalForObject(callback), ["BackstagePass"])) util.rehashing && !isinstance(Cu.getGlobalForObject(callback), ["BackstagePass"]))
return; return;
self.timeouts.splice(self.timeouts.indexOf(timer), 1); this.timeouts.splice(this.timeouts.indexOf(timer), 1);
util.trapErrors(callback, self); util.trapErrors(callback, this);
} };
let timer = services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT); let timer = services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT);
this.timeouts.push(timer); this.timeouts.push(timer);
return timer; return timer;
@@ -973,12 +972,11 @@ Class.prototype = {
* localized properties. * localized properties.
*/ */
update: function update() { update: function update() {
let self = this;
// XXX: Duplication. // XXX: Duplication.
for (let i = 0; i < arguments.length; i++) { for (let i = 0; i < arguments.length; i++) {
let src = arguments[i]; let src = arguments[i];
Object.getOwnPropertyNames(src || {}).forEach(function (k) { Object.getOwnPropertyNames(src || {}).forEach((k) => {
let desc = Object.getOwnPropertyDescriptor(src, k); let desc = Object.getOwnPropertyDescriptor(src, k);
if (desc.value instanceof Class.Property) if (desc.value instanceof Class.Property)
desc = desc.value.init(k, this) || desc.value; desc = desc.value.init(k, this) || desc.value;
@@ -986,12 +984,16 @@ Class.prototype = {
if (typeof desc.value === "function") { if (typeof desc.value === "function") {
let func = desc.value.wrapped || desc.value; let func = desc.value.wrapped || desc.value;
if (!func.superapply) { if (!func.superapply) {
func.__defineGetter__("super", function () Object.getPrototypeOf(self)[k]); func.__defineGetter__("super", () => Object.getPrototypeOf(this)[k]);
func.superapply = function superapply(self, args)
let (meth = Object.getPrototypeOf(self)[k]) func.superapply = function superapply(self, args) {
meth && meth.apply(self, args); let meth = Object.getPrototypeOf(self)[k];
func.supercall = function supercall(self) return meth && meth.apply(self, args);
func.superapply(self, Array.slice(arguments, 1)); };
func.supercall = function supercall(self) {
return func.superapply(self, Array.slice(arguments, 1));
}
} }
} }

View File

@@ -995,8 +995,6 @@ var Buffer = Module("Buffer", {
showPageInfo: function showPageInfo(verbose, sections) { showPageInfo: function showPageInfo(verbose, sections) {
let { commandline, dactyl, options } = this.modules; let { commandline, dactyl, options } = this.modules;
let self = this;
// Ctrl-g single line output // Ctrl-g single line output
if (!verbose) { if (!verbose) {
let file = this.win.location.pathname.split("/").pop() || _("buffer.noName"); let file = this.win.location.pathname.split("/").pop() || _("buffer.noName");
@@ -1004,7 +1002,7 @@ var Buffer = Module("Buffer", {
let info = template.map( let info = template.map(
(sections || options["pageinfo"]) (sections || options["pageinfo"])
.map(function (opt) Buffer.pageInfo[opt].action.call(self)), .map((opt) => Buffer.pageInfo[opt].action.call(this)),
function (res) res && iter(res).join(", ") || undefined, function (res) res && iter(res).join(", ") || undefined,
", ").join(""); ", ").join("");
@@ -1016,9 +1014,9 @@ var Buffer = Module("Buffer", {
return; return;
} }
let list = template.map(sections || options["pageinfo"], function (option) { let list = template.map(sections || options["pageinfo"], (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(this, true));
}, ["br"]); }, ["br"]);
commandline.commandOutput(list); commandline.commandOutput(list);
@@ -1254,14 +1252,13 @@ var Buffer = Module("Buffer", {
* Updates the zoom level of this buffer from a content preference. * Updates the zoom level of this buffer from a content preference.
*/ */
updateZoom: util.wrapCallback(function updateZoom() { updateZoom: util.wrapCallback(function updateZoom() {
let self = this;
let uri = this.uri; let uri = this.uri;
if (prefs.get("browser.zoom.siteSpecific")) { if (prefs.get("browser.zoom.siteSpecific")) {
this.getPref("dactyl.content.full-zoom", function (val) { this.getPref("dactyl.content.full-zoom", (val) => {
if (val != null && uri.equals(self.uri) && val != prefs.get("browser.zoom.full")) if (val != null && uri.equals(this.uri) && val != prefs.get("browser.zoom.full"))
[self.contentViewer.textZoom, self.contentViewer.fullZoom] = [this.contentViewer.textZoom, this.contentViewer.fullZoom] =
[self.contentViewer.fullZoom, self.contentViewer.textZoom]; [this.contentViewer.fullZoom, this.contentViewer.textZoom];
}); });
} }
}), }),

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// 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.
@@ -583,8 +583,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
this.remove(name); this.remove(name);
} }
let self = this; let closure = () => this._map[name];
let closure = function () self._map[name];
memoize(this._map, name, function () commands.Command(specs, description, action, extra)); memoize(this._map, name, function () commands.Command(specs, description, action, extra));
if (!extra.hidden) if (!extra.hidden)

View File

@@ -135,10 +135,10 @@ var CompletionContext = Class("CompletionContext", {
* {@link #filters} array. * {@link #filters} array.
*/ */
this.filterFunc = function filterFunc(items) { this.filterFunc = function filterFunc(items) {
let self = this; return this.filters
return this.filters. .reduce((res, filter)
reduce(function r(res, filter) res.filter(function f(item) filter.call(self, item)), => res.filter((item) => filter.call(this, item)),
items); items);
}; };
/** /**
* @property {Array} An array of predicates on which to filter the * @property {Array} An array of predicates on which to filter the
@@ -674,7 +674,6 @@ var CompletionContext = Class("CompletionContext", {
}, },
getRows: function getRows(start, end, doc) { getRows: function getRows(start, end, doc) {
let self = this;
let items = this.items; let items = this.items;
let cache = this.cache.rows; let cache = this.cache.rows;
let step = start > end ? -1 : 1; let step = start > end ? -1 : 1;
@@ -733,12 +732,10 @@ var CompletionContext = Class("CompletionContext", {
}, },
split: function split(name, obj, fn) { split: function split(name, obj, fn) {
const self = this;
let context = this.fork(name); let context = this.fork(name);
function alias(prop) { let alias = (prop) => {
context.__defineGetter__(prop, function get_() self[prop]); context.__defineGetter__(prop, () => this[prop]);
context.__defineSetter__(prop, function set_(val) self[prop] = val); context.__defineSetter__(prop, (val) => this[prop] = val);
} }
alias("_cache"); alias("_cache");
alias("_completions"); alias("_completions");
@@ -821,7 +818,6 @@ var CompletionContext = Class("CompletionContext", {
* context. * context.
*/ */
reset: function reset() { reset: function reset() {
let self = this;
if (this.parent) if (this.parent)
throw Error(); throw Error();
@@ -842,7 +838,7 @@ var CompletionContext = Class("CompletionContext", {
this.value = this._value; this.value = this._value;
this._caret = this.value.length; this._caret = this.value.length;
} }
//for (let key in (k for ([k, v] in Iterator(self.contexts)) if (v.offset > this.caret))) //for (let key in (k for ([k, v] in Iterator(this.contexts)) if (v.offset > this.caret)))
// delete this.contexts[key]; // delete this.contexts[key];
for each (let context in this.contexts) { for each (let context in this.contexts) {
context.hasItems = false; context.hasItems = false;

View File

@@ -19,8 +19,6 @@ var Const = function Const(val) Class.Property({ enumerable: true, value: val })
var Group = Class("Group", { var Group = Class("Group", {
init: function init(name, description, filter, persist) { init: function init(name, description, filter, persist) {
const self = this;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.filter = filter || this.constructor.defaultFilter; this.filter = filter || this.constructor.defaultFilter;
@@ -171,13 +169,12 @@ var Contexts = Module("contexts", {
Hives: Class("Hives", Class.Property, { Hives: Class("Hives", Class.Property, {
init: function init(name, constructor) { init: function init(name, constructor) {
const { contexts } = modules; const { contexts } = modules;
const self = this;
if (this.Hive) if (this.Hive)
return { return {
enumerable: true, enumerable: true,
get: function () array(contexts.groups[self.name]) get: () => array(contexts.groups[this.name])
}; };
this.Hive = constructor; this.Hive = constructor;

View File

@@ -23,21 +23,20 @@ var states = iter([v, k.slice(prefix.length).toLowerCase()]
var Download = Class("Download", { var Download = Class("Download", {
init: function init(id, list) { init: function init(id, list) {
let self = this;
this.download = services.downloadManager.getDownload(id); this.download = services.downloadManager.getDownload(id);
this.list = list; this.list = list;
this.nodes = { this.nodes = {
commandTarget: self commandTarget: this
}; };
DOM.fromJSON( DOM.fromJSON(
["tr", { highlight: "Download", key: "row" }, ["tr", { highlight: "Download", key: "row" },
["td", { highlight: "DownloadTitle" }, ["td", { highlight: "DownloadTitle" },
["span", { highlight: "Link" }, ["span", { highlight: "Link" },
["a", { key: "launch", href: self.target.spec, path: self.targetFile.path }, ["a", { key: "launch", href: this.target.spec, path: this.targetFile.path },
self.displayName], this.displayName],
["span", { highlight: "LinkInfo" }, ["span", { highlight: "LinkInfo" },
self.targetFile.path]]], this.targetFile.path]]],
["td", { highlight: "DownloadState", key: "state" }], ["td", { highlight: "DownloadState", key: "state" }],
["td", { highlight: "DownloadButtons Buttons" }, ["td", { highlight: "DownloadButtons Buttons" },
["a", { highlight: "Button", href: "javascript:0", key: "pause" }, _("download.action.Pause")], ["a", { highlight: "Button", href: "javascript:0", key: "pause" }, _("download.action.Pause")],
@@ -54,19 +53,19 @@ var Download = Class("Download", {
["td", { highlight: "DownloadSpeed", key: "speed" }], ["td", { highlight: "DownloadSpeed", key: "speed" }],
["td", { highlight: "DownloadTime", key: "time" }], ["td", { highlight: "DownloadTime", key: "time" }],
["td", {}, ["td", {},
["a", { highlight: "DownloadSource", key: "source", href: self.source.spec }, ["a", { highlight: "DownloadSource", key: "source", href: this.source.spec },
self.source.spec]]], this.source.spec]]],
this.list.document, this.nodes); this.list.document, this.nodes);
this.nodes.launch.addEventListener("click", function (event) { this.nodes.launch.addEventListener("click", (event) => {
if (event.button == 0) { if (event.button == 0) {
event.preventDefault(); event.preventDefault();
self.command("launch"); this.command("launch");
} }
}, false); }, false);
self.updateStatus(); this.updateStatus();
return self; return this;
}, },
get status() states[this.state], get status() states[this.state],
@@ -102,7 +101,6 @@ var Download = Class("Download", {
this.updateStatus(); this.updateStatus();
}, },
launch: function launch() { launch: function launch() {
let self = this;
// Behavior mimics that of the builtin Download Manager. // Behavior mimics that of the builtin Download Manager.
function action() { function action() {
try { try {
@@ -119,13 +117,13 @@ var Download = Class("Download", {
let file = io.File(this.targetFile); let file = io.File(this.targetFile);
if (file.isExecutable() && prefs.get("browser.download.manager.alertOnEXEOpen", true)) if (file.isExecutable() && prefs.get("browser.download.manager.alertOnEXEOpen", true))
this.list.modules.commandline.input(_("download.prompt.launchExecutable") + " ", this.list.modules.commandline.input(_("download.prompt.launchExecutable") + " ",
function (resp) { (resp) => {
if (/^a(lways)$/i.test(resp)) { if (/^a(lways)$/i.test(resp)) {
prefs.set("browser.download.manager.alertOnEXEOpen", false); prefs.set("browser.download.manager.alertOnEXEOpen", false);
resp = "yes"; resp = "yes";
} }
if (/^y(es)?$/i.test(resp)) if (/^y(es)?$/i.test(resp))
action.call(self); action.call(this);
}); });
else else
action.call(this); action.call(this);

View File

@@ -218,11 +218,12 @@ var Highlights = Module("Highlight", {
* @param {string} class * @param {string} class
*/ */
selector: function selector(class_) selector: function selector(class_)
let (self = this) class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g,
class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g, (m, n1, hl) => {
function (m, n1, hl) n1 + if (this.highlight[hl] && this.highlight[hl].class != class_)
(self.highlight[hl] && self.highlight[hl].class != class_ return n1 + this.highlight[hl].selector;
? self.highlight[hl].selector : "[dactyl|highlight~=" + hl + "]")), return n1 + "[dactyl|highlight~=" + hl + "]";
}),
groupRegexp: util.regexp(literal(/* groupRegexp: util.regexp(literal(/*
^ ^

View File

@@ -765,13 +765,12 @@ var JavaScript = Module("javascript", {
init: function init(context) { init: function init(context) {
init.supercall(this); init.supercall(this);
let self = this;
let sandbox = true || isinstance(context, ["Sandbox"]); let sandbox = true || isinstance(context, ["Sandbox"]);
this.context = modules.newContext(context, !sandbox, "Dactyl REPL Context"); this.context = modules.newContext(context, !sandbox, "Dactyl REPL Context");
this.js = modules.JavaScript(); this.js = modules.JavaScript();
this.js.replContext = this.context; this.js.replContext = this.context;
this.js.newContext = function newContext() modules.newContext(self.context, !sandbox, "Dactyl REPL Temp Context"); this.js.newContext = () => modules.newContext(this.context, !sandbox, "Dactyl REPL Temp Context");
this.js.globals = [ this.js.globals = [
[this.context, /*L*/"REPL Variables"], [this.context, /*L*/"REPL Variables"],

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2009-2013 Kris Maglione <maglione.k@gmail.com>
// //
// 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.
@@ -321,25 +321,24 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
}, },
scanModules: function scanModules() { scanModules: function scanModules() {
let self = this;
let { Module, modules } = this.modules; let { Module, modules } = this.modules;
defineModule.modules.forEach(function defModule(mod) { defineModule.modules.forEach((mod) => {
let names = Set(Object.keys(mod.INIT)); let names = Set(Object.keys(mod.INIT));
if ("init" in mod.INIT) if ("init" in mod.INIT)
Set.add(names, "init"); Set.add(names, "init");
keys(names).forEach(function (name) { self.deferInit(name, mod.INIT, mod); }); keys(names).forEach((name) => { this.deferInit(name, mod.INIT, mod); });
}); });
Module.list.forEach(function frobModule(mod) { Module.list.forEach((mod) => {
if (!mod.frobbed) { if (!mod.frobbed) {
modules.__defineGetter__(mod.className, function () { modules.__defineGetter__(mod.className, () => {
delete modules[mod.className]; delete modules[mod.className];
return self.loadModule(mod.className, null, Components.stack.caller); return this.loadModule(mod.className, null, Components.stack.caller);
}); });
Object.keys(mod.prototype.INIT) Object.keys(mod.prototype.INIT)
.forEach(function (name) { self.deferInit(name, mod.prototype.INIT, mod); }); .forEach((name) => { this.deferInit(name, mod.prototype.INIT, mod); });
} }
mod.frobbed = true; mod.frobbed = true;
}); });

View File

@@ -147,7 +147,6 @@ var Messages = Module("messages", {
obj[_prop] = this.default; obj[_prop] = this.default;
return { return {
get: function get() { get: function get() {
let self = this;
let value = this[_prop]; let value = this[_prop];
function getter(key, default_) function getter() messages.get([name, key].join("."), default_); function getter(key, default_) function getter() messages.get([name, key].join("."), default_);

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 by Kris Maglione <maglione.k@gmail.com>
// //
// 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.
@@ -908,8 +908,6 @@ var Options = Module("options", {
* @optional * @optional
*/ */
add: function add(names, description, type, defaultValue, extraInfo) { add: function add(names, description, type, defaultValue, extraInfo) {
const self = this;
if (!util.isDactyl(Components.stack.caller)) if (!util.isDactyl(Components.stack.caller))
deprecated.warn(add, "options.add", "group.options.add"); deprecated.warn(add, "options.add", "group.options.add");
@@ -927,7 +925,7 @@ var Options = Module("options", {
this.remove(name); this.remove(name);
} }
let closure = function () self._optionMap[name]; let closure = () => this._optionMap[name];
memoize(this._optionMap, name, function () Option.types[type](modules, names, description, defaultValue, extraInfo)); memoize(this._optionMap, name, function () Option.types[type](modules, names, description, defaultValue, extraInfo));
for (let alias in values(names.slice(1))) for (let alias in values(names.slice(1)))

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// 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.
@@ -139,7 +139,7 @@ var Services = Module("Services", {
if (service.quiet === false) if (service.quiet === false)
throw e.stack ? e : Error(e); throw e.stack ? e : Error(e);
if (typeof util !== "undefined") if (typeof util !== "undefined" && util != null)
util.reportError(e); util.reportError(e);
else else
dump("dactyl: Service creation failed for '" + service.class + "': " + e + "\n" + (e.stack || Error(e).stack)); dump("dactyl: Service creation failed for '" + service.class + "': " + e + "\n" + (e.stack || Error(e).stack));
@@ -176,13 +176,12 @@ var Services = Module("Services", {
* class. * class.
*/ */
addClass: function addClass(name, class_, ifaces, init, quiet) { addClass: function addClass(name, class_, ifaces, init, quiet) {
const self = this;
this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []), method: "createInstance", init: init, quiet: quiet }; this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []), method: "createInstance", init: init, quiet: quiet };
if (init) if (init)
memoize(this.services[name], "callable", memoize(this.services[name], "callable",
function () callable(XPCOMShim(this.interfaces)[this.init])); function () callable(XPCOMShim(this.interfaces)[this.init]));
this[name] = function Create() self._create(name, arguments); this[name] = (function Create() this._create(name, arguments)).bind(this);
update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))])); update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))]));
return this[name]; return this[name];
}, },

View File

@@ -241,7 +241,6 @@ var Storage = Module("Storage", {
}, },
newObject: function newObject(key, constructor, params) { newObject: function newObject(key, constructor, params) {
let self = this;
if (params == null || !isObject(params)) if (params == null || !isObject(params))
throw Error("Invalid argument type"); throw Error("Invalid argument type");
@@ -261,10 +260,10 @@ var Storage = Module("Storage", {
if (key in this && !reload) if (key in this && !reload)
throw Error("Cannot add storage key with that name."); throw Error("Cannot add storage key with that name.");
let load = function () self._loadData(key, params.store, params.type || myObject); let load = () => this._loadData(key, params.store, params.type || myObject);
this.keys[key] = new constructor(key, params.store, load, params); this.keys[key] = new constructor(key, params.store, load, params);
this.keys[key].timer = new Timer(1000, 10000, function () self.save(key)); this.keys[key].timer = new Timer(1000, 10000, () => this.save(key));
this.__defineGetter__(key, function () this.keys[key]); this.__defineGetter__(key, function () this.keys[key]);
} }
return this.keys[key]; return this.keys[key];

View File

@@ -203,7 +203,6 @@ var Hive = Class("Hive", {
* @param {number} index * @param {number} index
*/ */
remove: function remove(name, filter, css, index) { remove: function remove(name, filter, css, index) {
let self = this;
if (arguments.length == 1) { if (arguments.length == 1) {
var matches = [name]; var matches = [name];
name = null; name = null;
@@ -211,7 +210,7 @@ var Hive = Class("Hive", {
if (filter && filter.indexOf(",") > -1) if (filter && filter.indexOf(",") > -1)
return filter.split(",").reduce( return filter.split(",").reduce(
function (n, f) n + self.removeSheet(name, f, index), 0); (n, f) => n + this.removeSheet(name, f, index), 0);
if (filter == undefined) if (filter == undefined)
filter = ""; filter = "";

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// 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.
@@ -456,26 +456,24 @@ var Template = Module("Template", {
}, },
tabular: function tabular(headings, style, iter) { tabular: function tabular(headings, style, iter) {
let self = this;
// TODO: This might be mind-bogglingly slow. We'll see. // TODO: This might be mind-bogglingly slow. We'll see.
return ["table", {}, return ["table", {},
["tr", { highlight: "Title", align: "left" }, ["tr", { highlight: "Title", align: "left" },
this.map(headings, function (h) this.map(headings, function (h)
["th", {}, h])], ["th", {}, h])],
this.map(iter, function (row) this.map(iter, (row) =>
["tr", {}, ["tr", {},
self.map(Iterator(row), function ([i, d]) this.map(Iterator(row), function ([i, d])
["td", { style: style[i] || "" }, d])])]; ["td", { style: style[i] || "" }, d])])];
}, },
usage: function usage(iter, format) { usage: function usage(iter, format) {
let self = this;
format = format || {}; format = format || {};
let desc = format.description || function (item) self.linkifyHelp(item.description); let desc = format.description || (item => this.linkifyHelp(item.description));
let help = format.help || function (item) item.name; let help = format.help || (item => item.name);
function sourceLink(frame) { let sourceLink = (frame) => {
let source = self.sourceLink(frame); let source = this.sourceLink(frame);
source[1]["dactyl:hint"] = source[2]; source[1]["dactyl:hint"] = source[2];
return source; return source;
} }
@@ -483,25 +481,25 @@ var Template = Module("Template", {
format.headings ? format.headings ?
["thead", { highlight: "UsageHead" }, ["thead", { highlight: "UsageHead" },
["tr", { highlight: "Title", align: "left" }, ["tr", { highlight: "Title", align: "left" },
this.map(format.headings, function (h) ["th", {}, h])]] : this.map(format.headings, (h) => ["th", {}, h])]] :
[], [],
format.columns ? format.columns ?
["colgroup", {}, ["colgroup", {},
this.map(format.columns, function (c) ["col", { style: c }])] : this.map(format.columns, (c) => ["col", { style: c }])] :
[], [],
["tbody", { highlight: "UsageBody" }, ["tbody", { highlight: "UsageBody" },
this.map(iter, function (item) this.map(iter, (item) =>
// Urgh. // Urgh.
let (name = item.name || item.names[0], frame = item.definedAt) let (name = item.name || item.names[0], frame = item.definedAt)
["tr", { highlight: "UsageItem" }, ["tr", { highlight: "UsageItem" },
["td", { style: "padding-right: 2em;" }, ["td", { style: "padding-right: 2em;" },
["span", { highlight: "Usage Link" }, ["span", { highlight: "Usage Link" },
!frame ? name : !frame ? name :
[self.helpLink(help(item), name, "Title"), [this.helpLink(help(item), name, "Title"),
["span", { highlight: "LinkInfo" }, ["span", { highlight: "LinkInfo" },
_("io.definedAt"), " ", _("io.definedAt"), " ",
sourceLink(frame)]]]], sourceLink(frame)]]]],
item.columns ? self.map(item.columns, function (c) ["td", {}, c]) : [], item.columns ? this.map(item.columns, (c) => ["td", {}, c]) : [],
["td", {}, desc(item)]])]]; ["td", {}, desc(item)]])]];
} }
}); });

View File

@@ -40,7 +40,6 @@ function assertMessage(funcName, want, got, message) {
* @param {MozMillController} controller The browser's MozMill controller. * @param {MozMillController} controller The browser's MozMill controller.
*/ */
function Controller(controller) { function Controller(controller) {
var self = this;
this.controller = controller; this.controller = controller;
/** /**
@@ -51,13 +50,13 @@ function Controller(controller) {
this.errorCount = 0; this.errorCount = 0;
this._countBeep = function countBeep() { this._countBeep = () => {
self.beepCount++; this.beepCount++;
} }
this.errors = []; this.errors = [];
this._countError = function countError(message, highlight) { this._countError = (message, highlight) => {
if (/\b(Error|Warning)Msg\b/.test(highlight)) if (/\b(Error|Warning)Msg\b/.test(highlight))
self.errors.push(String(message)); this.errors.push(String(message));
} }
this.modules.dactyl.registerObserver("beep", this._countBeep); this.modules.dactyl.registerObserver("beep", this._countBeep);
this.modules.dactyl.registerObserver("echoLine", this._countError); this.modules.dactyl.registerObserver("echoLine", this._countError);
@@ -251,8 +250,7 @@ Controller.prototype = {
* @param {string} message The message to display upon assertion failure. @optional * @param {string} message The message to display upon assertion failure. @optional
*/ */
wrapAssertNoErrors: function (func, message) { wrapAssertNoErrors: function (func, message) {
let self = this; return () => this.assertNoErrors(func, this, arguments, message);
return function wrapped() self.assertNoErrors(func, this, arguments, message);
}, },
/** /**