<commit_before>/*  General purpose list view
*   Expects a Backbone collection and a itemView (name of a Backbone view resembling a li-row)
*/
Backbone.ListView = Backbone.View.extend({
  tagName: 'ul',
  initialize: function(options){
    this.itemView     = options.itemView;
    this.itemViews    = [];

    //Events
    this.listenTo(this.collection, 'add', this.render);
    this.listenTo(this.collection, 'reset', this.render);
  },
  render: function(){
    //reset the itemViews array
    this.purgeItemViews();

    if (this.collection.length > 0) {
      _.each(this.collection.models, function(model){
        var view = new this.itemView({model: model, collection: this.collection});
        this.itemViews.push(view)
        this.append(view);

      }, this);
    }

    this.trigger('rendered');
    return this;
  },
  append: function(itemView){
    this.$el.append(itemView.render().el);
    return this;
  },
  /* Remove all subviews and itself to prevent memory leak */
  remove: function(){
    //first remove all subviews, then this view
    this.purgeItemViews();
    Backbone.View.prototype.remove.apply(this, arguments);<commit_msg>Move event binding into its own method so it can be extended<commit_after>/*  General purpose list view
*   Expects a Backbone collection and a itemView (name of a Backbone view resembling a li-row)
*/
Backbone.ListView = Backbone.View.extend({
  tagName: 'ul',
  initialize: function(options){
    this.itemView     = options.itemView;
    this.itemViews    = [];

    this.eventBinder();
  },
  eventBinder: function(){
    //Events
    this.listenTo(this.collection, 'add', this.render);
    this.listenTo(this.collection, 'reset', this.render);
  },
  render: function(){
    //reset the itemViews array
    this.purgeItemViews();

    if (this.collection.length > 0) {
      _.each(this.collection.models, function(model){
        var view = new this.itemView({model: model, collection: this.collection});
        this.itemViews.push(view)
        this.append(view);

      }, this);
    }

    this.trigger('rendered');
    return this;
  },
  append: function(itemView){
    this.$el.append(itemView.render().el);
    return this;
  },
  /* Remove all subviews and itself to prevent memory leak */
  remove: function(){
    //first remove all subviews, then this view
    this.purgeItemViews();
    Backbone.View.prototype.remove.apply(this, arguments);
{'fraction_non_alphanumeric': 0.13239553165080678, 'fraction_numerical': 0.0008274720728175424, 'mean_word_length': 3.161790017211704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1317766', 'n_tokens_mistral': 731, 'n_tokens_neox': 712, 'n_words': 187}