<commit_before>// Cell click listener function
// ---------------------------------------------------------------------
function cell_click(e)
{
	var id;
	var row, column;

	// Get pressed cell row and column number
	id = $(this).attr('id');

	row = parseInt(id.substring(3, id.indexOf('col')));
	column = parseInt(id.substring(id.indexOf('col') + 3));

	// Manage cell opening
	open_cell(row, column);
}



// Cell opening procedure
// ---------------------------------------------------------------------
function open_cell(row, column)
{
	var i, j;
	var cell;
	
	// Cell HTML element
	cell = $("#row" + row + "col" + column);

	// If cell doesn't contain a mine, and it is not an alreay opened cell, increase open cells counter
	if (field[row][column] != "*" && open_cells[row][column] == 0)
	{
		open_cells_number++;
	}

	// Update visual indicators
	update_indicators();

	// Flag cell as opened
	open_cells[row][column] = 1;
	
	// Remove any cell flags and markers
	marked_cells[row][column] = "";

	// If cell isn't empty, show cell value
	if (field[row][column] != 0) cell.html(field[row][column]);
	else cell.html("");

	// Add open_cell CSS class
	cell.addClass("open_cell");

	// If cell has a numeric value, apply suited class
	for (i = 1; i <= 8; i++)
	{
		if (field[row][column] == i) cell.addClass("mine_" + i);
	}

	// If a mined cell was pressed, you're dead
	if (field[row][column] == "*")
	{
		cell.addClass("mine");		// Apply mined CSS class
		alert("You're dead :(")		// Warn of death 
		game_over();				// Call end of game function
		
		return;
	};

	// If remaining unopened cells number is 0, I win
	if (open_cells_number == (rows_number * cols_number) - mine_number)
	{
		alert("You win! :)");		// Warn of victory
		game_over();				// Call end of game function
		return;
	}

	// If cell has zero value, recursively open all surrounding cells
	if (field[row][column] == 0)
	{
		for (i= -1; i < 2; i++)
		{
			for (j = -1; j < 2; j++)
			{
				if (row+i < 0) continue;
				if (row+i >= rows_number) continue;
				if (column + j < 0) continue;
				if (column + j >= cols_number) continue;
				if (i == 0 && j == 0) continue;
				if (open_cells[row + i][column + j] == 1) continue;<commit_msg>Update listeners.js<commit_after>// Cell click listener function
// ---------------------------------------------------------------------
function cell_click(e)
{
	var id;
	var row, column;

	// Get pressed cell row and column number
	id = $(this).attr('id');

	row = parseInt(id.substring(3, id.indexOf('col')));
	column = parseInt(id.substring(id.indexOf('col') + 3));

	// Manage cell opening
	open_cell(row, column);
}



// Cell opening procedure
// ---------------------------------------------------------------------
function open_cell(row, column)
{
	var i, j;
	var cell;
	
	// Cell HTML element
	cell = $("#row" + row + "col" + column);

	// If cell doesn't contain a mine, and it is not an alreay opened cell, increase open cells counter
	if (field[row][column] != "*" && open_cells[row][column] == 0)
	{
		open_cells_number++;
	}

	// Update visual indicators
	update_indicators();

	// Flag cell as opened
	open_cells[row][column] = 1;
	
	// Remove any cell flags and markers
	marked_cells[row][column] = "";

	// If cell isn't empty, show cell value
	if (field[row][column] != 0) cell.html(field[row][column]);
	else cell.html("");

	// Add open_cell CSS class
	cell.addClass("open_cell");

	// If cell has a numeric value, apply suited class
	for (i = 1; i <= 8; i++)
	{
		if (field[row][column] == i) cell.addClass("mine_" + i);
	}

	// If a mined cell was pressed, you're dead
	if (field[row][column] == "*")
	{
		cell.addClass("mine");		// Apply mined CSS class
		alert("You're dead :(")		// Warn of death 
		game_over();			// Call end of game function
		
		return;
	};

	// If remaining unopened cells number is 0, I win
	if (open_cells_number == (rows_number * cols_number) - mine_number)
	{
		alert("You win! :)");		// Warn of victory
		game_over();			// Call end of game function
		return;
	}

	// If cell has zero value, recursively open all surrounding cells
	if (field[row][column] == 0)
	{
		for (i= -1; i < 2; i++)
		{
			for (j = -1; j < 2; j++)
			{
				if (row+i < 0) continue;
				if (row+i >= rows_number) continue;
				if (column + j < 0) continue;
				if (column + j >= cols_number) continue;
				if (i == 0 && j == 0) continue;
				if (open_cells[row + i][column + j] == 1) continue;
{'fraction_non_alphanumeric': 0.21728339350180506, 'fraction_numerical': 0.008122743682310469, 'mean_word_length': 2.4768627450980394, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '864971', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1458, 'n_words': 474}