diff --git a/content/commands.js b/content/commands.js index ee85a36f..ad770533 100644 --- a/content/commands.js +++ b/content/commands.js @@ -39,32 +39,33 @@ function Command(specs, description, action, extraInfo) //{{{ // convert command name abbreviation specs of the form // 'shortname[optional-tail]' to short and long versions Eg. 'abc[def]' -> // 'abc', 'abcdef' - var parseSpecs = function (specs) + function parseSpecs(specs) { - var shortNames = []; - var longNames = []; - var names = []; - for (let i = 0; i < specs.length; i++) + let shortNames = longNames = names = []; + + for (let [,spec] in Iterator(specs)) { - var match; - if (match = specs[i].match(/(\w+|!)\[(\w+)\]/)) + let matches = spec.match(/(\w+|!)\[(\w+)\]/); + + if (matches) { - shortNames.push(match[1]); - longNames.push(match[1] + match[2]); + shortNames.push(matches[1]); + longNames.push(matches[1] + matches[2]); // order as long1, short1, long2, short2 - names.push(match[1] + match[2]); - names.push(match[1]); + names.push(matches[1] + matches[2]); + names.push(matches[1]); } else { - longNames.push(specs[i]); - names.push(specs[i]); + longNames.push(spec); + names.push(spec); } } + return { names: names, longNames: longNames, shortNames: shortNames }; }; - var expandedSpecs = parseSpecs(specs); + let expandedSpecs = parseSpecs(specs); this.specs = specs; this.shortNames = expandedSpecs.shortNames; this.longNames = expandedSpecs.longNames; diff --git a/content/tabs.js b/content/tabs.js index a3f2eb64..e6b5407a 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -312,21 +312,22 @@ function Tabs() //{{{ if (args) { args = args.toLowerCase(); - var removed = 0; - var match; - if (match = args.match(/^(\d+):?/)) + let removed = 0; + let matches = args.match(/^(\d+):?/); + + if (matches) { - tabs.remove(tabs.getTab(parseInt(match[1], 10) - 1)); + tabs.remove(tabs.getTab(parseInt(matches[1], 10) - 1)); removed = 1; } else { - var browsers = getBrowser().browsers; + let browsers = getBrowser().browsers; for (let i = browsers.length - 1; i >= 0; i--) { - var title = browsers[i].contentTitle.toLowerCase() || ""; - var uri = browsers[i].currentURI.spec.toLowerCase(); - var host = browsers[i].currentURI.host.toLowerCase(); + let title = browsers[i].contentTitle.toLowerCase() || ""; + let uri = browsers[i].currentURI.spec.toLowerCase(); + let host = browsers[i].currentURI.host.toLowerCase(); if (host.indexOf(args) >= 0 || uri == args || (special && (title.indexOf(args) >= 0 || uri.indexOf(args) >= 0))) @@ -922,10 +923,10 @@ function Tabs() //{{{ if (typeof reverse != "boolean") reverse = false; - var match; - if (match = buffer.match(/^(\d+):?/)) + var matches = buffer.match(/^(\d+):?/); + if (matches) { - tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based + tabs.select(parseInt(matches[1], 10) - 1, false); // make it zero-based return; }