<commit_before>function PaginatedTable(opts) {
  var that = this;

  that._manager = opts.manager;
  that._table = opts.table;
  that._createRow = opts.createRow;
  that._currentPage = 0;

  if (opts.rowClick) {
    that._table.find("tr:not(.moreRow)").live("click", function() {
      var theRow = $(this);
      opts.rowClick(theRow.data("entity"));
    });
  }

  var numCols = that._table.find("thead tr td").length;
  that._more = $('<tr><td></td></tr>').addClass("moreRow");
  that._more.find("td").
    attr("colspan", numCols).
    append('<a href="#">More...</a>').
    append('<span class="loading">Loading...</span>');
  that._more.
    find(".loading").css({"font-style": "italic", color: "grey"}).hide().end().
    find("a").click(function() { that.loadPage(); }).end();

  that._table.find("tbody").append(this._more);
}

PaginatedTable.prototype = {

  // Append a page of entities to the list.
  loadPage: function() {
    this._more.
      find("a").hide().end().
      find(".loading").show();

    var PAGE_SIZE = 10;
    var offset = this._currentPage * PAGE_SIZE;

    var that = this;
    that._manager.createList(true, offset, PAGE_SIZE).forEachAsync({
      each: function(entity) {
        that.addRowFor(entity);
      },
      complete: function(entities) {
        that._currentPage += 1;

        if (entities.length == PAGE_SIZE) { // didn't reach end of list
          that._more.
            find(".loading").hide().end().
            find("a").show();
        }
        else {
          that._more.hide();
        }
      }
    });
  },

  addRowFor: function(entity) {
    var newRow = this._createRow(entity).data("entity", entity);
    this._more.before(newRow);
    newRow.effect("highlight", {}, 3000);
  },

  // Return a jQuery ojbect containing the row(s) for the given entity
  rowFor: function(entity) {
    return $("tr", this._table).filter(function() {
      return $(this).data("entity") == entity;
    });
  },

  // Replace the row for oldEntity with one for newEntity.
  replaceRowFor: function(oldEntity, newEntity) {
    var oldRow = this.rowFor(oldEntity);<commit_msg>Add 'odd'/'even' classes on table rows<commit_after>function PaginatedTable(opts) {
  var that = this;

  that._manager = opts.manager;
  that._table = opts.table;
  that._createRow = opts.createRow;
  that._currentPage = 0;

  if (opts.rowClick) {
    that._table.find("tr:not(.moreRow)").live("click", function() {
      var theRow = $(this);
      opts.rowClick(theRow.data("entity"));
    });
  }

  var numCols = that._table.find("thead tr td").length;
  that._more = $('<tr><td></td></tr>').addClass("moreRow");
  that._more.find("td").
    attr("colspan", numCols).
    append('<a href="#">More...</a>').
    append('<span class="loading">Loading...</span>');
  that._more.
    find(".loading").css({"font-style": "italic", color: "grey"}).hide().end().
    find("a").click(function() { that.loadPage(); }).end();

  that._table.find("tbody").append(this._more);
}

PaginatedTable.prototype = {

  // Append a page of entities to the list.
  loadPage: function() {
    this._more.
      find("a").hide().end().
      find(".loading").show();

    var PAGE_SIZE = 10;
    var offset = this._currentPage * PAGE_SIZE;

    var that = this;
    that._manager.createList(true, offset, PAGE_SIZE).forEachAsync({
      each: function(entity) {
        that.addRowFor(entity);
      },
      complete: function(entities) {
        that._currentPage += 1;

        if (entities.length == PAGE_SIZE) { // didn't reach end of list
          that._more.
            find(".loading").hide().end().
            find("a").show();
        }
        else {
          that._more.hide();
        }
      }
    });
  },

  addRowFor: function(entity) {
    var newRow = this._createRow(entity).data("entity", entity);
    this._more.before(newRow);
    if (newRow.prev().hasClass("odd"))
      newRow.addClass("even");
    else
      newRow.addClass("odd");
    newRow.effect("highlight", {}, 3000);
  },

  // Return a jQuery ojbect containing the row(s) for the given entity
  rowFor: function(entity) {
    return $("tr", this._table).filter(function() {
      return $(this).data("entity") == entity;
    });
  },

  // Replace the row for oldEntity with one for newEntity.
  replaceRowFor: function(oldEntity, newEntity) {
    var oldRow = this.rowFor(oldEntity);
{'fraction_non_alphanumeric': 0.18624314442413162, 'fraction_numerical': 0.003656307129798903, 'mean_word_length': 2.8394736842105264, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 19, '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': '115209', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1379, 'n_words': 277}