diff options
author | anekos | 2011-04-30 23:13:16 +0900 |
---|---|---|
committer | anekos | 2011-04-30 23:13:16 +0900 |
commit | 018875aa55263ab9ee3b39075e24136d3177c68e (patch) | |
tree | 94159243602c05a4fc2dfd319f8cf0f5c4ecd807 | |
parent | a11c0be0bfd73c0a78f2a1ae38c3a55fda883ce9 (diff) | |
download | vimperator-plugins-018875aa55263ab9ee3b39075e24136d3177c68e.tar.bz2 |
補完にテキストノードをごちゃごちゃいれてみた
-rw-r--r-- | google-translator.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/google-translator.js b/google-translator.js index edd3a64..63eb1f2 100644 --- a/google-translator.js +++ b/google-translator.js @@ -191,6 +191,20 @@ let INFO = (liberator.globalVariables.google_translator_actions || 'echo').split(' ') }; + function getTexts () + util.Array.uniq( + [it.textContent.trim().replace(/\n|\s+/g, ' ') for (it in Iterator(util.evaluateXPath('//text()')))], + true + ); + + function textCompleter (context, args) { + context.completions = [ + [it, ''] + for ([, it] in Iterator(getTexts())) + if (it.length > 3 && !/^\s*</(it)) + ]; + } + function guessRequest (text, done) { let url = 'http://ajax.googleapis.com/ajax/services/language/detect?v=1.0' + @@ -360,6 +374,7 @@ let INFO = [['-to', '-t'], commands.OPTION_STRING, null, languages], [['-guess', '-g'], commands.OPTION_NOARG] ], + completer: textCompleter }, true ); |