From a50af67315055d720c6bc302bdeb0c9f294986dd Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 19 Jan 2026 11:40:47 +0000 Subject: [PATCH] feat: enhance candidate details display with logout functionality and conditional action visibility --- index.html | 31 ++++++++++++++++++------------- js/main.js | 32 +++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index e73bed4..18faf01 100644 --- a/index.html +++ b/index.html @@ -118,19 +118,24 @@

RTS

- - + + + + + + +
diff --git a/js/main.js b/js/main.js index b47a24a..8638a39 100644 --- a/js/main.js +++ b/js/main.js @@ -126,6 +126,9 @@ function showCandidateDetails() { global_passcode = passToShow; $("#candidate-details").empty(); + $("#candidate-details").text(`Current: CID ${global_cid} / Passcode ${global_passcode}`); + + // Create logout action and place it in the actions area so we can hide actions when users disabled let logout = $("[x]"); logout.css({ cursor: "pointer", "margin-left": "8px" }); logout.click(() => { @@ -139,7 +142,16 @@ function showCandidateDetails() { } }); - $("#candidate-details").append(`Current: CID ${global_cid} / Passcode ${global_passcode} `).append(logout); + // Ensure the actions container exists and append the logout button there + if ($("#user-actions").length) { + $("#user-actions").empty().append(logout); + // Hide actions entirely if `allow_users` is false + if (!allow_users) { + $("#user-actions").hide(); + } else { + $("#user-actions").show(); + } + } // If an exam results URL is configured, update the options link to point to the candidate's results if (URLS.exam_results_url != "" && URLS.exam_results_url != undefined) { @@ -203,9 +215,10 @@ question_db.version(1).stores({ retrievePacketList(); if (!allow_users) { - // Keep the user/candidate details visible, but disable action buttons - $("#btn-user-login").prop("disabled", true).attr("title", "User login disabled"); - $("#btn-candidate-login").prop("disabled", true).attr("title", "Candidate entry disabled"); + // Keep the user/candidate details visible, but hide the action buttons entirely + $("#user-actions").hide(); +} else { + $("#user-actions").show(); } try { @@ -384,12 +397,21 @@ async function loadExamList(data) { $("#btn-user-login").hide(); let logout = $("[x]") + logout.css({ cursor: "pointer", "margin-left": "8px" }); logout.click(() => { localStorage.removeItem("cid.cid"); localStorage.removeItem("cid.passcode"); window.location = URLS.logout_url; }) - $("#user").append(logout); + // append logout to actions area so actions can be hidden when `allow_users` is false + if ($("#user-actions").length) { + $("#user-actions").append(logout); + if (!allow_users) { + $("#user-actions").hide(); + } + } else { + $("#user").append(logout); + } }