From 66351c964772c19f84116694c09a270b8e5a0b18 Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 11 Feb 2013 21:33:02 +0900 Subject: Drop E4X --- lookupDictionary.js | 15 +++++++++------ 1 file 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('
' + xs.serializeToString( result ).replace(/<[^>]+>/g,function (all) all.toLowerCase() ) + '
'), true); + liberator.echo(xml`
+ + ${new TemplateXML(xs.serializeToString( result ))} +
`); }, 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); } -- cgit v1.2.3