<commit_before>// console calls fail gracefully.
// from https://github.com/liamnewmarch/console-shim/blob/master/console-shim.js
if (!window.console) (function() {

    var __console, Console;

    Console = function() {
        var check = setInterval(function() {
            var f;
            if (window.console && console.log && !console.__buffer) {
                clearInterval(check);
                f = (Function.prototype.bind) ? Function.prototype.bind.call(console.log, console) : console.log;
                for (var i = 0; i < __console.__buffer.length; i++) f.apply(console, __console.__buffer[i]);
            }
        }, 1000);

        function log() {
            this.__buffer.push(arguments);
        }

        this.log = log;
        this.error = log;
        this.warn = log;
        this.info = log;
        this.__buffer = [];
    };

    __console = window.console = new Console();
})();

function setRoot(url){
    var vmLocalhost = "10.0.2.2"

    if (location.host.indexOf(vmLocalhost) === 0) {
        url = url.replace("localhost", vmLocalhost)
    }

    url.replace("http:", window.location.protocol)
    console.log("making new url; it's now", url)

    return url
}

var api_root=setRoot('{{ g.roots.api }}')
var api_root_pretty=setRoot('{{ g.roots.api_pretty }}')
var webapp_root=setRoot('{{ g.roots.webapp }}')
var webapp_root_pretty=setRoot('{{ g.roots.webapp_pretty }}')

var api_key='{{ g.api_key }}'
var request_url='{{ request_url }}' // i don't think we need, this, keeping for legacy code<commit_msg>debut code for widget https<commit_after>// console calls fail gracefully.
// from https://github.com/liamnewmarch/console-shim/blob/master/console-shim.js
if (!window.console) (function() {

    var __console, Console;

    Console = function() {
        var check = setInterval(function() {
            var f;
            if (window.console && console.log && !console.__buffer) {
                clearInterval(check);
                f = (Function.prototype.bind) ? Function.prototype.bind.call(console.log, console) : console.log;
                for (var i = 0; i < __console.__buffer.length; i++) f.apply(console, __console.__buffer[i]);
            }
        }, 1000);

        function log() {
            this.__buffer.push(arguments);
        }

        this.log = log;
        this.error = log;
        this.warn = log;
        this.info = log;
        this.__buffer = [];
    };

    __console = window.console = new Console();
})();

function setRoot(url){
    var vmLocalhost = "10.0.2.2"

    if (location.host.indexOf(vmLocalhost) === 0) {
        url = url.replace("localhost", vmLocalhost)
    }

    url.replace("http:", window.location.protocol)
    console.log("making new url; it's now", url)

    return url
}

console.log("loading globals")
var api_root=setRoot('{{ g.roots.api }}')
var api_root_pretty=setRoot('{{ g.roots.api_pretty }}')
var webapp_root=setRoot('{{ g.roots.webapp }}')
var webapp_root_pretty=setRoot('{{ g.roots.webapp_pretty }}')

console.log("webapp root in ", webapp_root)

var api_key='{{ g.api_key }}'
var request_url='{{ request_url }}' // i don't think we need, this, keeping for legacy code
{'fraction_non_alphanumeric': 0.15464240903387705, 'fraction_numerical': 0.006900878293601004, 'mean_word_length': 2.627986348122867, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3938849', 'n_tokens_mistral': 1041, 'n_tokens_neox': 990, 'n_words': 219}