Changeset 20024

Show
Ignore:
Timestamp:
09/27/08 12:48:36 (5 years ago)
Author:
janus_wel
Message:

add dictionary property to SITE_DEFINITION.
remove the variable "g:lookupDictionary_dictionary".
switch over dictionary by site definition.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/lookupDictionary.js

    r19995 r20024  
    1414    url: 'http://eow.alc.co.jp/%s/UTF-8/', 
    1515    shortHelp: 'SPACE ALC (英辞郎 on the Web)', 
    16     xpath: 'id("resultList")' 
     16    xpath: 'id("resultList")', 
     17    dictionary: 'en-US', 
    1718},{ 
    1819    names: ['goo'], 
     
    2122    encode: 'EUC-JP', 
    2223    xpath: '//div[@id="incontents"]/*[@class="ch04" or @class="fs14" or contains(@class,"diclst")]', 
    23     multi: true 
     24    multi: true, 
     25    dictionary: 'en-US', 
    2426},{ 
    2527    names: ['infokanji'], 
     
    2729    shorthelp: 'Infoseek 漢字辞書', 
    2830    encode: 'EUC-JP', 
    29     xpath: '//div[@class="NetDicHead"]' 
     31    xpath: '//div[@class="NetDicHead"]', 
    3032},{ 
    3133    names: ['answers'], 
    3234    url: 'http://www.answers.com/%s', 
    3335    shortHelp: 'Answers.com(英英辞書)', 
    34     xpath: 'id("firstDs")' 
     36    xpath: 'id("firstDs")', 
     37    dictionary: 'en-US', 
    3538}]; 
    3639 
     
    7881     */ 
    7982    setDictionary: function (dict) { 
    80         this.engine.dictionary = dict; 
     83        var dictionaries = this.getDictionaryList() 
     84        for (var i=0, max=dictionaries.length ; i<max ; ++i) { 
     85            if (dictionaries[i] === dict) { 
     86                this.engine.dictionary = dict; 
     87                return dict; 
     88            } 
     89        } 
     90        return null; 
    8191    }, 
    8292 
     
    148158        { 
    149159            completer: function (arg) { 
    150                 if (!spellChecker.dictionary()) return [0, []]; 
     160                if (!spellChecker || 
     161                    !dictionary.dictionary || 
     162                    !spellChecker.setDictionary(dictionary.dictionary)) 
     163                return [0, []]; 
    151164 
    152165                var suggestions = spellChecker.suggest(arg); 
     
    233246 
    234247    var spellChecker = new SpellChecker(); 
    235     var dict = liberator.globalVariables.lookupDictionary_dictionary || 'en-US'; 
    236     var dictionaries = spellChecker.getDictionaryList() 
    237     for (var i=0, max=dictionaries.length ; i<max ; ++i) { 
    238         if (dictionaries[i] === dict) spellChecker.setDictionary(dict); 
    239     } 
    240248 
    241249    var isBeginningWith = liberator.globalVariables.lookupDictionary_beginningWith