From 9d39f7394738f954ec973fa92be17aa74fdaae88 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 10 Jan 2007 00:17:52 +0000 Subject: [PATCH] - fixes issues with the ISI Web of Knowledge translator. in the process of testing, I realized that, when searching the Web of Knowledge for common words (e.g., "quark"), the Web of Knowledge does not return a meaningful set of results. neither the "Web of Science" links, nor the export feature (through Zotero or the web interface) work at all. perhaps this is something to contact ISI about? - fixes miscellaneous issues with frames (not relevant to b3) --- chrome/content/zotero/browser.js | 29 ++++++++++++++++++++--------- scrapers.sql | 21 ++++++++++++++------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 7007686c6..5bcb32e6c 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -232,7 +232,9 @@ var Zotero_Browser = new function() { * An event handler called when a new document is loaded. Creates a new document * object, and updates the status of the capture icon */ - function contentLoad(event) { + function contentLoad(event) { + Zotero.debug("contentLoad event"); + var isHTML = event.originalTarget instanceof HTMLDocument; if(isHTML) { @@ -293,6 +295,8 @@ var Zotero_Browser = new function() { * called to unregister Zotero icon, etc. */ function contentHide(event) { + Zotero.debug("contentHide event"); + if(event.originalTarget instanceof HTMLDocument && !event.originalTarget.defaultView.frameElement) { var doc = event.originalTarget; @@ -544,11 +548,13 @@ Zotero_Browser.Tab.prototype.detectTranslators = function(rootDoc, doc) { } // get translators - this.page.translate = new Zotero.Translate("web"); - this.page.translate.setDocument(doc); - this.page.translators = this.page.translate.getTranslators(); + var translate = new Zotero.Translate("web"); + translate.setDocument(doc); + var translators = translate.getTranslators(); // add document - if(this.page.translators && this.page.translators.length) { + if(translators && translators.length) { + this.page.translate = translate; + this.page.translators = translators; this.page.document = doc; } } @@ -588,10 +594,13 @@ Zotero_Browser.Tab.prototype.translate = function(saveLocation) { var me = this; // use first translator available - this.page.translate.setTranslator(this.page.translators[0]); - this.page.translate.setHandler("select", me._selectItems); - this.page.translate.setHandler("itemDone", function(obj, item) { Zotero_Browser.itemDone(obj, item, saveLocation) }); - this.page.translate.setHandler("done", function(obj, item) { Zotero_Browser.finishScraping(obj, item, saveLocation) }); + if(!this.page.hasBeenTranslated) { + this.page.translate.setTranslator(this.page.translators[0]); + this.page.translate.setHandler("select", me._selectItems); + this.page.translate.setHandler("itemDone", function(obj, item) { Zotero_Browser.itemDone(obj, item, saveLocation) }); + this.page.translate.setHandler("done", function(obj, item) { Zotero_Browser.finishScraping(obj, item, saveLocation) }); + this.page.hasBeenTranslated = true; + } this.page.translate.translate(); } } @@ -638,6 +647,8 @@ Zotero_Browser.Tab.prototype.getCaptureIcon = function() { // Handles the display of a div showing progress in scraping Zotero_Browser.Progress = new function() { + var _progressWindow; + var _windowLoaded = false; var _windowLoading = false; // keep track of all of these things in case they're called before we're diff --git a/scrapers.sql b/scrapers.sql index 7157bfee7..e6d605483 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -1,4 +1,4 @@ --- 162 +-- 163 -- ***** BEGIN LICENSE BLOCK ***** -- @@ -5502,17 +5502,16 @@ REPLACE INTO translators VALUES ('21ad38-3830-4836-aed7-7b5c2dbfa740', '1.0.0b3. var lines = text.split("\n"); var fieldRe = /^[A-Z0-9]{2}(?: |$)/; - var field, content, item; + var field, content, item, authors; for each(var line in lines) { if(fieldRe.test(line)) { if(item && field && content) { if(field == "AF") { // returns need to be processed separately when dealing with authors - var authors = content.split("\n"); - for each(var author in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author", true)); - } + authors = content; + } else if(field == "AU" && !authors) { + authors = content; } else { content = content.replace(/\n/g, " "); if(field == "TI") { @@ -5572,8 +5571,15 @@ REPLACE INTO translators VALUES ('21ad38-3830-4836-aed7-7b5c2dbfa740', '1.0.0b3. } field = content = undefined; } else if(field == "ER") { + if(authors) { + authors = authors.split("\n"); + for each(var author in authors) { + item.creators.push(Zotero.Utilities.cleanAuthor(author, "author", true)); + } + } + item.complete(); - item = field = content = undefined; + item = field = content = authors = undefined; } } else { content += "\n"+Zotero.Utilities.cleanString(line); @@ -5637,6 +5643,7 @@ function doWeb(doc, url) { var tableRows = doc.evaluate(''//tr[td/span/input[@name="marked_list_candidates"]]'', doc, nsResolver, XPathResult.ANY_TYPE, null); while(tableRow = tableRows.iterateNext()) { var id = tableRow.getElementsByTagName("input")[0].value; + Zotero.debug(id); items[id] = tableRow.getElementsByTagName("b")[0].textContent;