<commit_before>if (typeof MiroCommunity === 'undefined') {
    MiroCommunity = {
        Widget: function(args) {
            this.init(args);
        },
        jsonP: function(path) {
            script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = path;
            document.getElementsByTagName('head')[0].appendChild(script);
            return script;
        },
        createElement: function(name, attrs) {
            elm = document.createElement(name);
            for (attr in attrs) {
                elm[attr] = attrs[attr];
            }
            return elm;
        },
        createSpan: function(content, className) {
            span = document.createElement('span');
            span.className = className;
            span.innerHTML = content;
            return span;
        }
    };
    MiroCommunity.Widget._counter = 0;
    MiroCommunity.Widget._addedStyles = false;
    MiroCommunity.Widget.prototype = function() {
        return {
            init: function(options) {
                this.opts = options;
                this.counter = ++MiroCommunity.Widget._counter;
                this.id = 'mc-widget-' + this.counter;
                this.scriptTag = null;
            },
            versioned: function(method, args) {
                func = null;
                if (this.opts.version !== undefined) {
                    func = this[method + '_v' + this.opts.version]
                }
                if (!func) {
                    func = this[method];
                }
                return func.apply(this, Array.prototype.slice.call(arguments, 1));
            },
            render: function () {
                this.addStyle();
                if (this.opts.version && this.opts.version !== 1) {
                    widget_class = 'mc-widget-v' + this.opts.version
                } else {
                    widget_class = 'mc-widget'
                }
                document.write('<div id="' + this.id + '" class="' + widget_class + '"></div>');
                this.versioned('beforeLoad');
                this.load();
            },
            addStyle: function() {
                head = document.getElementsByTagName('head')[0];
                if (!MiroCommunity.Widget._addedStyles && this.opts.stylesheet !== '') {
                    link = document.createElement('link');
                    link.rel = 'stylesheet';
                    if (this.opts.stylesheet) {
                        link.href = this.opts.stylesheet;
                    } else {
                        link.href = 'http://' + this.opts.domain + '/css/widget.css';
                    }
                    head.appendChild(link);
                    MiroCommunity.Widget._addedStyles = true;
                }
            },
            load: function() {
                var t = this;
                ajax_path = 'http://' + t.opts.domain + '/feeds/json/' + t.opts.source;
                MiroCommunity['callback_' + t.counter] = function(json) {
                    t.scriptTag.parentNode.removeChild(t.scriptTag);
                    t.scriptTag = null;
                    var div = document.getElementById(t.id);
                    t.versioned('update', div, json);
                };
                t.scriptTag = MiroCommunity.jsonP(ajax_path + '?jsoncallback=MiroCommunity.callback_' + t.counter);
            },
            // Widget version 1
            beforeLoad: function () {
                width = this.opts.width ? this.opts.width : 300;
                div = document.getElementById(this.id);
                title = MiroCommunity.createElement('h2')<commit_msg>widget: don't break when the custom URL has a ? in it<commit_after>if (typeof MiroCommunity === 'undefined') {
    MiroCommunity = {
        Widget: function(args) {
            this.init(args);
        },
        jsonP: function(path) {
            script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = path;
            document.getElementsByTagName('head')[0].appendChild(script);
            return script;
        },
        createElement: function(name, attrs) {
            elm = document.createElement(name);
            for (attr in attrs) {
                elm[attr] = attrs[attr];
            }
            return elm;
        },
        createSpan: function(content, className) {
            span = document.createElement('span');
            span.className = className;
            span.innerHTML = content;
            return span;
        }
    };
    MiroCommunity.Widget._counter = 0;
    MiroCommunity.Widget._addedStyles = false;
    MiroCommunity.Widget.prototype = function() {
        return {
            init: function(options) {
                this.opts = options;
                this.counter = ++MiroCommunity.Widget._counter;
                this.id = 'mc-widget-' + this.counter;
                this.scriptTag = null;
            },
            versioned: function(method, args) {
                func = null;
                if (this.opts.version !== undefined) {
                    func = this[method + '_v' + this.opts.version]
                }
                if (!func) {
                    func = this[method];
                }
                return func.apply(this, Array.prototype.slice.call(arguments, 1));
            },
            render: function () {
                this.addStyle();
                if (this.opts.version && this.opts.version !== 1) {
                    widget_class = 'mc-widget-v' + this.opts.version
                } else {
                    widget_class = 'mc-widget'
                }
                document.write('<div id="' + this.id + '" class="' + widget_class + '"></div>');
                this.versioned('beforeLoad');
                this.load();
            },
            addStyle: function() {
                head = document.getElementsByTagName('head')[0];
                if (!MiroCommunity.Widget._addedStyles && this.opts.stylesheet !== '') {
                    link = document.createElement('link');
                    link.rel = 'stylesheet';
                    if (this.opts.stylesheet) {
                        link.href = this.opts.stylesheet;
                    } else {
                        link.href = 'http://' + this.opts.domain + '/css/widget.css';
                    }
                    head.appendChild(link);
                    MiroCommunity.Widget._addedStyles = true;
                }
            },
            load: function() {
                var t = this;
                ajax_path = 'http://' + t.opts.domain + '/feeds/json/' + t.opts.source;
                MiroCommunity['callback_' + t.counter] = function(json) {
                    t.scriptTag.parentNode.removeChild(t.scriptTag);
                    t.scriptTag = null;
                    var div = document.getElementById(t.id);
                    t.versioned('update', div, json);
                };
                if (t.opts.source.search(/[?]/) > -1) {
                    ajax_path = ajax_path + '&';
                } else {
                    ajax_path = ajax_path + '?';
                }
                t.scriptTag = MiroCommunity.jsonP(ajax_path + 'jsoncallback=MiroCommunity.callback_' + t.counter);
            },
            // Widget version 1
            beforeLoad: function () {
                width = this.opts.width ? this.opts.width : 300;
                div = document.getElementById(this.id);
                title = MiroCommunity.createElement('h2')
{'fraction_non_alphanumeric': 0.12220762155059132, 'fraction_numerical': 0.002759526938239159, 'mean_word_length': 1.3042688465031789, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '191874', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1859, 'n_words': 345}