{ "translatorID": "fce388a6-a847-4777-87fb-6595e710b7e7", "label": "ProQuest", "creator": "Avram Lyon", "target": "^https?://search\\.proquest\\.com.*\\/(docview|pagepdf|results|publicationissue|browseterms|browsetitles|browseresults|myresearch\\/(figtables|documents))", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", "lastUpdated": "2014-10-23 16:56:41" } /* ProQuest Translator Copyright (C) 2011 Avram Lyon, ajlyon@gmail.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ var language="English"; var L={}; var followLink; //returns an array of values for a given field or array of fields //the values are in the same order as the field names function getTextValue(doc, fields) { if(typeof(fields) != 'object') fields = [fields]; //localize fields fields = fields.map( function(field) { if(fieldNames[language]) { return fieldNames[language][field] || field; } else { return field; } }); var allValues = [], values; for(var i=0, n=fields.length; i 0 ? true : false); } var items = new Array(); for(var i=0, n=results.length; i 0 ? items : false); } function detectWeb(doc, url) { initLang(doc, url); followLink = false; //Check for multiple first if (url.indexOf('docview') == -1 && url.indexOf('pagepdf') == -1) { if (getSearchResults(doc, true)) return "multiple"; } var types = getTextValue(doc, ["Source type", "Document type", "Record type"]); var zoteroType = getItemType(types); if(zoteroType) return zoteroType; //hack for NYTs, which misses crucial data. var db = getTextValue(doc, "Database")[0]; if (db && db.indexOf("The New York Times") !== -1) { return "newspaperArticle"; } // Fall back on journalArticle-- even if we couldn't guess the type if(types.length) return "journalArticle"; if (url.indexOf("/results/") === -1) { //we might be on a page with a link to the abstract/metadata //e.g. pdf view var abstract_link = ZU.xpath(doc, '//a[@class="formats_base_sprite format_abstract"]'); if (abstract_link.length == 1) { //let the tranlator know that, instead of scraping this page, //we need to follow the link followLink = true; return (url.indexOf('/dissertations/') != -1)? "thesis" : "journalArticle"; } } return false; } //we can pass pdfUrl to doWeb if we're coming to abstract/metadata page //from full text pdf view function doWeb(doc, url, pdfUrl) { var type = detectWeb(doc, url); if (type != "multiple" && !followLink) { //see detectWeb scrape(doc, url, type, pdfUrl); } else if(type == "multiple") { // detect web returned multiple Zotero.selectItems(getSearchResults(doc, false), function (items) { if (!items) return true; var articles = new Array(); for(var item in items) { articles.push(item); } if (articles[0].indexOf("ebraryresults") > -1) { // if the first result is for ebrary, the rest are also ebrary ZU.processDocuments(articles, function(doc) { var translator = Zotero.loadTranslator("web"); translator.setTranslator("2abe2519-2f0a-48c0-ad3a-b87b9c059459"); translator.setDocument(doc); translator.setHandler("itemDone", function(obj, item) { item.complete(); }); translator.translate(); }); } else { ZU.processDocuments(articles, doWeb); } }); //pdfUrl should be undefined unless we are calling doWeb from the following //block, where it is set to false or an actual value } else if(followLink && pdfUrl === undefined) { pdfUrl = false; var link = ZU.xpathText(doc, '//a[@class="formats_base_sprite format_abstract"]/@href'); if(!link) return; //see if we can get the full text PDF link before we go //the logic here is actually slightly different from fetchEmbeddedPdf if(url.indexOf('fulltextPDF') != -1) { pdfUrl = ZU.xpath(doc, '//embed'); if(pdfUrl.length) { pdfUrl = pdfUrl[0].src; } else { pdfUrl = false; } } ZU.processDocuments(link, function(doc) { doWeb(doc, doc.location.href, pdfUrl) }); } } function scrape(doc, url, type, pdfUrl) { var item = new Zotero.Item(type); //get all rows var rows = ZU.xpath(doc, '//div[@class="display_record_indexing_row"]'); var label, value, enLabel; var dates = [], place = {}, altKeywords = []; for(var i=0, n=rows.length; i item.date.length))) { item.date = date; } item.abstractNote = ZU.xpath(doc, '//div[@id="abstractZone" or contains(@id,"abstractFull")]/p') .map(function(p) { return ZU.trimInternal(p.textContent) }).join('\n'); if(!item.tags.length && altKeywords.length) { item.tags = altKeywords.join(',').split(/\s*(?:,|;)\s*/); } item.attachments.push({ title: 'Snapshot', document: doc }); //we may already have a link to the full length PDF if(pdfUrl) { item.attachments.push({ title: 'Full Text PDF', url: pdfUrl, mimeType: 'application/pdf' }); } else { var pdfLink = ZU.xpath(doc, '(//div[@id="side_panel"]//\ a[contains(@class,"format_pdf") and contains(@href,"fulltext") or contains(@href, "preview")])[last()]'); if(pdfLink.length) { fetchEmbeddedPdf(pdfLink[0].href, item, function() { item.complete(); }); } } if(pdfUrl || !pdfLink.length) { item.complete(); } } function getItemType(types) { var guessType, govdoc, govdocType; for(var i=0, n=types.length; i