{ "translatorID": "229d4678-4fa0-44f8-95c4-f4cfdb9b254c", "label": "National Archive of the UK", "creator": "Sebastian Karcher", "target": "^https?://discovery\\.nationalarchives\\.gov\\.uk/", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcb", "lastUpdated": "2017-10-21 10:10:42" } /** Copyright (c) 2013 Sebastian Karcher This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ function detectWeb(doc, url) { if (url.search(/details\/r\//i) != -1) return "manuscript"; else if (url.search(/results\/r\/?\?.+hb=tna/i) != -1) return "multiple"; } function scrape(doc, url) { var id = url.match(/details\/r\/([A-Z\-0-9]+)/i)[1]; var reference = ZU.xpathText(doc, '//tr/th[contains(text(), "Reference")]/following-sibling::td') var tags = ZU.xpath(doc, '//span/a[@class="tagName"]'); var apiUrl = "http://discovery.nationalarchives.gov.uk/API/records/v1/details/" + id; Zotero.Utilities.doGet(apiUrl, function (text) { var data = JSON.parse(text); //Z.debug(data); var item = new Zotero.Item("manuscript"); var title = data.title || ZU.xpathText(doc, '//h1'); item.title = title.replace(/<.+?>/g, "").replace(/<.+?>/g, ""); item.archiveLocation = reference; item.language = data.language; item.date = data.coveringDates; if (data.scopeContent && data.scopeContent.description) { item.abstractNote = data.scopeContent.description.replace(/

/g, "\n").replace(/<p>/g, "\n").replace(/<.+?>/g, ""); } var holdings = data.heldBy; if (holdings && holdings.length>0) { item.archive = holdings.map(entry => entry.xReferenceName).join() } item.type = data.physicalDescriptionForm; item.attachments.push({ url: url, title: "British National Archive - Link", snapshot: false }); var creators = data.creatorName; for (var i=0; i