<commit_before>function Comment(attributes) {
  this.id = attributes.id
  this.content = attributes.content
  this.user_id = attributes.user_id
  this.resource_id = attributes.resource_id
}

Comment.prototype.renderLI = function () {
  return Comment.template(this)
};

Comment.success = function (json) {
  var comment = new Comment(json)
  var commentLI = comment.renderLI()

  $("ul.comments-list").append(commentLI)
}

Comment.error = function (response) {
  console.log("You broke it!", response)
}

Comment.formSubmit = function (e) {
  e.preventDefault()
  var $form = $(this)
  var action = $form.attr("action")
  var params = $form.serialize()

  $.post(action, params, Comment.success, "json")
  .error(Comment.error)
}

Comment.assignListeners = function functionName() {
  $(document).on("submit", "form#new_comment", Comment.formSubmit)
}

Comment.ready = function () {
  Comment.templateSource = $("#comment-template").html()
  Comment.template = Handlebars.compile(Comment.templateSource)
  Comment.assignListeners()
}

document.addEventListener("turbolinks:load", function(event) {
  Comment.ready()
});<commit_msg>Add jquery delete methods for comments.js.<commit_after>function Comment(attributes) {
  this.id = attributes.id
  this.content = attributes.content
  this.user_id = attributes.user_id
  this.resource_id = attributes.resource_id
}

Comment.prototype.renderLI = function () {
  return Comment.template(this)
};

Comment.success = function (json) {
  var comment = new Comment(json)
  var commentLI = comment.renderLI()

  $("ul.comments-list").append(commentLI)
}

Comment.error = function (response) {
  console.log("You broke it!", response)
}

Comment.formSubmit = function (e) {
  e.preventDefault()
  var $form = $(this)
  var action = $form.attr("action")
  var params = $form.serialize()

  $.post(action, params, Comment.success, "json")
  .error(Comment.error)
}

Comment.newCommentListener = function () {
  $("form#new_comment").on("submit", Comment.formSubmit)
}

Comment.destroy = function (json) {
  var comment = new Comment(json)
  comment.destroy()
}

Comment.prototype.$li = function () {
  return $(`li#comment-${this.id}`)
}

Comment.prototype.destroy = function () {
  this.$li().remove()
}

Comment.destroyCommentListener = function () {
  $("input.destroy").on("click", function (e) {
    e.preventDefault()
    var $form = $(this).parent("form")
    var action = $form.attr("action")
    var params = $form.serialize()

    $.ajax({
      url: action,
      data: params,
      dataType: "json",
      method: "DELETE"
    })
    .success(Comment.destroy)
  })
}

Comment.assignListeners = function functionName() {
  Comment.newCommentListener()
  Comment.destroyCommentListener()
}

Comment.ready = function () {
  Comment.templateSource = $("#comment-template").html()
  Comment.template = Handlebars.compile(Comment.templateSource)
  Comment.assignListeners()
}

document.addEventListener("turbolinks:load", function(event) {
  Comment.ready()
});
{'fraction_non_alphanumeric': 0.15374376039933443, 'fraction_numerical': 0.0, 'mean_word_length': 4.465454545454546, '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': '2344148', 'n_tokens_mistral': 923, 'n_tokens_neox': 923, 'n_words': 180}