{
"translatorID": "5f22bd25-5b70-11e1-bb1d-c4f24aa18c1e",
"label": "Annual Reviews",
"creator": "Aurimas Vinckevicius",
"target": "^https?://[^/]*annualreviews\\.org(:[\\d]+)?(?=/)[^?]*(/(toc|journal|doi)/|showMost(Read|Cited)Articles|doSearch)",
"minVersion": "3.0",
"maxVersion": "",
"priority": 150,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2017-01-01 15:19:19"
}
/**
Copyright (c) 2012 Aurimas Vinckevicius
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
.
*/
//add using BibTex
function addByBibTex(doi, tags) {
var baseUrl = 'http://www.annualreviews.org';
var risRequest = baseUrl + '/action/downloadCitation';
var articleUrl = baseUrl + '/doi/abs/' + doi;
var pdfUrl = baseUrl + '/doi/pdf/' + doi;
var postData = 'include=abs&direct=on&submit=Download+chapter+metadata&downloadFileName=citation' +
'&format=bibtex' + //bibtex
'&doi=' + encodeURIComponent(doi);
Zotero.Utilities.HTTP.doPost(risRequest, postData, function(text) {
var translator = Zotero.loadTranslator('import');
translator.setTranslator('9cb70025-a888-4a29-a210-93ec52da40d4'); //bibtex
translator.setString(text);
translator.setHandler('itemDone', function(obj, item) {
//title is sometimes in all caps
if (item.title == item.title.toUpperCase())
item.title = ZU.capitalizeTitle(item.title, true);
if (item.abstractNote){
item.abstractNote = item.abstractNote.replace(/^...?Abstract/, "")
}
//add tags
if (tags) {
item.tags = tags;
}
//set PDF file
item.attachments = [{
url: pdfUrl,
title: 'Full Text PDF',
mimeType: 'application/pdf'
}];
item.complete();
});
translator.translate();
});
}
function detectWeb(doc, url) {
var title = doc.title.toLowerCase();
if ( url.match(/\/doi\/(abs|full|pdf)\//) ) {
return 'journalArticle';
} else if ( title.match('- table of contents -') ||
title.match('- most downloaded reviews') ||
title.match('- most cited reviews') ||
title.match('- forthcoming -') ||
title.match('search results') ||
url.match('/journal/') ) { //individual journal home page
return 'multiple';
}
}
function doWeb(doc, url) {
if ( detectWeb(doc, url) == 'multiple' ) {
var articles = Zotero.Utilities.xpath(doc, '//div[@class="articleBoxWrapper"]');
var selectList = new Object();
var doi, title, article;
for ( var i in articles ) {
article = articles[i];
doi = Zotero.Utilities.xpath(article, './div[@class="articleCheck"]/input');
title = Zotero.Utilities.xpathText(article, './div[@class="articleBoxMeta"]/h2/a');
if ( doi && doi[0].value && title) {
selectList[doi[0].value] = title;
}
}
Zotero.selectItems(selectList, function(selectedItems) {
if (selectedItems == null) return true;
for (var item in selectedItems) {
addByBibTex(item);
}
});
} else {
var match = url.match(/\/(?:abs|full|pdf)\/([^?]+)/);
if (match) {
//get keywords before we leave
var tags, keywords = ZU.xpath(doc,
'//form[@id="frmQuickSearch"]\
/div[@class="pageTitle" and contains(text(), "KEYWORD")]\
/following-sibling::div/span[@class="data"]');
if (keywords) {
tags = new Array();
for (var i=0, n=keywords.length; i