Trans: Fix EEBO, closes ticket #1518.

This commit is contained in:
Avram Lyon 2011-07-03 19:35:09 +00:00
parent cf2f8c828b
commit b876e8bf27

View File

@ -3,12 +3,12 @@
"translatorType":4, "translatorType":4,
"label":"Early English Books Online", "label":"Early English Books Online",
"creator":"Michael Berkowitz", "creator":"Michael Berkowitz",
"target":"http://[^/]*eebo.chadwyck.com[^/]*/search", "target":"^http://[^/]*eebo.chadwyck.com[^/]*/search",
"minVersion":"1.0.0b4.r5", "minVersion":"2.1",
"maxVersion":"", "maxVersion":"",
"priority":100, "priority":100,
"inRepository":true, "inRepository":true,
"lastUpdated":"2008-02-11 19:30:00" "lastUpdated":"2011-06-14 19:30:00"
} }
function detectWeb(doc, url) { function detectWeb(doc, url) {
@ -25,19 +25,18 @@ function doWeb(doc, url) {
var hostRegexp = new RegExp("^(https?://[^/]+)/"); var hostRegexp = new RegExp("^(https?://[^/]+)/");
var hMatch = hostRegexp.exec(url); var hMatch = hostRegexp.exec(url);
var host = hMatch[1]; var host = hMatch[1];
var IDRegex = /&ID=([^&]+)/
if (doc.title == "Search Results - EEBO") { if (doc.title == "Search Results - EEBO") {
var items = new Object(); var items = new Object();
Zotero.debug("search page"); var IDxpath = '//td/input[@name="EeboId"]/@value';
var IDxpath = '//td[3]/script'; var Titlexpath = '//table[tbody/tr/td/input[@name="EeboId"]]/following-sibling::table[1]//i[1]';
var Titlexpath = '//td[3]/i';
var new_ids = doc.evaluate(IDxpath, doc, null, XPathResult.ANY_TYPE, null); var new_ids = doc.evaluate(IDxpath, doc, null, XPathResult.ANY_TYPE, null);
var new_titles = doc.evaluate(Titlexpath, doc, null, XPathResult.ANY_TYPE, null); var new_titles = doc.evaluate(Titlexpath, doc, null, XPathResult.ANY_TYPE, null);
var next_id = new_ids.iterateNext(); var next_id = new_ids.iterateNext();
var next_title = new_titles.iterateNext(); var next_title = new_titles.iterateNext();
var IDRegex = /'(\d+)'/;
while (next_id) { while (next_id) {
items[next_id.textContent.match(IDRegex)[1]] = next_title.textContent; items[next_id.textContent.trim()] = next_title.textContent.trim();
next_id = new_ids.iterateNext(); next_id = new_ids.iterateNext();
next_title = new_titles.iterateNext(); next_title = new_titles.iterateNext();
} }
@ -46,7 +45,6 @@ function doWeb(doc, url) {
eeboIDs.push(i); eeboIDs.push(i);
} }
} else { } else {
var IDRegex = /&ID=(\w+)&/
var eeboid = url.match(IDRegex)[1]; var eeboid = url.match(IDRegex)[1];
if (eeboid[0] == "D") { if (eeboid[0] == "D") {
eeboid = eeboid.slice(7, 14); eeboid = eeboid.slice(7, 14);
@ -63,11 +61,15 @@ function doWeb(doc, url) {
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text.substring(17)); translator.setString(text.substring(17));
translator.setHandler("itemDone", function(obj, item) { translator.setHandler("itemDone", function(obj, item) {
item.url = host+'/search/full_rec?SOURCE=pgimages.cfg&ACTION=ByID&ID=' + new_eeboid + '&FILE=../session/1190302085_15129&SEARCHSCREEN=CITATIONS&SEARCHCONFIG=config.cfg&DISPLAY=ALPHA'; item.attachments.push(
{url : host+'/search/full_rec?SOURCE=pgimages.cfg&ACTION=ByID&ID=' + new_eeboid + '&FILE=../session/1190302085_15129&SEARCHSCREEN=CITATIONS&SEARCHCONFIG=config.cfg&DISPLAY=ALPHA',
title : "EEBO Record",
snapshot : false });
item.complete(); item.complete();
}); });
translator.translate(); translator.translate();
Zotero.done(); Zotero.done();
}); });
} }
Zotero.wait();
} }