<commit_before>define([ "jquery", "message-bus", "datatables" ], function($, bus) {
	var ORDER_COLUMN_TYPE = "__gb__sorting__column_type__";

	function sortSelectedFirst(settings, col) {
		// We always get the first column because we won't use data at all
		// for ordering. We just the "selected" class of the <tr> element.
		var column = this.api().column(0, {
			order : "index"
		});
		return column.nodes().map(function(td, i) {
			return $(td).closest("tr").hasClass("selected") ? 0 : 1;
		});
	}

	bus.listen("ui-table:create", function(e, msg) {
		var table;
		var headers;
		var fields;

		var id = msg.div;
		var css = msg.css;

		var translations = msg.messages || {};
		var div = $("<div/>").attr("id", id);
		div.addClass(css);

		$("#" + msg.parentDiv).append(div);

		bus.listen("ui-table:" + id + ":clear", function() {
			div.empty();
			table = null;
		});

		bus.listen("ui-table:" + id + ":set-data", function(e, msg) {
			div.empty();
			fields = msg.fields;
			headers = Object.keys(msg.fields);

			table = $("<table/>").appendTo(div);
			table.addClass(css);
			var head = $("<thead/>").appendTo(table);

			var tr = $("<tr/>").appendTo(head);
			for (var i = 0; i < headers.length; i++) {
				$("<th/>").html(headers[i]).appendTo(tr);
			}
			// Add empty header column to be used for custom ordering
			$("<th/>").appendTo(tr);

			for (var i = 0; i < msg.data.length; i++) {
				var tr = $("<tr/>").appendTo(table);
				for (var j = 0; j < headers.length; j++) {
					var fieldName = msg.fields[headers[j]];
					$("<td/>").html(msg.data[i][fieldName]).appendTo(tr);
				}
				// Add hidden column with empty values to be used for custom
				// ordering
				$("<td/>").appendTo(tr);
			}

			table = table.DataTable({
				"pageLength" : 7,
				"scrollX" : true,
				"lengthChange" : false,
				"columnDefs" : [ {
					"orderDataType" : ORDER_COLUMN_TYPE,
					"targets" : [ headers.length ],
					"visible" : false
				} ],
				"language" : translations
			});

			table.on("click", "tr", function() {
				$(this).toggleClass("selected");

				var rows = table.rows(".selected").data().toArray();
				var selection = [];
				for (var i = 0; i < rows.length; i++) {
					var obj = {};
					for (var j = 0; j < headers.length; j++) {
						var fieldName = msg.fields[headers[j]];
						obj[fieldName] = rows[i][j];
					}
					selection.push(obj);
				}
<commit_msg>Change number of rows by page on ui-table. Refs #1996<commit_after>define([ "jquery", "message-bus", "datatables" ], function($, bus) {
	var ORDER_COLUMN_TYPE = "__gb__sorting__column_type__";

	function sortSelectedFirst(settings, col) {
		// We always get the first column because we won't use data at all
		// for ordering. We just the "selected" class of the <tr> element.
		var column = this.api().column(0, {
			order : "index"
		});
		return column.nodes().map(function(td, i) {
			return $(td).closest("tr").hasClass("selected") ? 0 : 1;
		});
	}

	bus.listen("ui-table:create", function(e, msg) {
		var table;
		var headers;
		var fields;

		var id = msg.div;
		var css = msg.css;

		var translations = msg.messages || {};
		var div = $("<div/>").attr("id", id);
		div.addClass(css);

		$("#" + msg.parentDiv).append(div);

		bus.listen("ui-table:" + id + ":clear", function() {
			div.empty();
			table = null;
		});

		bus.listen("ui-table:" + id + ":set-data", function(e, msg) {
			div.empty();
			fields = msg.fields;
			headers = Object.keys(msg.fields);

			table = $("<table/>").appendTo(div);
			table.addClass(css);
			var head = $("<thead/>").appendTo(table);

			var tr = $("<tr/>").appendTo(head);
			for (var i = 0; i < headers.length; i++) {
				$("<th/>").html(headers[i]).appendTo(tr);
			}
			// Add empty header column to be used for custom ordering
			$("<th/>").appendTo(tr);

			for (var i = 0; i < msg.data.length; i++) {
				var tr = $("<tr/>").appendTo(table);
				for (var j = 0; j < headers.length; j++) {
					var fieldName = msg.fields[headers[j]];
					$("<td/>").html(msg.data[i][fieldName]).appendTo(tr);
				}
				// Add hidden column with empty values to be used for custom
				// ordering
				$("<td/>").appendTo(tr);
			}

			table = table.DataTable({
				"pageLength" : 15,
				"scrollX" : true,
				"lengthChange" : false,
				"columnDefs" : [ {
					"orderDataType" : ORDER_COLUMN_TYPE,
					"targets" : [ headers.length ],
					"visible" : false
				} ],
				"language" : translations
			});

			table.on("click", "tr", function() {
				$(this).toggleClass("selected");

				var rows = table.rows(".selected").data().toArray();
				var selection = [];
				for (var i = 0; i < rows.length; i++) {
					var obj = {};
					for (var j = 0; j < headers.length; j++) {
						var fieldName = msg.fields[headers[j]];
						obj[fieldName] = rows[i][j];
					}
					selection.push(obj);
				}

{'fraction_non_alphanumeric': 0.2025710138917686, 'fraction_numerical': 0.004768816089570807, 'mean_word_length': 2.960591133004926, 'pattern_counts': {'":': 4, '<': 33, '<?xml version=': 0, '>': 23, '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': '3216980', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1657, 'n_words': 407}