diff options
| author | Niklas Baumstark | 2012-01-21 04:00:12 +0100 |
|---|---|---|
| committer | Niklas Baumstark | 2012-04-10 23:54:36 +0200 |
| commit | 69ea703f584f65c962fb04fcae7bb6500a11b76a (patch) | |
| tree | 2d82b2694d67a078d0ae757387ffbfb51d982eb2 /lib/completion.js | |
| parent | 79b0340f40149bafd48d3d23200c3e613068a9dc (diff) | |
| download | vimium-69ea703f584f65c962fb04fcae7bb6500a11b76a.tar.bz2 | |
allow custom functions as commands, add example in form of forced web search
Diffstat (limited to 'lib/completion.js')
| -rw-r--r-- | lib/completion.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/completion.js b/lib/completion.js index 2b29258f..6e8ea803 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -246,10 +246,17 @@ var completion = (function() { var term = query.slice(key.length, query.length); var command = commands[key]; var desc = command[0]; - var urlPattern = command[1]; + var pattern = command[1]; + var url; + + if (typeof pattern === 'function') + url = pattern(term); + else + url = pattern.replace(/%s/g, term); + suggestions.push({ render: createConstantFunction('<em>' + desc + '</em> ' + term), - action: createActionOpenUrl(utils.createFullUrl(urlPattern.replace(/%s/g, term))), + action: createActionOpenUrl(utils.createFullUrl(url)), }); } } |
