<commit_before>$(function(){
    $(".only-on-js").css({"visibility":"visible"});

    $("#button-add-email").click(function(){
        var allEmailBlocks = $("[id^='email-block-']");
        var displayedEmailCount = allEmailBlocks.size();
        var lastEmailBlock = allEmailBlocks.last();

        var myIndex = displayedEmailCount;
        var newBlock = cloneBlock('#email-template', 'email-block-' + myIndex, myIndex);

        if(lastEmailBlock.length > 0){
            lastEmailBlock.after(newBlock);
        }else{
            $('#email-container').prepend(newBlock);
        }

        newBlock.show();
    });

    $("button[id^='button-remove-email-']").click(function(){
        var myBlock = $(this).parent();
        myBlock.remove();
    });

    $("#button-add-phoneNumber").click(function(){
        var allPhoneNumberBlocks = $("[id^='phoneNumber-block-']");
        var displayedPhoneNumberCount = allPhoneNumberBlocks.size();
        var lastPhoneNumberBlock = allPhoneNumberBlocks.last();

        var myIndex = displayedPhoneNumberCount;
        var newBlock = cloneBlock('#phoneNumber-template', 'phoneNumber-block-' + myIndex, myIndex);

        if(lastPhoneNumberBlock.length > 0){
            lastPhoneNumberBlock.after(newBlock);
        }else{
            $('#phoneNumber-container').prepend(newBlock);
        }

        newBlock.show();
    });

    $("button[id^='button-remove-phoneNumber-']").click(function(){
        var myBlock = $(this).parent();
        myBlock.remove();
    });

    $("#button-add-im").click(function(){
        var allImBlocks = $("[id^='im-block-']");
        var displayedImCount = allImBlocks.size();
        var lastImBlock = allImBlocks.last();

        var myIndex = displayedImCount;
        var newBlock = cloneBlock('#im-template', 'im-block-' + myIndex, myIndex);

        if(lastImBlock.length > 0){
            lastImBlock.after(newBlock);
        }else{
            $('#im-container').prepend(newBlock);
        }

        newBlock.show();
    });

    $("button[id^='button-remove-im-']").click(function(){
        var myBlock = $(this).parent();
        myBlock.remove();
    });

    $("#button-add-certificate").click(function(){
        var allCertificatesBlocks = $("[id^='certificates-block-']");
        var displayedCertificatesCount = allCertificatesBlocks.size();
        var lastCertificatesBlock = allCertificatesBlocks.last();

        var myIndex = displayedCertificatesCount;
        var newBlock = cloneBlock('#certificate-template', 'certificates-block-' + myIndex, myIndex);

        if(lastCertificatesBlock.length > 0){
            lastCertificatesBlock.after(newBlock);
        }else{
            $('#certificates-container').prepend(newBlock);
        }

        newBlock.show();
    });

    $("button[id^='button-remove-certificates-']").click(function(){
        var myBlock = $(this).parent();
        myBlock.remove();
    });

    $("#button-add-entitlement").click(function(){
        var allEntitlementBlocks = $("[id^='entitlement-block-']");
        var displayedEntitlementCount = allEntitlementBlocks.size();
        var lastEntitlementBlock = allEntitlementBlocks.last();

        var myIndex = displayedEntitlementCount;
        var newBlock = cloneBlock('#entitlement-template', 'entitlement-block-' + myIndex, myIndex);

        if(lastEntitlementBlock.length > 0){
            lastEntitlementBlock.after(newBlock);
        }else{
            $('#entitlements-container').prepend(newBlock);
        }

        newBlock.show();
    });

    $("button[id^='button-remove-entitlement-']").click(function(){
        var myBlock = $(this).parent();
        myBlock.remove();
    });

    $("#button-add-address").click(function(){
        var allAddressBlocks = $("[id^='address-block-']");
        var displayedAddressCount = allAddressBlocks.size();
        var lastAddressBlock = allAddressBlocks.last();

        var myIndex = displayedAddressCount;
        var newBlock = cloneBlock('#address-template', 'address-block-' + myIndex, myIndex);

        if(lastAddressBlock.length > 0){
            lastAddressBlock.after(newBlock);
        }else{
            $('#addresses-container').prepend(newBlock);
        }

        newBlock.show();
    });

    $("button[id^='button-remove-address-']").click(function(){
        var myBlock = $(this).parent();
        myBlock.remove();
    });

    function cloneBlock(searchString, newId, newIndex){
        var templateBlock = $(searchString);
        var newBlock = templateBlock.clone();

        newBlock.attr('id', newId);
        newBlock.find('*').each(function(e, element) {
            $.each(this.attributes, function(a, attr){
                var name = attr.name;
                var value = attr.value;

                if(value.indexOf("ID") > -1){
                    var newValue = value.replace(/ID/g, newIndex);
                    $(element).attr(name, newValue);
                }

            });
        });
        return newBlock;
    };

});<commit_msg>fix problem with new added remove-button<commit_after>$(function(){
    $(".only-on-js").css({"visibility":"visible"});

    $("#button-add-email").click(function(){
        var allEmailBlocks = $("[id^='email-block-']");
        var displayedEmailCount = allEmailBlocks.size();
        var lastEmailBlock = allEmailBlocks.last();

        var myIndex = displayedEmailCount;
        var newBlock = cloneBlock('#email-template', 'email-block-' + myIndex, myIndex);

        if(lastEmailBlock.length > 0){
            lastEmailBlock.after(newBlock);
        }else{
            $('#email-container').prepend(newBlock);
        }

        newBlock.show();
        applyRemoveActions();
    });

    $("#button-add-phoneNumber").click(function(){
        var allPhoneNumberBlocks = $("[id^='phoneNumber-block-']");
        var displayedPhoneNumberCount = allPhoneNumberBlocks.size();
        var lastPhoneNumberBlock = allPhoneNumberBlocks.last();

        var myIndex = displayedPhoneNumberCount;
        var newBlock = cloneBlock('#phoneNumber-template', 'phoneNumber-block-' + myIndex, myIndex);

        if(lastPhoneNumberBlock.length > 0){
            lastPhoneNumberBlock.after(newBlock);
        }else{
            $('#phoneNumber-container').prepend(newBlock);
        }

        newBlock.show();
        applyRemoveActions();
    });

    $("#button-add-im").click(function(){
        var allImBlocks = $("[id^='im-block-']");
        var displayedImCount = allImBlocks.size();
        var lastImBlock = allImBlocks.last();

        var myIndex = displayedImCount;
        var newBlock = cloneBlock('#im-template', 'im-block-' + myIndex, myIndex);

        if(lastImBlock.length > 0){
            lastImBlock.after(newBlock);
        }else{
            $('#im-container').prepend(newBlock);
        }

        newBlock.show();
        applyRemoveActions();
    });

    $("#button-add-certificate").click(function(){
        var allCertificatesBlocks = $("[id^='certificates-block-']");
        var displayedCertificatesCount = allCertificatesBlocks.size();
        var lastCertificatesBlock = allCertificatesBlocks.last();

        var myIndex = displayedCertificatesCount;
        var newBlock = cloneBlock('#certificate-template', 'certificates-block-' + myIndex, myIndex);

        if(lastCertificatesBlock.length > 0){
            lastCertificatesBlock.after(newBlock);
        }else{
            $('#certificates-container').prepend(newBlock);
        }

        newBlock.show();
        applyRemoveActions();
    });

    $("#button-add-entitlement").click(function(){
        var allEntitlementBlocks = $("[id^='entitlement-block-']");
        var displayedEntitlementCount = allEntitlementBlocks.size();
        var lastEntitlementBlock = allEntitlementBlocks.last();

        var myIndex = displayedEntitlementCount;
        var newBlock = cloneBlock('#entitlement-template', 'entitlement-block-' + myIndex, myIndex);

        if(lastEntitlementBlock.length > 0){
            lastEntitlementBlock.after(newBlock);
        }else{
            $('#entitlements-container').prepend(newBlock);
        }

        newBlock.show();
        applyRemoveActions();
    });

    $("#button-add-address").click(function(){
        var allAddressBlocks = $("[id^='address-block-']");
        var displayedAddressCount = allAddressBlocks.size();
        var lastAddressBlock = allAddressBlocks.last();

        var myIndex = displayedAddressCount;
        var newBlock = cloneBlock('#address-template', 'address-block-' + myIndex, myIndex);

        if(lastAddressBlock.length > 0){
            lastAddressBlock.after(newBlock);
        }else{
            $('#addresses-container').prepend(newBlock);
        }

        newBlock.show();
        applyRemoveActions();
    });

    function applyRemoveActions(){
        $("button[id^='button-remove-email-']").click(function(){
            var myBlock = $(this).parent();
            myBlock.remove();
        });

        $("button[id^='button-remove-phoneNumber-']").click(function(){
            var myBlock = $(this).parent();
            myBlock.remove();
        });

        $("button[id^='button-remove-im-']").click(function(){
            var myBlock = $(this).parent();
            myBlock.remove();
        });

        $("button[id^='button-remove-certificates-']").click(function(){
            var myBlock = $(this).parent();
            myBlock.remove();
        });

        $("button[id^='button-remove-entitlement-']").click(function(){
            var myBlock = $(this).parent();
            myBlock.remove();
        });

        $("button[id^='button-remove-address-']").click(function(){
            var myBlock = $(this).parent();
            myBlock.remove();
        });
    }

    function cloneBlock(searchString, newId, newIndex){
        var templateBlock = $(searchString);
        var newBlock = templateBlock.clone();

        newBlock.attr('id', newId);
        newBlock.find('*').each(function(e, element) {
            $.each(this.attributes, function(a, attr){
                var name = attr.name;
                var value = attr.value;

                if(value.indexOf("ID") > -1){
                    var newValue = value.replace(/ID/g, newIndex);
                    $(element).attr(name, newValue);
                }

            });
        });
        return newBlock;
    };

    applyRemoveActions();
});
{'fraction_non_alphanumeric': 0.16142638036809817, 'fraction_numerical': 0.0013420245398773007, 'mean_word_length': 2.4466468450611165, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 17, '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': '4111409', 'n_tokens_mistral': 2922, 'n_tokens_neox': 2846, 'n_words': 444}