From e6a678257de1fa30670ab7a5a149ac4449c7daab Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Tue, 6 Nov 2007 10:21:12 +0000 Subject: [PATCH] return the boolean expression directly from option validators since nothing is done in the conditionals --- content/options.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/content/options.js b/content/options.js index da4dbd71..31dabeca 100644 --- a/content/options.js +++ b/content/options.js @@ -437,7 +437,10 @@ vimperator.Options = function() //{{{ "
  • paste: P and gP mappings
  • " + "", default_value: "homepage,quickmark,tabopen,paste", - validator: function(value) { return value.split(",").every(function(item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); }); } + validator: function(value) + { + return value.split(",").every(function(item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); }); + } } )); this.add(new vimperator.Option(["complete", "cpt"], "charlist", @@ -453,7 +456,7 @@ vimperator.Options = function() //{{{ "The order is important, so :set complete=bs would list bookmarks first, and then any available quick searches.
    " + "Add 'sort' to the 'wildoptions' option if you want all entries sorted.", default_value: "sfbh", - validator: function (value) { if (/[^sfbh]/.test(value)) return false; else return true; } + validator: function(value) { return !/[^sfbh]/.test(value); } } )); this.add(new vimperator.Option(["defsearch", "ds"], "string", @@ -507,14 +510,14 @@ vimperator.Options = function() //{{{ "", setter: function(value) { setGuiOptions(value); }, default_value: "", - validator: function (value) { if (/[^mTb]/.test(value)) return false; else return true; } + validator: function(value) { return !/[^mTb]/.test(value); } } )); this.add(new vimperator.Option(["hinttimeout", "hto"], "number", { short_help: "Automatically follow non unique numerical hint after {arg} ms", default_value: 500, - validator: function (value) { if (value >= 0) return true; else return false; } + validator: function(value) { return value >= 0; } } )); this.add(new vimperator.Option(["hintstyle", "hs"], "string", @@ -577,7 +580,7 @@ vimperator.Options = function() //{{{ "NOTE: laststatus=1 not implemented yet.", default_value: 2, setter: function(value) { setLastStatus(value); }, - validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } + validator: function(value) { return (value >= 0 && value <= 2); } } )); this.add(new vimperator.Option(["linksearch", "lks"], "boolean", @@ -621,7 +624,7 @@ vimperator.Options = function() //{{{ "NOTE: This option does not change the popup blocker of Firefox in any way.", default_value: 1, setter: function(value) { setPopups(value); }, - validator: function (value) { if (value >= 0 && value <= 3) return true; else return false; } + validator: function(value) { return (value >= 0 && value <= 3); } } )); this.add(new vimperator.Option(["preload"], "boolean", @@ -639,7 +642,7 @@ vimperator.Options = function() //{{{ "Close the preview window with :pclose.
    " + "NOTE: Option currently disabled", default_value: 10, - validator: function (value) { if (value >= 1 && value <= 50) return true; else return false; } + validator: function(value) { return (value >= 1 && value <= 50); } } )); this.add(new vimperator.Option(["scroll", "scr"], "number", @@ -649,7 +652,7 @@ vimperator.Options = function() //{{{ "When a {count} is specified to the <C-u> or <C-d> commands this is used to set the value of 'scroll' and also used for the current command. " + "The value can be reset to half the window height with :set scroll=0.", default_value: 0, - validator: function (value) { if (value >= 0) return true; else return false; } + validator: function(value) { return value >= 0; } } )); this.add(new vimperator.Option(["showmode", "smd"], "boolean", @@ -669,7 +672,7 @@ vimperator.Options = function() //{{{ "
  • 2: Show the link in the command line
  • " + "", default_value: 1, - validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } + validator: function(value) { return (value >= 0 && value <= 2); } } )); this.add(new vimperator.Option(["showtabline", "stal"], "number", @@ -683,7 +686,7 @@ vimperator.Options = function() //{{{ "", setter: function(value) { setShowTabline(value); }, default_value: 2, - validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; } + validator: function(value) { return (value >= 0 && value <= 2); } } )); this.add(new vimperator.Option(["smartcase", "scs"], "boolean", @@ -718,7 +721,7 @@ vimperator.Options = function() //{{{ help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with :javascript!.
    " + "The highest value is 9, being the most verbose mode.", default_value: 0, - validator: function (value) { if (value >= 0 && value <= 9) return true; else return false; } + validator: function(value) { return (value >= 0 && value <= 9); } } )); this.add(new vimperator.Option(["visualbell", "vb"], "boolean", @@ -746,12 +749,9 @@ vimperator.Options = function() //{{{ "" + "When there is only a single match, it is fully completed regardless of the case.", default_value: "list:full", - validator: function (value) + validator: function(value) { - if (/^(?:(?:full|longest|list|list:full|list:longest)(?:,(?!,))?){0,3}(?:full|longest|list|list:full|list:longest)?$/.test(value)) - return true; - else - return false; + return value.split(",").every(function(item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); }); } } )); @@ -764,7 +764,7 @@ vimperator.Options = function() //{{{ "sortAlways sorts completion list, overriding the 'complete' option." + "", default_value: "", - validator: function (value) { if (/^sort$/.test(value)) return true; else return false; } + validator: function(value) { return /^sort$/.test(value); } } )); //}}}