{ "translatorID": "b047a13c-fe5c-6604-c997-bef15e502b09", "label": "LexisNexis", "creator": "Philipp Zumstein", "target": "^https?://[^/]*lexis-?nexis\\.com", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsv", "lastUpdated": "2014-03-20 20:48:18" } /* ***** BEGIN LICENSE BLOCK ***** LexisNexis Translator, Copyright © 2014 Philipp Zumstein This file is part of Zotero. Zotero 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. Zotero 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 Zotero. If not, see . ***** END LICENSE BLOCK ***** */ //Select Test Frame in Scaffold: // single: (2nd) = Results Navigation Frame = Ergebnisnavigation // multiple: (5th) = Ergebnisanzeige function detectWeb(doc, url) { //besides deciding whether it is a single item or multiple items //it is also important here to select the correct frame! Zotero //will only focus on one frame and it is possible to work with that //frame further. //let's go for the navigation bar (2nd frame from top) to call new urls with hidden variables //(this is maybe not the natural choice, but it seems to work) if (url.indexOf("parent=docview") != -1 && url.indexOf("target=results_listview_resultsNav") != -1 ) { return "newspaperArticle"; } if ((url.indexOf("contentRenderer.do?") != -1 || url.indexOf("target=results_ResultsList") != -1) && ZU.xpath(doc, '//tr[./td/input[@name="frm_tagged_documents"]]/td/a').length > 0) { return "multiple"; } } function selectFrame(doc, url) { var frames = doc.getElementsByTagName("frame"); var gotoUrl; for (var i=0; i/.exec(text); var initializationPage = //.exec(text); var poststring2 = "screenReaderSupported=false&delRange=cur&selDocs=&exportType=dnldBiblio&disb="+encodeURIComponent(disb[1])+"&initializationPage="+encodeURIComponent(initializationPage[1]); //Z.debug(poststring2); ZU.doPost(urlRis, poststring2, function(text) { var risData = text; //type is GEN, but better NEWS (or CASE, JOUR) text = text.replace(/^TY\s+-\s+GEN\s*$/mg, 'TY - NEWS'); //the title information is sometimes somewhere else if ( text.search(/^TI\s+-/m) == -1) { if ( text.search(/^N2\s+-/m) != -1 ) {//see e.g. Test Case 5 text = text.replace(/^N2\s+-/m,"TI -"); text = text.replace(/^TY\s+-\s+NEWS\s*$/mg, 'TY - JOUR'); } else if ( text.search(/^U3\s+-/m) != -1 ) {//see e.g. Test Case 4 text = text.replace(/^U3\s+-/m,"TI -"); text = text.replace(/^TY\s+-\s+NEWS\s*$/mg, 'TY - CASE'); } } //most authors are saved in N1 tag, correct that: text = text.replace(/^N1\s+-[ \f\r\t\v\u00A0\u2028\u2029]+(\w.*)$/mg, cleanAuthorFields );//the range in the regexp is actually just \s without the line break //correct date format in RIS e.g. PY - 2013/05/09/ text = text.replace(/^PY\s+-\//mg, "DA -"); //correct page information, e.g. SP - WORLD; Pg. 8 text = text.replace(/^SP\s+-\s+(\w.*)$/mg, function(totalMatch, pageString){ var pageAbbreviations = ["Pg.", "S.", "Pag.", "Blz.", "Pág."]; var pageArray = pageString.split(";"); var pageArray2 = ZU.trimInternal(pageArray[pageArray.length-1]).split(" "); if (pageArray2.length == 2 && pageAbbreviations.indexOf(pageArray2[0]) > -1) {//see e.g. Test Cases 1,2,3 return 'SP - ' + pageArray2.slice(1).join(" ") + "\nSE - " + pageArray.slice(0,-1).join(";"); } else {//see e.g. Test Case 6 return 'SE - ' + pageString; } }); Z.debug(text); var trans = Zotero.loadTranslator('import'); trans.setTranslator('32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7');//https://github.com/zotero/translators/blob/master/RIS.js trans.setString(text); trans.setHandler('itemDone', function (obj, item) { item.url = permaLink; //for debugging TODO: delete later item.notes.push({note:risData}); item.attachments.push( { url: url.replace("target=results_listview_resultsNav","target=results_DocumentContent"), title: "LexisNexis Entry", mimeType: "text/html", } ); item.complete(); }); trans.translate(); }); }); } function cleanAuthorFields(m, authorStr) {//see e.g. Test Cases 2,3 //m = matched string (everything) //authorStr = second parenthesized submatch var authors = authorStr.split(';'); if(authors.length == 1) { //no semicolon authors = authorStr.split(','); if(authors.length < 3) { //at most single comma, don't mess with it return 'AU - ' + authorStr; } else if (authors.length == 3) { //we have to distinguish the correct cases where the third part is //just a suffix as "Jr." and wrong cases where this is a list of //three authors ==> easiest is maybe to check for a space if (ZU.trimInternal(authors[2]).indexOf(' ') == -1) { return 'AU - ' + authorStr; } } } //here: One of the following two cases holds: //(i) authorStr contains semicolon(s), authors is the array of its different parts, fixName = false //(ii) authorStr contains no semicolon but more than one comma, authors is the array of its different parts, fixName = true var str = ''; for(var i=0; i