{ "translatorID": "594ebe3c-90a0-4830-83bc-9502825a6810", "label": "ISI Web of Knowledge", "creator": "Michael Berkowitz, Avram Lyon", "target": "^https?://[^/]*webofknowledge\\.com/", "minVersion": "2.1", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 5, "browserSupport": "gcsv", "lastUpdated": "2014-07-24 21:53:33" } function detectWeb(doc, url) { if ( (url.indexOf("full_record.do") !== -1 || url.indexOf("InboundService.do") != -1) && getSingleItemId(doc) ) { return "journalArticle"; } else if (((doc.title.indexOf(" Results") !== -1) || url.indexOf("search_mode=") !== -1) && getRecords(doc).length) { return "multiple"; } } function getRecords(doc) { return ZU.xpath(doc, '//span[@id="records_chunks"]//div[starts-with(@id,"RECORD_")]'); } function getSingleItemId(doc) { var form = doc.forms['records_form']; if(form) return (form.elements.namedItem('marked_list_candidates') || {}).value; return false; } function doWeb(doc, url) { var ids = new Array(); if (detectWeb(doc, url) == "multiple") { var items = new Object; var records = getRecords(doc); var recordID, title; for(var i=0, n=records.length; i]+name=(['"]?)qid\1[\s\/][^>]*/); if(qid) qid = qid[0].match(/value=['"]?(\d+)/); if(qid) { qid = qid[1]; } else { qid = postData['qid']*1+1; //this can be wrong if pages are refreshed Z.debug("Could not find qid on page. Using 1 + previous qid: " + qid); text = text.replace(/\s*[\r\n]\s*/g, '\n'); //trim out the extra newlines var forms = text.match(//ig); if(forms) { Z.debug("Page contained the following forms:"); Z.debug(forms.join('\n==============================\n')); } else { Z.debug("Could not find any forms on the page. Here's the whole HTML"); Z.debug(text); } } postData2['qid'] = qid; var postUrl2 = 'http://ets.webofknowledge.com/ETS/saveDataToRef.do'; //Zotero should take care of proxies ZU.doPost(postUrl2, serializePostData(postData2), function(text) { importISIRecord(text); }, { 'Referer': postUrl }); }, { 'Referer': doc.location.href }); } function detectImport() { var line; var i = 0; while((line = Zotero.read()) !== false) { line = line.replace(/^\s+/, ""); if(line != "") { if(line.substr(0, 4).match(/^PT [A-Z]/)) { return true; } else { if(i++ > 3) { return false; } } } } } function processTag(item, field, content) { var map = { "J": "journalArticle", "S": "bookSection", // Not sure "P": "patent", "B": "book" }; if (field == "PT") { item.itemType = map[content]; if (item.itemType === undefined) { item.itemType = "journalArticle"; Zotero.debug("Unknown type: " + content); } } else if ((field == "AF" || field == "AU")) { //Z.debug("author: " + content); authors = content.split("\n"); for each (var author in authors) { author = author.replace(/\s+\(.*/, ''); item.creators[0][field].push(ZU.cleanAuthor(author, "author", author.match(/,/))); } } else if ((field == "BE")) { //Z.debug(content); authors = content.split("\n"); for each (var author in authors) { item.creators[1].push(ZU.cleanAuthor(author, "editor", author.match(/,/))); } } else if (field == "TI") { content = content.replace(/\s\s+/g, " "); item.title = content; } else if (field == "JI") { item.journalAbbreviation = content; } else if (field == "SO") { item.publicationTitle = content; } else if (field == "SN") { item.ISSN = content; } else if (field == "BN") { item.ISBN = content; } else if (field == "PD" || field == "PY") { if (item.date) { item.date += " " + content; } else { item.date = content; } var year = item.date.match(/\d{4}/); // If we have a double year, eliminate one if (year && item.date.replace(year[0],"").indexOf(year[0]) !== -1) item.date = item.date.replace(year[0],""); } else if (field == "VL") { item.volume = content; } else if (field == "IS") { item.issue = content; } else if (field == "UT") { item.extra += content; } else if (field == "BP" || field == "PS") { // not sure why this varies item.pages = content; } else if (field == "EP") { item.pages += "-" + content; } else if (field == "AR") { //save articleNumber - we're going to use that where we don't have pages & discard later on item.articleNumber = content; ; } else if (field == "AB") { content = content.replace(/\s\s+/g, " "); item.abstractNote = content; } else if (field == "PI" || field == "C1") { item.place = content; } else if (field == "LA") { item.language = content; } else if (field == "PU") { item.publisher = content; // Patent stuff } else if (field == "DG") { item.issueDate = content; } else if (field == "PN") { item.patentNumber = content; } else if (field == "AE") { item.assignee = content; } else if (field == "PL") { // not sure... item.priorityNumber = content; } else if (field == "PC") { // use for patents item.country = content; // A whole mess of tags } else if (field == "DE" || field == "BD" || field == "OR" || field == "ID" || field == "MC" || field == "MQ") { item.tags = item.tags.concat(content.split(";")); } else if (field == "DI") { item.DOI = content; } else { Zotero.debug("Discarding: " + field + " => "+content); } } function completeItem(item) { var i; var creators = []; // If we have full names, drop the short ones if (item.creators[0]["AF"].length) { creators = item.creators[0]["AF"]; } else { creators = item.creators[0]["AU"]; } // Add other creators if (item.creators[1]) item.creators = creators.concat(item.creators[1]); else item.creators = creators; // If we have a patent, change author to inventor if (item.itemType == "patent") { for (i in item.creators) { if (item.creators[i].creatorType == "author") { item.creators[i].creatorType = "inventor"; } } } if (item.articleNumber){ if (!item.pages) item.pages = item.articleNumber; delete item.articleNumber } // Fix caps, trim in various places for (i in item.tags) { item.tags[i] = item.tags[i].trim(); if (item.tags[i].toUpperCase() == item.tags[i]) item.tags[i]=item.tags[i].toLowerCase(); } var toFix = ["publisher", "publicationTitle", "place"]; for (i in toFix) { var field = toFix[i]; if (item[field] && item[field].toUpperCase() == item[field]) item[field]=ZU.capitalizeTitle(item[field].toLowerCase(),true); } item.complete(); } function doImport(text) { var tag = data = false; var debugBuffer = ''; //in case nothing is found var linesRead = 0, bufferMax = 100; var line = Zotero.read(); // first valid line is type while(line !== false && line.replace(/^\s+/, "").substr(0, 6).search(/^PT [A-Z]/) == -1) { if(linesRead < bufferMax) debugBuffer += line + '\n'; linesRead++; line = Zotero.read(); } if(line === false) { Z.debug("No valid data found\n" + "Read " + linesRead + " lines.\n" + "Here are the first " + (linesRead