diff --git a/public/index.html b/public/index.html index 02b1ed16c..951b84112 100644 --- a/public/index.html +++ b/public/index.html @@ -309,6 +309,15 @@
off
+
+

word highlight mode

+
When this option is enabled the caret will be hidden and words will be highlighted individually rather than per character. +
+
+
on
+
off
+
+

layout

diff --git a/public/js/commandline.js b/public/js/commandline.js index db9bfb6f0..574aa048c 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -71,6 +71,16 @@ let commands = { toggleQuickEnd(); } }, + { + id: "toggleHighlightMode", + display: "Toggle word highlight mode", + exec: () => { + hideCaret(); + highlightWord(currentWordIndex,currentInput,config.showError); + restartTest(); + toggleHighlightMode(); + } + }, { id: "toggleFlipTestColors", display: "Toggle flip test colors", diff --git a/public/js/layouts.js b/public/js/layouts.js index 608eddd0c..c41de53a4 100644 --- a/public/js/layouts.js +++ b/public/js/layouts.js @@ -20,5 +20,12 @@ const layouts = { "aA","rR","sS","tT","dD","hH","nN","eE","iI","oO","'\"", "zZ","xX","cC","vV","bB","kK","mM",",<",".>","/?", " " + ], + workman:[ + "`~","1!","2@","3#","4$","5%","6^","7&","8*","9(","0)","-_","=+", + "qQ","dD","rR","wW","bB","jJ","fF","uU","pP",";:","[{","]}","\\|", + "aA","sS","hH","tT","gG","yY","nN","eE","oO","iI","'\"", + "zZ","xX","mM","cC","vV","kK","lL",",<",".>","/?", + " " ] } \ No newline at end of file diff --git a/public/js/script.js b/public/js/script.js index 834b0b164..c0b3f7a3f 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -298,10 +298,39 @@ function updateActiveElement() { activeWordTop = $("#words .word.active").position().top; } -function compareInput(wrdIndex,input,showError) { +function highlightWord(wrdIndex, input, showError){ $($('#words .word')[wrdIndex]).empty(); + let currentWord = wordsList[wrdIndex]; + let ret = ""; + for (let i = 0; i < currentWord.length; i++) { + ret += '' + currentWord[i] + ""; + } + $($('#words .word')[wrdIndex]).html(ret); + if ((currentWord == input || (config.quickEnd && currentWord.length == input.length)) && wrdIndex == wordsList.length - 1) { + inputHistory.push(input); + currentInput = ""; + if(!resultVisible) showResult(); + } +} + +function compareInput(wrdIndex,input,showError) { let ret = ""; let currentWord = wordsList[wrdIndex]; + if (config.highlightMode){ + for (let i = 0; i < input.length; i++) { + if (currentWord[i] != input[i]){ + if(config.difficulty == "master"){ + if(!resultVisible) showResult(true); + restartCount++; + } + if (showError) + highlightBadWord(wrdIndex, showError); + } + } + return; + } + $($('#words .word')[wrdIndex]).empty(); + for (let i = 0; i < input.length; i++) { if (currentWord[i] == input[i]) { ret += '' + currentWord[i] + ""; @@ -868,7 +897,8 @@ function restartTest(withSameWordset = false) { }, 250); wpmOverTimeChart.options.annotation.annotations[0].value = "-20"; wpmOverTimeChart.update(); - + if (config.highlightMode) + highlightWord(currentWordIndex, currentInput, config.showError); // let oldHeight = $("#words").height(); // let newHeight = $("#words") @@ -1279,7 +1309,8 @@ $("#wordsInput").keypress((event) => { }); $("#wordsInput").on("focus", (event) => { - showCaret(); + if (!config.highlightMode) + showCaret(); }); $("#wordsInput").on("focusout", (event) => { @@ -1427,6 +1458,8 @@ $(document).keydown((event) => { if (currentInput == "") return; event.preventDefault(); let currentWord = wordsList[currentWordIndex]; + if (config.highlightMode) + highlightWord(currentWordIndex+1, currentInput, config.showError); if (config.mode == "time") { let currentTop = $($("#words .word")[currentWordIndex]).position().top; let nextTop = $($("#words .word")[currentWordIndex + 1]).position().top; diff --git a/public/js/settings.js b/public/js/settings.js index 29502ba63..74d56a530 100644 --- a/public/js/settings.js +++ b/public/js/settings.js @@ -25,8 +25,10 @@ function updateSettingsPage(){ setSettingsButton('blindMode', config.blindMode); setSettingsButton('quickEnd', config.quickEnd); setSettingsButton('flipTestColors', config.flipTestColors); + setSettingsButton('highlightMode', config.highlightMode); setSettingsButton('discordDot', config.showDiscordDot); + setActiveThemeButton(); setActiveLanguageButton(); setActiveLayoutButton(); @@ -265,6 +267,18 @@ $(".pageSettings .section.quickEnd .buttons .button.off").click(e => { setSettingsButton('quickEnd', config.quickEnd); }) +$(".pageSettings .section.highlightMode .buttons .button.on").click(e => { + setHighlightMode(true); + showNotification('Quick end on', 1000); + setSettingsButton('highlightMode', config.highlightMode); +}) +$(".pageSettings .section.highlightMode .buttons .button.off").click(e => { + setHighlightMode(false); + showNotification('Quick end off', 1000); + setSettingsButton('highlightMode', config.highlightMode); +}) + + //flip test $(".pageSettings .section.flipTestColors .buttons .button.on").click(e => { setFlipTestColors(true); diff --git a/public/js/userconfig.js b/public/js/userconfig.js index bb0d5b4b4..92a4aff61 100644 --- a/public/js/userconfig.js +++ b/public/js/userconfig.js @@ -19,6 +19,7 @@ let defaultConfig = { caretStyle: "default", flipTestColors: false, layout:"default", + highlightMode:false showDiscordDot: true } @@ -55,6 +56,7 @@ function loadConfigFromCookie() { setDifficulty(newConfig.difficulty,true); setBlindMode(newConfig.blindMode,true); setQuickEnd(newConfig.quickEnd,true); + setHighlightMode(newConfig.highlightMode, true); setFlipTestColors(newConfig.flipTestColors,true); setDiscordDot(newConfig.hideDiscordDot,true); if(newConfig.resultFilters == null || newConfig.resultFilters == undefined){ @@ -62,6 +64,22 @@ function loadConfigFromCookie() { } config = newConfig; } + if(config.difficulty == undefined){ + config.difficulty = "normal"; + saveConfigToCookie(); + } + if(config.blindMode == undefined){ + config.blindMode = false; + saveConfigToCookie(); + } + if(config.layout == undefined){ + config.layout = "default"; + saveConfigToCookie(); + } + if (config.highlightMode == undefined){ + config.highlightMode = false; + saveConfigToCookie(); + } Object.keys(defaultConfig).forEach(configKey => { if(config[configKey] == undefined){ config[configKey] = defaultConfig[configKey]; @@ -152,6 +170,23 @@ function setQuickEnd(qe, nosave){ if(!nosave) saveConfigToCookie(); } +function toggleHighlightMode(){ + hm = !config.highlightMode; + if(hm == undefined){ + hm = false; + } + config.highlightMode = hm; + saveConfigToCookie(); +} + +function setHighlightMode(hm, nosave){ + if(hm == undefined){ + hm = false; + } + config.highlightMode = hm; + saveConfigToCookie(); +} + //flip colors function setFlipTestColors(flip,nosave){