<commit_before>(function ($) {
    'use strict';

    $.fn.extend({
        personAutoComplete: function () {
            $(this).each(function () {
                var $element = $(this);
                var createUrl = $element.data('create-url');

                $element.dropdown('setting', 'allowAdditions', true);
                $element.dropdown('setting', 'hideAdditions', false);

                $element.dropdown('setting', 'onAdd', function (addedValue, addedText, $addedChoice) {
                    if ($addedChoice.hasClass('addition')) {
                        var lastName = getLastNameByConcatenatedNames(addedText);
                        var firstName = getFirstNameByConcatenatedNames(addedText);

                        postPerson($element, addedText, createUrl, lastName, firstName);

                        console.log(firstName);
                        console.log(lastName);
                    }
                });
            });
        }
    });

    function postPerson($element, addedText, url, lastName, firstName) {

        var $autoCompleteInput = $element.find('input.autocomplete');
        var values = $autoCompleteInput.val().split(',');

        $.ajax({
            type: "POST",
            url: url,
            data: {
                lastName: lastName,
                firstName: firstName
            },
            dataType: "json",
            accept: "application/json",
            success: function (data) {
                values.push(data.id);
                $autoCompleteInput.val(values.join(','));
            }
        });
    }

    /**
     * @param names
     *
     * @return string
     */
    function getLastNameByConcatenatedNames(names) {
        var nameParts = names.split(' ');

        if (nameParts.length === 1) {
            return nameParts[0];
        }

        nameParts.reverse();
        nameParts.pop();

        return nameParts.join(' ');
    }

    /**
     * @param names
     *
     * @return string|null
     */
    function getFirstNameByConcatenatedNames(names) {
        var lastName = getLastNameByConcatenatedNames(names);
        var firstName = names.replace(lastName, '').trim();

        return firstName !== "" ? firstName : null;
    }

})(jQuery);
<commit_msg>improve jsdoc for app-person-auto-complete<commit_after>(function ($) {
    'use strict';

    $.fn.extend({
        personAutoComplete: function () {
            $(this).each(function () {
                var $element = $(this);
                var createUrl = $element.data('create-url');

                $element.dropdown('setting', 'allowAdditions', true);
                $element.dropdown('setting', 'hideAdditions', false);

                $element.dropdown('setting', 'onAdd', function (addedValue, addedText, $addedChoice) {
                    if ($addedChoice.hasClass('addition')) {
                        var lastName = getLastNameByConcatenatedNames(addedText);
                        var firstName = getFirstNameByConcatenatedNames(addedText);

                        postPerson($element, addedText, createUrl, lastName, firstName);

                        console.log(firstName);
                        console.log(lastName);
                    }
                });
            });
        }
    });

    /**
     * @param {jQuery} $element
     * @param {string} addedText
     * @param {string} url
     * @param {string} lastName
     * @param {string} firstName
     */
    function postPerson($element, addedText, url, lastName, firstName) {

        var $autoCompleteInput = $element.find('input.autocomplete');
        var values = $autoCompleteInput.val().split(',');

        $.ajax({
            type: "POST",
            url: url,
            data: {
                lastName: lastName,
                firstName: firstName
            },
            dataType: "json",
            accept: "application/json",
            success: function (data) {
                values.push(data.id);
                $autoCompleteInput.val(values.join(','));
            }
        });
    }

    /**
     * @param {string} names
     *
     * @return {string}
     */
    function getLastNameByConcatenatedNames(names) {
        var nameParts = names.split(' ');

        if (nameParts.length === 1) {
            return nameParts[0];
        }

        nameParts.reverse();
        nameParts.pop();

        return nameParts.join(' ');
    }

    /**
     * @param {string} names
     *
     * @return {string|null}
     */
    function getFirstNameByConcatenatedNames(names) {
        var lastName = getLastNameByConcatenatedNames(names);
        var firstName = names.replace(lastName, '').trim();

        return firstName !== "" ? firstName : null;
    }

})(jQuery);

{'fraction_non_alphanumeric': 0.13119227539882453, 'fraction_numerical': 0.0008396305625524769, 'mean_word_length': 1.6605248464544946, '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': '1454767', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1233, 'n_words': 234}