{ "translatorID": "d0b1914a-11f1-4dd7-8557-b32fe8a3dd47", "label": "EBSCOhost", "creator": "Simon Kornblith, Michael Berkowitz, Josh Geller", "target": "^https?://[^/]+/(?:eds|bsi|ehost)/(?:results|detail|folder|pdfviewer)", "minVersion": "2.1", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsib", "lastUpdated": "2014-09-09 19:59:20" } function detectWeb(doc, url) { // See if this is a search results or folder results page var multiple = getResultList(doc, {}, {}); //we don't care about actual data at this point if(multiple) { return "multiple"; } var persistentLink = doc.getElementsByClassName("permalink-link"); if(persistentLink.length && persistentLink[0].nodeName.toUpperCase() == 'A') { return "journalArticle"; } else if(ZU.xpathText(doc, '//section[@class="record-header"]/h2')){ return "journalArticle"; } } /* * given the text of the delivery page, downloads an item */ function downloadFunction(text, url, prefs) { if (text.search(/^TY\s\s?-/m) == -1) { text = "\nTY - JOUR\n" + text; //this is probably not going to work if there is garbage text in the begining } //fix DOI text = text.replace(/^(?:L3|DI)(\s\s?-)/gm, 'DO$1'); // There are cases where the RIS type isn't good-- // there is sometimes better data in M3 // This list should be augmented over time var m, m3Data; var itemType = prefs.itemType; if (!itemType && (m = text.match(/^M3\s+-\s*(.*)$/m))) { m3Data = m[1]; //used later switch(m3Data) { case "Literary Criticism": case "Case Study": itemType = "journalArticle"; break; } } //remove M3 so it does not interfere with DOI. //hopefully EBCSOhost doesn't use this for anything useful text = text.replace(/^M3\s\s?-.*/gm, ''); //Let's try to keep season info // Y1 - 1993///Winter93 // Y1 - 2009///Spring2009 // maybe also Y1 - 1993///93Winter var season = text.match( /^(Y1\s+-\s+(\d{2})(\d{2})\/\/\/)(?:\2?\3(.+)|(.+?)\2?\3)\s*$/m); season = season && (season[4] || season[5]); // load translator for RIS var translator = Zotero.loadTranslator("import"); translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); translator.setString(text); translator.setHandler("itemDone", function(obj, item) { /* Fix capitalization issues */ //title if(!item.title && prefs.itemTitle) { item.title = prefs.itemTitle; } if(item.title) { // Strip final period from title if present item.title = item.title.replace(/([^\.])\.\s*$/,'$1'); if(item.title.toUpperCase() == item.title) { item.title = ZU.capitalizeTitle(item.title, true); } } //authors var fn, ln; for(var i=0, n=item.creators.length; ititle (in items) and item url->database info (in itemInfo) function getResultList(doc, items, itemInfo) { var results = ZU.xpath(doc, '//li[@class="result-list-li"]'); var title, folderData, count = 0; //make search results work if you can't add to folder, e.g. for EBSCO used as discovery service of library such as //http://search.ebscohost.com/login.aspx?direct=true&site=eds-live&scope=site&type=0&custid=s4895734&groupid=main&profid=eds&mode=and&lang=en&authtype=ip,guest,athens if (results.length>0) { var folder = ZU.xpathText(doc, '//span[@class = "item add-to-folder"]/input/@value|.//span[@class = "item add-to-folder"]/a[1]/@data-folder') for(var i=0, n=results.length; i 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; } function btoa(input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = utf8_encode(input); while(i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if(isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + base64KeyStr.charAt(enc1) + base64KeyStr.charAt(enc2) + base64KeyStr.charAt(enc3) + base64KeyStr.charAt(enc4); } return output; } /** * end borrowed code */ /** * EBSCOhost encodes the target url before posting the form * Replicated from http://global.ebsco-content.com/interfacefiles/13.4.0.98/javascript/bundled/_layout2/master.js */ function urlSafeEncodeBase64(str) { return btoa(str).replace(/\+/g, "-").replace(/\//g, "_") .replace(/=*$/, function(m) { return m.length; }); } //var counter; function doWeb(doc, url) { //counter = 0; var items = {}; var itemInfo = {}; var multiple = getResultList(doc, items, itemInfo); if(multiple) { Zotero.selectItems(items, function (items) { if(!items) { return true; } //fetch each url assynchronously var i; for(i in items) { (function(itemInfo) { ZU.processDocuments( i.replace(/#.*$/,''), function(doc) { doDelivery(doc, itemInfo); } ); })(itemInfo[i]); } }); } else { /**Individual record. * Record key exists in attribute for add to folder link in DOM */ doDelivery(doc); } } function doDelivery(doc, itemInfo) { var folderData; if(!itemInfo||!itemInfo.folderData) { /* Get the db, AN, and tag from ep.clientData instead */ var script, clientData; var scripts = doc.getElementsByTagName("script"); for(var i=0; i