<commit_before>/*--- GLOBAL VARS ---*/
var urlLastfm = "http://ws.audioscrobbler.com/2.0/?format=json";
var userInfoMethod = "user.getInfo";
var userTopArtistsMethod = "user.getTopArtists";
var artistSimilarMethod = "artist.getSimilar";
var currentTrack = null;
var playingClass = "playing_preview";

/*--- AUXILIAR FUNCTIONS ---*/
function generateLastfmApiUrl(method, optionalUrlParam){
	var content = urlLastfm + "&" + "api_key=" + apiKey + "&" + "method=" + method;
	if(optionalUrlParam!=undefined){
		for(i in optionalUrlParam){
			content += "&" + optionalUrlParam[i][0] + "=" + optionalUrlParam[i][1];
		}
	}
	return content;
}

function lastfmApiCall(method, callback, optionalUrlParam){
	ajaxCall(generateLastfmApiUrl(method, optionalUrlParam), callback);
}

/*--- BINDINGS ---*/
function bindUserTopArtistsRecommendations(){
	$(document).on("click",".artist_container", function(){
		if($(this).hasClass("selected_recommendation")){
			$(this).removeClass("selected_recommendation selected_artist");
			$(this).find("img").removeClass("gray_image");
			$("#current_recommendation").remove();
			$("#music_section_container").addClass("text_align_center");
		}else{
			if($(".selected_recommendation").length > 0){
				$(".selected_recommendation").find("img").removeClass("gray_image");
				$(".selected_recommendation").removeClass("selected_recommendation selected_artist");
				$("#current_recommendation").remove();	
				$("#music_section_container").addClass("text_align_center");
			}			
			$(this).addClass("selected_recommendation selected_artist");
			$(this).find("img").addClass("gray_image");
			$("#music_section_container").removeClass("text_align_center");
			searchSimilarArtists($(this));
		}	
	});
}
function bindSpotifySimilarArtists(){
	$(document).on("click",".similar_artist_container", function(){
		var targetArtist = $(this);
		console.log(targetArtist);
		if(currentTrack !== null && targetArtist.hasClass(playingClass)){
			$("."+playingClass).removeClass(playingClass);
			currentTrack.pause();
		}else{
			$("."+playingClass).removeClass(playingClass);
			if(currentTrack !== null){
				currentTrack.pause();
			}
			searchSpotifyArtistSong($(this).attr("id").replace("similar_", "").replace(/--/g, " "), function(){
				if(currentTrack !== null){<commit_msg>Correction of audio behaviour.<commit_after>/*--- GLOBAL VARS ---*/
var urlLastfm = "http://ws.audioscrobbler.com/2.0/?format=json";
var userInfoMethod = "user.getInfo";
var userTopArtistsMethod = "user.getTopArtists";
var artistSimilarMethod = "artist.getSimilar";
var currentTrack = null;
var playingClass = "playing_preview";

/*--- AUXILIAR FUNCTIONS ---*/
function generateLastfmApiUrl(method, optionalUrlParam){
	var content = urlLastfm + "&" + "api_key=" + apiKey + "&" + "method=" + method;
	if(optionalUrlParam!=undefined){
		for(i in optionalUrlParam){
			content += "&" + optionalUrlParam[i][0] + "=" + optionalUrlParam[i][1];
		}
	}
	return content;
}

function lastfmApiCall(method, callback, optionalUrlParam){
	ajaxCall(generateLastfmApiUrl(method, optionalUrlParam), callback);
}

/*--- BINDINGS ---*/
function bindUserTopArtistsRecommendations(){
	$(document).on("click",".artist_container", function(){
		if($(this).hasClass("selected_recommendation")){
			$(this).removeClass("selected_recommendation selected_artist");
			$(this).find("img").removeClass("gray_image");
			$("#current_recommendation").remove();
			$("#music_section_container").addClass("text_align_center");
		}else{
			if($(".selected_recommendation").length > 0){
				$(".selected_recommendation").find("img").removeClass("gray_image");
				$(".selected_recommendation").removeClass("selected_recommendation selected_artist");
				$("#current_recommendation").remove();	
				$("#music_section_container").addClass("text_align_center");
			}			
			$(this).addClass("selected_recommendation selected_artist");
			$(this).find("img").addClass("gray_image");
			$("#music_section_container").removeClass("text_align_center");
			searchSimilarArtists($(this));
		}

		if(currentTrack !== null ){
			currentTrack.pause();
		}	
	});
}
function bindSpotifySimilarArtists(){
	$(document).on("click",".similar_artist_container", function(){
		var targetArtist = $(this);
		console.log(targetArtist);
		if(currentTrack !== null && targetArtist.hasClass(playingClass)){
			$("."+playingClass).removeClass(playingClass);
			currentTrack.pause();
		}else{
			$("."+playingClass).removeClass(playingClass);
			if(currentTrack !== null){
				currentTrack.pause();
			}
			searchSpotifyArtistSong($(this).attr("id").replace("similar_", "").replace(/--/g, " "), function(){
				if(currentTrack !== null){
{'fraction_non_alphanumeric': 0.18917183821955916, 'fraction_numerical': 0.0021399529210357373, 'mean_word_length': 6.103343465045593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6760219', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1457, 'n_words': 197}