{
"translatorID": "2a5dc3ed-ee5e-4bfb-baad-36ae007e40ce",
"label": "DeGruyter",
"creator": "Sebastian Karcher",
"target": "^https?://www\\.degruyter\\.com",
"minVersion": "2.1.9",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsib",
"lastUpdated": "2014-04-21 10:39:45"
}
/*
DeGruyter (Replacing BE Press - based on BioMed Central Translator)
Copyright (C) 2012 Sebastian Karcher and Avram Lyon, ajlyon@gmail.com
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( doc.body.classList.contains('journalArticle') || doc.body.classList.contains('page-viewdatabaseentry') ) {
return "journalArticle";
}
if( doc.body.classList.contains('page-viewbook') || doc.body.classList.contains('page-viewbooktoc')) {
return "book";
}
if(doc.body.classList.contains('page-viewbookchapter')) {
return "bookSection";
}
if( (doc.body.classList.contains('page-search') || doc.body.classList.contains('page-searchwithinbase') || doc.body.classList.contains('page-databasecontent') || doc.body.classList.contains('page-viewjournalissue')) && getSearchResults(doc, url)) {
return "multiple";
}
//page-viewjournal --> full/whole journal (type in Zotero is planned)
return false;
}
function getSearchResults(doc, url) {
var items = {}, found = false, title;
var results = doc.getElementsByClassName('contentItem');
var searchEnvironment = doc.body.classList.contains('page-search') || doc.body.classList.contains('page-searchwithinbase') || doc.body.classList.contains('page-databasecontent');
for(var i=0; i/.exec(text)[1];
var formdata = //.exec(text)[1];
var poststring = "t:ac="+encodeURIComponent(ac)+"&t:formdata="+encodeURIComponent(formdata)+"&submit=Export";
//at the moment the page (end)numbers are only in MLA correct
//e.g. Journal of Ancient History, 1.2 (2013): 170-229. Retrieved 18 Apr. 2014
var pageRange = /\):\s+(\d+)-(\d+)\.\s+Retrieved /.exec(text);
ZU.doPost("/dg/cite.form", poststring, function(risData) {
if (risData.indexOf("<") == 0) {
Z.debug("No RIS");
scrapeMetadata(doc);
} else {
if (detectWeb(doc, url) == "bookSection") {
risData = risData.replace("TY - GENERIC", "TY - CHAP");
}
var trans = Zotero.loadTranslator('import');
trans.setTranslator('32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7');//https://github.com/zotero/translators/blob/master/RIS.js
trans.setString(risData);
trans.setHandler('itemDone', function (obj, item) {
//for debugging
//item.notes.push({note:risData});
//add endpage if missing
if (item.pages && item.pages.indexOf("-") == -1 && pageRange) {
if (pageRange[1] == item.pages) {
item.pages += "–"+pageRange[2];
}
}
//correct authors from RIS data
//they are of the form lastname firstname withouth a comma
//e.g., AU - Meggitt Justin J.
for(var i=0; i