-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrCompare.html
More file actions
74 lines (70 loc) · 2.28 KB
/
arrCompare.html
File metadata and controls
74 lines (70 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!doctype <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
function compareArray(arrA, arrB) {
var same = 1;
var getA = [],
getB = [];
if (!!arrA && !!arrB && (arrA.length == arrB.length)) {
for (var m = 0, Alen = arrA.length; m < Alen; m++) {
getA.push(arrA[m]);
}
for (var n = 0, Blen = arrB.length; n < Blen; n++) {
getB.push(arrB[n]);
}
var l = getA.length;
for (var i = 0; i < l; i++) {
if (!same) {
break;
}
for (var j = 0; j < l; j++) {
if ($.type(getA[i]) == $.type(getB[j])) {
if ($.type(getA[i]) == "object") {
var xcount = 1,
x_count = 1,
ycount = 1;
for (var x in getA[i]) {
xcount += 1;
if (getA[i][x] == getB[j][x]) {
x_count += 1;
}
}
for (var y in getB[j]) {
ycount += 1;
}
if (xcount == x_count && xcount == ycount) {
getB.splice(j, 1);
getA.splice(i, 1);
i--;
l--;
break;
}
} else if (getA[i] == getB[j]) {
getB.splice(j, 1);
getA.splice(i, 1);
i--;
l--;
break;
}
}
if (j == l - 1) {
same = 0;
break;
}
}
}
} else if (!arrA && !arrB) {
same = 1;
} else {
same = 0;
}
return same;
}
</script>
</body>
</html>