{ "translatorID": "eb876bd2-644c-458e-8d05-bf54b10176f3", "label": "Wanfang Data", "creator": "Ace Strong ", "target": "^https?://[ds]\\.(?:g\\.)?wanfangdata\\.com\\.cn", "minVersion": "2.0rc1", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcs", "lastUpdated": "2014-07-24 01:37:16" } /* Wanfang Data Translator Copyright (C) 2010 TAO Cheng, acestrong@gmail.com 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 . */ // ####################### // ##### Sample URLs ##### // ####################### /* * The starting point for an search is the URL below. * In testing, I tried the following: * * - A search listing of journals * - A search listing of thesis * - A search listing of conference papers * - A search listing of foreign literatures(for chinese) * - A journal paper page * - A thesis page * - A conference paper page * - A foreign literature page */ // http://g.wanfangdata.com.cn/Default.aspx // ################################# // #### Local utility functions #### // ################################# //sets the rs cookie value to the provided ID and returns the old value function setCookie(doc, rsId) { if(!rsId) return null; var matches = doc.cookie.match(/(?:$|; )rs=([^;]*)/); var oldCookie = matches ? unescape(matches[1]) : null; var domain = escape('wanfangdata.com.cn'); var id = escape( rsId ); doc.cookie = 'rs=' + id + ';domain=' + domain; return oldCookie; } function detectCode(url) { var pattern = /[ds]\.(?:g\.)?wanfangdata\.com\.cn\/([A-Za-z]*?)_/; if (pattern.test(url)) { var code = pattern.exec(url)[1]; return code; } return null; } function detectType(code) { if (code == "Periodical" || code == "OAPaper") { return "journalArticle"; } else if (code == "Thesis") { return "thesis"; } else if (code == "Conference") { return "conferencePaper"; } else if (code == "NSTLHY") { return "conferencePaper"; } else if (code == "NSTLQK") { return "journalArticle"; } else { return false; } } function getSearchResults(doc, checkOnly) { var items = [], found = false lis = ZU.xpath(doc, '//li[contains(@class,"title_li")]'); for(var i=0, n=lis.length; i((?:.|[\r\n])+?)<\/div>/i); if(!matches) return false; text = ZU.cleanTags( matches[1].replace(/[\r\n]/g,'') ); var translator = Zotero.loadTranslator('import'); translator.setTranslator('881f60f2-0802-411a-9228-ce5f47b64c7d'); translator.setString(text); translator.setHandler('itemDone', function(obj, item) { //author first and last names are mixed up for(var i=0, n=item.creators.length; i