<commit_before>/**
 * @file
 * Sample app code for backbone.drupal.js.
 */

var session = new Backbone.Drupal.Model.Session();

var app = new Marionette.Application();

app.addRegions({
  mainRegion: "#content"
});

app.addInitializer(function (options) {
  var nodesView = new NodesView({
    collection: options.nodes
  });
  app.mainRegion.show(nodesView);
});

NodeView = Marionette.ItemView.extend({
  template: "#node-template",
  tagName: 'tr',
  className: 'node',

  ui: {
    title: '.title'
  },

  events: {
    'click a.save': 'updateTitle',
    'loggedIn': 'updateState'
  },

  updateTitle: function () {
    var self = this;

    var title = this.ui.title.val();
    this.model.set('title', title);
    this.model.save().done(function () {
      self.model.fetch().done(function () {
        $('#messages').text('Node title updated.').slideDown('slow').delay(1500).slideUp('slow');
      });
    });
  },

  updateState: function () {
    this.ui.title.prop('disabled', false);
  }
});

NodesView = Marionette.CompositeView.extend({
  id: "nodes",
  template: "#nodes-template",
  childView: NodeView,
  childViewContainer: "tbody",

  initialize: function () {
    this.listenTo(this.collection, "sort", this.renderCollection);
  },

  appendHtml: function (collectionView, itemView) {
    collectionView.$("tbody").append(itemView.el);
  }
});

var nodelist;

$(document).ready(function() {

  session.login(username, password).done(function () {
    nodelist = new Backbone.Drupal.Collection.Node();

    nodelist.fetch({remove: false}).done(function () {
      nodelist.each(function (model) {
        model.fetch();
      });
    });

    app.start({nodes: nodelist});
  });
});<commit_msg>Remove more unnecessary example code.<commit_after>/**
 * @file
 * Sample app code for backbone.drupal.js.
 */

var session = new Backbone.Drupal.Model.Session();

var app = new Marionette.Application();

app.addRegions({
  mainRegion: "#content"
});

app.addInitializer(function (options) {
  var nodesView = new NodesView({
    collection: options.nodes
  });
  app.mainRegion.show(nodesView);
});

NodeView = Marionette.ItemView.extend({
  template: "#node-template",
  tagName: 'tr',
  className: 'node',

  ui: {
    title: '.title'
  },

  events: {
    'click a.save': 'updateTitle'
  },

  updateTitle: function () {
    var self = this;

    var title = this.ui.title.val();
    this.model.set('title', title);
    this.model.save().done(function () {
      // We have to re-fetch after a save, since the updated time will change
      // and we won't be able to save again.
      self.model.fetch().done(function () {
        $('#messages').text('Node title updated.').slideDown('slow').delay(1500).slideUp('slow');
      });
    });
  }

});

NodesView = Marionette.CompositeView.extend({
  id: "nodes",
  template: "#nodes-template",
  childView: NodeView,
  childViewContainer: "tbody"
});

var nodelist;

$(document).ready(function() {

  session.login(username, password).done(function () {
    nodelist = new Backbone.Drupal.Collection.Node();

    nodelist.fetch({remove: false, data: {pagesize: 10}});

    app.start({nodes: nodelist});
  });
});
{'fraction_non_alphanumeric': 0.17700787401574802, 'fraction_numerical': 0.0031496062992125984, 'mean_word_length': 3.4858757062146895, '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': '453462', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1012, 'n_words': 205}