<commit_before>$(document).ready(function(){

	var game = {};

	function board(width, height){
		if(width < 3){
			width = 3;
		}
		if(height < 3){
			height = 3;
		}

		var tileSize = "100";

		this.createBoard = function(){
			var html = "";
			for(var i = 0; i < height; i++){
				for(var j = 0; j < width; j++){
					html += j == (width-1) ? "<div class='rowEnd'></div>" : "<div></div>";
				}
			}

			$("#board").html(html).css({"grid-template-columns": "repeat("+width+", "+tileSize+"px)",
									 "grid-template-rows": "repeat("+height+", "+tileSize+"px) "});
		}
	}


	$(".createBoard").on("click", function(){
		var w = $("#width").val();
		var h = $("#height").val();

		var b = new board(w,h);
		b.createBoard();
	});



	$(".playerCount").on("change", function(){
		game.playerCount = parseInt($("input[name='playerCount']:checked").val());
		var pc2 = $(".psTwo");
		var plural = $(".plural");
		if(game.playerCount === 1){
			plural.hide();
			pc2.hide();
			pc2.find("input").prop('disabled', true);
		}else{
			plural.show();
			pc2.show();
			pc2.find("input").prop('disabled', false);
		}
	}).trigger("change");


	$(".btn.symbol").on("click", function(){
		if(!$(this).next(".symbolList").hasClass("show"))
		{
			$(".symbolList.show").removeClass("show");
			$(this).next(".symbolList").toggleClass("show");
		}
		else
		{
			$(this).next(".symbolList").removeClass("show")
		}
	})

	$(".symbolList > [class^='icon-']").on("click", function(){
		var cssClass = $(this).attr("class");
		$(".symbolList").removeClass("show");
		$(this).parent().prev(".btn.symbol").attr("class", "btn symbol "+cssClass );
		$(this).parent().next("input").val(cssClass.substr(5));
	});


	var validate = function(){
		var error = [];
		var pc1name = $("#pcOneName").val() != "";

		if(!pc1name){
			error.push("Player One - Missing Name");
		}

		if(game.playerCount === 2){
			var pc2name = $("#pcTwoName").val() != "";
			var symbols = $("#pcOneSymbol").val() != $("#pcTwoSymbol").val();

			if(!pc2name){
				error.push("Player Two - Missing Name");
			}

			if($("#pcOneName").val() == $("#pcTwoName").val() && pc1name && pc2name ){
				error.push("Player names must not be identical");
			}

			if(!symbols){
				error.push("Player One and Player Two cannot have the same symbol");
			}
		}
		return error;
	}


	var resetForm = function(){
		$("#pcOneName").val("");
		$("#pcOneSymbol").val("brand");
		$("#pcOneSymbolLabel").next(".symbol").attr("class", "btn symbol icon-brand");
		$("#pcTwoName").val("");
		$("#pcTwoSymbol").val("brand2");
		$("#pcTwoSymbolLabel").next(".symbol").attr("class", "btn symbol icon-brand2");
		$("#pcOne").trigger("click");
	}

	var processForm = function(){
		var json = {"players" : [{"name" : $("#pcOneName").val() , "symbol" : $("#pcOneSymbol").val()}],
					"boardWidth" : $("#tWidth").val(),
					"boardHeight" : $("#tHeight").val(),
					"winCondition" : $("#winRule").val()
					}

	    if (game.playerCount === 2){
			json.players.push({"name" : $("#pcTwoName").val() , "symbol" : $("#pcTwoSymbol").val()});
	    }
		return json;	
	}

	var toggleMenu = function(){
		$("#menuWrapper").toggleClass("show");
		$("#gameWrapper").toggleClass("show");
	}

	$(".btn.reset").on("click", resetForm);

	$(".btn.startGame").on("click", function(){
		var error = validate();
		if(error.length == 0){
			var json = processForm();
			$(".error").removeClass("show");
			alert(JSON.stringify(json));
			game.players = json.players;
			setTurn(0);
			$("#gameOver").removeClass("show");
			$("#gameTurn").addClass("show");
			toggleMenu();
		}
		else{
			$(".error").text(error).addClass("show");
		}
	});

	var setTurn = function(playerIndex){
		game.currentPlayer = playerIndex;
		$("#gameTurn").text(game.players[playerIndex].name + "'s turn");
	}


	var gameOver = function(winner) {
		$("#gameOver").addClass("show");
		$("#gameTurn").removeClass("show");

		if(winner != ""){
			$("#gameOverMessage").text(winner + " has won!");
		}
		else{
			$("#gameOverMessage").text("It's a draw");
		}
	}

	$("#menuButton").on("click", toggleMenu);

});<commit_msg>board now uses game menu settings, reset button updated, click events on gameTiles added<commit_after>$(document).ready(function(){

	var game = {};

	function board(width, height){
		if(width < 3){
			width = 3;
		}
		if(height < 3){
			height = 3;
		}

		var tileSize = "100";

		this.createBoard = function(){
			var html = "";
			for(var i = 0; i < height; i++){
				for(var j = 0; j < width; j++){
					html += j == (width-1) ? "<div class='gameTile rowEnd'></div>" : "<div class='gameTile'></div>";
				}
			}

			$("#board").html(html).css({"grid-template-columns": "repeat("+width+", "+tileSize+"px)",
									 "grid-template-rows": "repeat("+height+", "+tileSize+"px) "});
		}
	}


	$(".playerCount").on("change", function(){
		game.playerCount = parseInt($("input[name='playerCount']:checked").val());
		var pc2 = $(".psTwo");
		var plural = $(".plural");
		if(game.playerCount === 1){
			plural.hide();
			pc2.hide();
			pc2.find("input").prop('disabled', true);
		}else{
			plural.show();
			pc2.show();
			pc2.find("input").prop('disabled', false);
		}
	}).trigger("change");


	$(".btn.symbol").on("click", function(){
		if(!$(this).next(".symbolList").hasClass("show"))
		{
			$(".symbolList.show").removeClass("show");
			$(this).next(".symbolList").toggleClass("show");
		}
		else
		{
			$(this).next(".symbolList").removeClass("show")
		}
	})

	$(".symbolList > [class^='icon-']").on("click", function(){
		var cssClass = $(this).attr("class");
		$(".symbolList").removeClass("show");
		$(this).parent().prev(".btn.symbol").attr("class", "btn symbol "+cssClass );
		$(this).parent().next("input").val(cssClass.substr(5));
	});


	var validate = function(){
		var error = [];
		var pc1name = $("#pcOneName").val() != "";

		if(!pc1name){
			error.push("Player One - Missing Name");
		}

		if(game.playerCount === 2){
			var pc2name = $("#pcTwoName").val() != "";
			var symbols = $("#pcOneSymbol").val() != $("#pcTwoSymbol").val();

			if(!pc2name){
				error.push("Player Two - Missing Name");
			}

			if($("#pcOneName").val() == $("#pcTwoName").val() && pc1name && pc2name ){
				error.push("Player names must not be identical");
			}

			if(!symbols){
				error.push("Player One and Player Two cannot have the same symbol");
			}
		}
		return error;
	}


	var resetForm = function(){
		$("#pcOneName").val("");
		$("#pcOneSymbol").val("brand");
		$("#pcOneSymbolLabel").next(".symbol").attr("class", "btn symbol icon-brand");
		$("#pcTwoName").val("");
		$("#pcTwoSymbol").val("brand2");
		$("#pcTwoSymbolLabel").next(".symbol").attr("class", "btn symbol icon-brand2");
		$("#pcOne").trigger("click");
		$("#tWidth").val(3);
		$("#tHeight").val(3);
		$("#winRule").val(3);
	}

	var processForm = function(){
		var json = {"players" : [{"name" : $("#pcOneName").val() , "symbol" : $("#pcOneSymbol").val()}],
					"boardWidth" : $("#tWidth").val(),
					"boardHeight" : $("#tHeight").val(),
					"winCondition" : $("#winRule").val()
					}

	    if (game.playerCount === 2){
			json.players.push({"name" : $("#pcTwoName").val() , "symbol" : $("#pcTwoSymbol").val()});
	    }
		return json;	
	}

	var toggleMenu = function(){
		$("#menuWrapper").toggleClass("show");
		$("#gameWrapper").toggleClass("show");
	}

	$(".btn.reset").on("click", resetForm);

	$(".btn.startGame").on("click", function(){
		var error = validate();
		if(error.length == 0){
			var json = processForm();
			$(".error").removeClass("show");
			alert(JSON.stringify(json));
			game.players = json.players;
			setTurn(0);
			$("#gameOver").removeClass("show");
			$("#gameTurn").addClass("show");

			var b = new board(json.boardWidth, json.boardHeight);
			b.createBoard();
			toggleMenu();
		}
		else{
			$(".error").text(error).addClass("show");
		}
	});

	var setTurn = function(playerIndex){
		game.currentPlayer = playerIndex;
		$("#gameTurn").text(game.players[playerIndex].name + "'s turn");
	}


	var gameOver = function(winner) {
		$("#gameOver").addClass("show");
		$("#gameTurn").removeClass("show");

		if(winner != ""){
			$("#gameOverMessage").text(winner + " has won!");
		}
		else{
			$("#gameOverMessage").text("It's a draw");
		}
	}

	$("#menuButton").on("click", toggleMenu);

	$(document).on("click", '.gameTile', function(){
		doTurn($(this).index());
	});

	var doTurn = function(gameTileIndex){
		alert(gameTileIndex);
	}

});
{'fraction_non_alphanumeric': 0.2625029627873904, 'fraction_numerical': 0.007229201232519554, 'mean_word_length': 4.020226055919096, 'pattern_counts': {'":': 4, '<': 19, '<?xml version=': 0, '>': 13, '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': '1999394', 'n_tokens_mistral': 3266, 'n_tokens_neox': 2872, 'n_words': 501}