diff --git a/content/bookmarks.js b/content/bookmarks.js index d64aad23..431cf5fc 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -187,7 +187,7 @@ vimperator.Bookmarks = function () //{{{ for (var i in firefox_engines) { var alias = firefox_engines[i].alias; - if (!alias || !alias.match(/^[a-z0-9_-]+$/)) + if (!alias || !/^[a-z0-9_-]+$/.test(alias)) alias = firefox_engines[i].name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase(); if (!alias) alias = "search"; // for search engines which we can't find a suitable alias diff --git a/content/commands.js b/content/commands.js index 2aaaea28..5f437bb6 100644 --- a/content/commands.js +++ b/content/commands.js @@ -117,7 +117,7 @@ vimperator.Command.prototype.hasName = function (name) { return true; } - else if (this.specs[i].match(/^(\w+|!)\[\w+\]$/)) // abbreviation spec + else if (/^(\w+|!)\[\w+\]$/.test(this.specs[i])) // abbreviation spec { if (matchAbbreviation(name, this.specs[i])) return true; @@ -1037,19 +1037,19 @@ vimperator.Commands = function () //{{{ return; } - var match; + var matches; // 1 - type, 2 - name, 3 - +-., 4 - expr - if (match = args.match(/([$@&])?([\w:]+)\s*([+-.])?=\s*(.+)/)) + if (matches = args.match(/([$@&])?([\w:]+)\s*([+-.])?=\s*(.+)/)) { - if (!match[1]) + if (!matches[1]) { - var reference = vimperator.variableReference(match[2]); - if (!reference[0] && match[3]) - return vimperator.echoerr("E121: Undefined variable: " + match[2]); + var reference = vimperator.variableReference(matches[2]); + if (!reference[0] && matches[3]) + return vimperator.echoerr("E121: Undefined variable: " + matches[2]); - var expr = vimperator.eval(match[4]); + var expr = vimperator.eval(matches[4]); if (typeof expr === undefined) - return vimperator.echoerr("E15: Invalid expression: " + match[4]); + return vimperator.echoerr("E15: Invalid expression: " + matches[4]); else { if (!reference[0]) { @@ -1059,13 +1059,13 @@ vimperator.Commands = function () //{{{ return; // for now } - if (match[3]) + if (matches[3]) { - if (match[3] == "+") + if (matches[3] == "+") reference[0][reference[1]] += expr; - else if (match[3] == "-") + else if (matches[3] == "-") reference[0][reference[1]] -= expr; - else if (match[3] == ".") + else if (matches[3] == ".") reference[0][reference[1]] += expr.toString(); } else @@ -1074,11 +1074,11 @@ vimperator.Commands = function () //{{{ } } // 1 - name - else if (match = args.match(/^\s*([\w:]+)\s*$/)) + else if (matches = args.match(/^\s*([\w:]+)\s*$/)) { - var reference = vimperator.variableReference(match[1]); + var reference = vimperator.variableReference(matches[1]); if (!reference[0]) - return vimperator.echoerr("E121: Undefined variable: " + match[1]); + return vimperator.echoerr("E121: Undefined variable: " + matches[1]); var value = reference[0][reference[1]]; if (typeof value == "number") @@ -1394,7 +1394,7 @@ vimperator.Commands = function () //{{{ { usage: ["norm[al][!] {commands}"], short_help: "Execute Normal mode commands", - help: "Example: :normal 20j scrolls 20 lines down. " + + help: "Example: :normal 20j scrolls 20 lines down. " + "If the [!] is specified mappings will not be used." } )); diff --git a/content/events.js b/content/events.js index d88af378..7551bcdc 100644 --- a/content/events.js +++ b/content/events.js @@ -647,7 +647,7 @@ vimperator.Events = function () //{{{ map = vimperator.mappings.get(vimperator.mode, candidate_command); // counts must be at the start of a complete mapping (10j -> go 10 lines down) - if ((vimperator.input.buffer + key).match(/^[1-9][0-9]*$/)) + if (/^[1-9][0-9]*$/.test(vimperator.input.buffer + key)) { // no count for insert mode mappings if (vimperator.mode == vimperator.modes.INSERT || vimperator.mode == vimperator.modes.COMMAND_LINE) diff --git a/content/mappings.js b/content/mappings.js index b9043e45..5b2af960 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -1009,20 +1009,18 @@ vimperator.Mappings = function () //{{{ )); function isDirectory(url) { - if (url.match(/^file:\/\//) || url.match(/^\//)) + if (/^file:\/\/|^\//.test(url)) { - var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2"); - var file = vimperator.io.getFile(stripedFilename); + var strippedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2"); + var file = vimperator.io.getFile(strippedFilename); if (!file || !file.isDirectory()) return false; else return true; } + // for all other locations just check if the URL ends with / - if (url.match(/\/$/)) - return true; - else - return false; + return /\/$/.test(url); } addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gu", ""], function (count) diff --git a/content/options.js b/content/options.js index b9702b16..426475d1 100644 --- a/content/options.js +++ b/content/options.js @@ -297,7 +297,7 @@ vimperator.Options = function () //{{{ // work around firefox popup blocker var popup_allowed_events = loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit"); - if (!popup_allowed_events.match("keypress")) + if (!/keypress/.test(popup_allowed_events)) storePreference("dom.popup_allowed_events", popup_allowed_events + " keypress"); // TODO: shouldn't we be resetting these in destroy() as well? @@ -780,7 +780,7 @@ vimperator.Options = function () //{{{ { short_help: "String to search when looking for 'prev' page in document relation", help: "Change it to make it look for another string in links when pressing ]p
" + - "This value is case insensitive", + "This value is case insensitive", default_value: "\\bprev,previous\\b,^<$" } )); diff --git a/content/tabs.js b/content/tabs.js index f506c7c6..aab8d792 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -57,7 +57,7 @@ vimperator.Tabs = function () //{{{ position = spec; else if (spec === "$") return last; - else if (!spec.match(/^([+-]?\d+|)$/)) + else if (!/^([+-]?\d+|)$/.test(spec)) { // TODO: move error reporting to ex-command? vimperator.echoerr("E488: Trailing characters"); @@ -65,7 +65,7 @@ vimperator.Tabs = function () //{{{ } else { - if (spec.match(/^([+-]\d+)$/)) // relative position +/-N + if (/^([+-]\d+)$/.test(spec)) // relative position +/-N position += parseInt(spec, 10); else // absolute position position = parseInt(spec, 10); diff --git a/content/ui.js b/content/ui.js index df9084f7..d8e75f11 100644 --- a/content/ui.js +++ b/content/ui.js @@ -484,7 +484,7 @@ vimperator.CommandLine = function () //{{{ [completion_start_index, completions] = res; // sort the completion list - if (vimperator.options["wildoptions"].search(/\bsort\b/) > -1) + if (/\bsort\b/.test(vimperator.options["wildoptions"])) { completions.sort(function (a, b) { if (a[0] < b[0]) diff --git a/content/util.js b/content/util.js index 4eded0cf..2fb5f167 100644 --- a/content/util.js +++ b/content/util.js @@ -207,4 +207,5 @@ vimperator.util = { return strNum[0] + " " + unitVal[unitIndex]; } }; + // vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/vimperator.js b/content/vimperator.js index 88a71fa8..4bdce7e5 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -164,13 +164,13 @@ const vimperator = (function () //{{{ eval: function (string) { string = string.toString().replace(/^\s*/, "").replace(/\s*$/, ""); - var match = string.match(/^&(\w+)/); - if (match) + var matches = string.match(/^&(\w+)/); + if (matches) { - var opt = this.options.get(match[1]); + var opt = this.options.get(matches[1]); if (!opt) { - this.echoerr("E113: Unknown option: " + match[1]); + this.echoerr("E113: Unknown option: " + matches[1]); return; } var type = opt.type; @@ -181,10 +181,10 @@ const vimperator = (function () //{{{ } // String - else if (match = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) + else if (matches = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) { - if (match) - return match[2].toString(); + if (matches) + return matches[2].toString(); else { this.echoerr("E115: Missing quote: " + string); @@ -193,7 +193,7 @@ const vimperator = (function () //{{{ } // Number - else if (match = string.match(/^(\d+)$/)) + else if (matches = string.match(/^(\d+)$/)) { return parseInt(match[1], 10); } @@ -212,16 +212,16 @@ const vimperator = (function () //{{{ if (!string) return [null, null, null]; - var match = string.match(/^([bwtglsv]):(\w+)/); - if (match) // Variable + var matches = string.match(/^([bwtglsv]):(\w+)/); + if (matches) // Variable { // Other variables should be implemented - if (match[1] == "g") + if (matches[1] == "g") { - if (match[2] in this.globalVariables) - return [this.globalVariables, match[2], match[1]]; + if (matches[2] in this.globalVariables) + return [this.globalVariables, matches[2], matches[1]]; else - return [null, match[2], match[1]]; + return [null, matches[2], matches[1]]; } } else // Global variable