aboutsummaryrefslogtreecommitdiffstats
path: root/lookupDictionary.js
diff options
context:
space:
mode:
authorteramako2008-09-07 03:24:57 +0000
committerteramako2008-09-07 03:24:57 +0000
commitbdeada9ee45a8adf02fbf5c09ca4f0bba506957e (patch)
tree0104382ef86234e4ef0bdb2c7ed716ce888b6fd4 /lookupDictionary.js
parenta4d65d1f18f3ae5433178cbf4887a7b69fb38d02 (diff)
downloadvimperator-plugins-bdeada9ee45a8adf02fbf5c09ca4f0bba506957e.tar.bz2
- 文字化け対策にXMLHttpRequestのoverrideMimeTypeを用いてcharset付加
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@18935 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'lookupDictionary.js')
-rw-r--r--lookupDictionary.js21
1 files 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('<base href="' + url + '"/>' + 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);
}
/**