<commit_before>define([
    'require',
    '../core/parser',
    '../logging',
    '../lib/jquery'
], function(require) {
    var Parser = require('../core/parser'),
        parser = new Parser("injectcontent"),
        log = require('../logging').getLogger('collapsible');

    var init = function($el, opts) {
        // create collapsible structure
        var $ctrl = $el.children(':first'),
            $content = $el.children(':gt(0)'),
            $panel;
        if ($content.length > 0) {
            $panel = $content.wrapAll('<div class="panel-content" />')
                .parent();
        } else {
            $panel = $('<div class="panel-content" />').insertAfter($ctrl);
        }

        // set initial state
        if ((opts && opts.closed) || $el.hasClass("closed")) {
            $el.removeClass("closed");
            close($el, 0);
        } else {
            $el.addClass("open");
            loadcontent($el);
        }

        // bind to click events
        $ctrl.bind("click", function() { toggle($el, "fast"); });

        // allow for chaining
        return $el;
    };

    var loadcontent = function($el) {
        // check whether we have to fetch content
        var opts_str = $el.data('collapsible'),
            src, href, id, $panel, $sources;
        if (opts_str) {
            src = parser.parse(opts_str)["injectcontent"] || "";
            href = src.split('#')[0];
            id = src.split('#')[1];
            log.debug(href, id);
            if (!id) {
                log.error('Need id to fetch content for panel');
            } else {
                $panel = $el.find('.panel-content');
                $.ajax({
                    context: $el,
                    url: href,
                    error: function(jqxhr, status, error) {
                        log.error('Error loading panel content', jqxhr, status, error);
                        $panel.html(
                            status + ': Failed to load panel content from: ' + href
                        );
                    },
                    success: function(data, status, jqxhr) {
                        // just copied from old inject code
                        data = data
                            .replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "")
                            .replace(/<head\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/head>/gi, "")
                            .replace(/<body(.*)>/gi, '<div id="__original_body">')
                            .replace(/<\/body(.*)>/gi,'</div>');
                        var $src = $('<div/>').html(data).find('#' + id);
                        $panel.html($src.html());
                    }
                });
            }
        }
    };

    var open = function($el, duration) {<commit_msg>more explanatory error msg<commit_after>define([
    'require',
    '../core/parser',
    '../logging',
    '../lib/jquery'
], function(require) {
    var Parser = require('../core/parser'),
        parser = new Parser("injectcontent"),
        log = require('../logging').getLogger('collapsible');

    var init = function($el, opts) {
        // create collapsible structure
        var $ctrl = $el.children(':first'),
            $content = $el.children(':gt(0)'),
            $panel;
        if ($content.length > 0) {
            $panel = $content.wrapAll('<div class="panel-content" />')
                .parent();
        } else {
            $panel = $('<div class="panel-content" />').insertAfter($ctrl);
        }

        // set initial state
        if ((opts && opts.closed) || $el.hasClass("closed")) {
            $el.removeClass("closed");
            close($el, 0);
        } else {
            $el.addClass("open");
            loadcontent($el);
        }

        // bind to click events
        $ctrl.bind("click", function() { toggle($el, "fast"); });

        // allow for chaining
        return $el;
    };

    var loadcontent = function($el) {
        // check whether we have to fetch content
        var opts_str = $el.data('collapsible'),
            src, href, id, $panel, $sources;
        if (opts_str) {
            src = parser.parse(opts_str)["injectcontent"] || "";
            href = src.split('#')[0];
            id = src.split('#')[1];
            log.debug(href, id);
            if (!id) {
                log.error('injectcontent url needs id to fetch content for panel', src);
            } else {
                $panel = $el.find('.panel-content');
                $.ajax({
                    context: $el,
                    url: href,
                    error: function(jqxhr, status, error) {
                        log.error('Error loading panel content', jqxhr, status, error);
                        $panel.html(
                            status + ': Failed to load panel content from: ' + href
                        );
                    },
                    success: function(data, status, jqxhr) {
                        // just copied from old inject code
                        data = data
                            .replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "")
                            .replace(/<head\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/head>/gi, "")
                            .replace(/<body(.*)>/gi, '<div id="__original_body">')
                            .replace(/<\/body(.*)>/gi,'</div>');
                        var $src = $('<div/>').html(data).find('#' + id);
                        $panel.html($src.html());
                    }
                });
            }
        }
    };

    var open = function($el, duration) {
{'fraction_non_alphanumeric': 0.17876797443635717, 'fraction_numerical': 0.0017752529735487307, 'mean_word_length': 1.323298969072165, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 27, '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': '7432223', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1498, 'n_words': 320}