INNER CODE UNIT · JavaScript
actionButton
Dsadd4/AgentFigureGallery · frontend/reference_gallery/app.js:242
function actionButton(label, action, candidate) {
const button = document.createElement("button");
button.textContent = label;
button.className = action;
if (
(action === "like" && (candidate.status === "liked" || candidate.status === "selected")) ||
(action === "reject" && candidate.status === "rejected") ||
(action === "select" && candidate.status === "selected") ||
(action === "global_like" && candidate.global_status === "global_liked") ||
(action === "global_reject" && candidate.global_status === "global_rejected")
) {
button.classList.add("active");
}
button.addEventListener("click", async () => {
try {
button.disabled = true;
const candidateId = candidate.candidate_id || candidate.stable_candidate_id || candidate.display_id || candidate.session_candidate_id;
state.session = await api("/api/preferences", {