<commit_before>d3.json('index.json').on('load', function(index) {

    // Build initial title listing
    var titles = d3.select('#titles')
        .selectAll('li.title')
        .data(index.titles);

    var li = titles
        .enter()
        .append('li')
        .attr('class', 'title')
        .on('click', clickTitle)
        .append('div')
        .attr('class', 'clearfix');

    li.append('span')
        .attr('class', 'number')
        .text(function(d) { return d[0]; });

    li.append('span')
        .attr('class', 'name')
        .text(function(d) { return d[1]; });

    function clickTitle(d) {
        router.setRoute(d[0]);
        updateTitle(d[0]);
    }

    function findTitle(t) {
        var t = titles
            .classed('active', function(d) { return d[0] === t; })
            .filter(function(d,i) { return d[0] == t; });
        var d = t.data()[0];
        updateTitle(d[0]);
        sectionsFor(d);

        d3.select('#titles').classed('selected', true);
        d3.select('#sections').classed('selected', false);

        //Scroll to the item if we can't already see it
        var top = t.property('offsetTop');
        var tc = d3.select('.titles-container');
        if(top > tc.property('scrollTop') + tc.property('offsetHeight')-35){
            tc.property('scrollTop',top-35);
        }
    }

    function findSection(t, s) {
        updateTitle(s);
        //Only refresh section list if we're changing titles
        var currentTitle = d3.select(".title.active");
        if (currentTitle.empty() || currentTitle.data()[0][0] != t) {
            findTitle(t);
        }

        var sections = d3.select('#sections')
            .selectAll('li.section')
            .classed('active',function(d) { return d[0] === s; });
        var section = sections
            .filter(function(d, i){ return d[0] === s; });

        //Scroll to the right part of the sections list if we can't see it
        var sectionsContainer = d3.select('.sections-container');
        if(section.property('offsetTop') > sectionsContainer.property('scrollTop') + sectionsContainer.property('offsetHeight')){
            sectionsContainer.property('scrollTop',section.property('offsetTop')-35);
        }

        doSection(section.data()[0]);
    }

    function doSection(d) {
        d3.select('#section').classed('loading', true);
        d3.json('sections/' + d[0] + '.json').on('load', function(section) {
            d3.select('#section').classed('loading', false);
            var s = d3.select('#section');

            d3.select('#sections').classed('selected', true);

            var content = s.selectAll('div.content')
                .data([section], function(d) { return JSON.stringify(d); });

            content.exit().remove();

            var div = content.enter()
                .append('div')
                .attr('class', 'content');

            div.append('h1')
                .attr('class', 'pad1')
                .text(function(d) {
                    return d.heading.catch_text;
                });

            if (section.text) {
                div.append('div')
                    .attr('class', 'section-text pad1')
                    .selectAll('p')
                    .data(function(d) {
                        return section.text.split(/\n+/);
                    })
                    .enter()
                    .append('p')
                    .html(function(d) {
                        return cited(d);
                    });
            }

            var sections = div.append('div')
                .attr('class', 'pad1')
                .selectAll('section')
                .data(section.sections, function(d) {
                    return d.prefix + d.text;
                });

            function sectionClass(d) {
                var c = '';
                if (d.prefix.match(/([a-z])/)) c = 'section-1';
                else if (d.prefix.match(/([0-9])/)) c = 'section-2';
                else if (d.prefix.match(/([A-Z])/)) c = 'section-3';
                return c;
            }

            var sectionelem = sections.enter()
                .append('section')
                .attr('class', sectionClass);

            sections.exit().remove();

            var section_p = sectionelem.append('p');

            section_p.append('span')
                .attr('class', 'section-prefix')
                .text(function(d) {
                    return d.prefix;
                });

            section_p.append('span')
                .html(function(d) {
                    return cited(d.text);
                });

            if (section.credits) {
                var credits = div.append('div')
                    .attr('class', 'pad1 limited-text');
                credits.append('h4')
                    .text('Credits');
                credits.append('p')
                    .html(function(d) {
                        return cited(d.credits);
                    });
            }

            if (section.historical) {
                var history = div.append('div')
                    .attr('class', 'pad1 limited-text');
                history.append('h4')
                    .text('Historical and Statutory');
                history.append('p')
                    .html(function(d) {
                        return cited(d.historical);
                    });
            }
        }).get();
    }

    function doesNotApply(d) {
        return d[1].match(/\[(Repealed|Omitted|Expired)\]/g);
    }

    function cited(text) {
        return Citation.find(text, {
            context: {dc_code: {source: "dc_code"}},
            types: ["dc_code", "law", "stat"],
            replace: function(cite) {
                if (cite.type == "dc_code")
                    return "<a href=\"" + urlFor(cite) + "\">" + cite.match + "</a>";<commit_msg>Link to JSON download. Refs #2<commit_after>d3.json('index.json').on('load', function(index) {

    // Build initial title listing
    var titles = d3.select('#titles')
        .selectAll('li.title')
        .data(index.titles);

    var li = titles
        .enter()
        .append('li')
        .attr('class', 'title')
        .on('click', clickTitle)
        .append('div')
        .attr('class', 'clearfix');

    li.append('span')
        .attr('class', 'number')
        .text(function(d) { return d[0]; });

    li.append('span')
        .attr('class', 'name')
        .text(function(d) { return d[1]; });

    function clickTitle(d) {
        router.setRoute(d[0]);
        updateTitle(d[0]);
    }

    function findTitle(t) {
        var t = titles
            .classed('active', function(d) { return d[0] === t; })
            .filter(function(d,i) { return d[0] == t; });
        var d = t.data()[0];
        updateTitle(d[0]);
        sectionsFor(d);

        d3.select('#titles').classed('selected', true);
        d3.select('#sections').classed('selected', false);

        //Scroll to the item if we can't already see it
        var top = t.property('offsetTop');
        var tc = d3.select('.titles-container');
        if(top > tc.property('scrollTop') + tc.property('offsetHeight')-35){
            tc.property('scrollTop',top-35);
        }
    }

    function findSection(t, s) {
        updateTitle(s);
        //Only refresh section list if we're changing titles
        var currentTitle = d3.select(".title.active");
        if (currentTitle.empty() || currentTitle.data()[0][0] != t) {
            findTitle(t);
        }

        var sections = d3.select('#sections')
            .selectAll('li.section')
            .classed('active',function(d) { return d[0] === s; });
        var section = sections
            .filter(function(d, i){ return d[0] === s; });

        //Scroll to the right part of the sections list if we can't see it
        var sectionsContainer = d3.select('.sections-container');
        if(section.property('offsetTop') > sectionsContainer.property('scrollTop') + sectionsContainer.property('offsetHeight')){
            sectionsContainer.property('scrollTop',section.property('offsetTop')-35);
        }

        doSection(section.data()[0]);
    }

    function doSection(d) {
        d3.select('#section').classed('loading', true);
        d3.json('sections/' + d[0] + '.json').on('load', function(section) {
            d3.select('#section').classed('loading', false);
            var s = d3.select('#section');

            d3.select('#sections').classed('selected', true);

            var content = s.selectAll('div.content')
                .data([section], function(d) { return JSON.stringify(d); });

            content.exit().remove();

            var div = content.enter()
                .append('div')
                .attr('class', 'content');

            div.append('h1')
                .attr('class', 'pad1')
                .text(function(d) {
                    return d.heading.catch_text;
                });

            if (section.text) {
                div.append('div')
                    .attr('class', 'section-text pad1')
                    .selectAll('p')
                    .data(function(d) {
                        return section.text.split(/\n+/);
                    })
                    .enter()
                    .append('p')
                    .html(function(d) {
                        return cited(d);
                    });
            }

            var sections = div.append('div')
                .attr('class', 'pad1')
                .selectAll('section')
                .data(section.sections, function(d) {
                    return d.prefix + d.text;
                });

            function sectionClass(d) {
                var c = '';
                if (d.prefix.match(/([a-z])/)) c = 'section-1';
                else if (d.prefix.match(/([0-9])/)) c = 'section-2';
                else if (d.prefix.match(/([A-Z])/)) c = 'section-3';
                return c;
            }

            var sectionelem = sections.enter()
                .append('section')
                .attr('class', sectionClass);

            sections.exit().remove();

            var section_p = sectionelem.append('p');

            section_p.append('span')
                .attr('class', 'section-prefix')
                .text(function(d) {
                    return d.prefix;
                });

            section_p.append('span')
                .html(function(d) {
                    return cited(d.text);
                });

            if (section.credits) {
                var credits = div.append('div')
                    .attr('class', 'pad1 limited-text');
                credits.append('h4')
                    .text('Credits');
                credits.append('p')
                    .html(function(d) {
                        return cited(d.credits);
                    });
            }

            if (section.historical) {
                var history = div.append('div')
                    .attr('class', 'pad1 limited-text');
                history.append('h4')
                    .text('Historical and Statutory');
                history.append('p')
                    .html(function(d) {
                        return cited(d.historical);
                    });
            }

            var downloads = div.append('p').attr('class', 'pad1');

            downloads.append('span').text('download: ');

            downloads.append('a')
                .text(function(d) {
                    return d.heading.identifier + '.json';
                })
                .attr('href', function(d) {
                    return 'sections/' + d.heading.identifier + '.json';
                });

        }).get();
    }

    function doesNotApply(d) {
        return d[1].match(/\[(Repealed|Omitted|Expired)\]/g);
    }

    function cited(text) {
        return Citation.find(text, {
            context: {dc_code: {source: "dc_code"}},
            types: ["dc_code", "law", "stat"],
            replace: function(cite) {
                if (cite.type == "dc_code")
                    return "<a href=\"" + urlFor(cite) + "\">" + cite.match + "</a>";
{'fraction_non_alphanumeric': 0.1630166309896262, 'fraction_numerical': 0.007903836654042483, 'mean_word_length': 1.4539393939393939, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5952616', 'n_tokens_mistral': 3469, 'n_tokens_neox': 3276, 'n_words': 618}