From dd3f6cbc3cb9386f5593ae1e5faf9a78eb015afd Mon Sep 17 00:00:00 2001 From: Faisal N Date: Thu, 26 Sep 2024 17:47:45 -0400 Subject: [PATCH] fixes --- src/checker/admin.js | 9 ++++++++- src/checker/checker.js | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/checker/admin.js b/src/checker/admin.js index c33a5f4..5702e07 100644 --- a/src/checker/admin.js +++ b/src/checker/admin.js @@ -59,6 +59,7 @@ document.getElementById("reorder-courses-button").addEventListener("click", () = const fromHeight = current?.getBoundingClientRect().height; document.querySelector('.course-reorder').style.display = 'flex'; document.querySelector('.course-selector').style.display = 'none'; + document.getElementById('save-button').style.display = 'none'; const container = document.querySelector('.section'); const target = document.querySelector('.course-reorder'); const toHeight = target.getBoundingClientRect().height + calculateButtonHeights(target); @@ -81,6 +82,7 @@ document.getElementById("cancel-reorder-courses-button").addEventListener("click const current = document.querySelector('.course-reorder'); const fromHeight = current?.getBoundingClientRect().height; document.querySelector('.course-selector').style.display = 'flex'; + document.getElementById('save-button').style.display = ''; document.querySelector('.course-reorder').style.display = 'none'; const container = document.querySelector('.section'); const target = document.querySelector('.course-selector'); @@ -104,6 +106,7 @@ document.getElementById("save-course-order-button").addEventListener("click", () const current = document.querySelector('.course-reorder'); const fromHeight = current?.getBoundingClientRect().height; document.querySelector('.course-selector').style.display = 'flex'; + document.getElementById('save-button').style.display = ''; document.querySelector('.course-reorder').style.display = 'none'; const container = document.querySelector('.section'); const target = document.querySelector('.course-selector'); @@ -182,7 +185,7 @@ document.getElementById("save-course-order-button").addEventListener("click", () }); // Save -document.getElementById("save-button").addEventListener("click", () => { +document.getElementById("save-button").addEventListener("click", (e) => { var updatedInfo = { course: { id: document.getElementById("period-input").value, @@ -197,8 +200,12 @@ document.getElementById("save-button").addEventListener("click", () => { }, body: JSON.stringify(updatedInfo) }); + e.target.disabled = true; // Show submit confirmation ui.modeless(``, "Saved!"); + setTimeout(() => { + e.target.disabled = false; + }, 3000); }); // Remove attention ring when user types in either input diff --git a/src/checker/checker.js b/src/checker/checker.js index 255819d..c6993e4 100644 --- a/src/checker/checker.js +++ b/src/checker/checker.js @@ -79,7 +79,8 @@ let historyIndex = 0; } // Submit click -document.getElementById("submit-button").addEventListener("click", () => { +document.getElementById("submit-button").addEventListener("click", (e) => { + e.target.disabled = true; const mode = ui.getButtonSelectValue(document.getElementById("answer-mode-selector")); const segment = segmentInput.value?.trim(); const question = questionInput.value?.trim(); @@ -155,6 +156,9 @@ document.getElementById("submit-button").addEventListener("click", () => { } }); } + setTimeout(() => { + e.target.disabled = false; + }, 3000); }); // Remove attention ring when user types in either input @@ -207,10 +211,12 @@ function resetInputs() { // Check answer async function submitClick(code, segment, question, answer) { -window.scroll(0, 0); var qA = storage.get("questionsAnswered") || []; var alreadyAnswered = qA.find(q => q.segment == segment && q.question == question) -if (alreadyAnswered && alreadyAnswered.status == 'correct') return ui.modeless(``, 'Already Submitted!'); +if (alreadyAnswered && alreadyAnswered.status == 'Correct') { + window.scroll(0, 0); + return ui.modeless(``, 'Already Submitted!'); +} await fetch(domain + '/check_answer', { method: "POST", headers: { @@ -225,6 +231,7 @@ await fetch(domain + '/check_answer', { }) .then(r => r.json()) .then(r => { + window.scroll(0, 0); if (typeof r.correct != 'undefined') { ui.modeless(``, (r.correct) ? 'Correct' : 'Try Again'); qA.push({ "segment": segment, "question": question, "status": (r.correct) ? 'Correct' : 'In Progress' });