<commit_before>


let randNum = Math.round(Math.random() * GamePlay.countries.length);
let country = GamePlay.countries.splice(randNum, 1)[0];
console.log(country);
$('.answer').html(country.Name);

$("#Map").click((e) => {
    if(e.target.tagName === "AREA")
    {
        var target = e.target;
        if (parseInt(target.title) === parseInt(country.CountryId))
        {
            console.log("right answer");
        } else {
            console.log("wrong answer");
        }       
    }
});<commit_msg>ajax call for submit button<commit_after>let tries;
let statObjs = [];
function GetAnswer ()
{
    if (GamePlay.countries.length > 0){
        tries = 0;
        let randNum = Math.round(Math.random() * GamePlay.countries.length - 1);
        let country = GamePlay.countries.splice(randNum, 1)[0];
        $('.answer').html(country.Name);
        return country;
    } else{
        submit();
    }
    
}

function submit (){
    $.ajax({
        type: "POST",
        url: "http://localhost:5000/Stats/Create",
        data: {stats: statObjs}
    }).done((e) =>{
        console.log("something");
        console.log(typeof e);
        if (e === "success") {
            console.log("something else");
            window.location.href = 'http://localhost:5000/Stats';
        }
    }).fail((a,b,c) => {
        console.log("Failed")
    })
}

let country = GetAnswer();

$(".submit").click(submit);

$("#Map").click((e) => {
    if(e.target.tagName === "AREA"){
        tries++;
        var target = e.target;
        if (parseInt(target.title) === parseInt(country.CountryId)){
            statObjs.push({
                CountryId: country.CountryId,
                Tries: tries,
                Success: 1
            });
            console.log("right answer");
            country = GetAnswer();
            
        } else {
            if (tries > 4){
                statObjs.push({
                    CountryId: country.CountryId,
                    Tries: tries,
                    Success: 0
                });
                console.log("5 tries is too many");
                country = GetAnswer();
                
            } else {
                console.log("wrong answer, try again");
            }     
        } 
        console.log(statObjs);      
    }
});
{'fraction_non_alphanumeric': 0.1593573599652627, 'fraction_numerical': 0.008250108554059922, 'mean_word_length': 1.6391752577319587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3695989', 'n_tokens_mistral': 692, 'n_tokens_neox': 665, 'n_words': 126}