www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 24fc8d129214e805d866f707a8ac1d31475a666a
parent 070c8eb7a53c604f59a4902e43e1f9c6f332daed
Author: Avram Lyon <ajlyon@gmail.com>
Date:   Tue, 30 Nov 2010 22:04:27 +0000

Trans: Handling of conferencePaper and bookSection in RIS, also
handling of numPages. See http://forums.zotero.org/discussion/15376
and other discussion.


Diffstat:
Mtranslators/RIS.js | 32+++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/translators/RIS.js b/translators/RIS.js @@ -40,6 +40,16 @@ var fieldMap = { M3:"DOI" }; +var bookSectionFieldMap = { + ID:"itemID", + T1:"title", + T3:"series", + T2:"bookTitle", + CY:"place", + JA:"journalAbbreviation", + M3:"DOI" +}; + var inputFieldMap = { TI:"title", CT:"title", @@ -250,6 +260,9 @@ function processTag(item, tag, value) { // start page if(!item.pages) { item.pages = value; + // EndNote uses SP without EP for number of pages + // Save as numPages only if there were no previous pages tags + if (item.itemType == "book") item.numPages = value; } else if(item.pages[0] == "-") { // already have ending page item.pages = value + item.pages; } else { // multiple ranges? hey, it's a possibility @@ -262,6 +275,9 @@ function processTag(item, tag, value) { item.pages = value; } else if(value != item.pages) { item.pages += "-"+value; + // EndNote uses SP without EP for number of pages + // Here, clear numPages if we have an EP != SP + if (item.itemType == "book") item.numPages = undefined; } } } else if(tag == "SN") { @@ -441,8 +457,14 @@ function doExport() { addTag("TY", typeMap[item.itemType] ? typeMap[item.itemType] : "GEN"); // use field map - for(var j in fieldMap) { - if(item[fieldMap[j]]) addTag(j, item[fieldMap[j]]); + if (item.itemType == "bookSection" || item.itemType == "conferencePaper") { + for(var j in bookSectionFieldMap) { + if(item[bookSectionFieldMap[j]]) addTag(j, item[bookSectionFieldMap[j]]); + } + } else { + for(var j in fieldMap) { + if(item[fieldMap[j]]) addTag(j, item[fieldMap[j]]); + } } // creators @@ -458,7 +480,11 @@ function doExport() { risTag = "A2"; } - addTag(risTag, item.creators[j].lastName+","+item.creators[j].firstName); + var names = []; + if (item.creators[j].lastName) names.push(item.creators[j].lastName); + if (item.creators[j].firstName) names.push(item.creators[j].firstName); + + addTag(risTag, names.join(",")); } // assignee (patent)