{ "translatorID": "86c35e86-3f97-4e80-9356-8209c97737c2", "label": "MIDAS Journals", "creator": "Rupert Brooks", "target": "^https?://(www\\.)?(insight-journal|midasjournal|vtkjournal)\\.org/", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", "lastUpdated": "2018-04-16 11:27:22" } /* Midas Journal Translator (Includes ITKJournal,InsightJournal,VTKJournal) Copyright (C) 2016-18 Rupert Brooks 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 . */ // attr()/text() v2 function attr(docOrElem,selector,attr,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.getAttribute(attr):null;}function text(docOrElem,selector,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.textContent:null;} function detectWeb(doc, url) { if (url.includes("browse/publication")) return "journalArticle"; if (url.includes("search/?search=") || url.includes("/?journal=") || url.includes("/browse/journal/")) { if (getSearchResults(doc, true)) return "multiple"; } } function scrape(doc, url) { var newItem = new Zotero.Item("journalArticle"); newItem.title = text(doc, '#publication>div.title'); newItem.url = text(doc, '#publication>table>tbody>tr>td>a'); newItem.publicationTitle = text(doc, '#publication>div.journal>a', 0); newItem.seriesTitle = text(doc, '#publication>div.journal>a', 1); newItem.abstractNote = text(doc, '#publication>div.abstract'); if (newItem.abstractNote) newItem.abstractNote = ZU.trimInternal(newItem.abstractNote); var issnString = ZU.xpathText(doc, '//div[contains(@class,"issn")]'); var issnMatch = new RegExp('ISSN\\s+(\\w+-\\w+)'); var issnParse = issnMatch.exec(issnString); // The midas journal has no ISSN tag, for some reason if (issnParse) { newItem.ISSN = issnParse[1]; } var submittedString = text(doc, '#publication>div.submittedby'); //e.g. Submitted by Karthik Krishnan on 06-26-2013. var datematch = new RegExp("on +([0-9]+)\\-([0-9]+)\\-([0-9]+)"); var dateparse = datematch.exec(submittedString); newItem.date = dateparse[3]+"-"+dateparse[1]+"-"+ dateparse[2]; var splitDownloadPath = ZU.xpathText(doc, '//a[contains(text(),"Download All")]/@href').split('/'); var version = splitDownloadPath[splitDownloadPath.length-1]; newItem.extra="Revision: " + version; // Article ID newItem.pages = splitDownloadPath[splitDownloadPath.length-2]; var pdfhref = ZU.xpathText(doc, '//a[contains(text(),"Download Paper")]/@href'); if (pdfhref) { var tmp = url.split('/'); pdflink = tmp[0]+'//' + tmp[2] + pdfhref; newItem.attachments.push({ title: "Fulltext", url: pdflink, mimeType: "application/pdf" }); } newItem.attachments.push({ title: "Snapshot", document: doc, mimeType:"text/html" }); // Only in XML there are also the first name of the authors. var postData = "data[Export][select]=xml&data[Export][submit]=Export"; ZU.doPost(url, postData, function(text) { //Z.debug(text); parser = new DOMParser(); xml = parser.parseFromString(text, "application/xml"); var authors = ZU.xpath(xml, '//Author'); for (let author of authors) { let lastName = ZU.xpathText(author, './LastName'); let firstName = ZU.xpathText(author, './FirstName'); newItem.creators.push({ lastName: lastName, firstName: firstName, creatorType: "author" }); } var tags = ZU.xpath(xml, '//Keyword'); for (let tag of tags) { newItem.tags.push(tag.textContent); } newItem.language = ZU.xpathText(xml, '//Language'); newItem.complete(); }); } function getSearchResults(doc, checkOnly) { var items = {}; var found = false; var rows = doc.querySelectorAll('.publication_title>a, td>a'); for (var i=0; i