<commit_before>/**
 * Javascript based page load performance comparator
 */
ss = function(document, window, undefined) {

function getFollowerUrl(url) {
    var regexpStr = $("input[name='leaderMatch']").val()
    , re = new RegExp(regexpStr)
    , replacement = $("input[name='followReplace']").val()
    ;
    return url.replace(re, replacement);
};

/**
 * Loads the leader iframe from the inputted Url
 */
function loadFromInput() {
    var suffix = $("#setUrl").val()
    , url;
    if ( suffix.indexOf("/") == 0 ) {
        url = suffix;
    }
    else {
        url = "http://" + suffix;
    }
    time("#leader", url);
};

function refreshIframes() {
    var url = $("#leader").attr("src");
    time("#leader", url);
    sync(url);
}

/**
 * Update the follower pane to match the leader
 */
function sync(leaderUrl) {
    var followUrl = getFollowerUrl(leaderUrl)
    ;
    time("#follower", followUrl);
};

/**
 * Time the load time of a pane and report it to the DOM
 */
function time(selector, url) {
    var ele = $(selector)
    , iframeId = ele.attr("id")
    , timeEle = $(".timer[data-for='" + iframeId + "']")
    , start = new Date().getTime()
    , loadFunc = function(e) {
        var loadTime = new Date().getTime() - start
        ;
        timeEle.find(".time").html("Loaded in " + loadTime + " ms");
        timeEle.find(".url").html("At URL: " + ele.attr("src"));
        timeEle.removeClass("loading");
    }
    ;
    ele.one("load", loadFunc);
    timeEle.addClass("loading");
    ele.attr("src", url);
};

return {
    init:function() {
        $("#leader").load(function(e) {
            var url = e.target.contentWindow.location.href;
            sync(url);
        });
        $("input").not("#setUrl").change(function() {
            sync($("#leader").attr("src"));
        });
        $("#setUrl").change(loadFromInput);
        $("#reload").click(refreshIframes);

        // and kick off the first load
        loadFromInput();
    }
};

}(document, window, undefined);
<commit_msg>fixed the hud to work with the leader url<commit_after>/**
 * Javascript based page load performance comparator
 */
ss = function(document, window, undefined) {

function getFollowerUrl(url) {
    var regexpStr = $("input[name='leaderMatch']").val()
    , re = new RegExp(regexpStr)
    , replacement = $("input[name='followReplace']").val()
    ;
    return url.replace(re, replacement);
};

function urlFromIframe( iframe ) {
    return $(iframe)[0].contentWindow.location.href;
}

/**
 * Loads the leader iframe from the inputted Url
 */
function loadFromInput() {
    var suffix = $("#setUrl").val()
    , url;
    if ( suffix.indexOf("/") == 0 ) {
        url = suffix;
    }
    else {
        url = "http://" + suffix;
    }
    time("#leader", url);
};

function refreshIframes() {
    var url = urlFromIframe($("#leader"));
    time("#leader", url);
    sync(url);
}

/**
 * Update the follower pane to match the leader
 */
function sync(leaderUrl) {
    var followUrl = getFollowerUrl(leaderUrl)
    ;
    time("#follower", followUrl);
};

/**
 * Time the load time of a pane and report it to the DOM
 */
function time(selector, url) {
    var ele = $(selector)
    , iframeId = ele.attr("id")
    , hudEle = $(".timer[data-for='" + iframeId + "']")
    , start = new Date().getTime()
    , loadFunc = function(e) {
        var loadTime = new Date().getTime() - start
        , iframeUrl = urlFromIframe(ele)
        ;
        hud(hudEle, iframeUrl, loadTime);
        hudEle.removeClass("loading");
    }
    ;
    ele.one("load", loadFunc);
    hudEle.addClass("loading");
    ele.attr("src", url);
};

function hud(ele, url, time) {
    debugger;
    if (url) {
        ele.find(".url").html("At URL: " + url);
    }
    if (time) {
        ele.find(".time").html("Loaded in " + time + " ms");
    }
}

return {
    init:function() {
        $("#leader").load(function(e) {
            var url = urlFromIframe(e.target)
            , hudEle = $(".timer[data-for='leader']")
            ;
            sync(url);
            hud(hudEle, url, null);
        });
        $("input").not("#setUrl").change(function() {
            sync($("#leader").attr("src"));
        });
        $("#setUrl").change(loadFromInput);
        $("#reload").click(refreshIframes);

        // and kick off the first load
        loadFromInput();
    }
};

}(document, window, undefined);

{'fraction_non_alphanumeric': 0.18407281001137657, 'fraction_numerical': 0.0006825938566552901, 'mean_word_length': 2.55375909458367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6843391', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1385, 'n_words': 312}