From c6da52f24b6d6253944d2fe6df261514ec39293a Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 21 Jul 2012 20:17:14 -0400 Subject: [PATCH] Support saving snapshots from connector, part 1 Snapshots are currently saved using a tag. Thus, images are skipped. --- .../zotero/xpcom/connector/translate_item.js | 151 +++++++++++++++--- 1 file changed, 128 insertions(+), 23 deletions(-) diff --git a/chrome/content/zotero/xpcom/connector/translate_item.js b/chrome/content/zotero/xpcom/connector/translate_item.js index ef7d11ff32..9b9fb6ebd7 100644 --- a/chrome/content/zotero/xpcom/connector/translate_item.js +++ b/chrome/content/zotero/xpcom/connector/translate_item.js @@ -33,8 +33,10 @@ Zotero.Translate.ItemSaver = function(libraryID, attachmentMode, forceTagType, d this._cookie = document.cookie; } - // Add listener for callbacks - if(Zotero.Messaging && !Zotero.Translate.ItemSaver._attachmentCallbackListenerAdded) { + // Add listener for callbacks, but only for Safari or the bookmarklet. In Chrome, we + // (have to) save attachments from the inject page. + if(Zotero.Messaging && !Zotero.Translate.ItemSaver._attachmentCallbackListenerAdded + && (Zotero.isBookmarklet || Zotero.isSafari)) { Zotero.Messaging.addMessageListener("attachmentCallback", function(data) { var id = data[0], status = data[1]; @@ -173,21 +175,15 @@ Zotero.Translate.ItemSaver.prototype = { "_saveToServer":function(items, callback, attachmentCallback) { var newItems = [], typedArraysSupported = false; try { - // Safari <5.2 supports typed arrays, but doesn't support sending them in - // an XHR - typedArraysSupported = new Uint8Array(1) && (!Zotero.isSafari || window.WebKitBlobBuilder); + typedArraysSupported = !!(new Uint8Array(1) && new Blob()); } catch(e) {} + for(var i=0, n=items.length; i