diff --git a/translators/Royal Historical Society.js b/translators/Royal Historical Society.js index 777d23c40c..ff2274580e 100644 --- a/translators/Royal Historical Society.js +++ b/translators/Royal Historical Society.js @@ -12,10 +12,10 @@ } function detectWeb(doc, url) { - if (doc.evaluate('//tr/td[3][@class="bib_data"]/a[@class="bibref"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { + if (doc.evaluate('//div[@class="bib_data"]/a[contains(@title, "view in more detail")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { return "multiple"; } else if (doc.evaluate('//a[text() = "View records in XML"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; + return "document"; } } @@ -23,7 +23,7 @@ function doWeb(doc, url) { var books = new Array(); if (detectWeb(doc, url) == "multiple") { var items = new Object(); - var xpath = '//a[@class="bibref"]'; + var xpath = '//div[@class="bib_data"]/a[contains(@title, "view in more detail")]'; var results = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); var result; while (result = results.iterateNext()) { @@ -41,12 +41,14 @@ function doWeb(doc, url) { text = text.replace(/<\?[^?]+\?>/, ""); var xml = new XML(text); xml = xml..recordList; - var itemtype = "book"; - if (xml..journal_title.length() != 0) itemtype = "journalArticle"; + if (xml..journal.length() != 0) itemtype = "journalArticle"; + if (xml..in.length() != 0) itemtype = "bookSection"; var item = new Zotero.Item(itemtype); - item.title = Zotero.Utilities.capitalizeTitle(xml..title.toString()); + item.title = Zotero.Utilities.cleanTags(xml..title.toString()); + item.date = xml..date.toString().match(/\d+/); + item.pages = xml..length.toString(); for (var i = 0; i < xml..author.length(); i++) { var name = xml..author[i].toString().match(/^[^,]+,[^,]+/)[0].split(/,\s+/); item.creators.push({lastName:name[0], firstName:name[1], creatorType:"author"}); @@ -54,20 +56,33 @@ function doWeb(doc, url) { if (item.itemType == "book") { item.place = xml..place_of_publication.toString(); item.publisher = xml..publisher.toString(); - item.date = xml..publication_year.toString(); + item.ISBN = xml..ISBN.toString(); } else if (item.itemType == "journalArticle") { - item.publicationTitle = xml..journal_title.toString(); - var voliss = xml..journal_number.split(":"); - Zotero.debug(voliss); - item.volume = voliss[0]; - item.issue = voliss[1]; - item.date = xml..journal_issue_year; - item.pages = xml..journal_pages; + item.publicationTitle = xml..journal.toString(); + item.volume = xml..journal_volume.toString(); + item.issue = xml..journal_issue.toString(); + item.series = xml..series.toString(); + item.ISSN = xml..ISSN.toString(); + } else if (item.itemType == "bookSection") { + if (xml..title_interpolation.toString()) { + item.bookTitle = xml..title_interpolation.toString(); + } else { + item.bookTitle = xml..in.toString().match(/\),\s(.+)\s\(/)[1]; + } + + item.ISBN = xml..ISBN.toString(); + try { // this regex is iffy + bookInfo = xml..in.toString().match(/\(([A-Za-z;\s]+:[A-Za-z\s']+),\s\d+\)/)[1]; + } catch (e) { + Zotero.debug("regex didn't work"); + } + item.place = bookInfo.split(": ")[0] + item.publisher = bookInfo.split(": ")[1] } item.complete(); - }); - Zotero.done(); + }, function(){Zotero.done();}); + } Zotero.wait(); } \ No newline at end of file