From bdeada9ee45a8adf02fbf5c09ca4f0bba506957e Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 7 Sep 2008 03:24:57 +0000 Subject: - 文字化け対策にXMLHttpRequestのoverrideMimeTypeを用いてcharset付加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@18935 d0d07461-0603-4401-acd4-de1884942a52 --- lookupDictionary.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lookupDictionary.js b/lookupDictionary.js index f89bb44..e487b04 100644 --- a/lookupDictionary.js +++ b/lookupDictionary.js @@ -1,11 +1,11 @@ /** - * lookup dictionary (Vimperator plugin) - * For Vimperator 0.6pre + * ==VimperatorPlugin== + * @name lookup dictionary (Vimperator plugin) + * @description Lookup words from Web dictionaries, and show the results in the bottom of the window + * @description-ja Web上の辞書を引いた結果をコマンドライン・バッファへ出力します * @author teramako teramako@gmail.com - * @version 0.1 - * - * Lookup words from Web dictionaries - * And show the results in the bottom of the window + * @version 0.2 + * ==/VimperatorPlugin== */ (function(){ [{ @@ -25,7 +25,8 @@ dictionary.names, dictionary.shortHelp, function(arg,special){ - var sel = window.content.document.getSelection(); + var sel = (window.content.window.getSelection) ? + window.content.window.getSelection().toString() : null; if (special && sel) arg = sel; if (!arg) return; var url; @@ -46,15 +47,16 @@ } var xs = new XMLSerializer(); liberator.echo('' + xs.serializeToString( result ), true); - }); + }, dictionary.encode ? dictionary.encode : 'UTF-8'); },{} ); }); /** * @param {String} url * @param {Function} callback + * @param {String} charset */ -function getHTML(url, callback){ +function getHTML(url, callback, charset){ var xhr= new XMLHttpRequest(); xhr.onreadystatechange = function(){ if (xhr.readyState == 4){ @@ -66,6 +68,7 @@ function getHTML(url, callback){ } }; xhr.open('GET',url,true); + xhr.overrideMimeType('text/html; charset=' + charset); xhr.send(null); } /** -- cgit v1.2.3