diff options
Diffstat (limited to 'src/selection.js')
| -rw-r--r-- | src/selection.js | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/src/selection.js b/src/selection.js index eda20ae..bfaebc0 100644 --- a/src/selection.js +++ b/src/selection.js @@ -22,7 +22,7 @@ async function initSelection(idPrefix, fetchCandidates, fmtCandidate, onSelectio const candidates = await fetchCandidates(); loader.style.display = "none"; - let items = []; + const items = []; let currentFocus = -1; let visibleItems = []; @@ -34,7 +34,7 @@ async function initSelection(idPrefix, fetchCandidates, fmtCandidate, onSelectio } for (const candidate of candidates) { - let item = document.createElement("li"); + const item = document.createElement("li"); item.candidate = candidate; item.innerHTML = fmtCandidate(candidate); item.style.display = 'none'; @@ -109,62 +109,4 @@ async function initSelection(idPrefix, fetchCandidates, fmtCandidate, onSelectio }); } -function pointClickHandler(color) { - const textareaDiv = document.getElementById("student-info-point-reason-container"); - const textarea = document.getElementById("student-info-point-reason"); - const submitBtn = document.getElementById("student-info-point-reason-submit"); - - // TODO(muhq): Prefill the textarea with common reasons - switch (color) { - case "green": - textarea.style.background = "rgb(from green r g b / 20%)" - textarea.value = ""; - break; - case "orange": - textarea.style.background = "rgb(from orange r g b / 20%)" - textarea.value = ""; - break; - case "red": - textarea.style.background = "rgb(from red r g b / 20%)" - textarea.value = ""; - break; - } - textareaDiv.style.display = "block"; - textarea.focus(); - - // Can not use string interpolation because of Moodle's firstname filter. - const coach = firstname + " " + lastname; - - let submit = function() { - let change; - switch (color) { - case "green": - change = GraduationChange.newGreenPointChange(student, textarea.value, coach); - break; - case "orange": - change = GraduationChange.newOrangePointChange(student, textarea.value, coach); - break; - case "red": - change = GraduationChange.newRedPointChange(student, textarea.value, coach); - break; - default: - alert("Invalid color"); - break; - } - submitGraduationChange(student, change); - textareaDiv.style.display = "none"; - updateStudentInfo(); - } - // Use onEVENT to override any previous handler - textarea.onkeydown = function(e) { - if (e.shiftKey && e.key === "Enter") { - submit(); - } - if (e.key === "Escape") { - textareaDiv.style.display = "none"; - } - }; - submitBtn.onclick = submit; -} - export { initSelection }; |
