<commit_before>var DisplayValue = (function(){
    function roundDown(v, i) {
    	var c = 2;
    	var d = Math.pow(10, c);
    	return Math.floor(v * d) / d;
    }
    function Value(v) {
        if(v===undefined) {
            return ["&mdash;", 'val-undefined'];
    	} else if (v===null) {
            return ["null", 'val-null'];
        } else if (v===true) {
    	    return ["Yes"];
    	} else if (v===false) {
    	    return ["No"];
    	} else if (!isNaN(+v)) {
    	    return [roundDown(v)];
    	} else if ($.type(v) === "string") {
    	    return [NMIS.HackCaps(v)]
    	}
        return [v];
    }
    function DisplayInElement(d, td) {
        var res = Value(d);
        if (d[1]!==undefined) td.addClass(res[1]);
        return td.html(res[0]);
    }
    DisplayInElement.raw = Value;
    DisplayInElement.special = function(v, indicator) {
        var r = Value(v),
            o = {name: indicator.name, classes: "", value: r[0]};
        if(indicator.display_style==="checkmark_true") {
            o.classes = "label ";
            if(v===true) {
                o.classes += "chk-yes";
            } else if(v===false) {
                o.classes += "chk-no";
            } else {
                o.classes += "chk-null";
            }
        } else if(indicator.display_style==="checkmark_false") {
            o.classes = "label ";
            if(v===true) {
                o.classes += "chk-no";
            } else if(v===false) {
                o.classes += "chk-yes";
            } else {
                o.classes += "chk-null";
            }
        }
        return o;
    }
    DisplayInElement.inTdElem = function(facility, indicator, elem) {
        var vv = facility[indicator.slug],
            c = Value(vv);
        var chkY = indicator.display_style === "checkmark_true",
            chkN = indicator.display_style === "checkmark_false";

        if(chkY || chkN) {
            var oclasses = "label ";
            if($.type(vv)==="boolean") {
                if(vv) {
                    oclasses += chkY ? "chk-yes" : "chk-no";
                } else {
                    oclasses += chkY ? "chk-no" : "chk-yes";
                }
            } else {
                oclasses += "chk-null";
            }
            c[0] = $('<span />').addClass(oclasses).html(c[0]);
        }
        return elem.html(c[0]);
    }

    return DisplayInElement;
})();

var SectorDataTable = (function(){
    var dt, table;
    function dtOpts(_o) {
        return _.extend({
            sScrollY: 120,
            bScrollCollapse: false,
            bPaginate: false
        }, _o);
    }
    var tableSwitcher;
    function createIn(tableWrap, env, _opts) {
        var opts = _.extend({
            sScrollY: 120
        }, _opts);
        var data = NMIS.dataForSector(env.sector.slug);
        if(env.subsector===undefined) {
            throw(new Error("Subsector is undefined"));
        }
        env.subsector = env.sector.getSubsector(env.subsector.slug);
        var columns = env.subsector.columns();

        if(tableSwitcher) {tableSwitcher.remove();}
        tableSwitcher = $('<select />');
        _.each(env.sector.subGroups(), function(sg){
            $('<option />').val(sg.slug).text(sg.name).appendTo(tableSwitcher);
        });
        tableSwitcher
                    .val(env.subsector.slug)
                    .appendTo(tableWrap)
                    .change(function(){
                        var ssSlug = $(this).val();
                        var nextUrl = NMIS.urlFor(_.extend({},
                                        env,
                                        {subsector: env.sector.getSubsector(ssSlug)}));
                        dashboard.setLocation(nextUrl);
                    });
        table = $('<table />')
            .addClass('bs')
            .append(_createThead(columns))
            .append(_createTbody(columns, data));
        tableWrap.append(table);
        dt = table.dataTable(dtOpts({
            "sDom": "<'row'<'span8'l><'span8'f>r>t<'row'<'span8'i><'span8'p>>",
            sScrollY: opts.sScrollY
        }));
		table.delegate('tr', 'click', function(){
		    log($(this).data('rowData'));
		});
        return table;
    }
    function updateScrollSize(ss) {
        if(!!table) {
            dt = table.dataTable(dtOpts({
                sScrollY: ss,
                bDestroy: true
            }));
        }
    }
    function handleHeadRowClick() {
        var column = $(this).data('column');
        var indicatorSlug = column.slug;
        if(!!indicatorSlug) {
            var newEnv = _.extend({}, NMIS.Env(), {
                indicator: indicatorSlug
            });<commit_msg>facility tables selector now in the same row<commit_after>var DisplayValue = (function(){
    function roundDown(v, i) {
    	var c = 2;
    	var d = Math.pow(10, c);
    	return Math.floor(v * d) / d;
    }
    function Value(v) {
        if(v===undefined) {
            return ["&mdash;", 'val-undefined'];
    	} else if (v===null) {
            return ["null", 'val-null'];
        } else if (v===true) {
    	    return ["Yes"];
    	} else if (v===false) {
    	    return ["No"];
    	} else if (!isNaN(+v)) {
    	    return [roundDown(v)];
    	} else if ($.type(v) === "string") {
    	    return [NMIS.HackCaps(v)]
    	}
        return [v];
    }
    function DisplayInElement(d, td) {
        var res = Value(d);
        if (d[1]!==undefined) td.addClass(res[1]);
        return td.html(res[0]);
    }
    DisplayInElement.raw = Value;
    DisplayInElement.special = function(v, indicator) {
        var r = Value(v),
            o = {name: indicator.name, classes: "", value: r[0]};
        if(indicator.display_style==="checkmark_true") {
            o.classes = "label ";
            if(v===true) {
                o.classes += "chk-yes";
            } else if(v===false) {
                o.classes += "chk-no";
            } else {
                o.classes += "chk-null";
            }
        } else if(indicator.display_style==="checkmark_false") {
            o.classes = "label ";
            if(v===true) {
                o.classes += "chk-no";
            } else if(v===false) {
                o.classes += "chk-yes";
            } else {
                o.classes += "chk-null";
            }
        }
        return o;
    }
    DisplayInElement.inTdElem = function(facility, indicator, elem) {
        var vv = facility[indicator.slug],
            c = Value(vv);
        var chkY = indicator.display_style === "checkmark_true",
            chkN = indicator.display_style === "checkmark_false";

        if(chkY || chkN) {
            var oclasses = "label ";
            if($.type(vv)==="boolean") {
                if(vv) {
                    oclasses += chkY ? "chk-yes" : "chk-no";
                } else {
                    oclasses += chkY ? "chk-no" : "chk-yes";
                }
            } else {
                oclasses += "chk-null";
            }
            c[0] = $('<span />').addClass(oclasses).html(c[0]);
        }
        return elem.html(c[0]);
    }

    return DisplayInElement;
})();

var SectorDataTable = (function(){
    var dt, table;
    function dtOpts(_o) {
        return _.extend({
            sScrollY: 120,
            bScrollCollapse: false,
            bPaginate: false
        }, _o);
    }
    var tableSwitcher;
    function createIn(tableWrap, env, _opts) {
        var opts = _.extend({
            sScrollY: 120
        }, _opts);
        var data = NMIS.dataForSector(env.sector.slug);
        if(env.subsector===undefined) {
            throw(new Error("Subsector is undefined"));
        }
        env.subsector = env.sector.getSubsector(env.subsector.slug);
        var columns = env.subsector.columns();

        if(tableSwitcher) {tableSwitcher.remove();}
        tableSwitcher = $('<select />');
        _.each(env.sector.subGroups(), function(sg){
            $('<option />').val(sg.slug).text(sg.name).appendTo(tableSwitcher);
        });
        tableSwitcher
                    .val(env.subsector.slug)
                    .change(function(){
                        var ssSlug = $(this).val();
                        var nextUrl = NMIS.urlFor(_.extend({},
                                        env,
                                        {subsector: env.sector.getSubsector(ssSlug)}));
                        dashboard.setLocation(nextUrl);
                    });
        table = $('<table />')
            .append(_createThead(columns))
            .append(_createTbody(columns, data));
        tableWrap.append(table);
        dt = table.dataTable({
            sScrollY: opts.sScrollY,
            bScrollCollapse: false,
            bPaginate: false
        });
		$('.dataTables_filter', tableWrap).after($('<div />', {'class': 'dataTables_filter'}).html(tableSwitcher));
		table.delegate('tr', 'click', function(){
		    log($(this).data('rowData'));
		});
        return table;
    }
    function updateScrollSize(ss) {
        if(!!table) {
            dt = table.dataTable(dtOpts({
                sScrollY: ss,
                bDestroy: true
            }));
        }
    }
    function handleHeadRowClick() {
        var column = $(this).data('column');
        var indicatorSlug = column.slug;
        if(!!indicatorSlug) {
            var newEnv = _.extend({}, NMIS.Env(), {
                indicator: indicatorSlug
            });
{'fraction_non_alphanumeric': 0.155574395930479, 'fraction_numerical': 0.0038151759220008477, 'mean_word_length': 1.5320633217064663, 'pattern_counts': {'":': 1, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '812109', 'n_tokens_mistral': 2904, 'n_tokens_neox': 2854, 'n_words': 521}