<commit_before>
var saveList = 0,
    saveAssignment = function( pkgID, groupIDs ) {
        saveList += groupIDs.length;

        for( var i = 0; i < groupIDs.length; i++ ) {
            createAssignment( pkgID, groupIDs[i] );
        }
    },
    createAssignment = function( pkgID, groupID ) {
        var $elem = $( "#package_" + pkgID).find("form.addPackageGroupForm"),
            data = {
                'utf8': $elem.find("input[name='utf8']").val(),
                'authenticity_token': $elem.find("input[name='authenticity_token']").val(),
                'group_assignment': {
                    'package_id': pkgID,
                    'package_group_id': groupID
                },
                "package_assignment": true
            };

        $.ajax({
            url: $elem[0].action,
            headers: {
                Accept : "text/javascript; charset=utf-8",
                "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8'
            },
            type: 'POST',
            data: data,
            success: function(data) {
                debugger;
                saveList--;
                if ( saveList === 0 ) {
                    window.location = "/";
                }
            },
            error: function(data) {
                debugger;
            }
        });
    };

$(document).on("page:change", function(){
    saveList = 0;

    $("#packageList").off().on('click', ".remove_grp" , function( e ) {
        e.preventDefault();
        var id = $(this).parent(".grp_entry").data("grpId");

        $(this).parents("td").find(".addPackageGroupForm .grp_select").find('option[value="'+ id +'"]').removeAttr("disabled");
        $(this).parent().remove();

        return false;
    });


    $(".grp_select").off().on("change", function(){
        var grpID = $(this).val(),
            grpName = $(this).find(":selected").text();

        $(this).parents("td").find("ul").append(
            $('<li class="grp_entry" data-grp-id="'+ grpID +'">'+ grpName +'<a class="remove_grp"><i class="fa fa-remove"></i></a></li>')
        );

        $(this).find('option[value="'+ grpID +'"]').attr("disabled", "disabled");
        $(this).find('option:eq(0)').prop('selected', true);<commit_msg>removed debugger<commit_after>
var saveList = 0,
    saveAssignment = function( pkgID, groupIDs ) {
        saveList += groupIDs.length;

        for( var i = 0; i < groupIDs.length; i++ ) {
            createAssignment( pkgID, groupIDs[i] );
        }
    },
    createAssignment = function( pkgID, groupID ) {
        var $elem = $( "#package_" + pkgID).find("form.addPackageGroupForm"),
            data = {
                'utf8': $elem.find("input[name='utf8']").val(),
                'authenticity_token': $elem.find("input[name='authenticity_token']").val(),
                'group_assignment': {
                    'package_id': pkgID,
                    'package_group_id': groupID
                },
                "package_assignment": true
            };

        $.ajax({
            url: $elem[0].action,
            headers: {
                Accept : "text/javascript; charset=utf-8",
                "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8'
            },
            type: 'POST',
            data: data,
            success: function(data) {
                saveList--;
                if ( saveList === 0 ) {
                    window.location = "/";
                }
            },
            error: function(data) {}
        });
    };

$(document).on("page:change", function(){
    saveList = 0;

    $("#packageList").off().on('click', ".remove_grp" , function( e ) {
        e.preventDefault();
        var id = $(this).parent(".grp_entry").data("grpId");

        $(this).parents("td").find(".addPackageGroupForm .grp_select").find('option[value="'+ id +'"]').removeAttr("disabled");
        $(this).parent().remove();

        return false;
    });


    $(".grp_select").off().on("change", function(){
        var grpID = $(this).val(),
            grpName = $(this).find(":selected").text();

        $(this).parents("td").find("ul").append(
            $('<li class="grp_entry" data-grp-id="'+ grpID +'">'+ grpName +'<a class="remove_grp"><i class="fa fa-remove"></i></a></li>')
        );

        $(this).find('option[value="'+ grpID +'"]').attr("disabled", "disabled");
        $(this).find('option:eq(0)').prop('selected', true);
{'fraction_non_alphanumeric': 0.1935339021104625, 'fraction_numerical': 0.00449034575662326, 'mean_word_length': 1.8576010262989096, 'pattern_counts': {'":': 6, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6261291', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1290, 'n_words': 212}