| 1 | REPLACE INTO translators VALUES ('a77690cf-c5d1-8fc4-110f-d1fc765dcf88', '1.0.0b3.r1', '', '2007-08-29 12:34:33', '1', '100', '4', 'ProQuest', 'Simon Kornblith', '^https?://[^/]+/pqdweb\?((?:.*\&)?did=.*&Fmt=[0-9]|(?:.*\&)Fmt=[0-9].*&did=|(?:.*\&)searchInterface=)', |
|---|
| 2 | 'function detectWeb(doc, url) { |
|---|
| 3 | var namespace = doc.documentElement.namespaceURI; |
|---|
| 4 | var nsResolver = namespace ? function(prefix) { |
|---|
| 5 | if (prefix == ''x'') return namespace; else return null; |
|---|
| 6 | } : null; |
|---|
| 7 | |
|---|
| 8 | if(doc.evaluate(''//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]'', |
|---|
| 9 | doc, nsResolver, XPathResult.ANY_TYPE, null)) { |
|---|
| 10 | if(doc.title == "Results") { |
|---|
| 11 | return "multiple"; |
|---|
| 12 | } else { |
|---|
| 13 | return "magazineArticle"; |
|---|
| 14 | } |
|---|
| 15 | } |
|---|
| 16 | }', |
|---|
| 17 | 'function parseRIS(uris) { |
|---|
| 18 | |
|---|
| 19 | Zotero.debug("Begin parsing RIS"); |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | //GET /pqdweb?RQT=562&exportFormat=1&TS=1188401415&clientId=31810 |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | Zotero.Utilities.HTTP.doGet(uris, function(text){ |
|---|
| 27 | // load translator for RIS |
|---|
| 28 | var translator = Zotero.loadTranslator("import"); |
|---|
| 29 | translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); |
|---|
| 30 | translator.setString(text); |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | translator.setHandler("itemDone", function(obj, item) { |
|---|
| 35 | var cre = new Array(); |
|---|
| 36 | cre = item.creators; |
|---|
| 37 | for each(var e in cre) { |
|---|
| 38 | Zotero.debug("Creators: "+e[''lastName'']); |
|---|
| 39 | if(!e[''firstName'']) { |
|---|
| 40 | //check if there is a first name, if not, take the first word in the last name |
|---|
| 41 | var names = e[''lastName''].split(" "); |
|---|
| 42 | e[''firstName'']=names[0]; |
|---|
| 43 | e[''lastName'']=""; |
|---|
| 44 | for(var i = 1; i<names.length; i++) { |
|---|
| 45 | e[''lastName'']+=names[i]; |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | //item.creators.push({lastName:names[0], firstName:names[1], creatorType:"author"}); |
|---|
| 50 | item.complete(); |
|---|
| 51 | }); |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | translator.translate(); |
|---|
| 55 | Zotero.done(); |
|---|
| 56 | }, function() {}); |
|---|
| 57 | Zotero.wait(); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | function doWeb(doc, url) { |
|---|
| 61 | |
|---|
| 62 | var namespace = doc.documentElement.namespaceURI; |
|---|
| 63 | var nsResolver = namespace ? function(prefix) { |
|---|
| 64 | if (prefix == ''x'') return namespace; else return null; |
|---|
| 65 | } : null; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | if(doc.evaluate(''//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]'', |
|---|
| 69 | doc, nsResolver, XPathResult.ANY_TYPE, null)) { |
|---|
| 70 | if(doc.title == "Results") { |
|---|
| 71 | Zotero.debug("Multiple"); |
|---|
| 72 | } else { |
|---|
| 73 | Zotero.debug("Single"); |
|---|
| 74 | |
|---|
| 75 | var xpath = ''//input[@name="marked"][@type="checkbox"]''; |
|---|
| 76 | |
|---|
| 77 | var str= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; |
|---|
| 78 | Zotero.debug("Marked Info: "+str); |
|---|
| 79 | |
|---|
| 80 | //var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); |
|---|
| 81 | |
|---|
| 82 | /* |
|---|
| 83 | |
|---|
| 84 | while(elmt = elmts.iterateNext()) { |
|---|
| 85 | //Zotero.debug("ELMT TEXT CONTENT"+elmt.textContent); |
|---|
| 86 | if(elmt.textContent=="Basic") { |
|---|
| 87 | var urlstr = elmt.href; |
|---|
| 88 | urlarray = urlstr.split("&"); |
|---|
| 89 | urlstr = urlarray[urlarray.length-1]; |
|---|
| 90 | urlarray = urlstr.split("="); |
|---|
| 91 | urlstr = urlarray[urlarray.length-1]; |
|---|
| 92 | |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | */ |
|---|
| 97 | |
|---|
| 98 | url = "http://proquest.umi.com/pqdweb?RQT=530&markedListInfo="+str+"1"; |
|---|
| 99 | |
|---|
| 100 | Zotero.debug("RIS URL: "+url); |
|---|
| 101 | |
|---|
| 102 | var uris = new Array(); |
|---|
| 103 | uris.push(url); |
|---|
| 104 | |
|---|
| 105 | parseRIS(uris); |
|---|
| 106 | |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | }'); |
|---|