commit 14ac5a7d2d24b778b3796c639f77def2c9a224ac
parent 129805c62b5ad86cba0a90fa594ab9a8123aea8e
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 9 Apr 2012 12:47:02 -0400
Use onreadystatechange instead of onloadend, because the latter is not supported by MobileSafari, and add debug messages
Diffstat:
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
@@ -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<binaryHash.length; i++) {