From 14ac5a7d2d24b778b3796c639f77def2c9a224ac Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 9 Apr 2012 12:47:02 -0400 Subject: [PATCH 1/2] Use onreadystatechange instead of onloadend, because the latter is not supported by MobileSafari, and add debug messages --- .../content/zotero/xpcom/connector/translate_item.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/connector/translate_item.js b/chrome/content/zotero/xpcom/connector/translate_item.js index 9e2ed8e05a..e6a3f0603a 100644 --- a/chrome/content/zotero/xpcom/connector/translate_item.js +++ b/chrome/content/zotero/xpcom/connector/translate_item.js @@ -206,7 +206,7 @@ Zotero.Translate.ItemSaver.prototype = { } else { attachment.key = newKeys[i]; - Zotero.debug("Finished creating item"); + Zotero.debug("Finished creating items"); if(attachment.linkMode === "linked_url") { attachmentCallback(attachment, 100); } else if("data" in attachment) { @@ -312,9 +312,9 @@ Zotero.Translate.ItemSaver.prototype = { var xhr = new XMLHttpRequest(); xhr.open("GET", attachment.url, true); - xhr.responseType = "arraybuffer"; - xhr.onloadend = function() { - if(!checkHeaders()) return; + xhr.responseType = "arraybuffer"; + xhr.onreadystatechange = function() { + if(xhr.readyState !== 4 || !checkHeaders()) return; attachmentCallback(attachment, 50); attachment.data = xhr.response; @@ -324,7 +324,7 @@ Zotero.Translate.ItemSaver.prototype = { } }; xhr.onprogress = function(event) { - if(this.readyState < 2 || !checkHeaders()) return; + if(xhr.readyState < 2 || !checkHeaders()) return; if(event.total && attachmentCallback) { attachmentCallback(attachment, event.loaded/event.total*50); @@ -347,6 +347,7 @@ Zotero.Translate.ItemSaver.prototype = { * on failure or attachmentCallback(attachment, progressPercent) periodically during saving. */ "_uploadAttachmentToServer":function(attachment, attachmentCallback) { + Zotero.debug("Uploading attachment to server"); var binaryHash = this._md5(new Uint8Array(attachment.data), 0, attachment.data.byteLength), hash = ""; for(var i=0; i Date: Mon, 9 Apr 2012 16:47:12 -0400 Subject: [PATCH 2/2] Deal with spaces in ISBNs --- chrome/content/zotero/lookup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 0a2e43e84d..84d062e8cf 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -39,7 +39,7 @@ const Zotero_Lookup = new function () { if(doi) { var item = {itemType:"journalArticle", DOI:doi}; } else { - identifier = identifier.trim().replace("-", "", "g"); + identifier = identifier.trim().replace(/[\- ]/g, ""); if(identifier.length == 10 || identifier.length == 13) { // ISBN var item = {itemType:"book", ISBN:identifier};