<commit_before>$(function() {
  var input_date = location.search.substr(1).split('=')[1];

  $error = $("#error"),
  $body = $("body");


  function loadDate(date) {
    var parts = date.split('/');
    var d = parts[2] + '-' + parts[0] + '-' + parts[1];
    printTable(d);
  }

  function createDates(data) {
    var dates = {}

    //NOTE: dates are in: "2015-01-01 00:00:00" format
    var previous_value = 0;
    var last_date = '';
    for(var val in data) {
      var date = val.split(' ')[0];
      last_date = date;
      var current_value = data[val];

      //TODO: consider doing something different for more/less values
      if (current_value != previous_value) {
        var parts = date.split('-');
        date = parts[1] + '/' + parts[2] + '/' + parts[0];
        dates[new Date(date)] = new Date(date);
      }
      previous_value = current_value;
    }

    $(function() {
      $("#datepicker").datepicker({
        numberOfMonths: 3,
        minDate: new Date(2014, 11-1, 14),
        showButtonPanel: false,
        showOtherMonths: true,
        selectOtherMonths: true,
        onSelect: loadDate,
        beforeShowDay: function(date) {
          var annotated = dates[date];
          if (annotated) {
            return [true, 'annotated', ''];
          } else {
            return [true, '', ''];
          }
        }
      });
    });

    $("#datepicker").datepicker("setDate", "-2m");

    document.getElementById("toggle").addEventListener("click", toggleState);

    if (input_date === undefined || input_date === '') {
      printTable(last_date);
    } else {
      printTable(input_date);
    }
  }

  function printTable(date) {
    $.getJSON("/data/setadetails/", {date:date}).done(function (data) { getActiveJobs(data, date); });
  }

  function getActiveJobs(details, date) {
    $.getJSON("/data/jobtypes/").done(function (data) { outputTable(data, details, date); });
  }

  // Simple text replace of full names -> Group-Code format
  function printName(testname) {
    var retVal = testname.replace(/mochitest-browser-chrome[-]?/, 'M-bc');
    retVal = retVal.replace(/mochitest-e10s-browser-chrome[-]?/, 'Me10s-bc');
    retVal = retVal.replace(/mochitest-e10s-devtools-chrome[-]?/, 'M-dt');
    retVal = retVal.replace('mochitest-e10s', 'Me10s');
    retVal = retVal.replace(/mochitest-devtools-chrome[-]?/, 'M-dt');
    retVal = retVal.replace('mochitest-other', 'M-oth');
    retVal = retVal.replace('mochitest', 'M');
    retVal = retVal.replace('crashtest-ipc', 'R-C-ipc');
    retVal = retVal.replace('crashtest', 'R-C');
    retVal = retVal.replace('jsreftest', 'R-J');
    retVal = retVal.replace('reftest-no-accel', 'R-RU');
    retVal = retVal.replace('reftest-e10s', 'Re10s-R');
    retVal = retVal.replace('reftest', 'R-R');
    retVal = retVal.replace('xpcshell', 'O-X');
    retVal = retVal.replace('marionette', 'O-Mn');
    retVal = retVal.replace('cppunit', 'O-Cpp');
    retVal = retVal.replace(/jittest[-]?/, 'O-Jit');
    retVal = retVal.replace('web-platform-tests', 'WPT');
    return retVal;
  }

  function fixPlatform(plat) {
    retVal = plat.replace('osx10.6', 'osx-10-6');
    retVal = retVal.replace('osx10.8', 'osx-10-8');
    retVal = retVal.replace('winxp', 'windowsxp');
    retVal = retVal.replace('win7', 'windows7-32');
    retVal = retVal.replace('win8', 'windows8-64');

    return retVal
  }

  function toggleState() {
    item = document.getElementById("toggle");
    fetchData();
    if (item.value == "Show Optional Jobs") {
      item.value = "Hide Optional Jobs";
    } else {
      item.value = "Show Optional Jobs";
    }
  }

  // determine if we need a strike through or not
  function printableJobCode(rawName, partName, osMap) {
    item = document.getElementById("toggle");
    // when item.value == "Hide Optional Jobs", its true value is to "show".
    if (item.value == "Hide Optional Jobs") {
      if (osMap.indexOf(rawName) >= 0) {
        return "<span style='background: white; color: #444039;'>" + partName + " </span>";
      }
    }
    if (!(osMap.indexOf(rawName) >= 0)) {
      return "<span style='background: whilte; color: black; font-weight: 14px;'><b>" + partName + " </b></span>";
    }
  }

  function buildOSJobMap(joblist) {
    var map = {}

    for (var i = 0; i < joblist.length; i++) {
      var job = joblist[i];
      key = fixPlatform(job[0]) + " " + job[1];
      if (map[key] === undefined) {
          map[key] = [];
      }
      map[key].push(job[2]);
    }
    return map;
  }

  function outputTable(active_jobs, details, date) {
    // Get the list of jobs per platform that we don't need to run
    var optional_jobs = buildOSJobMap(details['jobtypes'][date]);

    var keys = []
    for (var key in optional_jobs) {
      keys.push(key);
    }
    if (keys.length == 0) {
      $('#datedesc').replaceWith('<div id="datedesc"><p><h3>Sorry, there is no data for the day ' + date + "</h3></div>");
      $('#seta').html('<table id="seta" border=0></table>');
      return;<commit_msg>fixed typo<commit_after>$(function() {
  var input_date = location.search.substr(1).split('=')[1];

  $error = $("#error"),
  $body = $("body");


  function loadDate(date) {
    var parts = date.split('/');
    var d = parts[2] + '-' + parts[0] + '-' + parts[1];
    printTable(d);
  }

  function createDates(data) {
    var dates = {}

    //NOTE: dates are in: "2015-01-01 00:00:00" format
    var previous_value = 0;
    var last_date = '';
    for(var val in data) {
      var date = val.split(' ')[0];
      last_date = date;
      var current_value = data[val];

      //TODO: consider doing something different for more/less values
      if (current_value != previous_value) {
        var parts = date.split('-');
        date = parts[1] + '/' + parts[2] + '/' + parts[0];
        dates[new Date(date)] = new Date(date);
      }
      previous_value = current_value;
    }

    $(function() {
      $("#datepicker").datepicker({
        numberOfMonths: 3,
        minDate: new Date(2014, 11-1, 14),
        showButtonPanel: false,
        showOtherMonths: true,
        selectOtherMonths: true,
        onSelect: loadDate,
        beforeShowDay: function(date) {
          var annotated = dates[date];
          if (annotated) {
            return [true, 'annotated', ''];
          } else {
            return [true, '', ''];
          }
        }
      });
    });

    $("#datepicker").datepicker("setDate", "-2m");

    document.getElementById("toggle").addEventListener("click", toggleState);

    if (input_date === undefined || input_date === '') {
      printTable(last_date);
    } else {
      printTable(input_date);
    }
  }

  function printTable(date) {
    $.getJSON("/data/setadetails/", {date:date}).done(function (data) { getActiveJobs(data, date); });
  }

  function getActiveJobs(details, date) {
    $.getJSON("/data/jobtypes/").done(function (data) { outputTable(data, details, date); });
  }

  // Simple text replace of full names -> Group-Code format
  function printName(testname) {
    var retVal = testname.replace(/mochitest-browser-chrome[-]?/, 'M-bc');
    retVal = retVal.replace(/mochitest-e10s-browser-chrome[-]?/, 'Me10s-bc');
    retVal = retVal.replace(/mochitest-e10s-devtools-chrome[-]?/, 'M-dt');
    retVal = retVal.replace('mochitest-e10s', 'Me10s');
    retVal = retVal.replace(/mochitest-devtools-chrome[-]?/, 'M-dt');
    retVal = retVal.replace('mochitest-other', 'M-oth');
    retVal = retVal.replace('mochitest', 'M');
    retVal = retVal.replace('crashtest-ipc', 'R-C-ipc');
    retVal = retVal.replace('crashtest', 'R-C');
    retVal = retVal.replace('jsreftest', 'R-J');
    retVal = retVal.replace('reftest-no-accel', 'R-RU');
    retVal = retVal.replace('reftest-e10s', 'Re10s-R');
    retVal = retVal.replace('reftest', 'R-R');
    retVal = retVal.replace('xpcshell', 'O-X');
    retVal = retVal.replace('marionette', 'O-Mn');
    retVal = retVal.replace('cppunit', 'O-Cpp');
    retVal = retVal.replace(/jittest[-]?/, 'O-Jit');
    retVal = retVal.replace('web-platform-tests', 'WPT');
    return retVal;
  }

  function fixPlatform(plat) {
    retVal = plat.replace('osx10.6', 'osx-10-6');
    retVal = retVal.replace('osx10.8', 'osx-10-8');
    retVal = retVal.replace('winxp', 'windowsxp');
    retVal = retVal.replace('win7', 'windows7-32');
    retVal = retVal.replace('win8', 'windows8-64');

    return retVal
  }

  function toggleState() {
    item = document.getElementById("toggle");
    fetchData();
    if (item.value == "Show Optional Jobs") {
      item.value = "Hide Optional Jobs";
    } else {
      item.value = "Show Optional Jobs";
    }
  }

  // determine if we need a strike through or not
  function printableJobCode(rawName, partName, osMap) {
    item = document.getElementById("toggle");
    // when item.value == "Hide Optional Jobs", its true value is to "show".
    if (item.value == "Hide Optional Jobs") {
      if (osMap.indexOf(rawName) >= 0) {
        return "<span style='background: white; color: #444039;'>" + partName + " </span>";
      }
    }
    if (!(osMap.indexOf(rawName) >= 0)) {
      return "<span style='background: white; color: black; font-weight: 14px;'><b>" + partName + " </b></span>";
    }
  }

  function buildOSJobMap(joblist) {
    var map = {}

    for (var i = 0; i < joblist.length; i++) {
      var job = joblist[i];
      key = fixPlatform(job[0]) + " " + job[1];
      if (map[key] === undefined) {
          map[key] = [];
      }
      map[key].push(job[2]);
    }
    return map;
  }

  function outputTable(active_jobs, details, date) {
    // Get the list of jobs per platform that we don't need to run
    var optional_jobs = buildOSJobMap(details['jobtypes'][date]);

    var keys = []
    for (var key in optional_jobs) {
      keys.push(key);
    }
    if (keys.length == 0) {
      $('#datedesc').replaceWith('<div id="datedesc"><p><h3>Sorry, there is no data for the day ' + date + "</h3></div>");
      $('#seta').html('<table id="seta" border=0></table>');
      return;
{'fraction_non_alphanumeric': 0.184734954165006, 'fraction_numerical': 0.01733758469509765, 'mean_word_length': 2.8309160305343513, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, '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': '2834891', 'n_tokens_mistral': 3545, 'n_tokens_neox': 3397, 'n_words': 716}