Merge branch 'connector' into 4.0

This commit is contained in:
Simon Kornblith 2015-09-28 20:28:38 -04:00
commit 310ff1cf53

View file

@ -174,13 +174,14 @@ Zotero.Translate.ItemSaver.prototype = {
* attachmentCallback() will be called with all attachments that will be saved * attachmentCallback() will be called with all attachments that will be saved
*/ */
"_saveToServer":function(items, callback, attachmentCallback) { "_saveToServer":function(items, callback, attachmentCallback) {
var newItems = [], typedArraysSupported = false; var newItems = [], itemIndices = [], typedArraysSupported = false;
try { try {
typedArraysSupported = !!(new Uint8Array(1) && new Blob()); typedArraysSupported = !!(new Uint8Array(1) && new Blob());
} catch(e) {} } catch(e) {}
for(var i=0, n=items.length; i<n; i++) { for(var i=0, n=items.length; i<n; i++) {
var item = items[i]; var item = items[i];
itemIndices[i] = newItems.length;
newItems = newItems.concat(Zotero.Utilities.itemToServerJSON(item)); newItems = newItems.concat(Zotero.Utilities.itemToServerJSON(item));
if(typedArraysSupported) { if(typedArraysSupported) {
for(var j=0; j<item.attachments.length; j++) { for(var j=0; j<item.attachments.length; j++) {
@ -214,9 +215,8 @@ Zotero.Translate.ItemSaver.prototype = {
function(prefs) { function(prefs) {
if(typedArraysSupported) { if(typedArraysSupported) {
Zotero.debug(response); for(var i=0; i<items.length; i++) {
for(var i in resp.success) { var item = items[i], key = resp.success[itemIndices[i]];
var item = items[i], key = resp.success[i];
if(item.attachments && item.attachments.length) { if(item.attachments && item.attachments.length) {
me._saveAttachmentsToServer(key, me._getFileBaseNameFromItem(item), me._saveAttachmentsToServer(key, me._getFileBaseNameFromItem(item),
item.attachments, prefs, attachmentCallback); item.attachments, prefs, attachmentCallback);