<commit_before>// objects containing the actual sensor data as string and value
var sensors = {}, gauge = {}, displays = {};
// create an array of sensor values to pass on to a graph
var numgauge = 0;
// link to the web server's IP address for socket connection
var socket = io.connect(location.host);
socket.on('connect', function () {
	socket.on('mqtt', function (msg) {
		// split the received message at the slashes
		var message = msg.topic.split('/');
		// the sensor message type is the third value
		var area = message[3];
		// pass the message topic and content to the html part
		$('#message').html(msg.topic + ', ' + msg.payload);
		var sensor = message[2]; // the sensor ID
		var value = JSON.parse(msg.payload); // the transferred payload
		var unit = '';
		// now compute the gauge
		switch (area) {
		case 'gauge':
			// Sensor handling - transfer the current values from the payload
			if (value.length == null) {
				sensors[sensor] = value;
				gauge[sensor] = value;
			} else {
				switch (value.length) {
				case 1:
					sensors[sensor] = value[0];
					gauge[sensor] = value[0];
					unit = '';
					break;
				case 2:
					sensors[sensor] = value[0] + ' ' + value[1];
					gauge[sensor] = value[0];
					unit = value[1];
					break;
				case 3:
					var date = new Date(value[0] * 1000); // the timestamp
					sensors[sensor] = value[1] + ' ' + value[2] + ' (' + date.toLocaleTimeString("en-EN") + ')';
					gauge[sensor] = value[1];
					unit = value[2];
					break;
				default:
					break;
				}
			}
			// create and fill an array of last n gauge
			// also create the corresponding table row to show - only if it not yet exists
			if (displays[sensor] == null) {
				numgauge++;
				// put always two gauges into one table row
				var tabcol = '<td style=\"vertical-align:middle;\">\
															<h4>Gauge ' + numgauge + '<br/>' +
					'<div id=\"' + sensor + '\"></div></td>';
				if (numgauge % 2 == 1) {
					var tabrow = '<tr id=\"gr' + numgauge + '\"></tr>';
					$('#gauge').append(tabrow);
					$('#gr' + numgauge).append(tabcol);
				} else
					$('#gr' + (numgauge - 1)).append(tabcol);
				displays[sensor] = new JustGage({
						id : sensor,
						value : gauge[sensor],<commit_msg>always 2 gauges per table row<commit_after>// objects containing the actual sensor data as string and value
var sensors = {}, gauge = {}, displays = {};
// create an array of sensor values to pass on to a graph
var numgauge = 0;
// link to the web server's IP address for socket connection
var socket = io.connect(location.host);
socket.on('connect', function () {
	socket.on('mqtt', function (msg) {
		// split the received message at the slashes
		var message = msg.topic.split('/');
		// the sensor message type is the third value
		var area = message[3];
		// pass the message topic and content to the html part
		$('#message').html(msg.topic + ', ' + msg.payload);
		var sensor = message[2]; // the sensor ID
		var value = JSON.parse(msg.payload); // the transferred payload
		var unit = '';
		// now compute the gauge
		switch (area) {
		case 'gauge':
			// Sensor handling - transfer the current values from the payload
			if (value.length == null) {
				sensors[sensor] = value;
				gauge[sensor] = value;
			} else {
				switch (value.length) {
				case 1:
					sensors[sensor] = value[0];
					gauge[sensor] = value[0];
					unit = '';
					break;
				case 2:
					sensors[sensor] = value[0] + ' ' + value[1];
					gauge[sensor] = value[0];
					unit = value[1];
					break;
				case 3:
					var date = new Date(value[0] * 1000); // the timestamp
					sensors[sensor] = value[1] + ' ' + value[2] + ' (' + date.toLocaleTimeString("en-EN") + ')';
					gauge[sensor] = value[1];
					unit = value[2];
					break;
				default:
					break;
				}
			}
			// create and fill an array of last n gauge
			// also create the corresponding table row to show - only if it not yet exists
			if (displays[sensor] == null) {
				numgauge++;
				// put always two gauges into one table row
				var tabcell = '<div id="' + sensor + '"></div>';
				if (numgauge % 2 == 1) {
					var tabrow = '<tr>' +
					'<td id="gc' + numgauge + '"></td>' +
					'<td id="gc' + (numgauge + 1) + '"></td>' +
					'</tr>';
					$('#gauge').append(tabrow);
				};
				$('#gc' + numgauge).append(tabcell);
				displays[sensor] = new JustGage({
						id : sensor,
						value : gauge[sensor],
{'fraction_non_alphanumeric': 0.15945330296127563, 'fraction_numerical': 0.011389521640091117, 'mean_word_length': 2.656119900083264, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '2091161', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1364, 'n_words': 462}