commit f4544bd38651ec271f67e2505b29ff65728d270b
parent 6ca230379df5aaf65fd8fafdb276b2c1c3b73096
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 27 Dec 2009 02:11:32 +0000
Reverse Zotero.Utilities.prototype.arrayDiff operator order to be consistent with PHP's array_diff
Diffstat:
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/chrome/content/zotero/xpcom/commons.js b/chrome/content/zotero/xpcom/commons.js
@@ -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++) {
diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js
@@ -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
+ thisData.childCollections, otherData.childCollections
);
var d2 = Zotero.Utilities.prototype.arrayDiff(
- thisData.childCollections, otherData.childCollections
+ 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;
diff --git a/chrome/content/zotero/xpcom/data/tag.js b/chrome/content/zotero/xpcom/data/tag.js
@@ -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;
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -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;
}
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -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);
}