<commit_before>//TODO THis is mostly a dummy page ATM copied from CorpusView but we will want to think criticially about what we will want on a page that allows users to create a new  corpus.
define([ 
    "use!backbone", 
    "use!handlebars", 
    "text!corpus/new_corpus.handlebars",
    "corpus/Corpus",
    "libs/Utils"
], function(
    Backbone, 
    Handlebars, 
    new_corpusTemplate, 
    Corpus
) {
      var NewCorpusView = Backbone.View
          .extend(
          /** @lends CorpusView.prototype */
          {
            /**
             * @class This is the new corpus view. This allows users to make a
             *        new corpus. Set permissions on the corpus, teams, etc.
             * 
             * @description Starts the Corpus and initializes all its children.
             * 
             * @extends Backbone.View
             * @constructs
             */
            initialize : function() {

            },

            /**
             * The underlying model of the NewCorpusView is a Corpus.
             */
            model : Corpus,

            events : {
//              "change" : "render",
              "blur .title" : "updateTitle",
              "blur .description" : "updateDescription",
              "click .save" : "saveNewCorpus"
            },

            /**
             * The Handlebars template rendered as the CorpusView.
             */
            template : Handlebars.compile(new_corpusTemplate),

            /**
             * Renders the CorpusView and all of its child Views.
             */
            render : function() {
              Utils.debug("CORPUS render: " + this.el);
              if (this.model != undefined) {
                // Display the CorpusView
                this.setElement($("#new-corpus"));
                $(this.el).html(this.template(this.model.toJSON()));

              } else {
                Utils.debug("\Corpus model was undefined.");
              }

              return this;
            },
            updateTitle : function(){
              this.model.set("title", this.$el.children(".title").val());
              this.model.set("titleAsUrl", encodeURIComponent(this.$el.children(".title").val()));
            },
            updateDescription : function(){
              this.model.set("description", this.$el.children(".description").val());
            },
            saveNewCorpus : function(){
              this.model.save(
                  null,
                  {
                  success : function() {
                    appView.authView.model.get("user").get("corpuses").push(this.model.id); 
                  },
                  error : function() {
                    alert("Unable to create new corpus.");
                  }
                }
              );
              window.location = "#user/"+appView.authView.model.get("username");
            }
          });

      return NewCorpusView;
});<commit_msg>forgot a this and self in one of the save success callbacks, now inserting ids into the corpuses arrays<commit_after>//TODO THis is mostly a dummy page ATM copied from CorpusView but we will want to think criticially about what we will want on a page that allows users to create a new  corpus.
define([ 
    "use!backbone", 
    "use!handlebars", 
    "text!corpus/new_corpus.handlebars",
    "corpus/Corpus",
    "libs/Utils"
], function(
    Backbone, 
    Handlebars, 
    new_corpusTemplate, 
    Corpus
) {
      var NewCorpusView = Backbone.View
          .extend(
          /** @lends CorpusView.prototype */
          {
            /**
             * @class This is the new corpus view. This allows users to make a
             *        new corpus. Set permissions on the corpus, teams, etc.
             * 
             * @description Starts the Corpus and initializes all its children.
             * 
             * @extends Backbone.View
             * @constructs
             */
            initialize : function() {

            },

            /**
             * The underlying model of the NewCorpusView is a Corpus.
             */
            model : Corpus,

            events : {
//              "change" : "render",
              "blur .title" : "updateTitle",
              "blur .description" : "updateDescription",
              "click .save" : "saveNewCorpus"
            },

            /**
             * The Handlebars template rendered as the CorpusView.
             */
            template : Handlebars.compile(new_corpusTemplate),

            /**
             * Renders the CorpusView and all of its child Views.
             */
            render : function() {
              Utils.debug("CORPUS render: " + this.el);
              if (this.model != undefined) {
                // Display the CorpusView
                this.setElement($("#new-corpus"));
                $(this.el).html(this.template(this.model.toJSON()));

              } else {
                Utils.debug("\Corpus model was undefined.");
              }

              return this;
            },
            updateTitle : function(){
              this.model.set("title", this.$el.children(".title").val());
              this.model.set("titleAsUrl", encodeURIComponent(this.$el.children(".title").val()));
            },
            updateDescription : function(){
              this.model.set("description", this.$el.children(".description").val());
            },
            saveNewCorpus : function(){
              var self = this;
              this.model.save(
                  null,
                  {
                  success : function() {
                    appView.authView.model.get("user").get("corpuses").push(self.model.id); 
                  },
                  error : function() {
                    alert("Unable to create new corpus.");
                  }
                }
              );
              window.location = "#user/"+appView.authView.model.get("username");
            }
          });

      return NewCorpusView;
});
{'fraction_non_alphanumeric': 0.11343630626141837, 'fraction_numerical': 0.0, 'mean_word_length': 1.3332041844246416, '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': '2737863', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1455, 'n_words': 373}