commit 1cf83d176039a22fe79d7af507462eb1bec152e7
parent cec3b1d31eb6a8b7cc138c63f1a6ecfb5169e77d
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 30 Apr 2009 00:10:03 +0000
- fixes processDocuments() under Firefox 3.5
- makes translator progress window work a little better with translators that call Zotero.done() incorrectly, and complains when item.complete() is called after Zotero.done()
Diffstat:
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js
@@ -55,6 +55,7 @@ var Zotero_Browser = new function() {
this.tabbrowser = null;
this.appcontent = null;
this.statusImage = null;
+ this.isScraping = false;
var _scrapePopupShowing = false;
var _browserData = new Object();
@@ -450,14 +451,18 @@ var Zotero_Browser = new function() {
*/
function finishScraping(obj, returnValue) {
if(!returnValue) {
+ Zotero_Browser.progress.show();
Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.scrapeError"));
// Include link to Known Translator Issues page
var url = "http://www.zotero.org/documentation/known_translator_issues";
var linkText = '<a href="' + url + '" tooltiptext="' + url + '">'
+ Zotero.getString('ingester.scrapeErrorDescription.linkText') + '</a>';
Zotero_Browser.progress.addDescription(Zotero.getString("ingester.scrapeErrorDescription", linkText));
+ Zotero_Browser.progress.startCloseTimer(8000);
+ } else {
+ Zotero_Browser.progress.startCloseTimer();
}
- Zotero_Browser.progress.startCloseTimer();
+ Zotero_Browser.isScraping = false;
}
@@ -467,6 +472,7 @@ var Zotero_Browser = new function() {
function itemDone(obj, item, collection) {
var title = item.getField("title");
var icon = item.getImageSrc();
+ Zotero_Browser.progress.show();
Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.scraping"));
Zotero_Browser.progress.addLines([title], [icon]);
@@ -474,6 +480,15 @@ var Zotero_Browser = new function() {
if(collection) {
collection.addItem(item.getID());
}
+
+ if(Zotero_Browser.isScraping) {
+ // initialize close timer between item saves in case translator doesn't call done
+ Zotero_Browser.progress.startCloseTimer(10000); // is this long enough?
+ } else {
+ // if we aren't supposed to be scraping now, the translator is broken; assume we're
+ // done
+ Zotero_Browser.progress.startCloseTimer();
+ }
}
//////////////////////////////////////////////////////////////////////////////
@@ -657,6 +672,7 @@ Zotero_Browser.Tab.prototype._attemptLocalFileImport = function(doc) {
Zotero_Browser.Tab.prototype.translate = function(saveLocation) {
if(this.page.translators && this.page.translators.length) {
Zotero_Browser.progress.show();
+ Zotero_Browser.isScraping = true;
if(saveLocation) {
saveLocation = Zotero.Collections.get(saveLocation);
diff --git a/chrome/content/zotero/xpcom/translate.js b/chrome/content/zotero/xpcom/translate.js
@@ -894,7 +894,9 @@ Zotero.Translate.prototype._enableAsynchronousDetect = function() {
Zotero.Translate.prototype._enableAsynchronousTranslate = function() {
var me = this;
this.waitForCompletion = true;
- this._sandbox.Zotero.done = function(val) { me._translationComplete(val) };
+ this._sandbox.Zotero.done = function(val, error) {
+ me._translationComplete(val == undefined ? true : val, (error ? error : ""))
+ };
}
/*
@@ -1115,6 +1117,11 @@ Zotero.Translate.prototype._itemTagsAndSeeAlso = function(item, newItem) {
*/
Zotero.Translate._urlRe = /(([A-Za-z]+):\/\/[^\s]*)/i;
Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
+ // warn if itemDone called after translation completed
+ if(this._complete) {
+ Zotero.debug("Translate: WARNING: Zotero.Item.complete() called after Zotero.done(); please fix your code", 2);
+ }
+
if(this.type == "web") {
// store repository if this item was captured from a website, and
// repository is truly undefined (not false or "")
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -1295,6 +1295,7 @@ Zotero.Utilities.HTTP = new function() {
* @inner
*/
var onLoad = function() {
+ if(hiddenBrowser.contentDocument.location.href == "about:blank") return;
Zotero.debug(hiddenBrowser.contentDocument.location.href+" has been loaded");
if(hiddenBrowser.contentDocument.location.href != prevUrl) { // Just in case it fires too many times
prevUrl = hiddenBrowser.contentDocument.location.href;