Spaces:
Build error
Build error
// 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."); | |
} | |
}); | |
}); |