<commit_before>var $$ = {
  storeData: function() {
    localStorage["karma.data"] = JSON.stringify(this.data);
  },
  readData: function() {
    this.data = JSON.parse(localStorage["karma.data"]);
  },
  leaderboard: function() {
    return this.data.sort(this.compare);
  },
  compare: function (a, b){
    return b.points - a.points;
  },
  // modifyPointsFor(0, 2);
  modifyPointsFor: function(indexInArray, newPoints) {
    this.data[indexInArray].points = newPoints;
    this.storeData();
  },
  data: []
};

$(document).ready(function() {
  $$.readData();
  var sorted = $$.leaderboard();

  var $template = $(".person:first"), $clonedLi;
  var ppl = sorted.map(function(p, i) {
    $clonedLi = $template.clone().show();
    $clonedLi.data("order", i);
    $clonedLi.find(".name").text(p.name);
    $clonedLi.find(".points").text(p.points);
    $clonedLi.find("input").val(p.points);
    return $clonedLi;
  });

  $("#ppl").append(ppl);

  var person;

  $("#ppl")
  .on("dblclick", ".points", function() {
    $(this).hide('.points');
    $(this).siblings('.input:first').removeClass('hidden');
    person = $(this).parents(".person");
    console.log(person.data("order"));
  })
  .on("keyup", "input", function(event) {
    if (event.which === 13) {
      console.log("Enter");
      $('.input').addClass('hidden');
      $('.points').show('.input');
      var newPoints = $(this).val();
      console.log(newPoints);
      $$.modifyPointsFor(person.data("order"), newPoints);
    }

  });

});<commit_msg>works!<commit_after>var $$ = {
  storeData: function() {
    localStorage["karma.data"] = JSON.stringify(this.data);
  },
  readData: function() {
    this.data = JSON.parse(localStorage["karma.data"]);
  },
  leaderboard: function() {
    return this.data.sort(this.compare);
  },
  compare: function (a, b){
    return b.points - a.points;
  },
  // modifyPointsFor(0, 2);
  modifyPointsFor: function(indexInArray, newPoints) {
    this.data[indexInArray].points = newPoints;
    this.storeData();
  },
  data: []
};

$(document).ready(function() {
  $$.readData();
  var sorted = $$.leaderboard();

  var $template = $(".person:first"), $clonedLi;
  var ppl = sorted.map(function(p, i) {
    $clonedLi = $template.clone().show();
    $clonedLi.data("order", i);
    $clonedLi.find(".name").text(p.name);
    $clonedLi.find(".points").text(p.points);
    $clonedLi.find("input").val(p.points);
    return $clonedLi;
  });

  $("#ppl").append(ppl);

  var person;

  $("#ppl")
  .on("dblclick", ".points", function() {
    $(this).hide('.points');
    $(this).siblings('.input:first').removeClass('hidden');
    person = $(this).parents(".person");
    console.log(person.data("order"));
  })
  .on("keyup", "input", function(event) {
    if (event.which === 13) {
      console.log("Enter");
      $('.input').addClass('hidden');
      $('.points').show('.input');
      var newPoints = $(this).val();
      console.log(newPoints);
      $$.modifyPointsFor(person.data("order"), newPoints);
      $('.points') === newPoints;
      window.location.reload();
    }

  });

});
{'fraction_non_alphanumeric': 0.22955059812479794, 'fraction_numerical': 0.0025864856126737797, 'mean_word_length': 3.4710982658959537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7304350', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1067, 'n_words': 159}