diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index c0a2f2486..7007686c6 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -49,6 +49,8 @@ var Zotero_Browser = new function() { this.tabSelect = tabSelect; this.tabClose = tabClose; this.resize = resize; + this.finishScraping = finishScraping; + this.itemDone = itemDone; this.tabbrowser = null; this.appcontent = null; @@ -344,6 +346,41 @@ var Zotero_Browser = new function() { tab.page.annotations.refresh(); } + + /* + * Callback to be executed when scraping is complete + */ + function finishScraping(obj, returnValue, collection) { + if(!returnValue) { + Zotero_Browser.Progress.changeHeadline(Zotero.getString("ingester.scrapeError")); + Zotero_Browser.Progress.addDescription(Zotero.getString("ingester.scrapeErrorDescription")); + } + + if(collection) { + // notify about modified items + Zotero.Notifier.trigger("modify", "collection", collection.getID()); + } + + Zotero_Browser.Progress.fade(); + } + + + /* + * Callback to be executed when an item has been finished + */ + function itemDone(obj, item, collection) { + var title = item.getField("title"); + var icon = item.getImageSrc(); + Zotero_Browser.Progress.addLines([title], [icon]); + + // add item to collection, if one was specified + if(collection) { + Zotero.Notifier.disable(); + collection.addItem(item.getID()); + Zotero.Notifier.enable(); + } + } + ////////////////////////////////////////////////////////////////////////////// // // Private Zotero_Browser methods @@ -553,28 +590,12 @@ Zotero_Browser.Tab.prototype.translate = function(saveLocation) { // 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) { me._itemDone(obj, item, saveLocation) }); - this.page.translate.setHandler("done", function(obj, item) { me._finishScraping(obj, item, saveLocation) }); + 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.translate.translate(); } } -/* - * Callback to be executed when an item has been finished - */ -Zotero_Browser.Tab.prototype._itemDone = function(obj, item, collection) { - var title = item.getField("title"); - var icon = item.getImageSrc(); - Zotero_Browser.Progress.addLines([title], [icon]); - - // add item to collection, if one was specified - if(collection) { - Zotero.Notifier.disable(); - collection.addItem(item.getID()); - Zotero.Notifier.enable(); - } -} - /* * called when a user is supposed to select items */ @@ -591,23 +612,6 @@ Zotero_Browser.Tab.prototype._selectItems = function(obj, itemList) { return io.dataOut; } -/* - * Callback to be executed when scraping is complete - */ -Zotero_Browser.Tab.prototype._finishScraping = function(obj, returnValue, collection) { - if(!returnValue) { - Zotero_Browser.Progress.changeHeadline(Zotero.getString("ingester.scrapeError")); - Zotero_Browser.Progress.addDescription(Zotero.getString("ingester.scrapeErrorDescription")); - } - - if(collection) { - // notify about modified items - Zotero.Notifier.trigger("modify", "collection", collection.getID()); - } - - Zotero_Browser.Progress.fade(); -} - /* * returns the URL of the image representing the translator to be called on the * current page, or false if the page cannot be scraped diff --git a/chrome/content/zotero/xpcom/ingester.js b/chrome/content/zotero/xpcom/ingester.js index 4cf546383..c1cc175aa 100644 --- a/chrome/content/zotero/xpcom/ingester.js +++ b/chrome/content/zotero/xpcom/ingester.js @@ -749,18 +749,18 @@ Zotero.Ingester.MIMEHandler.StreamListener.prototype.onStopRequest = function(ch try { saveLocation = frontWindow.ZoteroPane.getSelectedCollection(); } catch(e) {} - translation.setHandler("itemDone", function(obj, item) { frontWindow.Zotero_Browser._itemDone(obj, item, saveLocation) }); - translation.setHandler("done", function(obj, item) { frontWindow.Zotero_Browser._finishScraping(obj, item, saveLocation) }); + translation.setHandler("itemDone", function(obj, item) { frontWindow.Zotero_Browser.itemDone(obj, item, saveLocation) }); + translation.setHandler("done", function(obj, item) { frontWindow.Zotero_Browser.finishScraping(obj, item, saveLocation) }); // attempt to retrieve translators var translators = translation.getTranslators(); if(!translators.length) { // we lied. we can't really translate this file. call // nsIExternalHelperAppService with the data - this._frontWindow.Zotero_Browser.Progress.kill(); + frontWindow.Zotero_Browser.Progress.kill(); var streamListener; - if(streamListener = externalHelperAppService.doContent(this._contentType, this._request, this._frontWindow)) { + if(streamListener = externalHelperAppService.doContent(this._contentType, this._request, frontWindow)) { // create a string input stream var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"]. createInstance(Components.interfaces.nsIStringInputStream);