Code Duplication    Length = 88-93 lines in 2 locations

api/js/etemplate/test/jquery.js 1 location

@@ 4807-4899 (lines=93) @@
4804
4805
var sortOrder, siblingCheck;
4806
4807
if ( document.documentElement.compareDocumentPosition ) {
4808
	sortOrder = function( a, b ) {
4809
		if ( a === b ) {
4810
			hasDuplicate = true;
4811
			return 0;
4812
		}
4813
4814
		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4815
			return a.compareDocumentPosition ? -1 : 1;
4816
		}
4817
4818
		return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4819
	};
4820
4821
} else {
4822
	sortOrder = function( a, b ) {
4823
		// The nodes are identical, we can exit early
4824
		if ( a === b ) {
4825
			hasDuplicate = true;
4826
			return 0;
4827
4828
		// Fallback to using sourceIndex (in IE) if it's available on both nodes
4829
		} else if ( a.sourceIndex && b.sourceIndex ) {
4830
			return a.sourceIndex - b.sourceIndex;
4831
		}
4832
4833
		var al, bl,
4834
			ap = [],
4835
			bp = [],
4836
			aup = a.parentNode,
4837
			bup = b.parentNode,
4838
			cur = aup;
4839
4840
		// If the nodes are siblings (or identical) we can do a quick check
4841
		if ( aup === bup ) {
4842
			return siblingCheck( a, b );
4843
4844
		// If no parents were found then the nodes are disconnected
4845
		} else if ( !aup ) {
4846
			return -1;
4847
4848
		} else if ( !bup ) {
4849
			return 1;
4850
		}
4851
4852
		// Otherwise they're somewhere else in the tree so we need
4853
		// to build up a full list of the parentNodes for comparison
4854
		while ( cur ) {
4855
			ap.unshift( cur );
4856
			cur = cur.parentNode;
4857
		}
4858
4859
		cur = bup;
4860
4861
		while ( cur ) {
4862
			bp.unshift( cur );
4863
			cur = cur.parentNode;
4864
		}
4865
4866
		al = ap.length;
4867
		bl = bp.length;
4868
4869
		// Start walking down the tree looking for a discrepancy
4870
		for ( var i = 0; i < al && i < bl; i++ ) {
4871
			if ( ap[i] !== bp[i] ) {
4872
				return siblingCheck( ap[i], bp[i] );
4873
			}
4874
		}
4875
4876
		// We ended someplace up the tree so do a sibling check
4877
		return i === al ?
4878
			siblingCheck( a, bp[i], -1 ) :
4879
			siblingCheck( ap[i], b, 1 );
4880
	};
4881
4882
	siblingCheck = function( a, b, ret ) {
4883
		if ( a === b ) {
4884
			return ret;
4885
		}
4886
4887
		var cur = a.nextSibling;
4888
4889
		while ( cur ) {
4890
			if ( cur === b ) {
4891
				return -1;
4892
			}
4893
4894
			cur = cur.nextSibling;
4895
		}
4896
4897
		return 1;
4898
	};
4899
}
4900
4901
// Check to see if the browser returns elements by name when
4902
// querying by getElementById (and provide a workaround)

api/js/egw_action/test/js/jquery.js 1 location

@@ 4148-4235 (lines=88) @@
4145
4146
var sortOrder, siblingCheck;
4147
4148
if ( document.documentElement.compareDocumentPosition ) {
4149
	sortOrder = function( a, b ) {
4150
		if ( a === b ) {
4151
			hasDuplicate = true;
4152
			return 0;
4153
		}
4154
4155
		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4156
			return a.compareDocumentPosition ? -1 : 1;
4157
		}
4158
4159
		return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4160
	};
4161
4162
} else {
4163
	sortOrder = function( a, b ) {
4164
		var al, bl,
4165
			ap = [],
4166
			bp = [],
4167
			aup = a.parentNode,
4168
			bup = b.parentNode,
4169
			cur = aup;
4170
4171
		// The nodes are identical, we can exit early
4172
		if ( a === b ) {
4173
			hasDuplicate = true;
4174
			return 0;
4175
4176
		// If the nodes are siblings (or identical) we can do a quick check
4177
		} else if ( aup === bup ) {
4178
			return siblingCheck( a, b );
4179
4180
		// If no parents were found then the nodes are disconnected
4181
		} else if ( !aup ) {
4182
			return -1;
4183
4184
		} else if ( !bup ) {
4185
			return 1;
4186
		}
4187
4188
		// Otherwise they're somewhere else in the tree so we need
4189
		// to build up a full list of the parentNodes for comparison
4190
		while ( cur ) {
4191
			ap.unshift( cur );
4192
			cur = cur.parentNode;
4193
		}
4194
4195
		cur = bup;
4196
4197
		while ( cur ) {
4198
			bp.unshift( cur );
4199
			cur = cur.parentNode;
4200
		}
4201
4202
		al = ap.length;
4203
		bl = bp.length;
4204
4205
		// Start walking down the tree looking for a discrepancy
4206
		for ( var i = 0; i < al && i < bl; i++ ) {
4207
			if ( ap[i] !== bp[i] ) {
4208
				return siblingCheck( ap[i], bp[i] );
4209
			}
4210
		}
4211
4212
		// We ended someplace up the tree so do a sibling check
4213
		return i === al ?
4214
			siblingCheck( a, bp[i], -1 ) :
4215
			siblingCheck( ap[i], b, 1 );
4216
	};
4217
4218
	siblingCheck = function( a, b, ret ) {
4219
		if ( a === b ) {
4220
			return ret;
4221
		}
4222
4223
		var cur = a.nextSibling;
4224
4225
		while ( cur ) {
4226
			if ( cur === b ) {
4227
				return -1;
4228
			}
4229
4230
			cur = cur.nextSibling;
4231
		}
4232
4233
		return 1;
4234
	};
4235
}
4236
4237
// Utility function for retreiving the text value of an array of DOM nodes
4238
Sizzle.getText = function( elems ) {