<commit_before>function dataTableRESTAdapter( sSource, aoData, fnCallback ) {

	//extract name/value pairs into a simpler map for use later
	var paramMap = {};
	for ( var i = 0; i < aoData.length; i++ ) {
		paramMap[aoData[i].name] = aoData[i].value;
	}

	//page calculations
	var pageSize = paramMap.iDisplayLength;
	var start = paramMap.iDisplayStart;
	var pageNum = (start == 0) ? 1 : (start / pageSize) + 1; // pageNum is 1 based

	// extract sort information
	var sortCol = paramMap.iSortCol_0;
	var sortDir = paramMap.sSortDir_0;
	var sortName = paramMap['mDataProp_' + sortCol];

	//create new json structure for parameters for REST request
	var restParams = new Array();
	restParams.push( {"name":"limit", "value":pageSize} );
	restParams.push( {"name":"page", "value":pageNum } );
	restParams.push( { "name":"sort", "value":sortName } );
	restParams.push( { "name":sortName + ".dir", "value":sortDir } );

	jQuery.ajax( {
					 "dataType":'json',
					 "type":"GET",
					 "url":sSource,
					 "data":restParams,
					 "success":function ( data ) {
						 data.iTotalRecords = data.page.totalElements;
						 data.iTotalDisplayRecords = data.page.totalElements;

						 fnCallback( data );
					 }
				 } );
}

function extractStrValue( dataValue ) {
	if ( dataValue instanceof Array ) {
		var items = '';
		for (var arrayIndex in dataValue) {
			var arrayItem = dataValue[arrayIndex];
			if ( arrayItem['stringRepresentation'] !== undefined) {
				items += arrayItem['stringRepresentation'] + '<br/>';
			}
		}
		return items;
	}

	if (typeof dataValue === 'object' && dataValue['stringRepresentation'] !== undefined) {
		return dataValue['stringRepresentation'];
	}

	return dataValue;
}

function quickLook( aData ) {
	var detailsHtmlBlock = '<div class="innerDetails"><dl class="dl-horizontal">';

	for (var prop in aData) {
		if ( prop != 'links' && prop != 'stringRepresentation') {
			var name = aData[prop]['name'] !== undefined ? aData[prop]['name'] : prop;
			var value = aData[prop]['value'] !== undefined ? aData[prop]['value'] : aData[prop];
			detailsHtmlBlock += '<dt>' + name + '</dt>';
			value = extractStrValue( value );
			detailsHtmlBlock += '<dd>' + ( value == '' ? '&nbsp;' : value ) + '</dd>';
		}
	}
	detailsHtmlBlock += '</dl></div>';

	return detailsHtmlBlock;
}

/* Add event listener for opening and closing details
 * Note that the indicator for showing which row is open is not controlled by DataTables,
 * rather it is done here
 */
function bindInfoClickHandlers( tableElement, dataTable ) {
	$( 'tbody td img', $(tableElement) ).live( 'click', function () {
		var infoImg = $( this );
		var nTr = infoImg.parents( 'tr' )[0];
		if ( dataTable.fnIsOpen( nTr ) ) {
			$('div.innerDetails', $(nTr).next()[0]).slideUp('slow', function () {
				dataTable.fnClose( nTr );
				infoImg.attr('src', "../images/details_open.png");
			});
		} else {
			var aData = dataTable.fnGetData( nTr );
			var restEntityUrl = aData.links[0].href;
			jQuery.ajax( {
				 "dataType" : 'json',
				 "type" : "GET",
				 "url" : restEntityUrl,
				 "success":function ( data ) {
					 var nDetailsRow = dataTable.fnOpen( nTr, quickLook( data ), 'details' );
					 $('div.innerDetails', nDetailsRow).hide();
					 $('div.innerDetails', nDetailsRow).slideDown('slow', function () {
						 infoImg.attr('src', "../images/details_close.png");
					 });
				 }
			} );
		}
	} );
}<commit_msg>Dynamic button title for showing/hiding Quick View<commit_after>function dataTableRESTAdapter( sSource, aoData, fnCallback ) {

	//extract name/value pairs into a simpler map for use later
	var paramMap = {};
	for ( var i = 0; i < aoData.length; i++ ) {
		paramMap[aoData[i].name] = aoData[i].value;
	}

	//page calculations
	var pageSize = paramMap.iDisplayLength;
	var start = paramMap.iDisplayStart;
	var pageNum = (start == 0) ? 1 : (start / pageSize) + 1; // pageNum is 1 based

	// extract sort information
	var sortCol = paramMap.iSortCol_0;
	var sortDir = paramMap.sSortDir_0;
	var sortName = paramMap['mDataProp_' + sortCol];

	//create new json structure for parameters for REST request
	var restParams = new Array();
	restParams.push( {"name":"limit", "value":pageSize} );
	restParams.push( {"name":"page", "value":pageNum } );
	restParams.push( { "name":"sort", "value":sortName } );
	restParams.push( { "name":sortName + ".dir", "value":sortDir } );

	jQuery.ajax( {
					 "dataType":'json',
					 "type":"GET",
					 "url":sSource,
					 "data":restParams,
					 "success":function ( data ) {
						 data.iTotalRecords = data.page.totalElements;
						 data.iTotalDisplayRecords = data.page.totalElements;

						 fnCallback( data );
					 }
				 } );
}

function extractStrValue( dataValue ) {
	if ( dataValue instanceof Array ) {
		var items = '';
		for (var arrayIndex in dataValue) {
			var arrayItem = dataValue[arrayIndex];
			if ( arrayItem['stringRepresentation'] !== undefined) {
				items += arrayItem['stringRepresentation'] + '<br/>';
			}
		}
		return items;
	}

	if (typeof dataValue === 'object' && dataValue['stringRepresentation'] !== undefined) {
		return dataValue['stringRepresentation'];
	}

	return dataValue;
}

function quickLook( aData ) {
	var detailsHtmlBlock = '<div class="innerDetails"><dl class="dl-horizontal">';

	for (var prop in aData) {
		if ( prop != 'links' && prop != 'stringRepresentation') {
			var name = aData[prop]['name'] !== undefined ? aData[prop]['name'] : prop;
			var value = aData[prop]['value'] !== undefined ? aData[prop]['value'] : aData[prop];
			detailsHtmlBlock += '<dt>' + name + '</dt>';
			value = extractStrValue( value );
			detailsHtmlBlock += '<dd>' + ( value == '' ? '&nbsp;' : value ) + '</dd>';
		}
	}
	detailsHtmlBlock += '</dl></div>';

	return detailsHtmlBlock;
}

/* Add event listener for opening and closing details
 * Note that the indicator for showing which row is open is not controlled by DataTables,
 * rather it is done here
 */
function bindInfoClickHandlers( tableElement, dataTable ) {
	$( 'tbody td img', $(tableElement) ).live( 'click', function () {
		var infoImg = $( this );
		var nTr = infoImg.parents( 'tr' )[0];
		if ( dataTable.fnIsOpen( nTr ) ) {
			$('div.innerDetails', $(nTr).next()[0]).slideUp('slow', function () {
				dataTable.fnClose( nTr );
				infoImg.attr('src', "../images/details_open.png");
				infoImg.attr('title', "Click to show Info");
			});
		} else {
			var aData = dataTable.fnGetData( nTr );
			var restEntityUrl = aData.links[0].href;
			jQuery.ajax( {
				 "dataType" : 'json',
				 "type" : "GET",
				 "url" : restEntityUrl,
				 "success":function ( data ) {
					 var nDetailsRow = dataTable.fnOpen( nTr, quickLook( data ), 'details' );
					 $('div.innerDetails', nDetailsRow).hide();
					 $('div.innerDetails', nDetailsRow).slideDown('slow', function () {
						 infoImg.attr('src', "../images/details_close.png");
						 infoImg.attr('title', "Click to hide Info");
					 });
				 }
			} );
		}
	} );
}
{'fraction_non_alphanumeric': 0.17060178520011518, 'fraction_numerical': 0.0028793550244745176, 'mean_word_length': 3.659289067739772, 'pattern_counts': {'":': 28, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3627690', 'n_tokens_mistral': 2520, 'n_tokens_neox': 2173, 'n_words': 552}