<commit_before>const UI = {
	welcomeWrapper: $("#welcome-wrapper"),
	votingWrapper: $("#voting-wrapper"),
	submitNameBtn: $("#submit-name"),
	field: $("#name"),
	yesBtn: $("#yes"),
	noBtn: $("#no"),
	idkBtn: $("#idk"),
	selected: $("#idk")
};

var URL = '/gary/join';
const sub = 'ws.';
const WS_PORT = "";
console.log('forms');

const conn = {};

const ROOM = window.location.pathname.split("/")[1];

UI.submitNameBtn.click(function(ev) {
	console.log('click');
	console.log(UI.field.val());
	$.ajax({
		url: "http://" + window.location.hostname + URL,
			type: "POST",
			headers: {
					"Content-Type": "application/json",
			},
			contentType: "application/json",
			data: JSON.stringify({
				"name": UI.field.val()
			}),
			dataType: "json"
	})
	.done(function(data, textStatus, jqXHR) {
		console.log("HTTP Request Succeeded: " + jqXHR.status);
		console.log(data);
		UI.welcomeWrapper.hide();
		UI.votingWrapper.show();
		const id = data.id;
		console.log(id);

		conn.ws = new WebSocket('ws://' + sub + location.hostname + WS_PORT);

		console.log(conn.ws);
		conn.ws.onopen = function() {
			console.log('connected');
			function Choice (choice) {
				this.choice = choice;
				this.id = id;
				this.room = ROOM;
			}
			UI.yesBtn.click(function(ev) {
				console.log('yes');
				UI.yesBtn.addClass("selected");
				console.log(new Choice('yes'));
				conn.ws.send(JSON.stringify(new Choice('yes')));
				UI.noBtn.removeClass("selected");
				UI.idkBtn.removeClass("selected");
			});
			UI.noBtn.click(function(ev) {
				console.log('no');
				UI.noBtn.addClass("selected");
				conn.ws.send(JSON.stringify(new Choice('no')));
				UI.yesBtn.removeClass("selected");
				UI.idkBtn.removeClass("selected");
			});
			UI.idkBtn.click(function(ev) {
				console.log('idk');
				UI.idkBtn.addClass("selected");
				conn.ws.send(JSON.stringify(new Choice('idk')));
				UI.noBtn.removeClass("selected");
				UI.yesBtn.removeClass("selected");
			});

			conn.ws.onmessage = function(msg) {
				console.log(msg);
				msg.data = JSON.parse(msg.data);
				console.log(msg);
				console.log(msg.data);
				console.log(msg.data.room);<commit_msg>parse<commit_after>const UI = {
	welcomeWrapper: $("#welcome-wrapper"),
	votingWrapper: $("#voting-wrapper"),
	submitNameBtn: $("#submit-name"),
	field: $("#name"),
	yesBtn: $("#yes"),
	noBtn: $("#no"),
	idkBtn: $("#idk"),
	selected: $("#idk")
};

var URL = '/gary/join';
const sub = 'ws.';
const WS_PORT = "";
console.log('forms');

const conn = {};

const ROOM = window.location.pathname.split("/")[1];

UI.submitNameBtn.click(function(ev) {
	console.log('click');
	console.log(UI.field.val());
	$.ajax({
		url: "http://" + window.location.hostname + URL,
			type: "POST",
			headers: {
					"Content-Type": "application/json",
			},
			contentType: "application/json",
			data: JSON.stringify({
				"name": UI.field.val()
			}),
			dataType: "json"
	})
	.done(function(data, textStatus, jqXHR) {
		console.log("HTTP Request Succeeded: " + jqXHR.status);
		console.log(data);
		UI.welcomeWrapper.hide();
		UI.votingWrapper.show();
		const id = data.id;
		console.log(id);

		conn.ws = new WebSocket('ws://' + sub + location.hostname + WS_PORT);

		console.log(conn.ws);
		conn.ws.onopen = function() {
			console.log('connected');
			function Choice (choice) {
				this.choice = choice;
				this.id = id;
				this.room = ROOM;
			}
			UI.yesBtn.click(function(ev) {
				console.log('yes');
				UI.yesBtn.addClass("selected");
				console.log(new Choice('yes'));
				conn.ws.send(JSON.stringify(new Choice('yes')));
				UI.noBtn.removeClass("selected");
				UI.idkBtn.removeClass("selected");
			});
			UI.noBtn.click(function(ev) {
				console.log('no');
				UI.noBtn.addClass("selected");
				conn.ws.send(JSON.stringify(new Choice('no')));
				UI.yesBtn.removeClass("selected");
				UI.idkBtn.removeClass("selected");
			});
			UI.idkBtn.click(function(ev) {
				console.log('idk');
				UI.idkBtn.addClass("selected");
				conn.ws.send(JSON.stringify(new Choice('idk')));
				UI.noBtn.removeClass("selected");
				UI.yesBtn.removeClass("selected");
			});

			conn.ws.onmessage = function(msg) {
				console.log(msg);
				msg = JSON.parse(msg);
				msg.data = JSON.parse(msg.data);
				console.log(msg);
				console.log(msg.data);
				console.log(msg.data.room);
{'fraction_non_alphanumeric': 0.2098307442615349, 'fraction_numerical': 0.0004637143519591931, 'mean_word_length': 3.725082146768894, 'pattern_counts': {'":': 4, '<': 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': '2045095', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1544, 'n_words': 235}