From dd72f6150e3eb6899fc03619bbef1bb20ab846fe Mon Sep 17 00:00:00 2001 From: Philip Kaludercic <philip.kaludercic@fau.de> Date: Sun, 21 Jan 2024 13:54:30 +0000 Subject: [PATCH] Reload site after a permalinked question --- quiz.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/quiz.js b/quiz.js index 9a9ee57..311ae2d 100644 --- a/quiz.js +++ b/quiz.js @@ -7,7 +7,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/. */ "use strict"; -const version = "$Id: quiz.js,v 1.23 2024/01/21 13:00:54 oj14ozun Exp oj14ozun $"; +const version = "$Id: quiz.js,v 1.24 2024/01/21 13:09:44 oj14ozun Exp oj14ozun $"; const js_version = document.getElementById("js-version"); js_version.innerText = version; @@ -219,11 +219,6 @@ function submit() { class_list.add("answer"); class_list.remove("tried"); action.disabled = false; - - // remove any permalink - const url = new URL(window.location); - url.search = ""; - window.history.replaceState({} , document.title, url.toString()); } // listen to keys @@ -254,8 +249,14 @@ document.onkeyup = evt => { // setup action button action.onclick = _ => { - if (class_list.contains("answer")) - next(); + if (class_list.contains("answer")) { + // remove any permalink + if (new URLSearchParams(window.location.search).get("show")) { + window.location.search = ""; + } else { + next(); + } + } else if (class_list.contains("tried")) submit(); } -- GitLab