From 372fc54e2d4b35b9c98907c95c13e0ebeca73d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 May 2013 18:24:35 +0200 Subject: [PATCH] Better Array comparison that works to compare Array inside Array --- src/common.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/common.js b/src/common.js index 9851923bf5..0c5410d5d5 100644 --- a/src/common.js +++ b/src/common.js @@ -13,8 +13,19 @@ Sao.common.F3_KEYCODE = 114; Sao.common.compare = function(arr1, arr2) { - return (jQuery(arr1).not(arr2).length === 0 && - jQuery(arr2).not(arr1).length === 0); + if (arr1.length != arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; i++) { + if (arr1[i] instanceof Array && arr2[i] instanceof Array) { + if (!Sao.common.compare(arr1[i], arr2[i])) { + return false; + } + } else if (arr1[i] != arr2[i]) { + return false; + } + } + return true; }; // Find the intersection of two arrays.