<commit_before>'use strict';
(function(){
    var ExcerptManager = function(locationFilter, inputElementsNewBoundingBox) {
        this.locationFilter = locationFilter;
        this.inputElementsNewBoundingBox = inputElementsNewBoundingBox;

        /**
         * Synchronize coordinates in input fields to excerpt on map
         */
        this.updateInputElementsBoundingBox = function() {
            var locationFilterBounds = this.locationFilter.getBounds();
            this.inputElementsNewBoundingBox.inputElementNorth.value = locationFilterBounds._northEast.lat;
            var ev = new CustomEvent("valueUpdate");
            this.inputElementsNewBoundingBox.inputElementNorth.dispatchEvent(ev);
            this.inputElementsNewBoundingBox.inputElementWest.value = locationFilterBounds._southWest.lng;
            this.inputElementsNewBoundingBox.inputElementWest.dispatchEvent(ev);
            this.inputElementsNewBoundingBox.inputElementEast.value = locationFilterBounds._northEast.lng;
            this.inputElementsNewBoundingBox.inputElementEast.dispatchEvent(ev);
            this.inputElementsNewBoundingBox.inputElementSouth.value = locationFilterBounds._southWest.lat;
            this.inputElementsNewBoundingBox.inputElementSouth.dispatchEvent(ev);
        };
        this.areAllBoxesSet = function(){
            return this.inputElementsNewBoundingBox.inputElementNorth.value &&
                this.inputElementsNewBoundingBox.inputElementWest.value &&
                this.inputElementsNewBoundingBox.inputElementEast.value &&
                this.inputElementsNewBoundingBox.inputElementSouth.value
        }.bind(this);

        /**
         * Synchronize excerpt on map to coordinates in input fields
         */
        this.updateMapExcerpt = function() {
            var locationFilterBounds = this.locationFilter.getBounds();
            locationFilterBounds._northEast.lat = this.inputElementsNewBoundingBox.inputElementNorth.value;
            locationFilterBounds._southWest.lng = this.inputElementsNewBoundingBox.inputElementWest.value;
            locationFilterBounds._northEast.lng = this.inputElementsNewBoundingBox.inputElementEast.value;
            locationFilterBounds._southWest.lat = this.inputElementsNewBoundingBox.inputElementSouth.value;
            if (this.areAllBoxesSet()) {
                this.locationFilter.setBounds(locationFilterBounds);
            }
        };

          // update coordinates input elements on change of excerpt on map
        this.locationFilter.on("change", function (event) {
            this.updateInputElementsBoundingBox();
        }.bind(this));

        // update excerpt on map on change of coordinates input elements
        Object.keys(this.inputElementsNewBoundingBox).forEach(function(inputElementKey) {
            this.inputElementsNewBoundingBox[inputElementKey].addEventListener('change', this.updateMapExcerpt.bind(this));
        }.bind(this));
    };

    var map = L.map('map').setView([0, 0], 2);
    // add an OpenStreetMap tile layer
    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);

    var locationFilter = new L.LocationFilter({
        enable: true,
        enableButton: false
    }).addTo(map);

    var excerptManager = new ExcerptManager(
        locationFilter,
        {
            inputElementNorth: document.getElementById('id_north'),
            inputElementWest: document.getElementById('id_west'),
            inputElementEast: document.getElementById('id_east'),
            inputElementSouth: document.getElementById('id_south')
        }
    );

    // push initial values to text inputs
    excerptManager.updateInputElementsBoundingBox();
})();
<commit_msg>use a separate instance for each event<commit_after>'use strict';
(function(){
    var ExcerptManager = function(locationFilter, inputElementsNewBoundingBox) {
        this.locationFilter = locationFilter;
        this.inputElementsNewBoundingBox = inputElementsNewBoundingBox;

        /**
         * Synchronize coordinates in input fields to excerpt on map
         */
        this.updateInputElementsBoundingBox = function() {
            var locationFilterBounds = this.locationFilter.getBounds();
            this.inputElementsNewBoundingBox.inputElementNorth.value = locationFilterBounds._northEast.lat;
            this.inputElementsNewBoundingBox.inputElementNorth.dispatchEvent(new CustomEvent("valueUpdate"));
            this.inputElementsNewBoundingBox.inputElementWest.value = locationFilterBounds._southWest.lng;
            this.inputElementsNewBoundingBox.inputElementWest.dispatchEvent(new CustomEvent("valueUpdate"));
            this.inputElementsNewBoundingBox.inputElementEast.value = locationFilterBounds._northEast.lng;
            this.inputElementsNewBoundingBox.inputElementEast.dispatchEvent(new CustomEvent("valueUpdate"));
            this.inputElementsNewBoundingBox.inputElementSouth.value = locationFilterBounds._southWest.lat;
            this.inputElementsNewBoundingBox.inputElementSouth.dispatchEvent(new CustomEvent("valueUpdate"));
        };
        this.areAllBoxesSet = function(){
            return this.inputElementsNewBoundingBox.inputElementNorth.value &&
                this.inputElementsNewBoundingBox.inputElementWest.value &&
                this.inputElementsNewBoundingBox.inputElementEast.value &&
                this.inputElementsNewBoundingBox.inputElementSouth.value
        }.bind(this);

        /**
         * Synchronize excerpt on map to coordinates in input fields
         */
        this.updateMapExcerpt = function() {
            var locationFilterBounds = this.locationFilter.getBounds();
            locationFilterBounds._northEast.lat = this.inputElementsNewBoundingBox.inputElementNorth.value;
            locationFilterBounds._southWest.lng = this.inputElementsNewBoundingBox.inputElementWest.value;
            locationFilterBounds._northEast.lng = this.inputElementsNewBoundingBox.inputElementEast.value;
            locationFilterBounds._southWest.lat = this.inputElementsNewBoundingBox.inputElementSouth.value;
            if (this.areAllBoxesSet()) {
                this.locationFilter.setBounds(locationFilterBounds);
            }
        };

          // update coordinates input elements on change of excerpt on map
        this.locationFilter.on("change", function (event) {
            this.updateInputElementsBoundingBox();
        }.bind(this));

        // update excerpt on map on change of coordinates input elements
        Object.keys(this.inputElementsNewBoundingBox).forEach(function(inputElementKey) {
            this.inputElementsNewBoundingBox[inputElementKey].addEventListener('change', this.updateMapExcerpt.bind(this));
        }.bind(this));
    };

    var map = L.map('map').setView([0, 0], 2);
    // add an OpenStreetMap tile layer
    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);

    var locationFilter = new L.LocationFilter({
        enable: true,
        enableButton: false
    }).addTo(map);

    var excerptManager = new ExcerptManager(
        locationFilter,
        {
            inputElementNorth: document.getElementById('id_north'),
            inputElementWest: document.getElementById('id_west'),
            inputElementEast: document.getElementById('id_east'),
            inputElementSouth: document.getElementById('id_south')
        }
    );

    // push initial values to text inputs
    excerptManager.updateInputElementsBoundingBox();
})();

{'fraction_non_alphanumeric': 0.09489240342234898, 'fraction_numerical': 0.00077780658542909, 'mean_word_length': 3.0950106157112525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5940204', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1908, 'n_words': 304}