2008-09-11 04:40:07 +00:00
|
|
|
{
|
|
|
|
"translatorID":"a77690cf-c5d1-8fc4-110f-d1fc765dcf88",
|
|
|
|
"translatorType":4,
|
|
|
|
"label":"ProQuest",
|
|
|
|
"creator":"Simon Kornblith",
|
|
|
|
"target":"^https?://[^/]+/pqdweb\\?((?:.*\\&)?did=.*&Fmt=[0-9]|(?:.*\\&)Fmt=[0-9].*&did=|(?:.*\\&)searchInterface=|(?:.*\\&)TS=[0-9])",
|
|
|
|
"minVersion":"1.0.0b3.r1",
|
|
|
|
"maxVersion":"",
|
|
|
|
"priority":100,
|
|
|
|
"inRepository":true,
|
2009-07-24 07:56:58 +00:00
|
|
|
"lastUpdated":"2009-07-24 07:55:00"
|
2008-09-11 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function detectWeb(doc, url) {
|
|
|
|
var namespace = doc.documentElement.namespaceURI;
|
|
|
|
var nsResolver = namespace ? function(prefix) {
|
|
|
|
if (prefix == 'x') return namespace; else return null;
|
|
|
|
} : null;
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
if(doc.evaluate('//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]',
|
|
|
|
doc, nsResolver, XPathResult.ANY_TYPE, null)) {
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
|
|
|
|
var xpath = '//table[@id="tableIndexTerms"]/tbody/tr/td[@class="textSmall"]';
|
|
|
|
var data= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
|
|
|
var aitem;
|
|
|
|
var source;
|
|
|
|
while(aitem = data.iterateNext()) {
|
|
|
|
source=aitem.textContent;
|
|
|
|
if(source=="Source type:") {
|
|
|
|
source=data.iterateNext().textContent;
|
|
|
|
Zotero.debug("Item Source Type: "+source);
|
|
|
|
break;
|
|
|
|
}
|
2009-07-24 07:56:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(doc.title.match("Results")) {
|
2008-09-11 04:40:07 +00:00
|
|
|
return "multiple";
|
2009-07-24 07:56:58 +00:00
|
|
|
} else if(doc.title.match("Document View")) {
|
2008-09-11 04:40:07 +00:00
|
|
|
switch (source) {
|
|
|
|
case 'Dissertation':
|
|
|
|
return "thesis";
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
case 'Historical Newspaper':
|
|
|
|
case 'Newspaper':
|
|
|
|
return "newspaperArticle";
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
default:
|
|
|
|
return "journalArticle";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//^https?://[^/]+/pqdweb\?((?:.*\&)?did=.*&Fmt=[0-9]|(?:.*\&)Fmt=[0-9].*&did=|(?:.*\&)searchInterface=)
|
|
|
|
|
|
|
|
function parseRIS(uris) {
|
|
|
|
Zotero.Utilities.HTTP.doGet(uris, function(text, xmlhttp, url){
|
|
|
|
// load translator for RIS
|
|
|
|
if(url.match("exportFormat=1")=="exportFormat=1") {
|
|
|
|
var translator = Zotero.loadTranslator("import");
|
|
|
|
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
2009-07-24 07:56:58 +00:00
|
|
|
|
|
|
|
// Put AB note in abstract field
|
|
|
|
text = text.replace(/^AB \-/gm, 'N2 -');
|
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
// Strip lines with just whitespace, which mess up RIS parsing
|
|
|
|
text = text.replace(/^\s*$\n/gm, '');
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
translator.setString(text);
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
//Set Handler fixes anomaly in Proquest RIS format. Properly formats author name as [last name], [first name]
|
|
|
|
translator.setHandler("itemDone", function(obj, item) {
|
|
|
|
var cre = new Array();
|
|
|
|
cre = item.creators;
|
2009-03-25 16:44:12 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
for each(var e in cre) {
|
2009-03-25 16:44:12 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
if(!e['firstName']) {
|
2009-03-25 16:44:12 +00:00
|
|
|
// Rather than parse, change creator to a single field.
|
|
|
|
e.fieldMode = 1;
|
2008-09-11 04:40:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-25 16:44:12 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
if (item.publicationTitle) item.publicationTitle = Zotero.Utilities.trimInternal(item.publicationTitle.replace(/\([\d\-]+\)/g, ""));
|
2009-07-24 07:56:58 +00:00
|
|
|
|
|
|
|
// Don't save database page as URL
|
|
|
|
item.url = undefined;
|
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
item.complete();
|
|
|
|
});
|
2009-07-24 07:56:58 +00:00
|
|
|
|
2008-09-11 04:40:07 +00:00
|
|
|
translator.translate();
|
|
|
|
Zotero.done();
|
|
|
|
}
|
|
|
|
|
|
|
|
}, function() {});
|
|
|
|
Zotero.wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
function doWeb(doc, url) {
|
|
|
|
var namespace = doc.documentElement.namespaceURI;
|
|
|
|
var nsResolver = namespace ? function(prefix) {
|
|
|
|
if (prefix == 'x') return namespace; else return null;
|
|
|
|
} : null;
|
|
|
|
|
|
|
|
var hostRegexp = new RegExp("^(https?://[^/]+)/");
|
|
|
|
var hMatch = hostRegexp.exec(url);
|
|
|
|
var host = hMatch[1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(doc.evaluate('//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]',
|
|
|
|
doc, nsResolver, XPathResult.ANY_TYPE, null)) {
|
2009-07-24 07:56:58 +00:00
|
|
|
if(doc.title.match("Results")) {
|
2008-09-11 04:40:07 +00:00
|
|
|
|
|
|
|
//Get Client ID
|
|
|
|
var xpath = '//a';
|
|
|
|
var data= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
|
|
|
var aitem;
|
|
|
|
var clientID;
|
|
|
|
while(aitem = data.iterateNext()) {
|
|
|
|
clientID=aitem.href;
|
|
|
|
if(clientID.indexOf("clientId")!=-1) {
|
|
|
|
clientID = clientID.substr(clientID.indexOf("clientId")+9,clientID.length);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var multXpath = '//input[@name="chk"][@type="checkbox"]';
|
|
|
|
var titleXpath = '//a[@class="bold"]';
|
|
|
|
var mInfos = doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
|
|
|
var titleElmts = doc.evaluate(titleXpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
|
|
|
var titleElmt;
|
|
|
|
var mInfo;
|
|
|
|
mInfo = mInfos.iterateNext();
|
|
|
|
titleElmt = titleElmts.iterateNext();
|
|
|
|
|
|
|
|
var items = new Array();
|
|
|
|
|
|
|
|
do {
|
|
|
|
//Get item ID
|
|
|
|
|
|
|
|
var str= mInfo.value;
|
|
|
|
str= str.replace("retrieveGroup", "sid");
|
|
|
|
var url = host+"/pqdweb?RQT=530&markedListInfo="+str+"1";
|
|
|
|
items[url] = Zotero.Utilities.trimInternal(titleElmt.textContent);
|
|
|
|
|
|
|
|
} while((mInfo = mInfos.iterateNext()) && (titleElmt = titleElmts.iterateNext()));
|
|
|
|
|
|
|
|
items = Zotero.selectItems(items);
|
|
|
|
if(!items) return true;
|
|
|
|
|
|
|
|
|
|
|
|
//Array of URLs for the doGet
|
|
|
|
var uris = new Array();
|
|
|
|
|
|
|
|
//Clear Basket
|
|
|
|
uris.push(host+"/pqdweb?RQT=531&clientId="+clientID);
|
|
|
|
uris.push(host+"/pqdweb?RQT=532&clientId="+clientID);
|
|
|
|
|
|
|
|
//Add URLS to the basket
|
|
|
|
for(var bibcode in items) {
|
|
|
|
uris.push(bibcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Export basket as a RIS file
|
|
|
|
uris.push(host+"/pqdweb?RQT=532&clientId="+clientID);
|
|
|
|
uris.push(host+"/pqdweb?RQT=562&MRR=M&clientId="+clientID);
|
|
|
|
uris.push(host+"/pqdweb?RQT=562&exportFormat=1&clientId="+clientID);
|
|
|
|
|
|
|
|
parseRIS(uris);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//Get Client ID
|
|
|
|
var xpath = '//a';
|
|
|
|
var data= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
|
|
|
var aitem;
|
|
|
|
var clientID;
|
|
|
|
while(aitem = data.iterateNext()) {
|
|
|
|
clientID=aitem.href;
|
|
|
|
if(clientID.indexOf("clientId")!=-1) {
|
|
|
|
clientID = clientID.substr(clientID.indexOf("clientId")+9,clientID.length);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get item ID
|
|
|
|
var xpath = '//input[@name="marked"][@type="checkbox"]';
|
|
|
|
var str= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value;
|
|
|
|
str= str.replace("retrieveGroup", "sid");
|
|
|
|
|
|
|
|
//Array of URLs for the doGet
|
|
|
|
var uris = new Array();
|
|
|
|
|
|
|
|
//Clear Basket
|
|
|
|
uris.push(host+"/pqdweb?RQT=531&clientId="+clientID);
|
|
|
|
uris.push(host+"/pqdweb?RQT=532&clientId="+clientID);
|
|
|
|
|
|
|
|
//Create URL to add item to basket
|
|
|
|
url = host+"/pqdweb?RQT=530&markedListInfo="+str+"1";
|
|
|
|
Zotero.debug("RIS URL: "+url);
|
|
|
|
|
|
|
|
uris.push(url);
|
|
|
|
|
|
|
|
//Export basket as a RIS file
|
|
|
|
uris.push(host+"/pqdweb?RQT=532&clientId="+clientID);
|
|
|
|
uris.push(host+"/pqdweb?RQT=562&MRR=M&clientId="+clientID);
|
|
|
|
uris.push(host+"/pqdweb?RQT=562&exportFormat=1&clientId="+clientID);
|
|
|
|
|
|
|
|
parseRIS(uris);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|