Another tweak to processDocuments

This commit is contained in:
Simon Kornblith 2012-11-07 23:52:30 -05:00
parent 7754d530da
commit 6b66dbfafa

View File

@ -492,7 +492,8 @@ Zotero.HTTP = new function() {
// (Approximately) how many seconds to wait if the document is left in the loading state and // (Approximately) how many seconds to wait if the document is left in the loading state and
// pageshow is called before we call pageshow with an incomplete document // pageshow is called before we call pageshow with an incomplete document
const LOADING_STATE_TIMEOUT = 120; const LOADING_STATE_TIMEOUT = 120;
var firedLoadEvent = 0; var firedLoadEvent = 0,
loaded = false;
/** /**
* Loads the next page * Loads the next page
@ -503,6 +504,7 @@ Zotero.HTTP = new function() {
var url = urls[currentURL], var url = urls[currentURL],
hiddenBrowser = hiddenBrowsers[currentURL]; hiddenBrowser = hiddenBrowsers[currentURL];
firedLoadEvent = 0; firedLoadEvent = 0;
loaded = false;
currentURL++; currentURL++;
try { try {
Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url); Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url);
@ -527,6 +529,7 @@ Zotero.HTTP = new function() {
* @inner * @inner
*/ */
var onLoad = function(e) { var onLoad = function(e) {
if(loaded) return;
var hiddenBrowser = e.currentTarget, var hiddenBrowser = e.currentTarget,
doc = hiddenBrowser.contentDocument; doc = hiddenBrowser.contentDocument;
if(!doc) return; if(!doc) return;
@ -540,6 +543,7 @@ Zotero.HTTP = new function() {
Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded"); Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded");
hiddenBrowser.removeEventListener("pageshow", onLoad, true); hiddenBrowser.removeEventListener("pageshow", onLoad, true);
loaded = true;
try { try {
processor(doc); processor(doc);