src/main/webapp/js/singlepage-interface.js
/**
	 * Convert a blacklab-server reply containing information about hit or document groups into a table containing the results.
	 * Some minor styling is applied based on whether the results are hits or documents.
	 *
	 * @param {any} data the blacklab-server response.
	 * @returns An array of html strings containing the <thead> and <tbody>, but without the enclosing <table> element.
	 */
Convert a blacklab-server reply containing information about hit or document groups into a table containing the results.
Some minor styling is applied based on whether the results are hits or documents.

@param {any} data the blacklab-server response.
@returns An array of html strings containing the  and , but without the enclosing  element.
Convert a blacklab - server reply containing information about hit or document groups into a table containing the results . Some minor styling is applied based on whether the results are hits or documents . @param { any } data the blacklab - server response . @returns An array of html strings containing the and but without the enclosing element .
function formatGroups(data) {
		var html = [];
		html.push(
			'<thead><tr>',
				'<th style="width:30%;"><a data-bls-sort="identity">Group</a></th>',
				'<th style="width:70%;"><a data-bls-sort="numhits">Hits</a></th>',
			'</tr></thead>'
		);
		var displayClass = data.hitGroups ? 'progress-bar-success' : 'progress-bar-warning';
		var idPrefix = data.hitGroups ? 'hg' : 'dg'; 
		html.push('<tbody>');
		var groups = data.hitGroups || data.docGroups;
		$.each(groups, function(index, group) {
			var groupId = group.identity;
			var htmlId = idPrefix + index;
			var displayName = group.identityDisplay;
			var displayWidth = (group.size / data.summary.largestGroupSize) * 100;
			html.push(
				'<tr>',
					'<td>', displayName, '</td>',
					'<td>',
						'<div class="progress group-size-indicator" data-toggle="collapse" data-target="#', htmlId, '" style="cursor:pointer;">',
							'<div class="progress-bar ', displayClass, '" style="min-width: ', displayWidth, '%;">', group.size, '</div>',
						'</div>',
						'<div class="collapse inline-concordance" id="', htmlId, '">',
							'<div>',
								'<button type="button" class="btn btn-sm btn-link viewconcordances" data-group-name="', displayName, '" data-group-id="', groupId, '">&#171; View detailed concordances in this group</button> - ',
								'<button type="button" class="btn btn-sm btn-link loadconcordances" data-group-id="', groupId, '">Load more concordances...</button>',
							'</div>',
						'</div>',
					'</td>',
				'</tr>');
		});
		html.push('</tbody>');
		return html;
	}
function formatGroups ( data ) { var html = [ ] ; html . push ( '<thead><tr>' , '<th style="width:30%;"><a data-bls-sort="identity">Group</a></th>' , '<th style="width:70%;"><a data-bls-sort="numhits">Hits</a></th>' , '</tr></thead>' ) ; var displayClass = data . hitGroups ? 'progress-bar-success' : 'progress-bar-warning' ; var idPrefix = data . hitGroups ? 'hg' : 'dg' ; html . push ( '<tbody>' ) ; var groups = data . hitGroups || data . docGroups ; $ . each ( groups , function ( index , group ) { var groupId = group . identity ; var htmlId = idPrefix + index ; var displayName = group . identityDisplay ; var displayWidth = ( group . size / data . summary . largestGroupSize ) * 100 ; html . push ( '<tr>' , '<td>' , displayName , '</td>' , '<td>' , '<div class="progress group-size-indicator" data-toggle="collapse" data-target="#' , htmlId , '" style="cursor:pointer;">' , '<div class="progress-bar ' , displayClass , '" style="min-width: ' , displayWidth , '%;">' , group . size , '</div>' , '</div>' , '<div class="collapse inline-concordance" id="' , htmlId , '">' , '<div>' , '<button type="button" class="btn btn-sm btn-link viewconcordances" data-group-name="' , displayName , '" data-group-id="' , groupId , '">&#171; View detailed concordances in this group</button> - ' , '<button type="button" class="btn btn-sm btn-link loadconcordances" data-group-id="' , groupId , '">Load more concordances...</button>' , '</div>' , '</div>' , '</td>' , '</tr>' ) ; } ) ; html . push ( '</tbody>' ) ; return html ; }
Convert a blacklab-server reply containing information about hit or document groups into a table containing the results.
Convert a blacklab - server reply containing information about hit or document groups into a table containing the results .
// give the display a different color based on whether we're showing hits or docs // hitgroup : docgroup