<commit_before>$(document).ready(function(){

  var Log = Backbone.Model.extend({});
  var LogStore = Backbone.Collection.extend({
   model: Log,
     url: '/logs'
  });

  var LogTableView = Backbone.View.extend({

    offset: 0,

    howManyShown: 15,

    events: {
      "click .arrow-left  img": "swapLeft",
      "click .arrow-right img": "swapRight"
    },

    swapLeft: function(){
      this.offset = Math.max(this.offset - this.howManyShown, 0);
      this.render();
    },

    swapRight: function(){
      this.offset = Math.min(this.offset + this.howManyShown, logs.size()-1);
      this.render();
    },

    logsToShow: function(){
      var l = logs.map(function(x){ return x.toJSON(); });
      return l.slice(this.offset, this.offset + this.howManyShown);
    },

    render: function() {
      view = this;
      $.get('views/log-table.mustache', function(tpl){
        var shownlogs = view.logsToShow();
        var htmlText = Mustache.render(tpl, {logs: shownlogs});
        view.$el.html(htmlText);
      })
    }

  });

  var logs = new LogStore;
  var logTableView = new LogTableView({el: '#log-table'});

  logs.fetch({success: function(){ logTableView.render(); }});
})<commit_msg>Internal Model/View inside the table view itself.<commit_after>var LogBook = (typeof module !== "undefined" && module.exports) || {};

(function (exports) {

  // One single log tuple as a Backbone model
  exports.Log  = Backbone.Model.extend({});

  // All log tuples (as seen by the client) as a Backbone collection
  exports.Logs = Backbone.Collection.extend({
   model: exports.Log,
     url: '/logs'
  });

  // The table view
  exports.LogTableView = Backbone.View.extend({

    events: {
      "click .arrow-left  img": "swapLeft",
      "click .arrow-right img": "swapRight"
    },

    initialize: function(options) {
      this.model.on('all', this.render, this);
      this.State = Backbone.Model.extend({});
      this.state = new this.State({
        offset: 0,
        limit: 15
      });
      this.state.on('all', this.render, this);
    },

    offset: function(){ return this.state.get('offset'); },
    limit:  function(){ return this.state.get('limit');  },

    getLogs: function() {
      offset = this.offset();
      limit  = this.limit();
      return this.model
                 .map(function(x){ return x.toJSON(); })
                 .slice(offset, offset + limit);
    },

    swapLeft: function(){
      this.state.set({offset: Math.max(this.offset() - this.limit(), 0)});
    },

    swapRight: function(){
      this.state.set({offset: Math.min(this.offset() + this.limit(), this.model.size()-1)});
    },

    render: function() {
      var view = this;
      $.get('views/log-table.mustache', function(tpl){
        var shownlogs = view.getLogs(view.state);
        var htmlText = Mustache.render(tpl, {logs: shownlogs});
        view.$el.html(htmlText);
      })
    }

  });

})(LogBook);

$(document).ready(function(){
  var logs = new LogBook.Logs;
  var logTableView = new LogBook.LogTableView({model: logs, el: '#log-table'});
  logs.fetch();
})
{'fraction_non_alphanumeric': 0.17194570135746606, 'fraction_numerical': 0.003232062055591467, 'mean_word_length': 2.67141162514828, 'pattern_counts': {'":': 4, '<': 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': '6233461', 'n_tokens_mistral': 1008, 'n_tokens_neox': 979, 'n_words': 216}