$( "#save-new-glsa-comment" ).click(function() { var glsaid = $("#glsa-id").html(); var comment = $('#comment').val(); $('#comment').val(" "); $('#comment').focusout(); commentGLSA(glsaid, comment, "comment"); }); $( "#save-new-glsa-approve" ).click(function() { var glsaid = $("#glsa-id").html(); var comment = $('#comment').val(); $('#comment').val(" "); $('#comment').focusout(); commentGLSA(glsaid, comment, "approve"); }); $( "#save-new-glsa-decline" ).click(function() { var glsaid = $("#glsa-id").html(); var comment = $('#comment').val(); $('#comment').val(" "); $('#comment').focusout(); commentGLSA(glsaid, comment, "decline"); }); function commentGLSA(glsaid, comment, commentType){ $.post( '/glsa/comment/add', { glsaid: glsaid, comment: comment, commentType: commentType, }, function(data) { if(data != "err") { console.log("hi"); console.log(data); var comment = JSON.parse(data); var commentDate = comment.Date.split("T")[0] + ' ' + comment.Date.split("T")[1].split(".")[0] + ' UTC'; var background = ""; var hint = ""; if(comment.Type == "approve"){ background = "background:#DFF0D8;"; hint = 'Approved: '; } else if(comment.Type == "decline"){ background = "background:#F2DEDE;"; hint = 'Declined: '; } var newComment = '
' + '
' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + comment.UserBadge.Name + '' + '' + '' + '
' + '
' + '' + commentDate + '' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + '
' + '
' + '
' + '
' + '
' + hint + comment.Message + '
' + '
' + '
'; $('#comments-section').append(newComment); } return }); } $('#btn-delete-glsa').on('click', function(event){ var glsaid = $("#glsa-id").html(); $.get( "/glsa/delete/" + glsaid, function( data ) { document.location.href = "/"; }); });