Code Duplication    Length = 96-108 lines in 2 locations

styles/admin/bower_components/datatables.net/js/jquery.dataTables.js 2 locations

@@ 2693-2800 (lines=108) @@
2690
	 */
2691
	function _fnSetObjectDataFn( mSource )
2692
	{
2693
		if ( $.isPlainObject( mSource ) )
2694
		{
2695
			/* Unlike get, only the underscore (global) option is used for for
2696
			 * setting data since we don't know the type here. This is why an object
2697
			 * option is not documented for `mData` (which is read/write), but it is
2698
			 * for `mRender` which is read only.
2699
			 */
2700
			return _fnSetObjectDataFn( mSource._ );
2701
		}
2702
		else if ( mSource === null )
2703
		{
2704
			/* Nothing to do when the data source is null */
2705
			return function () {};
2706
		}
2707
		else if ( typeof mSource === 'function' )
2708
		{
2709
			return function (data, val, meta) {
2710
				mSource( data, 'set', val, meta );
2711
			};
2712
		}
2713
		else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
2714
			      mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
2715
		{
2716
			/* Like the get, we need to get data from a nested object */
2717
			var setData = function (data, val, src) {
2718
				var a = _fnSplitObjNotation( src ), b;
2719
				var aLast = a[a.length-1];
2720
				var arrayNotation, funcNotation, o, innerSrc;
2721
	
2722
				for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
2723
				{
2724
					// Check if we are dealing with an array notation request
2725
					arrayNotation = a[i].match(__reArray);
2726
					funcNotation = a[i].match(__reFn);
2727
	
2728
					if ( arrayNotation )
2729
					{
2730
						a[i] = a[i].replace(__reArray, '');
2731
						data[ a[i] ] = [];
2732
	
2733
						// Get the remainder of the nested object to set so we can recurse
2734
						b = a.slice();
2735
						b.splice( 0, i+1 );
2736
						innerSrc = b.join('.');
2737
	
2738
						// Traverse each entry in the array setting the properties requested
2739
						if ( $.isArray( val ) )
2740
						{
2741
							for ( var j=0, jLen=val.length ; j<jLen ; j++ )
2742
							{
2743
								o = {};
2744
								setData( o, val[j], innerSrc );
2745
								data[ a[i] ].push( o );
2746
							}
2747
						}
2748
						else
2749
						{
2750
							// We've been asked to save data to an array, but it
2751
							// isn't array data to be saved. Best that can be done
2752
							// is to just save the value.
2753
							data[ a[i] ] = val;
2754
						}
2755
	
2756
						// The inner call to setData has already traversed through the remainder
2757
						// of the source and has set the data, thus we can exit here
2758
						return;
2759
					}
2760
					else if ( funcNotation )
2761
					{
2762
						// Function call
2763
						a[i] = a[i].replace(__reFn, '');
2764
						data = data[ a[i] ]( val );
2765
					}
2766
	
2767
					// If the nested object doesn't currently exist - since we are
2768
					// trying to set the value - create it
2769
					if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
2770
					{
2771
						data[ a[i] ] = {};
2772
					}
2773
					data = data[ a[i] ];
2774
				}
2775
	
2776
				// Last item in the input - i.e, the actual set
2777
				if ( aLast.match(__reFn ) )
2778
				{
2779
					// Function call
2780
					data = data[ aLast.replace(__reFn, '') ]( val );
2781
				}
2782
				else
2783
				{
2784
					// If array notation is used, we just want to strip it and use the property name
2785
					// and assign the value. If it isn't used, then we get the result we want anyway
2786
					data[ aLast.replace(__reArray, '') ] = val;
2787
				}
2788
			};
2789
	
2790
			return function (data, val) { // meta is also passed in, but not used
2791
				return setData( data, val, mSource );
2792
			};
2793
		}
2794
		else
2795
		{
2796
			/* Array or flat object mapping */
2797
			return function (data, val) { // meta is also passed in, but not used
2798
				data[mSource] = val;
2799
			};
2800
		}
2801
	}
2802
	
2803
	
@@ 2585-2680 (lines=96) @@
2582
					data;
2583
			};
2584
		}
2585
		else if ( mSource === null )
2586
		{
2587
			/* Give an empty string for rendering / sorting etc */
2588
			return function (data) { // type, row and meta also passed, but not used
2589
				return data;
2590
			};
2591
		}
2592
		else if ( typeof mSource === 'function' )
2593
		{
2594
			return function (data, type, row, meta) {
2595
				return mSource( data, type, row, meta );
2596
			};
2597
		}
2598
		else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
2599
			      mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
2600
		{
2601
			/* If there is a . in the source string then the data source is in a
2602
			 * nested object so we loop over the data for each level to get the next
2603
			 * level down. On each loop we test for undefined, and if found immediately
2604
			 * return. This allows entire objects to be missing and sDefaultContent to
2605
			 * be used if defined, rather than throwing an error
2606
			 */
2607
			var fetchData = function (data, type, src) {
2608
				var arrayNotation, funcNotation, out, innerSrc;
2609
	
2610
				if ( src !== "" )
2611
				{
2612
					var a = _fnSplitObjNotation( src );
2613
	
2614
					for ( var i=0, iLen=a.length ; i<iLen ; i++ )
2615
					{
2616
						// Check if we are dealing with special notation
2617
						arrayNotation = a[i].match(__reArray);
2618
						funcNotation = a[i].match(__reFn);
2619
	
2620
						if ( arrayNotation )
2621
						{
2622
							// Array notation
2623
							a[i] = a[i].replace(__reArray, '');
2624
	
2625
							// Condition allows simply [] to be passed in
2626
							if ( a[i] !== "" ) {
2627
								data = data[ a[i] ];
2628
							}
2629
							out = [];
2630
	
2631
							// Get the remainder of the nested object to get
2632
							a.splice( 0, i+1 );
2633
							innerSrc = a.join('.');
2634
	
2635
							// Traverse each entry in the array getting the properties requested
2636
							if ( $.isArray( data ) ) {
2637
								for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
2638
									out.push( fetchData( data[j], type, innerSrc ) );
2639
								}
2640
							}
2641
	
2642
							// If a string is given in between the array notation indicators, that
2643
							// is used to join the strings together, otherwise an array is returned
2644
							var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
2645
							data = (join==="") ? out : out.join(join);
2646
	
2647
							// The inner call to fetchData has already traversed through the remainder
2648
							// of the source requested, so we exit from the loop
2649
							break;
2650
						}
2651
						else if ( funcNotation )
2652
						{
2653
							// Function call
2654
							a[i] = a[i].replace(__reFn, '');
2655
							data = data[ a[i] ]();
2656
							continue;
2657
						}
2658
	
2659
						if ( data === null || data[ a[i] ] === undefined )
2660
						{
2661
							return undefined;
2662
						}
2663
						data = data[ a[i] ];
2664
					}
2665
				}
2666
	
2667
				return data;
2668
			};
2669
	
2670
			return function (data, type) { // row and meta also passed, but not used
2671
				return fetchData( data, type, mSource );
2672
			};
2673
		}
2674
		else
2675
		{
2676
			/* Array or flat object mapping */
2677
			return function (data, type) { // row and meta also passed, but not used
2678
				return data[mSource];
2679
			};
2680
		}
2681
	}
2682
	
2683