function updateExplanation()

in project/paperbench/paperbench/gui/static/script.js [282:307]


function updateExplanation(taskId) {
    var newExplanation = document.getElementById('explanation-' + taskId).innerText.trim();
    
    fetch('/update_explanation', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ 'node_id': taskId, 'explanation': newExplanation }),
    })
    .then(response => response.json())
    .then(data => {
        if (data.status === 'success') {
            console.log('Explanation updated for node', taskId);
        } else {
            console.error('Error updating explanation:', data.message);
            alert('Failed to update explanation: ' + data.message);
            location.reload(); // Reload to reset the displayed explanation
        }
    })
    .catch(error => {
        console.error('Error updating explanation:', error);
        alert('Failed to update explanation. Please try again.');
        location.reload(); // Reload to reset the displayed explanation
    });
}