Fixes #1478, tweaked xpath and added logic to catch empty selectItems arrays.
This commit is contained in:
parent
c938a06ae2
commit
c562d145ec
1 changed files with 11 additions and 3 deletions
|
@ -37,7 +37,7 @@ function doWeb(doc, url) {
|
||||||
var xpath;
|
var xpath;
|
||||||
if (url.indexOf("_ob=PublicationURL") != -1) {
|
if (url.indexOf("_ob=PublicationURL") != -1) {
|
||||||
// not sure if this case still arises. may need to be fixed at some point
|
// not sure if this case still arises. may need to be fixed at some point
|
||||||
xpath = '//table[@class="txt"]/tbody/tr/td[2]';
|
xpath = '//table[@class="resultRow"]/tbody/tr/td[2]/a';
|
||||||
} else {
|
} else {
|
||||||
xpath = '//div[@class="font3"][@id="bodyMainResults"]/table/tbody/tr/td[2]/a';
|
xpath = '//div[@class="font3"][@id="bodyMainResults"]/table/tbody/tr/td[2]/a';
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,10 @@ function doWeb(doc, url) {
|
||||||
} else {
|
} else {
|
||||||
articles = [url];
|
articles = [url];
|
||||||
}
|
}
|
||||||
|
if(articles.length == 0) {
|
||||||
|
Zotero.debug('no items');
|
||||||
|
return;
|
||||||
|
}
|
||||||
Zotero.Utilities.processDocuments(articles, function(newDoc) {
|
Zotero.Utilities.processDocuments(articles, function(newDoc) {
|
||||||
var doi = newDoc.evaluate('//div[@class="articleHeaderInner"][@id="articleHeader"]/a[contains(text(), "doi")]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(4);
|
var doi = newDoc.evaluate('//div[@class="articleHeaderInner"][@id="articleHeader"]/a[contains(text(), "doi")]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(4);
|
||||||
|
|
||||||
|
@ -123,7 +127,7 @@ function doWeb(doc, url) {
|
||||||
if (detectWeb(doc, url) == "multiple") {
|
if (detectWeb(doc, url) == "multiple") {
|
||||||
var items = new Object();
|
var items = new Object();
|
||||||
if (url.indexOf("_ob=PublicationURL") != -1) {
|
if (url.indexOf("_ob=PublicationURL") != -1) {
|
||||||
xpath = '//table[@class="txt"]/tbody/tr[1]/td[2]';
|
xpath = '//table[@class="resultRow"]/tbody/tr/td[2]/a';
|
||||||
// not sure whether this case still exists
|
// not sure whether this case still exists
|
||||||
} else {
|
} else {
|
||||||
xpath = '//div[@class="font3"][@id="bodyMainResults"]/table/tbody/tr/td[2]/a';
|
xpath = '//div[@class="font3"][@id="bodyMainResults"]/table/tbody/tr/td[2]/a';
|
||||||
|
@ -133,7 +137,7 @@ function doWeb(doc, url) {
|
||||||
while (next_row = rows.iterateNext()) {
|
while (next_row = rows.iterateNext()) {
|
||||||
var title = next_row.textContent;
|
var title = next_row.textContent;
|
||||||
var link = next_row.href;
|
var link = next_row.href;
|
||||||
items[link] = title;
|
if (!title.match(/PDF \(/) && !title.match(/Related Articles/)) items[link] = title;
|
||||||
}
|
}
|
||||||
items = Zotero.selectItems(items);
|
items = Zotero.selectItems(items);
|
||||||
for (var i in items) {
|
for (var i in items) {
|
||||||
|
@ -142,6 +146,10 @@ function doWeb(doc, url) {
|
||||||
} else {
|
} else {
|
||||||
articles = [url];
|
articles = [url];
|
||||||
}
|
}
|
||||||
|
if(articles.length == 0) {
|
||||||
|
Zotero.debug('no items');
|
||||||
|
return;
|
||||||
|
}
|
||||||
Zotero.Utilities.processDocuments(articles, function(doc2) {
|
Zotero.Utilities.processDocuments(articles, function(doc2) {
|
||||||
var item = new Zotero.Item("journalArticle");
|
var item = new Zotero.Item("journalArticle");
|
||||||
item.repository = "ScienceDirect";
|
item.repository = "ScienceDirect";
|
||||||
|
|
Loading…
Reference in a new issue