<commit_before>/*****************************************************************************/
/* ParagraphsNew: Event Handlers and Helpersss .js*/
/*****************************************************************************/
Template.ParagraphsNew.events({
  /*
   * Example:
   *  'click .selector': function (e, tmpl) {
   *
   *  }
   */
  'submit #new-paragraph-form': function (e, tmpl) {
    e.preventDefault();

    var pageId = this._id;

    var content = tmpl.find('#newParagraph').value;

    Pages.update({ _id: pageId }, {
      $inc: { paragraphs: 1 }
    });

    Paragraphs.insert({
      pageId: pageId,
      content: content,
      rank: Paragraphs.find().count() + 1
    });

    Session.set('newParagraph', null);
  },

  'click #cancel-new-paragraph': function (e) {
    e.preventDefault();

    Session.set('newParagraph', null);
  },

  'click #new-smart-editor-toggle': function (e, tmpl) {
    e.preventDefault();

    var content = tmpl.find('#newParagraph').value;
    Session.set('newParagraphContent', content);

    if (Session.get('smartEditor')) {
      Session.set('smartEditor', false);
      App.setAlert('Text area editor enabled.', 'info');
      Meteor.setTimeout(function () {
        $('.new-paragraph-text-area').autosize();
      }, 50);
    } else {
      Session.set('smartEditor', true);
      App.setAlert('Smart editor enabled.', 'info');
      Meteor.setTimeout(function () {
        $('.new-paragraph-text-area').trigger('autosize.destroy');<commit_msg>Clear up newParagraphContent session var on save/clear<commit_after>/*****************************************************************************/
/* ParagraphsNew: Event Handlers and Helpersss .js*/
/*****************************************************************************/
Template.ParagraphsNew.events({
  /*
   * Example:
   *  'click .selector': function (e, tmpl) {
   *
   *  }
   */
  'submit #new-paragraph-form': function (e, tmpl) {
    e.preventDefault();

    var pageId = this._id;

    var content = tmpl.find('#newParagraph').value;

    Pages.update({ _id: pageId }, {
      $inc: { paragraphs: 1 }
    });

    Paragraphs.insert({
      pageId: pageId,
      content: content,
      rank: Paragraphs.find().count() + 1
    });

    Session.set('newParagraph', null);
    Session.set('newParagraphContent', null);
  },

  'click #cancel-new-paragraph': function (e) {
    e.preventDefault();

    Session.set('newParagraph', null);
    Session.set('newParagraphContent', content);
  },

  'click #new-smart-editor-toggle': function (e, tmpl) {
    e.preventDefault();

    var content = tmpl.find('#newParagraph').value;
    Session.set('newParagraphContent', content);

    if (Session.get('smartEditor')) {
      Session.set('smartEditor', false);
      App.setAlert('Text area editor enabled.', 'info');
      Meteor.setTimeout(function () {
        $('.new-paragraph-text-area').autosize();
      }, 50);
    } else {
      Session.set('smartEditor', true);
      App.setAlert('Smart editor enabled.', 'info');
      Meteor.setTimeout(function () {
        $('.new-paragraph-text-area').trigger('autosize.destroy');
{'fraction_non_alphanumeric': 0.25698856416772553, 'fraction_numerical': 0.0025412960609911056, 'mean_word_length': 3.385793871866295, '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': '4151876', 'n_tokens_mistral': 956, 'n_tokens_neox': 909, 'n_words': 171}