function openCommentReportModal(ID) { openAsyncModal( '/blog/getReportModal', 'Kommentar melden', {ID}, () => { $('#commentReportForm').on('submit', function(event) { event.preventDefault(); const reason = $('#commentReportReason').val(); const text = $('#commentReportText').val(); reportComment(ID, reason, text); }); }, 'commentReportModal' ); } function reportComment(ID, reason, text) { const modal = $('#commentReportModal'); $.ajax({ url: '/blog/reportComment', data: { ID, reason, text }, method: 'POST', success: (result) => { console.log(result); modal.modal('hide'); if(result.success) { addSnackbar('success', result.message); } else { addSnackbar('danger', result.message); } }, error: (result) => { console.log(result); } }); } function openCommentDeleteModal(ID) { openAsyncModal( '/blog/getDeleteModal', 'Kommentar löschen', {ID}, () => { console.log('tetst'); }, 'commentDeleteModal', 'lg' ) } function deleteComment(ID) { const modal = $('#commentDeleteModal'); modal.find('.modal-body').empty().append('
'); $.ajax({ url: '/blog/deleteComment', data: { ID }, method: 'POST', success: (result) => { modal.modal('hide'); console.log(result); if(result.success) { addSnackbar('success', result.message); $('#comment-' + ID).slideUp(); let commentCount = $('.comment-count').text(); if(commentCount !== '') { commentCount = parseInt(commentCount) - 1; $('.comment-count').text(commentCount); } setTimeout(() => { $('#comment-' + ID).remove(); }, 500) } else { addSnackbar('danger', result.message); } }, error: console.log }); }