diff options
author | drry | 2009-02-15 15:10:19 +0000 |
---|---|---|
committer | drry | 2009-02-15 15:10:19 +0000 |
commit | fd858975e1704c70749486d758d417aec043e960 (patch) | |
tree | a2dbc10bc88dd421bee995ffdb14213b745a047d /cpan-search.js | |
parent | 5d5d16dadd586b6239f8e183e9683d526df6677a (diff) | |
download | vimperator-plugins-fd858975e1704c70749486d758d417aec043e960.tar.bz2 |
* fixed regexes.
* et cetera.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@30102 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'cpan-search.js')
-rw-r--r-- | cpan-search.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/cpan-search.js b/cpan-search.js index fed9353..f484e5f 100644 --- a/cpan-search.js +++ b/cpan-search.js @@ -22,23 +22,23 @@ var PLUGIN_INFO = var p = function(arg) { Application.console.log(arg); // liberator.log(arg); -} +}; -// preload cpan list +// preload CPAN list var cpanListURL = liberator.globalVariables.cpanSearchListURL || 'http://cpan.ma.la/list'; if (!liberator.globalVariables.cpanListCache) { - var xhr = new XMLHttpRequest(); + let xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { liberator.globalVariables.cpanListCache = - xhr.responseText.split(/\r?\n/).map(function(i) [i, '', i.toUpperCase()]); + xhr.responseText.split(/\r\n|[\r\n]/).map(function(i) [i, '', i.toUpperCase()]); } else { - liberator.echoerr('CPAN Search: XHR Error: ' + xhr.statusText); + liberator.echoerr('CPAN search: XHR Error: ' + xhr.statusText); // throw new Error(xhr.statusText); } } - } + }; xhr.open('GET', cpanListURL, true); xhr.send(null); } @@ -47,7 +47,7 @@ commands.addUserCommand( ['cpan'], 'CPAN Search', function(args) { - var name = (args.string || '').replace(/\s/g, '').replace(/^\^/,''); + var name = (args.string || '').replace(/^\^|\s+/g, ''); var url = 'http://search.cpan.org/perldoc?' + name; liberator.open(url, args.bang ? liberator.NEW_TAB : null); }, { @@ -55,7 +55,7 @@ commands.addUserCommand( context.title = ['MODULE NAME', '']; var word = context.filter.toUpperCase(); if (word.indexOf(':') >= 0) { - var regex = word.split(/:+/).map(function(i) i + '[^:]*').join('::'); + let regex = word.split(/:+/).map(function(i) i + '[^:]*').join('::'); regex = new RegExp('^' + regex.replace(/\[\^:\]\*$/, '')); context.filters = [function(item) regex.test(item.item[2])]; } else { @@ -64,7 +64,7 @@ commands.addUserCommand( context.completions = liberator.globalVariables.cpanListCache || []; }, argCount: '1', - bang: true, + bang: true }, true ); |