{ "translatorID": "d21dcd90-c997-4e14-8fe0-353b8e19a47a", "label": "SAGE Knowledge", "creator": "ProQuest, Philipp Zumstein", "target": "^https?://sk\\.sagepub\\.com/", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", "lastUpdated": "2017-06-25 19:38:38" } /* SAGE Knowledge Translator Copyright (C) 2014 ProQuest LLC, Philipp Zumstein 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 . */ function detectWeb(doc, url) { if (url.indexOf('/Search')>-1) { //automatic test for multiples are not working (easily), but you //can test manually, e..g // http://sk.sagepub.com/Search/Results?IncludeParts=true&IncludeSegments=true&DocumentTypes=&BioId=&Products=&Subjects=&Disciplines=&Sort=relevance&Keywords%5B0%5D.Text=leader&Keywords%5B0%5D.Field=FullText // http://sk.sagepub.com/Search/Results?SearchId=0&IncludeEntireWorks=true&IncludeParts=true&IncludeSegments=true&AvailableToMeOnly=false&SearchWithin=&BioId=&CaseProvider=&Keywords%5B0%5D.Text=zotero&Keywords%5B0%5D.Field=FullText&Contributor=&ContributorTypes=All+People&ContributorTypes=Author%2FEditor&ContributorTypes=Academic&ContributorTypes=Counselor&ContributorTypes=Director&ContributorTypes=Interviewee&ContributorTypes=Interviewer&ContributorTypes=Narrator&ContributorTypes=Practitioner&ContributorTypes=Producer&ContributorTypes=Speaker&Publisher=&PublisherLocation=&OriginalPublicationYear.StartYear=&OriginalPublicationYear.EndYear=&OnlinePublicationYear.StartYear=&OnlinePublicationYear.EndYear=&Products=0&Products=1&Products=5&Products=2&Products=3&Products=4&Products=6&DocumentTypes=Books&VideoTypes=All+Video+Types&VideoTypes=Archival+Content&VideoTypes=Conference&VideoTypes=Counseling+Session&VideoTypes=Definition&VideoTypes=Documentary&VideoTypes=Film&VideoTypes=In+Practice&VideoTypes=Interview&VideoTypes=Key+Note&VideoTypes=Lecture&VideoTypes=Panel+Discussion&VideoTypes=Raw%2FObservational+Footage&VideoTypes=Tutorial&VideoTypes=Video+Case&AcademicLevels=All&AcademicLevels=Basic&AcademicLevels=Intermediate&AcademicLevels=Complex&CaseLengthStart=&CaseLengthEnd=&Disciplines=All&Disciplines=1&Disciplines=2&Disciplines=3&Disciplines=4&Disciplines=5&Disciplines=6&Disciplines=7&Disciplines=8&Disciplines=9&Disciplines=10&PersonsDiscussed=&OrganizationsDiscussed=&EventsDiscussed=&PlacesDiscussed=&CaseOrganizationsDiscussed=&CaseIndustriesDiscussed= if (getSearchResults(doc)) { return "multiple"; } } else { return getItemType(doc, url); } } function getItemType(doc, url) { if (url.split('/').length>5) { //This includes now also encyclopadiaArticles and dictionaryEntries. return "bookSection"; } else { return "book"; } } function getItem(doc, url) { var id = ZU.xpathText(doc, '(//input[@id="contentId"]/@value)[1]'); var urlParts = url.split('/'); if (urlParts.length>5) { var chapterId = urlParts[urlParts.length-1].replace('.xml', ''); var citeLink = '//sk.sagepub.com/CitationExport/ExportEntryCitation/'+id+'?type=Endnote&xmlId='+chapterId; } else { var citeLink = '//sk.sagepub.com/CitationExport/exportcitation/'+id+'?type=Endnote'; } //Z.debug(citeLink) ZU.doGet(citeLink, function(text) { var match = text .replace(/NV\s+-\s+1\n/, "") .replace(/^AU\s+-\s+,\s+$/m, '') .replace(/^(AU\s+-\s+.+?),? Ph\.? ?D\.?\b/mg, '$1') .replace(/^DA(\s+-)/mg, 'Y2$1') .replace(/^C1(\s+-)/mg, 'T2$1') .replace(/^C2(\s+-\s+)pages\s+/mg, 'SP$1'); //Z.debug(text); //Z.debug(match); var translator = Zotero.loadTranslator("import"); translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");//RIS translator translator.setString(match); translator.setHandler("itemDone", function (obj, item) { var keywords = ZU.xpathText(doc, "//meta[@name='keywords']/@content"); if (keywords) { item.tags = keywords.split(','); } item.url = url; item.attachments.push({ title: "SAGE Knowledge Snapshot", document: doc }); for (var i = 0; i < item.creators.length; i++) { var creator = item.creators[i]; if (creator.fieldMode && creator.lastName.indexOf(" of ") == -1) { item.creators[i] = ZU.cleanAuthor(creator.lastName, creator.creatorType, creator.lastName.indexOf(",") > -1); } creator = item.creators[i]; if (/^\s*(?:(?:Jr|Sr)\.?|I{1,3})\s*$/i.test(creator.lastName)) { item.creators[i] = ZU.cleanAuthor(creator.firstName, creator.creatorType, creator.firstName.indexOf(",") != -1); item.creators[i].firstName += ', ' + creator.lastName.trim(); } } if (item.series == item.title) { delete item.series; } var stripPeriods = ['title', 'bookTitle', 'encyclopediaTitle', 'dictionaryTitle']; for (var i=0; i