Spaces:
Build error
Build error
File size: 1,477 Bytes
a23cfdb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// Modify the Refresh Comments button event listener
document.getElementById('refreshCommentsBtn').addEventListener('click', function() {
const videoId = "{{ video.id }}";
window.location.href = `/refresh_comments/${videoId}`;
});
// Modify the Keep Comment button handler
document.querySelectorAll('.keep-comment-btn').forEach(button => {
button.addEventListener('click', async function() {
const commentId = this.getAttribute('data-comment-id');
const videoId = "{{ video.id }}";
try {
const response = await fetch(`/api/comments/keep/${commentId}?video_id=${videoId}`, {
method: 'POST'
});
const data = await response.json();
if (data.success) {
// Remove from flagged comments
const commentCard = this.closest('.comment-card');
commentCard.remove();
// Update flagged comments count
const flaggedCommentsCount = document.querySelector('h2 span');
const currentCount = parseInt(flaggedCommentsCount.textContent.replace(/[()]/g, ''));
flaggedCommentsCount.textContent = `(${currentCount - 1})`;
} else {
alert("Failed to keep comment. Please try again.");
}
} catch (err) {
console.error(err);
alert("Error processing comment.");
}
});
}); |