X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=common%2Fmodules%2Faddons.jsm;fp=common%2Fmodules%2Faddons.jsm;h=fb1e59616a57e86d8bca74d159e32dfd852512b2;hb=354a049cce8415487552ce405cce167b7071fe1f;hp=e2c577ad9f704a611207314cf97ffd40881e112b;hpb=3d837eb266a3a01d424192aa4ec1a167366178c5;p=dactyl.git diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index e2c577a..fb1e596 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2012 Kris Maglione +// Copyright (c) 2009-2013 Kris Maglione // Copyright (c) 2009-2010 by Doug Kearns // // This work is licensed for reuse under an MIT license. Details are @@ -53,7 +53,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, { this.remaining = addons; this.upgrade = []; - this.dactyl.echomsg(_("addon.check", addons.map(function (a) a.name).join(", "))); + this.dactyl.echomsg(_("addon.check", addons.map(a => a.name).join(", "))); for (let addon in values(addons)) addon.findUpdates(this, AddonManager.UPDATE_WHEN_USER_REQUESTED, null, null); @@ -64,11 +64,11 @@ var updateAddons = Class("UpgradeListener", AddonListener, { install.install(); }, onUpdateFinished: function (addon, error) { - this.remaining = this.remaining.filter(function (a) a.type != addon.type || a.id != addon.id); + this.remaining = this.remaining.filter(a => (a.type != addon.type || a.id != addon.id)); if (!this.remaining.length) this.dactyl.echomsg( this.upgrade.length - ? _("addon.installingUpdates", this.upgrade.map(function (i) i.name).join(", ")) + ? _("addon.installingUpdates", this.upgrade.map(i => i.name).join(", ")) : _("addon.noUpdates")); } }); @@ -118,8 +118,10 @@ var actions = { }); }, get filter() { - return function (addon) !addon.userDisabled && - !(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE)); + return addon => ( + !addon.userDisabled && + !(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE + | AddonManager.OP_NEEDS_RESTART_DISABLE))); }, perm: "disable" }, @@ -302,7 +304,7 @@ var AddonList = Class("AddonList", { addon = Addon(addon, this); this.addons[addon.id] = addon; - let index = values(this.addons).sort(function (a, b) a.compare(b)) + let index = values(this.addons).sort((a, b) => a.compare(b)) .indexOf(addon); this.nodes.list.insertBefore(addon.nodes.row, @@ -343,10 +345,10 @@ var AddonList = Class("AddonList", { }); var Addons = Module("addons", { - errors: Class.Memoize(function () + errors: Class.Memoize(() => array(["ERROR_NETWORK_FAILURE", "ERROR_INCORRECT_HASH", "ERROR_CORRUPT_FILE", "ERROR_FILE_ACCESS"]) - .map(function (e) [AddonManager[e], _("AddonManager." + e)]) + .map(e => [AddonManager[e], _("AddonManager." + e)]) .toObject()) }, { }, { @@ -360,7 +362,7 @@ var Addons = Module("addons", { modules.commandline.echo(addons); if (modules.commandline.savingOutput) - util.waitFor(function () addons.ready); + util.waitFor(() => addons.ready); }, { argCount: "?", @@ -398,7 +400,7 @@ var Addons = Module("addons", { }, { argCount: "1", completer: function (context) { - context.filters.push(function ({ isdir, text }) isdir || /\.xpi$/.test(text)); + context.filters.push(({ isdir, text }) => isdir || /\.xpi$/.test(text)); completion.file(context); }, literal: 0 @@ -420,7 +422,7 @@ var Addons = Module("addons", { AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) { if (!args.bang || command.bang) { - list = list.filter(function (addon) addon.id == name || addon.name == name); + list = list.filter(addon => (addon.id == name || addon.name == name)); dactyl.assert(list.length, _("error.invalidArgument", name)); dactyl.assert(list.some(ok), _("error.invalidOperation")); list = list.filter(ok); @@ -429,14 +431,14 @@ var Addons = Module("addons", { if (command.actions) command.actions(list, this.modules); else - list.forEach(function (addon) command.action.call(this.modules, addon, args.bang), this); + list.forEach(addon => { command.action.call(this.modules, addon, args.bang) }); })); }, { argCount: "?", // FIXME: should be "1" bang: true, completer: function (context, args) { completion.addon(context, args["-types"]); - context.filters.push(function ({ item }) ok(item)); + context.filters.push(({ item }) => ok(item)); }, literal: 0, options: [ @@ -455,7 +457,7 @@ var Addons = Module("addons", { completion.addonType = function addonType(context) { let base = ["extension", "theme"]; function update(types) { - context.completions = types.map(function (t) [t, util.capitalize(t)]); + context.completions = types.map(t => [t, util.capitalize(t)]); } context.generate = function generate() { @@ -464,7 +466,7 @@ var Addons = Module("addons", { context.incomplete = true; AddonManager.getAllAddons(function (addons) { context.incomplete = false; - update(array.uniq(base.concat(addons.map(function (a) a.type)), + update(array.uniq(base.concat(addons.map(a => a.type)), true)); }); } @@ -475,7 +477,7 @@ var Addons = Module("addons", { context.title = ["Add-on"]; context.anchored = false; context.keys = { - text: function (addon) [addon.name, addon.id], + text: addon => [addon.name, addon.id], description: "description", icon: "iconURL" };