<commit_before>// labels is a map of campaign statuses to
// CSS classes
var labels = {
    "Email Sent" : "label-primary",
    "Email Opened" : "label-info",
	"Success" : "label-success",
    "Clicked Link" : "label-success",
	"Error" : "label-danger"
}

var campaign = {}

function dismiss(){
    $("#modal\\.flashes").empty()
    $("#modal").modal('hide')
    $("#resultsTable").dataTable().DataTable().clear().draw()
}

// Deletes a campaign after prompting the user
function deleteCampaign(){
    if (confirm("Are you sure you want to delete: " + campaign.name + "?")){
        api.campaignId.delete(campaign.id)
        .success(function(msg){
            console.log(msg)
        })
        .error(function(e){
            $("#modal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
                <i class=\"fa fa-exclamation-circle\"></i> " + data.responseJSON.message + "</div>")
        })
    }
}

$(document).ready(function(){
    campaign.id = window.location.pathname.split('/').slice(-1)[0]
    api.campaignId.get(campaign.id)
    .success(function(c){
        campaign = c
        if (campaign){
            // Setup our graphs
            var timeline_chart = {labels:[],series:[[]]}
            var email_chart = {series:[]}
            var timeline_opts = {
                axisX: {
                    showGrid: false
                },
                showArea: true,
                plugins: []
            }
            var email_opts = {
                donut : true,
                donutWidth: 40,
                chartPadding: 0,
                showLabel: false
            }
            $("#loading").hide()
            $("#campaignResults").show()
            resultsTable = $("#resultsTable").DataTable();
            $.each(campaign.results, function(i, result){
                label = labels[result.status] || "label-default";
                resultsTable.row.add([
                    result.first_name || "",
                    result.last_name || "",
                    result.email || "",
                    result.position || "",
                    "<span class=\"label " + label + "\">" + result.status + "</span>"
                ]).draw()
            })
        }
    })
    .error(function(){
        errorFlash(" Campaign not found!")
    })
})<commit_msg>Fixed event timeline chart - should work fairly well<commit_after>// labels is a map of campaign statuses to
// CSS classes
var labels = {
    "Email Sent" : "label-primary",
    "Email Opened" : "label-info",
	"Success" : "label-success",
    "Clicked Link" : "label-success",
	"Error" : "label-danger"
}

var campaign = {}

function dismiss(){
    $("#modal\\.flashes").empty()
    $("#modal").modal('hide')
    $("#resultsTable").dataTable().DataTable().clear().draw()
}

// Deletes a campaign after prompting the user
function deleteCampaign(){
    if (confirm("Are you sure you want to delete: " + campaign.name + "?")){
        api.campaignId.delete(campaign.id)
        .success(function(msg){
            console.log(msg)
        })
        .error(function(e){
            $("#modal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
                <i class=\"fa fa-exclamation-circle\"></i> " + data.responseJSON.message + "</div>")
        })
    }
}

$(document).ready(function(){
    campaign.id = window.location.pathname.split('/').slice(-1)[0]
    api.campaignId.get(campaign.id)
    .success(function(c){
        campaign = c
        if (campaign){
            // Setup our graphs
            var timeline_data = {labels:[],series:[]}
            var email_data = {series:[]}
            var timeline_opts = {
                axisX: {
                    showGrid: false,
                },
                axisY: {
                    type: Chartist.FixedScaleAxis,
                    ticks: [0, 1, 2],
                    low: 0,
                    showLabel: false
                },
                showArea: true,
                plugins: []
            }
            var email_opts = {
                donut : true,
                donutWidth: 40,
                chartPadding: 0,
                showLabel: false
            }
            // Setup the results table
            resultsTable = $("#resultsTable").DataTable();
            $.each(campaign.results, function(i, result){
                label = labels[result.status] || "label-default";
                resultsTable.row.add([
                    result.first_name || "",
                    result.last_name || "",
                    result.email || "",
                    result.position || "",
                    "<span class=\"label " + label + "\">" + result.status + "</span>"
                ]).draw()
            })
            // Setup the graphs
            $.each(campaign.timeline, function(i, event){
                timeline_data.labels.push(moment(event.time).format('MMMM Do YYYY h:mm'))
                timeline_data.series.push([{meta : i, value: 1}])
            })
            var timeline_chart = new Chartist.Line('#timeline_chart', timeline_data, timeline_opts)

            // Setup the overview chart listeners
            $chart = $("#timeline_chart")
            var $toolTip = $chart
            .append('<div class="chartist-tooltip"></div>')
            .find('.chartist-tooltip')
            .hide();

            $chart.on('mouseenter', '.ct-point', function() {
                var $point = $(this)
                value = $point.attr('ct:value')
                cidx = $point.attr('ct:meta')
                html = "Event: " + campaign.timeline[cidx].message
                if (campaign.timeline[cidx].email) {
                    html += '<br>' + "Email: " + campaign.timeline[cidx].email
                }
                $toolTip.html(html).show()
            });

            $chart.on('mouseleave', '.ct-point', function() {
                $toolTip.hide();
            });
            $chart.on('mousemove', function(event) {
                $toolTip.css({
                    left: (event.offsetX || event.originalEvent.layerX) - $toolTip.width() / 2 - 10,
                    top: (event.offsetY + 0 || event.originalEvent.layerY) - $toolTip.height() - 40
                });
            });
            $("#loading").hide()
            $("#campaignResults").show()
        }
    })
    .error(function(){
        errorFlash(" Campaign not found!")
    })
})
{'fraction_non_alphanumeric': 0.15941358024691357, 'fraction_numerical': 0.0032407407407407406, 'mean_word_length': 1.5708052360174534, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '7466570', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1716, 'n_words': 347}