diff options
author | janus_wel | 2008-09-27 03:48:36 +0000 |
---|---|---|
committer | janus_wel | 2008-09-27 03:48:36 +0000 |
commit | 9fcc205cb53d42fd978538cdd10c62fe77cb576b (patch) | |
tree | 5b0df92ff75f6b654c87924e3300491aa94a0aac /lookupDictionary.js | |
parent | eff615d400ea5888dbc67ebf7d781c9f4d95a480 (diff) | |
download | vimperator-plugins-9fcc205cb53d42fd978538cdd10c62fe77cb576b.tar.bz2 |
add dictionary property to SITE_DEFINITION.
remove the variable "g:lookupDictionary_dictionary".
switch over dictionary by site definition.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20024 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'lookupDictionary.js')
-rw-r--r-- | lookupDictionary.js | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lookupDictionary.js b/lookupDictionary.js index 8e69540..20cb00d 100644 --- a/lookupDictionary.js +++ b/lookupDictionary.js @@ -13,25 +13,28 @@ const SITE_DEFINITION = [{ names: ['eiji[ro]'], url: 'http://eow.alc.co.jp/%s/UTF-8/', shortHelp: 'SPACE ALC (英辞郎 on the Web)', - xpath: 'id("resultList")' + xpath: 'id("resultList")', + dictionary: 'en-US', },{ names: ['goo'], url: 'http://dictionary.goo.ne.jp/search.php?MT=%s&kind=all&mode=0', shortHelp: 'goo 辞書', encode: 'EUC-JP', xpath: '//div[@id="incontents"]/*[@class="ch04" or @class="fs14" or contains(@class,"diclst")]', - multi: true + multi: true, + dictionary: 'en-US', },{ names: ['infokanji'], url: 'http://dictionary.www.infoseek.co.jp/?sc=1&se=on&lp=0&gr=kj&sv=KJ&qt=&qty=%s&qtb=&qtk=0', shorthelp: 'Infoseek 漢字辞書', encode: 'EUC-JP', - xpath: '//div[@class="NetDicHead"]' + xpath: '//div[@class="NetDicHead"]', },{ names: ['answers'], url: 'http://www.answers.com/%s', shortHelp: 'Answers.com(英英辞書)', - xpath: 'id("firstDs")' + xpath: 'id("firstDs")', + dictionary: 'en-US', }]; // class definition @@ -77,7 +80,14 @@ SpellChecker.prototype = { * @param {String} dict */ setDictionary: function (dict) { - this.engine.dictionary = dict; + var dictionaries = this.getDictionaryList() + for (var i=0, max=dictionaries.length ; i<max ; ++i) { + if (dictionaries[i] === dict) { + this.engine.dictionary = dict; + return dict; + } + } + return null; }, /** @@ -147,7 +157,10 @@ SITE_DEFINITION.forEach(function(dictionary){ }, { completer: function (arg) { - if (!spellChecker.dictionary()) return [0, []]; + if (!spellChecker || + !dictionary.dictionary || + !spellChecker.setDictionary(dictionary.dictionary)) + return [0, []]; var suggestions = spellChecker.suggest(arg); var candidates = []; @@ -232,11 +245,6 @@ function buildSpellChecker() { if (!enable) return; var spellChecker = new SpellChecker(); - var dict = liberator.globalVariables.lookupDictionary_dictionary || 'en-US'; - var dictionaries = spellChecker.getDictionaryList() - for (var i=0, max=dictionaries.length ; i<max ; ++i) { - if (dictionaries[i] === dict) spellChecker.setDictionary(dict); - } var isBeginningWith = liberator.globalVariables.lookupDictionary_beginningWith isBeginningWith = (isBeginningWith === undefined) ? false : !!parseInt(isBeginningWith, 10); |