<commit_before>var currentQuestion = 0;
var currentCitizen; 
var currentCitizenName ="";
var currentPageId;
var conceptToJudge;

$(document).ready(function(){

	// hide everything by default
	
	$(".page").hide();

	// Get a name from the server if we don't have one
	var query = (localStorage.myName && localStorage.gameId) 
		? "?citizen=" + localStorage.myName + "&gameId=" + localStorage.gameId
		: "";
	$.getJSON("/_joinGame" + query, {format: "json"}).done(function(data){
		if(data.error) {
			console.error("Failed to join the game", data.error);
		}
		else {
			localStorage.setItem('myName', data.yourName);
			localStorage.setItem('gameId', data.gameId);

			$(".yourName").text(data.yourName);

			if(data.youAreANewbie) {
				currentPageId = '#setup-account';
				localStorage.setItem('IAmANewbie', true);
				getUnjudgedConcept();
			}
			else {
				currentPageId = '#map';
				localStorage.setItem('IAmANewbie', false);
				getMap();	
			}
			$(currentPageId).show();
		}
	});

	//$('#judge .profile').on('swipeleft', swipeleftHandler);
	//$('#judge .profile').on('swiperight', swiperightHandler);
	
	$('.decision').on('touchstart', function(){
		$(this).css(
			'transform', 'scale(0.8)'
		);
	});

	$('.decision').on('touchend', function(){
		$(this).css(
			'transform', 'scale(1)'
		);
	});
	
	$('#dislike').on('touchend', function(){
		swipeleftHandler();
	});
	
	$('#like').on('touchend', function(){
		swiperightHandler();
	});

	$('#map-icon').on('click', function(){
		if(localStorage.IAmANewbie == "false") {
			getMap();
			setPage("#map");
		}
		else {
			console.log("You can't see map yet, you're a newbie");
		}
	})

	$('#judge-icon').on('click', function(){
		if(localStorage.IAmANewbie == "false") {
			getUnjudgedCitizen();
			setPage("#judge");
		}
		else {
			console.log("You can't judge yet, you're a newbie");
		}
	})
	
	$('.answers .icon-container').on('click', function(e) {
		judgeConcept($(this).attr("id"), conceptToJudge); // TODO : GET THE VALUE (2) FROM THE BUTTON
	});

});

// ----------------------------------------------------------------------------
// JUDGE CITIZEN POSITIVE OR NEGATIVE
// ----------------------------------------------------------------------------

function getUnjudgedCitizen() {	
	$.getJSON("/_getUnjudgedCitizen?citizen=" + localStorage.myName, {format: "json"}).done(function(data){    
    currentCitizen = data;
    currentCitizenName = data.name;
    citizen = data;

		newDiv = '<div class="profile untouched">' +
					'<img src="images/profilepics/profile.jpg" class="profile-pic">' +
						'<div class="infos">' +
							'<h1 class="name">'+ citizen.name + '</h1>' +
								'<div class="opinion">' +
									'<div class="icon-container opinion1">' +
										'<img src="images/icons/icon.png">' +
									'</div>' +
									'<div class="icon-container opinion2">' +
										'<img src="images/icons/icon.png">' +
									'</div>' +
									'<div class="icon-container opinion3">' +
										'<img src="images/icons/icon.png">' +
									'</div>' +
								'</div>' +
							'</div>' +
						'</div>';
		$('#profile-container')
			.append(newDiv)
			.on('swiperight', swiperightHandler)
			.on('swipeleft', swipeleftHandler);
	});<commit_msg>no message<commit_after>var currentQuestion = 0;
var currentCitizen; 
var currentCitizenName ="";
var currentPageId;
var conceptToJudge;

$(document).ready(function(){

	// hide everything by default
	
	$(".page").hide();

	// Get a name from the server if we don't have one
	var query = (localStorage.myName && localStorage.gameId) 
		? "?citizen=" + localStorage.myName + "&gameId=" + localStorage.gameId
		: "";
	$.getJSON("/_joinGame" + query, {format: "json"}).done(function(data){
		if(data.error) {
			console.error("Failed to join the game", data.error);
		}
		else {
			localStorage.setItem('myName', data.yourName);
			localStorage.setItem('gameId', data.gameId);

			$(".yourName").text(data.yourName);

			if(data.youAreANewbie) {
				currentPageId = '#setup-account';
				localStorage.setItem('IAmANewbie', true);
				getUnjudgedConcept();
			}
			else {
				currentPageId = '#map';
				localStorage.setItem('IAmANewbie', false);
				getMap();	
			}
			$(currentPageId).show();
		}
	});

	//$('#judge .profile').on('swipeleft', swipeleftHandler);
	//$('#judge .profile').on('swiperight', swiperightHandler);
	
	$('.decision').on('touchstart', function(){
		$(this).css(
			'transform', 'scale(0.8)'
		);
	});

	$('.decision').on('touchend', function(){
		$(this).css(
			'transform', 'scale(1)'
		);
	});
	
	$('#dislike').on('touchend', function(){
		swipeleftHandler();
	});
	
	$('#like').on('touchend', function(){
		swiperightHandler();
	});

	$('#map-icon').on('click', function(){
		if(localStorage.IAmANewbie == "false") {
			getMap();
			setPage("#map");
		}
		else {
			console.log("You can't see map yet, you're a newbie");
		}
	})

	$('#judge-icon').on('click', function(){
		if(localStorage.IAmANewbie == "false") {
			getUnjudgedCitizen();
			setPage("#judge");
		}
		else {
			console.log("You can't judge yet, you're a newbie");
		}
	})
	
	$('.answers .icon-container').on('click', function(e) {
		judgeConcept($(this).attr("id"), conceptToJudge); // TODO : GET THE VALUE (2) FROM THE BUTTON
	});

});

// ----------------------------------------------------------------------------
// JUDGE CITIZEN POSITIVE OR NEGATIVE
// ----------------------------------------------------------------------------

function getUnjudgedCitizen() {	
	
	$.getJSON("/_getUnjudgedCitizen?citizen=" + localStorage.myName, {format: "json"}).done(function(data){    
    currentCitizen = data;
    currentCitizenName = data.name;
    citizen = data;

		newDiv = '<div class="profile untouched">' +
					'<img src="images/profilepics/profile.jpg" class="profile-pic">' +
						'<div class="infos">' +
							'<h1 class="name">'+ citizen.name + '</h1>' +
								'<div class="opinion">' +
									'<div class="icon-container opinion1">' +
										'<img src="images/icons/icon.png">' +
									'</div>' +
									'<div class="icon-container opinion2">' +
										'<img src="images/icons/icon.png">' +
									'</div>' +
									'<div class="icon-container opinion3">' +
										'<img src="images/icons/icon.png">' +
									'</div>' +
								'</div>' +
							'</div>' +
						'</div>';
		$('#profile-container')
			.append(newDiv)
			.on('swiperight', swiperightHandler)
			.on('swipeleft', swipeleftHandler);
	});
{'fraction_non_alphanumeric': 0.248491412656661, 'fraction_numerical': 0.0030945381401825778, 'mean_word_length': 2.8203309692671397, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '1728817', 'n_tokens_mistral': 2638, 'n_tokens_neox': 2157, 'n_words': 379}