diff --git a/src/js/script.js b/src/js/script.js index 701309226..c921617a0 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -872,7 +872,14 @@ function showWords() { updateHighlightedKeymapKey(); } + updateActiveElement(); + updateCaretPosition(); +} + +$("#restartTestButton, #startTestButton").on("click", function () { + console.log("click"); if (activeFunBox === "memory") { + console.log("activate timer", window.location.pathname); memoryFunboxInterval = clearInterval(memoryFunboxInterval); memoryFunboxTimer = Math.round(Math.pow(wordsList.length, 1.2)); memoryFunboxInterval = setInterval(() => { @@ -885,10 +892,18 @@ function showWords() { } }, 1000); } +}); - updateActiveElement(); - updateCaretPosition(); -} +(function (history) { + var pushState = history.pushState; + history.pushState = function (state) { + if (activeFunBox === "memory" && state !== "/") { + memoryFunboxInterval = clearInterval(memoryFunboxInterval); + memoryFunboxTimer = null; + } + return pushState.apply(history, arguments); + }; +})(window.history); function updateActiveElement() { let active = document.querySelector("#words .active"); diff --git a/static/index.html b/static/index.html index 95dd85869..28754f050 100644 --- a/static/index.html +++ b/static/index.html @@ -772,6 +772,7 @@