<commit_before>var checklist = require('./checklist.js');
var occurrences = require('./occurrences.js');
var selectors = require('./selector.js');
var util = require('./util.js');


var effechecka = {};
module.exports = effechecka;

var init = function () {
    selectors.addTo(document.querySelector('#effechecka-selector'));
    checklist.addTo(document.querySelector('#effechecka-checklist'));
    occurrences.addTo(document.querySelector('#effechecka-occurrences'));

    var selector = selectors.createSelectors();

    if (document.querySelector('#effechecka-checklist')) {
        checklist.select(selector);
    }
    if (document.querySelector('#effechecka-occurrences')) {
        occurrences.select(selector);
    }

    function initOccurrenceFilter(filterName) {
        var filterElementId = 'effechecka-' + filterName;
        var filterElem = document.getElementById(filterElementId);
        if (filterElem) {
            var filter = selector.getDataFilter();
            var filterValue = filter[filterName];
            if (filterValue !== undefined) {
                filterElem.value = filterValue;
            }

            filterElem.addEventListener('change', function (event) {
                var filter = selector.getDataFilter();
                var filterValue = event.target.value;
                if (filterValue !== undefined) {
                    filter[filterName] = filterValue;
                    selector.setDataFilter(filter);
                    selector.emit('update');
                }
            });
        }
    }

    initOccurrenceFilter('addedBefore');
    initOccurrenceFilter('addedAfter');

    selector.init();

    function initFeed() {
        if (document.getElementById('occurrenceProgress')) {
            util.enableFeed(function (monitorStatus) {
                var dataFilter = selector.getDataFilter();
                var selectorWebContext = { taxonSelector: dataFilter['taxonSelector'].replace(/,/g, "|"), wktString: dataFilter['wktString'], traitSelector: dataFilter['traitSelector']};
                var selectorFeedContext = monitorStatus.selector;

                if (util.deepEqualIgnoreEmpty(selectorWebContext, selectorFeedContext)) {
                    var feedElem = document.getElementById('occurrenceProgress');
                    if (feedElem) {
                        feedElem.textContent = '&nbsp;(' + monitorStatus.percentComplete + '%)';
                    }
                    var feedStatus = document.getElementById('occurrencesStatus')
                    if (feedStatus) {
                        if (status === 'ready') {
                            selector.emit('update');
                        }
                        feedStatus.textContent = monitorStatus.status;
                    }
                }
            });
        }
    }

    initFeed();
};

window.addEventListener('load', function () {
    init();
});

window.addEventListener('popstate', function (event) {
    ['#effechecka-selector', '#effechecka-checklist', '#effechecka-occurrences']
        .forEach(function (id) {
            util.removeChildren(id);
        });
    init();
});

<commit_msg>tweak<commit_after>var checklist = require('./checklist.js');
var occurrences = require('./occurrences.js');
var selectors = require('./selector.js');
var util = require('./util.js');


var effechecka = {};
module.exports = effechecka;

var init = function () {
    selectors.addTo(document.querySelector('#effechecka-selector'));
    checklist.addTo(document.querySelector('#effechecka-checklist'));
    occurrences.addTo(document.querySelector('#effechecka-occurrences'));

    var selector = selectors.createSelectors();

    if (document.querySelector('#effechecka-checklist')) {
        checklist.select(selector);
    }
    if (document.querySelector('#effechecka-occurrences')) {
        occurrences.select(selector);
    }

    function initOccurrenceFilter(filterName) {
        var filterElementId = 'effechecka-' + filterName;
        var filterElem = document.getElementById(filterElementId);
        if (filterElem) {
            var filter = selector.getDataFilter();
            var filterValue = filter[filterName];
            if (filterValue !== undefined) {
                filterElem.value = filterValue;
            }

            filterElem.addEventListener('change', function (event) {
                var filter = selector.getDataFilter();
                var filterValue = event.target.value;
                if (filterValue !== undefined) {
                    filter[filterName] = filterValue;
                    selector.setDataFilter(filter);
                    selector.emit('update');
                }
            });
        }
    }

    initOccurrenceFilter('addedBefore');
    initOccurrenceFilter('addedAfter');

    selector.init();

    function initFeed() {
        if (document.getElementById('occurrenceProgress')) {
            util.enableFeed(function (monitorStatus) {
                var dataFilter = selector.getDataFilter();
                var selectorWebContext = { taxonSelector: dataFilter['taxonSelector'].replace(/,/g, "|"), wktString: dataFilter['wktString'], traitSelector: dataFilter['traitSelector']};
                var selectorFeedContext = monitorStatus.selector;

                if (util.deepEqualIgnoreEmpty(selectorWebContext, selectorFeedContext)) {
                    var feedElem = document.getElementById('occurrenceProgress');
                    if (feedElem) {
                        feedElem.textContent = '(' + monitorStatus.percentComplete + '%)';
                    }
                    var feedStatus = document.getElementById('occurrencesStatus')
                    if (feedStatus) {
                        if (status === 'ready') {
                            selector.emit('update');
                        }
                        feedStatus.textContent = monitorStatus.status + "...";
                    }
                }
            });
        }
    }

    initFeed();
};

window.addEventListener('load', function () {
    init();
});

window.addEventListener('popstate', function (event) {
    ['#effechecka-selector', '#effechecka-checklist', '#effechecka-occurrences']
        .forEach(function (id) {
            util.removeChildren(id);
        });
    init();
});


{'fraction_non_alphanumeric': 0.1251970987070325, 'fraction_numerical': 0.0, 'mean_word_length': 2.1494538232373386, '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': '6994405', 'n_tokens_mistral': 1622, 'n_tokens_neox': 1536, 'n_words': 255}