<commit_before>window.FactsView = Backbone.View.extend({
  tagName: "div",
  className: "facts",
  _views: [],
  _loading: false,
  _page: 1,
  tmpl: $('#facts_tmpl').html(),
  initialize: function() {
    var self = this;
    
    this.collection.bind('add', this.addFact, this);
    this.collection.bind('reset', this.resetFacts, this);
    
    $(this.el).html(Mustache.to_html(this.tmpl));
    
    this.collection.fetch({
      data: {
        page: self._page
      }
    });
  },
  render: function() {
    if ( this.collection.length > 0 ) {
      this.resetFacts();
    }
    
    return this;
  },
  addFact: function(fact) {
    var view = new FactView({
      model: fact
    });
    
    $( this.el ).append(view.render().el);
    
    this._views.push(view);
  },
  resetFacts: function() {
    var self = this;
    
    $(this.el).find('div.loading').hide();
    
    $(this.el).find('div.no_facts').toggle(this.collection.length);
    
    this.collection.forEach(function(fact) {
      self.addFact(fact);
    });
  }
});<commit_msg>Updated loading/no_facts logic in facts_view<commit_after>window.FactsView = Backbone.View.extend({
  tagName: "div",
  className: "facts",
  _views: [],
  _loading: true,
  _page: 1,
  tmpl: $('#facts_tmpl').html(),
  initialize: function() {
    var self = this;
    
    this.collection.bind('add', this.addFact, this);
    this.collection.bind('reset', this.resetFacts, this);
    
    $(this.el).html(Mustache.to_html(this.tmpl));
        
    this.setLoading();
    
    this.collection.fetch({
      data: {
        page: self._page
      }
    });
  },
  render: function() {
    if ( this.collection.length > 0 ) {
      this.resetFacts();
    }
    
    return this;
  },
  addFact: function(fact) {
    var view = new FactView({
      model: fact
    });
    
    $( this.el ).append(view.render().el);
    
    this._views.push(view);
  },
  resetFacts: function() {
    var self = this;
    
    this.stopLoading();
    
    if ( this.collection.length === 0 ) {
      this.showNoFacts();
    } else {
      this.collection.forEach(function(fact) {
        self.addFact(fact);
      });
    }
  },
  showNoFacts: function() {
    $(this.el).find('div.no_facts').show();
  },
  hideNoFacts: function() {
    $(this.el).find('div.no_facts').hide();
  },
  setLoading: function() {
    this._loading = true;
    $(this.el).find('div.loading').show();
  },
  stopLoading: function() {
    this._loading = false;
    $(this.el).find('div.loading').hide();
  }
});
{'fraction_non_alphanumeric': 0.18167393891312972, 'fraction_numerical': 0.0019833399444664813, 'mean_word_length': 2.440654843110505, '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': '250277', 'n_tokens_mistral': 888, 'n_tokens_neox': 872, 'n_words': 139}