<commit_before>if (typeof jQuery === 'undefined') {
    var jQuery = django.jQuery;
}

(function ($) {
    $(function () {
        $('.sortedm2m-container').find('.sortedm2m-items').addClass('hide');
        function prepareUl(ul) {
            ul.addClass('sortedm2m');
            var checkboxes = ul.find('input[type=checkbox]');
            var id;
            var name;

            if (checkboxes.length) {
                id = checkboxes.first().attr('id').match(/^(.*)_\d+$/)[1];
                name = checkboxes.first().attr('name');
                checkboxes.removeAttr('name');
            } else {
                var label;
                var currentElement = ul;

                while (!label || !label.length) {
                    currentElement = currentElement.parent();
                    label = currentElement.siblings('label');
                }

                id = label.attr('for').match(/^(.*)_\d+$/)[1];
                name = id.replace(/^id_/, '');<commit_msg>Fixed JS error in admin widget when zero elements<commit_after>if (typeof jQuery === 'undefined') {
    var jQuery = django.jQuery;
}

(function ($) {
    $(function () {
        $('.sortedm2m-container').find('.sortedm2m-items').addClass('hide');
        function prepareUl(ul) {
            ul.addClass('sortedm2m');
            var checkboxes = ul.find('input[type=checkbox]');
            var id;
            var name;

            if (checkboxes.length) {
                id = checkboxes.first().attr('id').match(/^(.*)_\d+$/)[1];
                name = checkboxes.first().attr('name');
                checkboxes.removeAttr('name');
            } else {
                var label, labelFor;
                var currentElement = ul;

                while (!label || !label.length) {
                    currentElement = currentElement.parent();
                    label = currentElement.siblings('label');
                }

                labelFor = label.attr('for');
                if (!labelFor) { return; }
                id = labelFor.match(/^(.*)_\d+$/)[1];
                name = id.replace(/^id_/, '');
{'fraction_non_alphanumeric': 0.16493383742911152, 'fraction_numerical': 0.004725897920604915, 'mean_word_length': 1.5943627450980393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4639517', 'n_tokens_mistral': 601, 'n_tokens_neox': 560, 'n_words': 102}