commit b34653a033ff46bbd4519f427482d0467f3779f4 parent a037109cc70472d0b58fb01d4a3b793a9a9a80b6 Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com> Date: Mon, 1 Jun 2020 16:36:25 -0700 Implement resume session confirmation. Diffstat:
| M | Scripts/Quizzer.js | | | 16 | +++++++++++++++- |
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/Scripts/Quizzer.js b/Scripts/Quizzer.js @@ -60,12 +60,26 @@ function Start() { // Resume the previous session function Resume() { + // Validate selected sets + for (var i = 0; i < setId; i++) + { + if (document.getElementById(`settingsSet-${i}`)) + { + if (confirm("This will remove the vocab sets you have already selected. Are you sure?")) { + break; + } + else { + return; + } + } + } + // Load terms and progress Terms = JSON.parse(localStorage.getItem("terms")); Term = parseInt(localStorage.getItem("term")) - 1; // Validate Terms - if (!Terms || Terms.length == 0 || !Term || Term < 0 || Term > Terms.length) { + if (!Terms || Terms.length == 0 || !Term || Term < -1 || Term > Terms.length) { document.getElementById("settingsError").textContent = "An error occured while resuming the previous session."; document.getElementById("settingsError").scrollIntoView(false); return;