<commit_before>var map_data = {};
var form = this;
var player_data = {};
var current_map = null;
var hero_names = [];
var hero_sub_roles = {};
var sub_role_classes = {};

function load_player_data(player_id) {
	$('#load_player_message').text('');
	$.ajax({
		dataType: 'json',
		url: '../data/players/'+player_id+'.JSON',
		success: function(data) {
			$('#load_player_message').text('Successfully loaded player data.');
			if (player_data[player_id] == undefined) {
				$('select.player_select').append("<OPTION value='"+player_id+"'>"+player_id+"</OPTION>");
			}
			player_data[player_id] = data;
		},
		error: function() {
			$('#load_player_message').text('Could not load player data.');
		}
	});
}

$(document).ready(function() {
	// Load Player functionality
	$('form#load_player_form').submit(function(e){
		e.preventDefault();
		var player_id = this.player_region.value + "_" + this.bt_name.value + "_" + this.bt_number.value;
		load_player_data(player_id);
	});

	// Set current map whenever map is changed.
	$('select#map').change(function(){
		current_map = $(this).val();
	});

	$('select').change(function() {
		update_suggestions();
	});

	$.getJSON(
		'../data/hero_sub_roles.json',
		function(data) {
			window.hero_sub_roles = data;
			for (hero in data) {
				role = data[hero];
				sub_role_classes[role] = role.replace(' ','');
			}
		}
	);

	$.getJSON(
		'../data/players/player_list.JSON',
		function(data) {
			for (var i = 0, len = data.length; i < len; i++) {
				load_player_data(data[i]);
			}
		}
	);

	// Load map data
	$.getJSON(
		'../data/maps/map_data.json',
		function(data) {
			window.map_data = data;
			for ( map_name in map_data ) {
				$('select#map').append("<OPTION>"+map_name+"</OPTION>");
			}
			for ( hero_name in map_data[map_name] ) {
				hero_names.push(hero_name);
			}
			hero_names.sort();
			for (var i = 0, len = hero_names.length; i < len; i++) {
				$('select.hero_select').append("<OPTION>"+hero_names[i]+"</OPTION>");
			}
		}
	);
});

function update_suggestions() {
	if (current_map) {
		// Get ban suggestions
		update_ban_suggestions();

		// Get players suggestions
		update_players_suggestions();
	} else {
		alert('Please select a map.');
	}
}

function hero_display(name, score) {
	return '<SPAN class="hero '+sub_role_classes[hero_sub_roles[name]]+'" alt="'+hero_sub_roles[name]+'">'+ name + ' (' + score + ')</SPAN>';
}

function update_ban_suggestions() {
	ban_suggestions = get_ban_suggestions();
	display = "";
	for (var i = 0; i < 8; i++) {<commit_msg>Use proper tooltip attribute.<commit_after>var map_data = {};
var form = this;
var player_data = {};
var current_map = null;
var hero_names = [];
var hero_sub_roles = {};
var sub_role_classes = {};

function load_player_data(player_id) {
	$('#load_player_message').text('');
	$.ajax({
		dataType: 'json',
		url: '../data/players/'+player_id+'.JSON',
		success: function(data) {
			$('#load_player_message').text('Successfully loaded player data.');
			if (player_data[player_id] == undefined) {
				$('select.player_select').append("<OPTION value='"+player_id+"'>"+player_id+"</OPTION>");
			}
			player_data[player_id] = data;
		},
		error: function() {
			$('#load_player_message').text('Could not load player data.');
		}
	});
}

$(document).ready(function() {
	// Load Player functionality
	$('form#load_player_form').submit(function(e){
		e.preventDefault();
		var player_id = this.player_region.value + "_" + this.bt_name.value + "_" + this.bt_number.value;
		load_player_data(player_id);
	});

	// Set current map whenever map is changed.
	$('select#map').change(function(){
		current_map = $(this).val();
	});

	$('select').change(function() {
		update_suggestions();
	});

	$.getJSON(
		'../data/hero_sub_roles.json',
		function(data) {
			window.hero_sub_roles = data;
			for (hero in data) {
				role = data[hero];
				sub_role_classes[role] = role.replace(' ','');
			}
		}
	);

	$.getJSON(
		'../data/players/player_list.JSON',
		function(data) {
			for (var i = 0, len = data.length; i < len; i++) {
				load_player_data(data[i]);
			}
		}
	);

	// Load map data
	$.getJSON(
		'../data/maps/map_data.json',
		function(data) {
			window.map_data = data;
			for ( map_name in map_data ) {
				$('select#map').append("<OPTION>"+map_name+"</OPTION>");
			}
			for ( hero_name in map_data[map_name] ) {
				hero_names.push(hero_name);
			}
			hero_names.sort();
			for (var i = 0, len = hero_names.length; i < len; i++) {
				$('select.hero_select').append("<OPTION>"+hero_names[i]+"</OPTION>");
			}
		}
	);
});

function update_suggestions() {
	if (current_map) {
		// Get ban suggestions
		update_ban_suggestions();

		// Get players suggestions
		update_players_suggestions();
	} else {
		alert('Please select a map.');
	}
}

function hero_display(name, score) {
	return '<SPAN class="hero '+sub_role_classes[hero_sub_roles[name]]+'" title="'+hero_sub_roles[name]+'">'+ name + ' (' + score + ')</SPAN>';
}

function update_ban_suggestions() {
	ban_suggestions = get_ban_suggestions();
	display = "";
	for (var i = 0; i < 8; i++) {
{'fraction_non_alphanumeric': 0.19711917916337807, 'fraction_numerical': 0.0015785319652722968, 'mean_word_length': 4.0639360639360635, 'pattern_counts': {'":': 0, '<': 25, '<?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': '4845320', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1848, 'n_words': 329}