<commit_before>/*globals d3*/

isic.views.ImagesViewSubViews = isic.views.ImagesViewSubViews || {};

isic.views.ImagesViewSubViews.HistogramPane = Backbone.View.extend({
    initialize: function () {
        var self = this;

        self.individualHistograms = {};

        self.listenTo(self.model, 'change:overviewHistogram', self.render);
        self.listenTo(self.model, 'change:filteredSetHistogram', self.render);
        self.listenTo(self.model, 'change:pageHistogram', self.render);
    },
    render: function () {
        var self = this;

        if (!self.addedCollapseImage) {
            // little hack to inject the correct expander image path into the
            // stylesheet (afaik, we can't access girder.staticRoot from the
            // stylus files)
            var isicStylesheet = Array.from(document.styleSheets)
                .filter(function (sheet) {
                    return sheet.href &&
                        sheet.href.indexOf('isic_archive.min.css') !== -1;
                })[0];
            isicStylesheet.addRule('#isic-images-histogramPane ' +
                '.attributeSection .header input.expander:before',
                'background-image: url(' + girder.staticRoot +
                    '/built/plugins/isic_archive/extra/img/collapse.svg);');
            self.addedCollapseImage = true;
        }

        var attributeOrder = Object.keys(self.model.get('overviewHistogram'))
            .filter(function (d) {
                return d !== '__passedFilters__' && d !== 'folderId';
            });

        var attributeSections = d3.select(this.el).selectAll('.attributeSection')
            .data(attributeOrder, function (d) {
                return d;
            });
        var attributeSectionsEnter = attributeSections.enter().append('div');
        attributeSections.exit()
            .each(function (d) {
                var histogramId = window.shims.makeValidId(d + '_histogramContent');
                delete self.individualHistograms[histogramId];<commit_msg>Use a more modern API method to interact with CSSStyleSheet<commit_after>/*globals d3*/

isic.views.ImagesViewSubViews = isic.views.ImagesViewSubViews || {};

isic.views.ImagesViewSubViews.HistogramPane = Backbone.View.extend({
    initialize: function () {
        var self = this;

        self.individualHistograms = {};

        self.listenTo(self.model, 'change:overviewHistogram', self.render);
        self.listenTo(self.model, 'change:filteredSetHistogram', self.render);
        self.listenTo(self.model, 'change:pageHistogram', self.render);
    },
    render: function () {
        var self = this;

        if (!self.addedCollapseImage) {
            // little hack to inject the correct expander image path into the
            // stylesheet (afaik, we can't access girder.staticRoot from the
            // stylus files)
            var isicStylesheet = Array.from(document.styleSheets)
                .filter(function (sheet) {
                    return sheet.href &&
                        sheet.href.indexOf('isic_archive.min.css') !== -1;
                })[0];
            isicStylesheet.insertRule('#isic-images-histogramPane ' +
                '.attributeSection .header input.expander:before ' +
                '{background-image: url(' + girder.staticRoot +
                    '/built/plugins/isic_archive/extra/img/collapse.svg);}',
                0);
            self.addedCollapseImage = true;
        }

        var attributeOrder = Object.keys(self.model.get('overviewHistogram'))
            .filter(function (d) {
                return d !== '__passedFilters__' && d !== 'folderId';
            });

        var attributeSections = d3.select(this.el).selectAll('.attributeSection')
            .data(attributeOrder, function (d) {
                return d;
            });
        var attributeSectionsEnter = attributeSections.enter().append('div');
        attributeSections.exit()
            .each(function (d) {
                var histogramId = window.shims.makeValidId(d + '_histogramContent');
                delete self.individualHistograms[histogramId];
{'fraction_non_alphanumeric': 0.12028073572120039, 'fraction_numerical': 0.0021781219748305907, 'mean_word_length': 2.123960695389267, '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': '4935830', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1090, 'n_words': 207}