<commit_before>
$(document).ready(function() {
  $(".comment-form-container").hide();
  addkudosEventListener();
  addListenerToNewPostForm();
  addkudosCommentEventListener();
  postCommentEventListener();
});

// Add Kudos to Post
var addkudosEventListener = function(){
  $(".message-board-container").on("click", ".post-kudos-vote", function(event){
    var clickedKudos = $(this)
    kudosAjaxCall(clickedKudos);
  });
}
var kudosAjaxCall = function(clickedKudos){
  postId = clickedKudos.closest(".post-container").attr('id')

  var request = $.ajax({
    url: "/posts/" + postId +"/likes",
    method: "POST"
  });
  request.done(function(response){
    clickedKudos.text("Kudos " + response.like_count)
  });
}
// Add Kudos to Comment
var addkudosCommentEventListener = function(){
  $(".message-board-container").on("click", ".comment-kudos-vote", function(event){
    var clickedCommentKudos = $(this)
    kudosCommentAjaxCall(clickedCommentKudos);
  });
}

var kudosCommentAjaxCall = function(clickedCommentKudos){
  commentId = clickedCommentKudos.closest(".individual-comment-container").attr('id')

  var request = $.ajax({
    url: "/comments/" + commentId + "/likes",
    method: "POST"
  });
  request.done(function(response){
    clickedCommentKudos.text("Kudos " + response.like_count)
  })
}

// Add New Post
var addListenerToNewPostForm = function(){
  $("#new-post-form").submit(function(e){
    e.preventDefault();
    var formContainer = $(this);
    newPostAjaxCall();
  })
}

var newPostAjaxCall = function(){
  var request = $.ajax({
    url: $("#new_post").attr("action"),
    method: $("#new_post").attr("method"),
    data: $("#new_post").serialize()
  });
  request.done(function(response){
    $('.post-field').prepend(response)
    $('#new_post')[0].reset()
  })

}

//Add comment on post

var postCommentEventListener = function(){
  $(".message-board-container").on("click", ".comment-button", function(){
    console.log("clicked comment")
    $(".comment-form-container").slideDown();
  })
  
}<commit_msg>Add jquery so add comment form slides down on click<commit_after>
$(document).ready(function() {
  $(".comment-form-container").hide();
  addkudosEventListener();
  addListenerToNewPostForm();
  addkudosCommentEventListener();
  postCommentEventListener();
});

// Add Kudos to Post
var addkudosEventListener = function(){
  $(".message-board-container").on("click", ".post-kudos-vote", function(event){
    var clickedKudos = $(this)
    kudosAjaxCall(clickedKudos);
  });
}
var kudosAjaxCall = function(clickedKudos){
  postId = clickedKudos.closest(".post-container").attr('id')

  var request = $.ajax({
    url: "/posts/" + postId +"/likes",
    method: "POST"
  });
  request.done(function(response){
    clickedKudos.text("Kudos " + response.like_count)
  });
}
// Add Kudos to Comment
var addkudosCommentEventListener = function(){
  $(".message-board-container").on("click", ".comment-kudos-vote", function(event){
    var clickedCommentKudos = $(this)
    kudosCommentAjaxCall(clickedCommentKudos);
  });
}

var kudosCommentAjaxCall = function(clickedCommentKudos){
  commentId = clickedCommentKudos.closest(".individual-comment-container").attr('id')

  var request = $.ajax({
    url: "/comments/" + commentId + "/likes",
    method: "POST"
  });
  request.done(function(response){
    clickedCommentKudos.text("Kudos " + response.like_count)
  })
}

// Add New Post
var addListenerToNewPostForm = function(){
  $("#new-post-form").submit(function(e){
    e.preventDefault();
    var formContainer = $(this);
    newPostAjaxCall();
  })
}

var newPostAjaxCall = function(){
  var request = $.ajax({
    url: $("#new_post").attr("action"),
    method: $("#new_post").attr("method"),
    data: $("#new_post").serialize()
  });
  request.done(function(response){
    $('.post-field').prepend(response)
    $('#new_post')[0].reset()
  })

}

//Add comment on post

var postCommentEventListener = function(){
  $(".message-board-container").on("click", ".comment-button", function(){
    var clickedComment = $(this).parent().siblings().last().find(".comment-form-container")
    clickedComment.slideDown();
  })
  
}
{'fraction_non_alphanumeric': 0.18622510199184064, 'fraction_numerical': 0.00047996160307175426, 'mean_word_length': 4.491436100131752, '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': '2350044', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1361, 'n_words': 228}