<commit_before>var nextPlayerNum = 5;
var gameOptions;
var teamOptions;
var playerOptions;
var gameList;
var teamList;
var playerList;

$(document).ready(function() {
    gameOptions = { valueNames : ["round", "team1name", "team2name"]};
    gameList = new List("gamediv", gameOptions);

    teamOptions = { valueNames : ["teamname", "division"]};
    teamList = new List("teamdiv", teamOptions);

    playerOptions = { valueNames : []};

    $("#entergamebutton").prop("disabled", true);
    $("#entergamebutton").removeClass("btn-success").addClass("btn-danger");

    $(".collapsable").click(function(e) {
        e.stopImmediatePropagation();
        $(this).next().toggle(300);
    });

    $("#add-team-button").click(function(e) {
        $("#team_name_input").css("border-color", "white");
        if ($("#team_name_input").val().length !== 0) {
            $(this).prop("disabled", true);
            sendTeamToServer();
        } else {
            $("#team_name_input").css("border-color", "red");
        }
    });

    $("#team_name_input").keyup(function(e) {
        var teamname = $("#team_name_input").val().trim();
        $("#player_team_dynamic").val(teamname);
    });

    $("#newlineplayer").click(function(e) {
        createPlayerInputField();
    });

    $(".teamselect").change(function(e) {
        if ($(this).attr("id") == "leftchoice") {
            findPlayersByTeamnameAndTournament("LEFT");
            $("#leftteamnameID").val($(this).find(":selected").text());
            // console.log($("#leftteamnameID").val());
        } else {
            findPlayersByTeamnameAndTournament("RIGHT");
            $("#rightteamnameID").val($(this).find(":selected").text());
        }
        var bothselect = true;
        $(".teamselect").each(function(i, obj) {
            if ($(this).val() === "") {
                $("#entergamebutton").prop("disabled", true);
                $("#entergamebutton").removeClass("btn-success").addClass("btn-danger");
                bothselect = false;
            }
        });
        if (bothselect) {
            $("#entergamebutton").prop("disabled", false);
            $("#entergamebutton").removeClass("btn-danger").addClass("btn-success");
        }
    });

    $("#add-point-value-button").click(function(e) {

    });

    $("#entergamebutton").click(function(e) {
        // console.log($("#gamedataform").serialize());
        // document.getElementById("gamedataform").reset();
        $(this).prop("disabled", true);
        $("#add-game-message").empty().
            append("<p style='margin-left:10px; font-size:16px;'>Adding Game <i class='fa fa-spinner fa-spin'></i></p>");
        $("#updategamediv").empty().
            append("<p style='margin-left:10px; font-size:16px;'>Adding Game <i class='fa fa-spinner fa-spin'></i></p>");
        sendGameToServer();
    });

    $(".deletebutton").click(function(e) {
        // console.log($(this).parent().serialize());
        removeGame($(this).parent().serialize(), $(this));
    });

    $(".deleteteambutton").click(function(e) {
        // console.log($(this).parent().serialize());
        removeTeam($(this).parent().serialize(), $(this));
    });

    $("#save-point-schema-button").click(function(e) {
        var pointTypes = formatPointTypes();
        formatPointSchemaForm(pointTypes);
        changePointSchemeAJAX(pointTypes);
    });

    $("#save-divisions-button").click(function(e) {
        formatDivisionsForm();
        changeDivisionsAJAX();
    });

    $("#edittournamentbutton").click(function(e) {
        editTournamentAJAX();
    });

    $(".custombutton").click(function(e) {
        // generateCustomStatsAJAX($(this));
        var postURL = $(this).attr("data-post-url");
        // console.log(postURL);
        $("#filterstatsform").attr("action", postURL);
        $("#filterstatsform").submit();
    });

    $("#searchcollabbutton").click(function() {
        if ($("#searchcollabinput").val().length > 0) {
            findDirectorsAJAX();
        }
    });

    $("#searchcollabinput").keypress(function(e) {
        if (e.which == 13) {
            e.preventDefault();
            if ($(this).val().length > 0) {
                findDirectorsAJAX();
            }
        }
    });

    $("#addcollabbutton").click(function() {
        // console.log($("#addcollabform").serializeArray());
        addCollaboratorsAJAX();
    });

    $(".removcollab").click(function() {
        removeCollabAJAX(this);
    });

    $("#playerstatstable th").each(function(index, head) {
        // console.log($(head).text());
        playerOptions.valueNames.push($(head).text());
    });
    playerList = new List("players", playerOptions);

    $("#submitregistration").click(function() {
        var empty = checkTournamentRegistration();
        if (!empty) {
            var numTeams = parseFloat($("#team-number-s").val());
            if (numTeams > 0 && numTeams - Math.floor(numTeams) == 0) {
                $(this).prop("disabled", true);
                submitTournamentRegistration();
            } else {
                $("#tregmessage").empty().
                    append("<p style='margin-left:10px; font-size:18px;'>Enter a valid number of teams.</p>");
            }
        } else {
            $("#tregmessage").empty().<commit_msg>fix negative number of teams in registration and empty string collab search<commit_after>var nextPlayerNum = 5;
var gameOptions;
var teamOptions;
var playerOptions;
var gameList;
var teamList;
var playerList;

$(document).ready(function() {
    gameOptions = { valueNames : ["round", "team1name", "team2name"]};
    gameList = new List("gamediv", gameOptions);

    teamOptions = { valueNames : ["teamname", "division"]};
    teamList = new List("teamdiv", teamOptions);

    playerOptions = { valueNames : []};

    $("#entergamebutton").prop("disabled", true);
    $("#entergamebutton").removeClass("btn-success").addClass("btn-danger");

    $(".collapsable").click(function(e) {
        e.stopImmediatePropagation();
        $(this).next().toggle(300);
    });

    $("#add-team-button").click(function(e) {
        $("#team_name_input").css("border-color", "white");
        if ($("#team_name_input").val().length !== 0) {
            $(this).prop("disabled", true);
            sendTeamToServer();
        } else {
            $("#team_name_input").css("border-color", "red");
        }
    });

    $("#team_name_input").keyup(function(e) {
        var teamname = $("#team_name_input").val().trim();
        $("#player_team_dynamic").val(teamname);
    });

    $("#newlineplayer").click(function(e) {
        createPlayerInputField();
    });

    $(".teamselect").change(function(e) {
        if ($(this).attr("id") == "leftchoice") {
            findPlayersByTeamnameAndTournament("LEFT");
            $("#leftteamnameID").val($(this).find(":selected").text());
            // console.log($("#leftteamnameID").val());
        } else {
            findPlayersByTeamnameAndTournament("RIGHT");
            $("#rightteamnameID").val($(this).find(":selected").text());
        }
        var bothselect = true;
        $(".teamselect").each(function(i, obj) {
            if ($(this).val() === "") {
                $("#entergamebutton").prop("disabled", true);
                $("#entergamebutton").removeClass("btn-success").addClass("btn-danger");
                bothselect = false;
            }
        });
        if (bothselect) {
            $("#entergamebutton").prop("disabled", false);
            $("#entergamebutton").removeClass("btn-danger").addClass("btn-success");
        }
    });

    $("#add-point-value-button").click(function(e) {

    });

    $("#entergamebutton").click(function(e) {
        // console.log($("#gamedataform").serialize());
        // document.getElementById("gamedataform").reset();
        $(this).prop("disabled", true);
        $("#add-game-message").empty().
            append("<p style='margin-left:10px; font-size:16px;'>Adding Game <i class='fa fa-spinner fa-spin'></i></p>");
        $("#updategamediv").empty().
            append("<p style='margin-left:10px; font-size:16px;'>Adding Game <i class='fa fa-spinner fa-spin'></i></p>");
        sendGameToServer();
    });

    $(".deletebutton").click(function(e) {
        // console.log($(this).parent().serialize());
        removeGame($(this).parent().serialize(), $(this));
    });

    $(".deleteteambutton").click(function(e) {
        // console.log($(this).parent().serialize());
        removeTeam($(this).parent().serialize(), $(this));
    });

    $("#save-point-schema-button").click(function(e) {
        var pointTypes = formatPointTypes();
        formatPointSchemaForm(pointTypes);
        changePointSchemeAJAX(pointTypes);
    });

    $("#save-divisions-button").click(function(e) {
        formatDivisionsForm();
        changeDivisionsAJAX();
    });

    $("#edittournamentbutton").click(function(e) {
        editTournamentAJAX();
    });

    $(".custombutton").click(function(e) {
        // generateCustomStatsAJAX($(this));
        var postURL = $(this).attr("data-post-url");
        // console.log(postURL);
        $("#filterstatsform").attr("action", postURL);
        $("#filterstatsform").submit();
    });

    $("#searchcollabbutton").click(function() {
        if ($("#searchcollabinput").val().length > 0) {
            findDirectorsAJAX();
        }
    });

    $("#searchcollabinput").keypress(function(e) {
        if (e.which == 13) {
            e.preventDefault();
            if ($(this).val().length > 0) {
                findDirectorsAJAX();
            }
        }
    });

    $("#addcollabbutton").click(function() {
        // console.log($("#addcollabform").serializeArray());
        addCollaboratorsAJAX();
    });

    $(".removcollab").click(function() {
        removeCollabAJAX(this);
    });

    $("#playerstatstable th").each(function(index, head) {
        // console.log($(head).text());
        playerOptions.valueNames.push($(head).text());
    });
    playerList = new List("players", playerOptions);

    $("#submitregistration").click(function() {
        var empty = checkTournamentRegistration();
        if (!empty) {
            var numTeams = parseFloat($("#team-number-s").val());
            if (numTeams >= 1 && numTeams - Math.floor(numTeams) == 0) {
                $(this).prop("disabled", true);
                submitTournamentRegistration();
            } else {
                $("#tregmessage").empty().
                    append("<p style='margin-left:10px; font-size:18px;'>Enter a valid number of teams.</p>");
            }
        } else {
            $("#tregmessage").empty().
{'fraction_non_alphanumeric': 0.20658374637613391, 'fraction_numerical': 0.004675956233049659, 'mean_word_length': 2.6103983794733288, 'pattern_counts': {'":': 4, '<': 23, '<?xml version=': 0, '>': 29, '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': '3815876', 'n_tokens_mistral': 3147, 'n_tokens_neox': 3088, 'n_words': 406}