<commit_before>Template.ksEdit.helpers({
  ks: function () {
    var ks = this;
    ks.books = Books.find();
    return ks;
  }
});

Template.ksEdit.events({
  'submit form': function (elt) {
    var _id = $('input.id').val(),
      ks = _id ? KSessions.findOne(_id) : {};

    elt.preventDefault();
    ks.i = +$("input.i").val();
    ks.klubMaster = $("input.klubMaster").val();
    ks.date = $("input.date").val();
    ks.voteer = $("input.vote").val();
    ks.meetup = $("input.meetup").val();
    ks.book_id = $("select[name=selBook]").val();
    // Update an existent record or create it
    if (_id) {
      KSessions.update(_id, ks);
    } else {
      KSessions.insert(ks);
    }
  },
  'click .delete': function (elt) {
    var _id = $('input.id').val();

    elt.preventDefault();
    KSessions.remove(this._id);
    Router.go('admin');
  }
});

Template.ksEdit.rendered = function () {
  /*
  Add this method because it works on refresh
  but won't by clicking on previous list page.
 */
  this.$("select[name='selBook']").val(this.$('input.book-id').val());
};<commit_msg>Insert or update anonymous when no klubmaster are specify<commit_after>Template.ksEdit.helpers({
  ks: function () {
    var ks = this;
    ks.books = Books.find();
    return ks;
  }
});

Template.ksEdit.events({
  'submit form': function (elt) {
    var _id = $('input.id').val(),
      ks = _id ? KSessions.findOne(_id) : {};

    elt.preventDefault();
    ks.i = +$("input.i").val();
    ks.klubMaster = $("input.klubMaster").val() || "anonymous";
    ks.date = $("input.date").val();
    ks.voteer = $("input.vote").val();
    ks.meetup = $("input.meetup").val();
    ks.book_id = $("select[name=selBook]").val();
    // Update an existent record or create it
    if (_id) {
      KSessions.update(_id, ks);
    } else {
      KSessions.insert(ks);
    }
  },
  'click .delete': function (elt) {
    var _id = $('input.id').val();

    elt.preventDefault();
    KSessions.remove(this._id);
    Router.go('admin');
  }
});

Template.ksEdit.rendered = function () {
  /*
  Add this method because it works on refresh
  but won't by clicking on previous list page.
 */
  this.$("select[name='selBook']").val(this.$('input.book-id').val());
};
{'fraction_non_alphanumeric': 0.2072678331090175, 'fraction_numerical': 0.0, 'mean_word_length': 2.9469026548672566, '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': '1950119', 'n_tokens_mistral': 817, 'n_tokens_neox': 777, 'n_words': 161}