From 26b5a6c433d68fbcf3735a4969f7f8228dfbeef9 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 13 Jul 2020 15:59:13 +0100 Subject: [PATCH] text timer/progress now works in words mode --- public/js/script.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index f8e27873b..67888cd39 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -760,20 +760,30 @@ function updateTimer() { // $("#timerNumber").html(config.time - time); } } else if ( - (config.mode === "words" || - config.mode === "custom" || - config.mode === "quote") && - config.timerStyle === "bar" + config.mode === "words" || + config.mode === "custom" || + config.mode === "quote" ) { - let percent = Math.floor(((currentWordIndex + 1) / wordsList.length) * 100); - $("#timer") - .stop(true, true) - .animate( - { - width: percent + "vw", - }, - 250 + if (config.timerStyle === "bar") { + let percent = Math.floor( + ((currentWordIndex + 1) / wordsList.length) * 100 ); + $("#timer") + .stop(true, true) + .animate( + { + width: percent + "vw", + }, + 250 + ); + } else if (config.timerStyle === "text") { + let outof = wordsList.length; + if (config.mode === "words") { + outof = config.words; + } + $("#timerNumber").html(`${inputHistory.length}/${outof}`); + // $("#timerNumber").html(config.time - time); + } } }