From 26cd14344809b4b3f4373903f96b1c4da5e06461 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 15 Nov 2008 09:54:27 +0000 Subject: see http://fifnel.com/2008/11/14/1980/ git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@23788 d0d07461-0603-4401-acd4-de1884942a52 --- lookupDictionary.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lookupDictionary.js b/lookupDictionary.js index 050f353..9120797 100644 --- a/lookupDictionary.js +++ b/lookupDictionary.js @@ -12,32 +12,34 @@ const SITE_DEFINITION = [{ names: ['eiji[ro]'], url: 'http://eow.alc.co.jp/%s/UTF-8/', - shortHelp: 'SPACE ALC (英辞郎 on the Web)', + shortHelp: 'SPACE ALC (\u82F1\u8F9E\u6717 on the Web)', xpath: 'id("resultList")', dictionary: 'en-US' },{ names: ['goo[dictionary]'], url: 'http://dictionary.goo.ne.jp/search.php?MT=%s&kind=all&mode=0&IE=UTF-8', - shortHelp: 'goo 辞書', + shortHelp: 'goo \u8F9E\u66F8', xpath: 'id("incontents")/*[@class="ch04" or @class="fs14" or contains(@class,"diclst")]', multi: true, - dictionary: 'en-US' + dictionary: 'en-US', + srcEncode: 'EUC-jp', + urlEncode: 'UTF-8' },{ names: ['answers'], url: 'http://www.answers.com/%s', - shortHelp: 'Answers.com(英英辞書)', + shortHelp: 'Answers.com(\u82F1\u82F1\u8F9E\u66F8)', xpath: 'id("firstDs")', dictionary: 'en-US' },{ names: ['wikipe[diaja]'], url: 'http://ja.wikipedia.org/wiki/%s', - shortHelp: 'ウィキペディア lite', + shortHelp: 'Wikipedia lite(ja)', xpath: 'id("bodyContent")/p[1]', dictionary: 'ja' },{ names: ['wikipe[diaen]'], url: 'http://en.wikipedia.org/wiki/%s', - shortHelp: 'Wikipedia lite', + shortHelp: 'Wikipedia lite(en)', xpath: 'id("bodyContent")/p[1]', dictionary: 'en' }]; @@ -154,10 +156,11 @@ SITE_DEFINITION.forEach(function (dictionary) { if (special && sel) arg = sel; if (!arg) return; var url; - if (dictionary.encode) { + if (dictionary.urlEncode) { let ttbu = Components.classes['@mozilla.org/intl/texttosuburi;1'] .getService( Components.interfaces.nsITextToSubURI); - url = dictionary.url.replace(/%s/g, ttbu.ConvertAndEscape(dictionary.encode, arg)); + url = dictionary.url.replace(/%s/g, ttbu.ConvertAndEscape(dictionary.urlEncode, arg)); + url = dictionary.url.replace(/%s/g,encodeURIComponent(arg)); } else { url = dictionary.url.replace(/%s/g,encodeURIComponent(arg)); } @@ -171,7 +174,7 @@ SITE_DEFINITION.forEach(function (dictionary) { } var xs = new XMLSerializer(); liberator.echo(new XMLList('