<commit_before>"use strict;"

var dateFromInput = document.getElementById("dateFromInput");
var dateToInput = document.getElementById("dateToInput");
var placeholderDiv = document.getElementById("placeholder1");
var tooltip = "tooltip1";
var tooltipDiv = "#" + tooltip;
var legendDiv = document.getElementById("legend");
var graphDiv = document.getElementById("graph1");
var sampleSelector = document.getElementById("sampleSelector");
var metricSelector = document.getElementById("metricSelector");
var encoderSelector = document.getElementById("encoderSelector");
var executeButton = document.getElementById("fetch");

var thousand = 1000;

var legendTitleClass = "legendTitle";
var legendInfoClass = "legendInfo";


/**
 * Handling link between Encoder and Git Revision
 */
// Specify your encoder with the git revision base link
var mapEncoder = new Object();
mapEncoder["https://github.com/videolan/x265"] = "x265";
mapEncoder["https://www.google.ch/#q="] = "xTOTO";

function gitUrlToEncoder(gitUrl) {
    return mapEncoder[gitUrl];
}

// Combine a git revision with his base link
function mapEncoGitToLink(encoder, git_commit) {
    return encoder + '/commit/' + git_commit;
}

// Date format displayed
function formatDate(date) {
    return '{0} {1}'.format(
        date.toLocaleDateString(),
        date.toLocaleTimeString()
    );
}

/* source:
* http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery */
String.prototype.format = function () {
  var args = arguments;
  return this.replace(/\{(\d+)\}/g, function (m, n) { return args[n]; });
};

/**
 * Activate the chosen selector (Sample and Encoders)
 */
$(".my_select_box").chosen({
    no_results_text: "Oops, nothing found!",
    search_contains: true,
    width: "100%"
});

/**
 * Configure the DateTime input adding a new system to chose the minutes and seconds
 * and activate it (dateInputFrom and dateInputTo)
 * From the example : http://trentrichardson.com/examples/timepicker/
 */
var myControl = {
    create: function (tp_inst, obj, unit, val, min, max, step) {
        $('<input class="ui-timepicker-input" value="' + val + '" style="width:50%">')
            .appendTo(obj)
            .spinner({
                min: min,
                max: max,
                step: step,
                change: function (e, ui) { // key events
                    // don't call if api was used and not key press
                    if (e.originalEvent !== undefined)
                        tp_inst._onTimeChange();
                    tp_inst._onSelectHandler();
                },
                spin: function (e, ui) { // spin events
                    tp_inst.control.value(tp_inst, obj, unit, ui.value);
                    tp_inst._onTimeChange();
                    tp_inst._onSelectHandler();
                }
            });
        return obj;
    },
    options: function (tp_inst, obj, unit, opts, val) {
        if (typeof (opts) == 'string' && val !== undefined)
            return obj.find('.ui-timepicker-input').spinner(opts, val);
        return obj.find('.ui-timepicker-input').spinner(opts);
    },
    value: function (tp_inst, obj, unit, val) {
        if (val !== undefined)
            return obj.find('.ui-timepicker-input').spinner('value', val);
        return obj.find('.ui-timepicker-input').spinner('value');
    }
};

$(dateFromInput).datetimepicker({
    controlType: myControl,
    timeFormat: 'HH:mm:ss',
});
$(dateFromInput).datetimepicker('setDate', (new Date()));

$(dateToInput).datetimepicker({
    controlType: myControl,
    timeFormat: 'HH:mm:ss'
});
$(dateToInput).datetimepicker('setDate', (new Date()));


/**
 * Generate the graph in function of the data
 */
function generateGraph(data) {
    //http://stackoverflow.com/questions/9150964/identifying-hovered-point-with-flot
    //Create a table of tuple (x,y) for each encoder metric

    var xyEncoder = new Object();<commit_msg>Change the default From date to 7 days before the current date<commit_after>"use strict;"

var dateFromInput = document.getElementById("dateFromInput");
var dateToInput = document.getElementById("dateToInput");
var placeholderDiv = document.getElementById("placeholder1");
var tooltip = "tooltip1";
var tooltipDiv = "#" + tooltip;
var legendDiv = document.getElementById("legend");
var graphDiv = document.getElementById("graph1");
var sampleSelector = document.getElementById("sampleSelector");
var metricSelector = document.getElementById("metricSelector");
var encoderSelector = document.getElementById("encoderSelector");
var executeButton = document.getElementById("fetch");

var thousand = 1000;

var legendTitleClass = "legendTitle";
var legendInfoClass = "legendInfo";


/**
 * Handling link between Encoder and Git Revision
 */
// Specify your encoder with the git revision base link
var mapEncoder = new Object();
mapEncoder["https://github.com/videolan/x265"] = "x265";
mapEncoder["https://www.google.ch/#q="] = "xTOTO";

function gitUrlToEncoder(gitUrl) {
    return mapEncoder[gitUrl];
}

// Combine a git revision with his base link
function mapEncoGitToLink(encoder, git_commit) {
    return encoder + '/commit/' + git_commit;
}

// Date format displayed
function formatDate(date) {
    return '{0} {1}'.format(
        date.toLocaleDateString(),
        date.toLocaleTimeString()
    );
}

/* source:
* http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery */
String.prototype.format = function () {
  var args = arguments;
  return this.replace(/\{(\d+)\}/g, function (m, n) { return args[n]; });
};

/**
 * Activate the chosen selector (Sample and Encoders)
 */
$(".my_select_box").chosen({
    no_results_text: "Oops, nothing found!",
    search_contains: true,
    width: "100%"
});

/**
 * Configure the DateTime input adding a new system to chose the minutes and seconds
 * and activate it (dateInputFrom and dateInputTo)
 * From the example : http://trentrichardson.com/examples/timepicker/
 */
var myControl = {
    create: function (tp_inst, obj, unit, val, min, max, step) {
        $('<input class="ui-timepicker-input" value="' + val + '" style="width:50%">')
            .appendTo(obj)
            .spinner({
                min: min,
                max: max,
                step: step,
                change: function (e, ui) { // key events
                    // don't call if api was used and not key press
                    if (e.originalEvent !== undefined)
                        tp_inst._onTimeChange();
                    tp_inst._onSelectHandler();
                },
                spin: function (e, ui) { // spin events
                    tp_inst.control.value(tp_inst, obj, unit, ui.value);
                    tp_inst._onTimeChange();
                    tp_inst._onSelectHandler();
                }
            });
        return obj;
    },
    options: function (tp_inst, obj, unit, opts, val) {
        if (typeof (opts) == 'string' && val !== undefined)
            return obj.find('.ui-timepicker-input').spinner(opts, val);
        return obj.find('.ui-timepicker-input').spinner(opts);
    },
    value: function (tp_inst, obj, unit, val) {
        if (val !== undefined)
            return obj.find('.ui-timepicker-input').spinner('value', val);
        return obj.find('.ui-timepicker-input').spinner('value');
    }
};

$(dateFromInput).datetimepicker({
    controlType: myControl,
    timeFormat: 'HH:mm:ss',
});
var dateFrom = new Date();
dateFrom.setDate(dateFrom.getDate() - 7); //Remove 7 days to the current date
$(dateFromInput).datetimepicker('setDate', dateFrom);

$(dateToInput).datetimepicker({
    controlType: myControl,
    timeFormat: 'HH:mm:ss'
});
$(dateToInput).datetimepicker('setDate', (new Date()));


/**
 * Generate the graph in function of the data
 */
function generateGraph(data) {
    //http://stackoverflow.com/questions/9150964/identifying-hovered-point-with-flot
    //Create a table of tuple (x,y) for each encoder metric

    var xyEncoder = new Object();
{'fraction_non_alphanumeric': 0.14235764235764237, 'fraction_numerical': 0.008866133866133866, 'mean_word_length': 3.0185649774209735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '2703767', 'n_tokens_mistral': 2374, 'n_tokens_neox': 2260, 'n_words': 588}