<commit_before>var remoteUrl = "http://52.10.162.213/";
var localUrl = "http://127.0.0.1:8000/";
var baseUrl = remoteUrl;
var googleid;

var myHRData;

// Load the Visualization API library and the piechart library.
google.load('visualization', '1.0', {'packages':['corechart']});

function showTile(tileName) {
  $("#tileContent").css("display", "none");
  $(".jumbotron").css("display", "none");

  switch (tileName) {
    case  "sleep":
      showSleepTile();
      break;
    case "fitness":
      showFitnessTile();
      break;
    case "calories":
      showCaloriesTile()
      break;
    case "intensity":
      showIntensityTile();
      break;
    case "otherUsers":
      showOtherUsersTile();
      break;
    case "myData":
      showMyDataTile();
      break;
  }
}

function createUser () {
  $('#newUserModal').modal();
}

function showMyDataTile() {
  var myDataUrl = baseUrl + "dataSet/entries/id/" + googleid + "/";

  $.ajax({
    type: "GET",
    url: myDataUrl
  }).done(function(result) {
    console.log("got some data");
    myHRData = result;
    drawAHRGraph("#myDataChart", "#myHRDataTable", "My Heart Rate", myHRData);
  }).fail(function(error){
    console.log("could not get myData");
    console.log(error);
  });


  var toAppend = "<button onclick='goToHomePage()'>&#10096; Home</button>";
  toAppend += "<h1>My Health Data</h1>";
  toAppend += '<button type="submit" style="margin-left: 70%;" class="btn btn-success" data-toggle="modal" data-target="#manualDataEntryModal">Enter New Data</button>';
  toAppend += '<br><div class="btn-group" role="group" aria-label="..."><button type="button" onclick="showMyHRDataGraph()" id="myHRDataGraphBtn" class="btn active btn-default">Graph</button><button type="button" onclick="showMyHRDataTable()" id="myHRDataTableBtn" class="btn btn-default">Table</button></div>'
  toAppend += '<div id="myDataChart" class="barGraph"></div>';
  toAppend += "<div id='myHRDataTable'></div>"

  $("#tileDetail").empty().append(toAppend);
  setTimeout(showMyDataTile, 500);
}

function showMyHRDataTable() {
  $("#myHRDataTableBtn").addClass("active")
  $("#myHRDataGraphBtn").removeClass("active")

  drawATable("#myHRDataTable", "#myDataChart", myHRData);
}

function showMyHRDataGraph() {
  $("#myHRDataTableBtn").removeClass("active")
  $("#myHRDataGraphBtn").addClass("active")

  drawAHRGraph("#myDataChart", "#myHRDataTable", "My Heart Rate", myHRData);
}

function drawATable(activate, deactivate, dataSource) {
  $(deactivate).css("display", "none");
  $(activate).css("display", "inline");

  var toAppend = "<div class='table-responsive'>";<commit_msg>changed graph redraw from 500ms to 5 seconds<commit_after>var remoteUrl = "http://52.10.162.213/";
var localUrl = "http://127.0.0.1:8000/";
var baseUrl = remoteUrl;
var googleid;

var myHRData;

// Load the Visualization API library and the piechart library.
google.load('visualization', '1.0', {'packages':['corechart']});

function showTile(tileName) {
  $("#tileContent").css("display", "none");
  $(".jumbotron").css("display", "none");

  switch (tileName) {
    case  "sleep":
      showSleepTile();
      break;
    case "fitness":
      showFitnessTile();
      break;
    case "calories":
      showCaloriesTile()
      break;
    case "intensity":
      showIntensityTile();
      break;
    case "otherUsers":
      showOtherUsersTile();
      break;
    case "myData":
      showMyDataTile();
      break;
  }
}

function createUser () {
  $('#newUserModal').modal();
}

function showMyDataTile() {
  var myDataUrl = baseUrl + "dataSet/entries/id/" + googleid + "/";

  $.ajax({
    type: "GET",
    url: myDataUrl
  }).done(function(result) {
    console.log("got some data");
    myHRData = result;
    drawAHRGraph("#myDataChart", "#myHRDataTable", "My Heart Rate", myHRData);
  }).fail(function(error){
    console.log("could not get myData");
    console.log(error);
  });


  var toAppend = "<button onclick='goToHomePage()'>&#10096; Home</button>";
  toAppend += "<h1>My Health Data</h1>";
  toAppend += '<button type="submit" style="margin-left: 70%;" class="btn btn-success" data-toggle="modal" data-target="#manualDataEntryModal">Enter New Data</button>';
  toAppend += '<br><div class="btn-group" role="group" aria-label="..."><button type="button" onclick="showMyHRDataGraph()" id="myHRDataGraphBtn" class="btn active btn-default">Graph</button><button type="button" onclick="showMyHRDataTable()" id="myHRDataTableBtn" class="btn btn-default">Table</button></div>'
  toAppend += '<div id="myDataChart" class="barGraph"></div>';
  toAppend += "<div id='myHRDataTable'></div>"

  $("#tileDetail").empty().append(toAppend);
  setTimeout(showMyDataTile, 5 * 1000);
}

function showMyHRDataTable() {
  $("#myHRDataTableBtn").addClass("active")
  $("#myHRDataGraphBtn").removeClass("active")

  drawATable("#myHRDataTable", "#myDataChart", myHRData);
}

function showMyHRDataGraph() {
  $("#myHRDataTableBtn").removeClass("active")
  $("#myHRDataGraphBtn").addClass("active")

  drawAHRGraph("#myDataChart", "#myHRDataTable", "My Heart Rate", myHRData);
}

function drawATable(activate, deactivate, dataSource) {
  $(deactivate).css("display", "none");
  $(activate).css("display", "inline");

  var toAppend = "<div class='table-responsive'>";
{'fraction_non_alphanumeric': 0.19194402420574885, 'fraction_numerical': 0.01399394856278366, 'mean_word_length': 4.7993421052631575, 'pattern_counts': {'":': 12, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '7220941', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1699, 'n_words': 337}