- 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()
This commit is contained in:
Simon Kornblith 2009-04-30 00:10:03 +00:00
parent cec3b1d31e
commit 1cf83d1760
3 changed files with 26 additions and 2 deletions

View file

@ -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,15 +451,19 @@ 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.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);

View file

@ -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 "")

View file

@ -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;