Reverse Zotero.Utilities.prototype.arrayDiff operator order to be consistent with PHP's array_diff
This commit is contained in:
parent
6ca230379d
commit
f4544bd386
|
@ -119,8 +119,8 @@ Zotero.Commons = new function() {
|
|||
|
||||
// newPrefBucketNames currently contains intersection
|
||||
// of prefBucketNames and iaBucketNames
|
||||
var askToAddBuckets = zu.arrayDiff(newPrefBucketNames, iaBucketNames);
|
||||
var askToRemoveBuckets = zu.arrayDiff(newPrefBucketNames, prefBucketNames);
|
||||
var askToAddBuckets = zu.arrayDiff(iaBucketNames, newPrefBucketNames);
|
||||
var askToRemoveBuckets = zu.arrayDiff(prefBucketNames, newPrefBucketNames);
|
||||
|
||||
// prompt user about adding buckets
|
||||
for(var i = 0, len = askToAddBuckets.length; i < len; i++) {
|
||||
|
|
|
@ -820,16 +820,16 @@ Zotero.Collection.prototype.diff = function (collection, includeMatches, ignoreO
|
|||
|
||||
// For the moment, just compare children and increase numDiffs if any differences
|
||||
var d1 = Zotero.Utilities.prototype.arrayDiff(
|
||||
otherData.childCollections, thisData.childCollections
|
||||
);
|
||||
var d2 = Zotero.Utilities.prototype.arrayDiff(
|
||||
thisData.childCollections, otherData.childCollections
|
||||
);
|
||||
var d2 = Zotero.Utilities.prototype.arrayDiff(
|
||||
otherData.childCollections, thisData.childCollections
|
||||
);
|
||||
var d3 = Zotero.Utilities.prototype.arrayDiff(
|
||||
otherData.childItems, thisData.childItems
|
||||
thisData.childItems, otherData.childItems
|
||||
);
|
||||
var d4 = Zotero.Utilities.prototype.arrayDiff(
|
||||
thisData.childItems, otherData.childItems
|
||||
otherData.childItems, thisData.childItems
|
||||
);
|
||||
numDiffs += d1.length + d2.length;
|
||||
|
||||
|
|
|
@ -369,8 +369,8 @@ Zotero.Tag.prototype.save = function (full) {
|
|||
var sql = "SELECT itemID FROM itemTags WHERE tagID=?";
|
||||
var dbItemIDs = Zotero.DB.columnQuery(sql, tagID);
|
||||
if (dbItemIDs) {
|
||||
removed = Zotero.Utilities.prototype.arrayDiff(currentIDs, dbItemIDs);
|
||||
newids = Zotero.Utilities.prototype.arrayDiff(dbItemIDs, currentIDs);
|
||||
removed = Zotero.Utilities.prototype.arrayDiff(dbItemIDs, currentIDs);
|
||||
newids = Zotero.Utilities.prototype.arrayDiff(currentIDs, dbItemIDs);
|
||||
}
|
||||
else {
|
||||
newids = currentIDs;
|
||||
|
@ -379,10 +379,10 @@ Zotero.Tag.prototype.save = function (full) {
|
|||
else {
|
||||
if (this._previousData.linkedItems) {
|
||||
removed = Zotero.Utilities.prototype.arrayDiff(
|
||||
currentIDs, this._previousData.linkedItems
|
||||
this._previousData.linkedItems, currentIDs
|
||||
);
|
||||
newids = Zotero.Utilities.prototype.arrayDiff(
|
||||
this._previousData.linkedItems, currentIDs
|
||||
currentIDs, this._previousData.linkedItems
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -471,10 +471,10 @@ Zotero.Tag.prototype.diff = function (tag, includeMatches, ignoreOnlyDateModifie
|
|||
|
||||
// For the moment, just compare linked items and increase numDiffs if any differences
|
||||
var d1 = Zotero.Utilities.prototype.arrayDiff(
|
||||
thisData.linkedItems, otherData.linkedItems
|
||||
otherData.linkedItems, thisData.linkedItems
|
||||
);
|
||||
var d2 = Zotero.Utilities.prototype.arrayDiff(
|
||||
otherData.linkedItems, thisData.linkedItems
|
||||
thisData.linkedItems, otherData.linkedItems
|
||||
);
|
||||
numDiffs += d1.length + d2.length;
|
||||
|
||||
|
|
|
@ -2989,7 +2989,7 @@ Zotero.Sync.Server.Data = new function() {
|
|||
if (!itemIDs) {
|
||||
return false;
|
||||
}
|
||||
var newItemIDs = Zotero.Utilities.prototype.arrayDiff(childItems, itemIDs);
|
||||
var newItemIDs = Zotero.Utilities.prototype.arrayDiff(itemIDs, childItems);
|
||||
if (itemIDs.length == newItemIDs.length) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -366,10 +366,10 @@ Zotero.Utilities.prototype.isEmpty = function (obj) {
|
|||
* Compares an array with another and returns an array with
|
||||
* the values from array2 that don't exist in array1
|
||||
*
|
||||
* @param {Array} array1 Array that will be checked
|
||||
* @param {Array} array2 Array that will be compared
|
||||
* @param {Array} array1
|
||||
* @param {Array} array2
|
||||
* @param {Boolean} useIndex If true, return an array containing just
|
||||
* the index of the comparator's elements;
|
||||
* the index of array2's elements;
|
||||
* otherwise return the values
|
||||
*/
|
||||
Zotero.Utilities.prototype.arrayDiff = function(array1, array2, useIndex) {
|
||||
|
@ -381,9 +381,9 @@ Zotero.Utilities.prototype.arrayDiff = function(array1, array2, useIndex) {
|
|||
}
|
||||
|
||||
var val, pos, vals = [];
|
||||
for (var i=0; i<array2.length; i++) {
|
||||
val = array2[i];
|
||||
pos = array1.indexOf(val);
|
||||
for (var i=0; i<array1.length; i++) {
|
||||
val = array1[i];
|
||||
pos = array2.indexOf(val);
|
||||
if (pos == -1) {
|
||||
vals.push(useIndex ? pos : val);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user