Use onreadystatechange instead of onloadend, because the latter is not supported by MobileSafari, and add debug messages
This commit is contained in:
parent
129805c62b
commit
14ac5a7d2d
1 changed files with 6 additions and 5 deletions
|
@ -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++) {
|
||||
|
|
Loading…
Reference in a new issue