<commit_before>// Constants ===================================================================
var SOCKET_PORT = 4444;
var SOCKET_SERVER = 'ws://localhost:' + SOCKET_PORT;

// Globals =====================================================================
var ugly = {
	currentChunk: undefined,
	queuedCommands: [],
};

// Main code ===================================================================
function initConnection () {
	console.log ('Attempting to connect to websocket server ' + SOCKET_SERVER);
	var socket = new WebSocket (SOCKET_SERVER);

	socket.onmessage = function (message_) {
		handleLine (message_.data);
	};

	socket.onclose = function () {
		console.log ('Socket closed, attempting to reconnect in 5 seconds...');
		setTimeout (initConnection, 5 * 1000);
	};
}

// Command parsing =============================================================
// Parsing on the client side is in many ways the same as parsing on the server
// side. The exception is that since we've already gone through the server, we
// can assume that anything we get is valid according to the protocol.

// Returns true iff string_ begins with prefix_
function startsWith (prefix_, string_) {
	console.assert (typeof (prefix_) === 'string');
	console.assert (typeof (string_) === 'string');

	return string_.indexOf (prefix_) === 0;
}<commit_msg>Implement defaults<commit_after>// Constants ===================================================================
var SOCKET_PORT = 4444;
var SOCKET_SERVER = 'ws://localhost:' + SOCKET_PORT;

// Globals =====================================================================
var ugly = {
	currentChunk: undefined,
	queuedCommands: [],
	defaultConfig: [
		'letterbox_color #000000',
	],
};

// Main code ===================================================================
function initConnection () {
	ugly.queuedCommands = ugly.defaultConfig;
	processQueuedCommands ();

	console.log ('Attempting to connect to websocket server ' + SOCKET_SERVER);
	var socket = new WebSocket (SOCKET_SERVER);

	socket.onmessage = function (message_) {
		handleLine (message_.data);
	};

	socket.onclose = function () {
		console.log ('Socket closed, attempting to reconnect in 5 seconds...');
		setTimeout (initConnection, 5 * 1000);
	};
}

// Command parsing =============================================================
// Parsing on the client side is in many ways the same as parsing on the server
// side. The exception is that since we've already gone through the server, we
// can assume that anything we get is valid according to the protocol.


function startsWith (prefix_, string_) {
	console.assert (typeof (prefix_) === 'string');
	console.assert (typeof (string_) === 'string');

	return string_.indexOf (prefix_) === 0;
}
{'fraction_non_alphanumeric': 0.2879448075526507, 'fraction_numerical': 0.010167029774872912, 'mean_word_length': 5.406976744186046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4785329', 'n_tokens_mistral': 730, 'n_tokens_neox': 664, 'n_words': 236}