<commit_before>var dashboardGraphs = ['updateBuildModel', 'updateWTFModel', 'updateHydrationModel', 'updateCaffeineModel', 'updateBuildDurationModel', 'updateHourlyBuildHeatMap', 'updateHourlyWtfHeatMap', 'updateHourlyHydrationHeatMap', 'updateHourlyCaffeineHeatMap', 'updateActiveEvents', 'updateHourlyGithubPushHeatMap','updateCorrelationData'];

$("#builds-x").ready(function() {
    window.qd.registerForBuildModelUpdates(function() {
        var displayBuildCountAndBuildComparison = function(buildCount, buildCountElementId, comparisonValue, comparisonElementId) {
            $(buildCountElementId).text(buildCount);
            var buildComparison = Math.abs(comparisonValue);
            if (buildComparison && buildComparison !== Infinity) {
                $(comparisonElementId).text(buildComparison + "%");
                if (comparisonValue < 0) {
                    $(comparisonElementId).addClass("icon-caret-down");
                } else if (comparisonValue > 0) {
                    $(comparisonElementId).addClass("icon-caret-up");
                }
            }
        };

        displayBuildCountAndBuildComparison(window.qd.todaysTotalBuildCount, "#builds-x", window.qd.totalBuildComparison, "#total-build-comparison");
        displayBuildCountAndBuildComparison(window.qd.todaysPassedBuildCount, "#passed-x", window.qd.passedBuildComparison, "#passed-build-comparison");
        displayBuildCountAndBuildComparison(window.qd.todaysFailedBuildCount, "#failed-x", window.qd.failedBuildComparison, "#failed-build-comparison");
    });
});

$(window).resize(function() {
    window.qd.plotGraphs(dashboardGraphs);
});

$(window).load(function() {
    //does not work in document.ready()
    if ($("#showOverlayFlag").attr("showOverlay") == 'true') {
        $("#noDataSourceMessage").modal("show")
    } else {
        window.qd.plotGraphs(dashboardGraphs);
    }
});


var handleConnectToGithub = function() {
    var button = $("#github-push-events-sync");
    $('#noDataSourceMessage').modal('hide');

    var showGitHubEvents = function(data) {
        var hourlyGithubErrorCallback = function() {
            alert("Github events error");
        };
        var hourlyGithubSuccessCallback = function(hourlyGithubPushEvents) {
            button.prop("disabled", false );
            window.qd.hourlyGithubPushEvents = hourlyGithubPushEvents;
            window.qd.plotHeatmapWith('#hourlyGithubPush-heat-map-parent', '#hourlyGithubPush-heat-map', hourlyGithubPushEvents);
        };
        postAjax("hourlyGithubPushEvents", hourlyGithubSuccessCallback, hourlyGithubErrorCallback);
    }

    button.prop("disabled", true);
    $("#hourlyGithubPush-heat-map").html("");
    var html_data =  '<div class="githubPushEvents text-center grid" ><div  class="grid-row"><div  class="grid-cell" ><img src="/img/loading.gif"></div></div></div>'
    $("#hourlyGithubPush-heat-map").html(html_data);

    postQDRouteAjax("connect_to_github", showGitHubEvents, function(error) {
        console.log(error);
    })
}

$("#connect_to_github_btn").click(handleConnectToGithub);
$("#github-push-events-sync").click(handleConnectToGithub);
$("#connect_to_github_link_popup_btn").click(handleConnectToGithub);<commit_msg>Use jsonp to connect to gitHub<commit_after>var dashboardGraphs = ['updateBuildModel', 'updateWTFModel', 'updateHydrationModel', 'updateCaffeineModel', 'updateBuildDurationModel', 'updateHourlyBuildHeatMap', 'updateHourlyWtfHeatMap', 'updateHourlyHydrationHeatMap', 'updateHourlyCaffeineHeatMap', 'updateActiveEvents', 'updateHourlyGithubPushHeatMap','updateCorrelationData'];

$("#builds-x").ready(function() {
    window.qd.registerForBuildModelUpdates(function() {
        var displayBuildCountAndBuildComparison = function(buildCount, buildCountElementId, comparisonValue, comparisonElementId) {
            $(buildCountElementId).text(buildCount);
            var buildComparison = Math.abs(comparisonValue);
            if (buildComparison && buildComparison !== Infinity) {
                $(comparisonElementId).text(buildComparison + "%");
                if (comparisonValue < 0) {
                    $(comparisonElementId).addClass("icon-caret-down");
                } else if (comparisonValue > 0) {
                    $(comparisonElementId).addClass("icon-caret-up");
                }
            }
        };

        displayBuildCountAndBuildComparison(window.qd.todaysTotalBuildCount, "#builds-x", window.qd.totalBuildComparison, "#total-build-comparison");
        displayBuildCountAndBuildComparison(window.qd.todaysPassedBuildCount, "#passed-x", window.qd.passedBuildComparison, "#passed-build-comparison");
        displayBuildCountAndBuildComparison(window.qd.todaysFailedBuildCount, "#failed-x", window.qd.failedBuildComparison, "#failed-build-comparison");
    });
});

$(window).resize(function() {
    window.qd.plotGraphs(dashboardGraphs);
});

$(window).load(function() {
    //does not work in document.ready()
    if ($("#showOverlayFlag").attr("showOverlay") == 'true') {
        $("#noDataSourceMessage").modal("show")
    } else {
        window.qd.plotGraphs(dashboardGraphs);
    }
});


var handleConnectToGithub = function() {
    var button = $("#github-push-events-sync");
    $('#noDataSourceMessage').modal('hide');

    var showGitHubEvents = function(data) {
        var hourlyGithubErrorCallback = function() {
            alert("Github events error");
        };
        var hourlyGithubSuccessCallback = function(hourlyGithubPushEvents) {
            button.prop("disabled", false );
            window.qd.hourlyGithubPushEvents = hourlyGithubPushEvents;
            window.qd.plotHeatmapWith('#hourlyGithubPush-heat-map-parent', '#hourlyGithubPush-heat-map', hourlyGithubPushEvents);
        };
        postAjax("hourlyGithubPushEvents", hourlyGithubSuccessCallback, hourlyGithubErrorCallback);
    }

    button.prop("disabled", true);
    $("#hourlyGithubPush-heat-map").html("");
    var html_data =  '<div class="githubPushEvents text-center grid" ><div  class="grid-row"><div  class="grid-cell" ><img src="/img/loading.gif"></div></div></div>'
    $("#hourlyGithubPush-heat-map").html(html_data);

    postQDRouteAjax("connect_to_github?callback=?", showGitHubEvents, function(error) {
        console.log(error);
    })
}

$("#connect_to_github_btn").click(handleConnectToGithub);
$("#github-push-events-sync").click(handleConnectToGithub);
$("#connect_to_github_link_popup_btn").click(handleConnectToGithub);
{'fraction_non_alphanumeric': 0.1447247000922793, 'fraction_numerical': 0.0006151953245155337, 'mean_word_length': 4.136650868878357, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '2989819', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1854, 'n_words': 236}