<commit_before>import {Controller} from "stimulus";

export default class extends Controller {

    /**
     *
     */
    connect() {
        this.addListenerForTargets();
    }

    /**
     *
     */
    addListenerForTargets() {
        this.targets.forEach(name => {
            document.querySelectorAll(`[name="${name}"]`)
                .forEach((field) =>
                    field.addEventListener('change', () => this.render())
                );
        });
    }


    render() {
        let params = {};

        this.targets.forEach(name => document.querySelectorAll(`[name="${name}"]`)
            .forEach((field) => {

                if ((field.type === 'checkbox' || field.type === 'radio') && !field.checked) {
                    return;
                }

                params[name] = field.value;
            }));

        this.asyncLoadData(params);
    }

    /**
     *
     * @param params
     */
    asyncLoadData(params) {
<commit_msg>Fixed multiple calls to the listener<commit_after>import {Controller} from "stimulus";

export default class extends Controller {

    /**
     *
     */
    connect() {
        this.addListenerForTargets();
    }

    /**
     *
     */
    addListenerForTargets() {
        this.targets.forEach(name => {
            document.querySelectorAll(`[name="${name}"]`)
                .forEach((field) =>
                    field.addEventListener('change', () => this.render(), {
                        once: true
                    })
                );
        });
    }


    render() {
        let params = {};

        this.targets.forEach(name => document.querySelectorAll(`[name="${name}"]`)
            .forEach((field) => {

                if ((field.type === 'checkbox' || field.type === 'radio') && !field.checked) {
                    return;
                }

                params[name] = field.value;
            }));

        this.asyncLoadData(params);
    }

    /**
     *
     * @param params
     */
    asyncLoadData(params) {

{'fraction_non_alphanumeric': 0.15833745670460167, 'fraction_numerical': 0.0, 'mean_word_length': 1.453883495145631, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '412805', 'n_tokens_mistral': 561, 'n_tokens_neox': 526, 'n_words': 79}