aboutsummaryrefslogtreecommitdiffstats
path: root/lookupDictionary.js
diff options
context:
space:
mode:
authorteramako2013-02-11 21:33:02 +0900
committerteramako2013-02-11 21:33:02 +0900
commit66351c964772c19f84116694c09a270b8e5a0b18 (patch)
tree33219821bed45e822dfb7542a30f25eb9d68ff3d /lookupDictionary.js
parentdc2b221ec3fe386527a23d8fa17dcd9a29edb1a8 (diff)
downloadvimperator-plugins-66351c964772c19f84116694c09a270b8e5a0b18.tar.bz2
Drop E4X
Diffstat (limited to 'lookupDictionary.js')
-rw-r--r--lookupDictionary.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/lookupDictionary.js b/lookupDictionary.js
index 6d6e7ff..3acfeca 100644
--- a/lookupDictionary.js
+++ b/lookupDictionary.js
@@ -164,15 +164,17 @@ SITE_DEFINITION.forEach(function (dictionary) {
url = dictionary.url.replace(/%s/g,encodeURIComponent(arg));
}
//liberator.log('URL: ' +url);
- var result;
- getHTML(url, function (str) {
- var doc = createHTMLDocument(str);
+ getHTML(url, function (doc) {
var result = getNodeFromXPath(dictionary.xpath, doc, dictionary.multi);
if (!result) {
liberator.echoerr('Nothing to show...');
+ return;
}
var xs = new XMLSerializer();
- liberator.echo(new XMLList('<div style="white-space:normal;"><base href="' + util.escapeHTML(url) + '"/>' + xs.serializeToString( result ).replace(/<[^>]+>/g,function (all) all.toLowerCase() ) + '</div>'), true);
+ liberator.echo(xml`<div style="white-space:normal;">
+ <base href=${util.escapeHTML(url)}/>
+ ${new TemplateXML(xs.serializeToString( result ))}
+ </div>`);
}, dictionary.srcEncode ? dictionary.srcEncode : null);
},
{
@@ -210,16 +212,17 @@ commands.addUserCommand(
*/
function getHTML(url, callback, charset) {
var xhr= new XMLHttpRequest();
+ xhr.open('GET',url,true);
+ xhr.responseType = "document";
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
- callback.call(this,xhr.responseText);
+ callback.call(this,xhr.response);
} else {
throw new Error(xhr.statusText);
}
}
};
- xhr.open('GET',url,true);
if (charset) xhr.overrideMimeType('text/html; charset=' + charset);
xhr.send(null);
}