This commit is contained in:
Jack 2020-06-06 13:24:15 +01:00
commit 51ec5fbb1a
6 changed files with 3 additions and 111 deletions

View file

@ -309,15 +309,6 @@
<div class="button off" tabindex="0" onclick="this.blur();">off</div>
</div>
</div>
<div class="section highlightMode">
<h1>word highlight mode</h1>
<div class="text">When this option is enabled the caret will be hidden and words will be highlighted individually rather than per character.
</div>
<div class="buttons">
<div class="button on" tabindex="0" onclick="this.blur();">on</div>
<div class="button off" tabindex="0" onclick="this.blur();">off</div>
</div>
</div>
<div class="section layouts">
<h1>layout</h1>
<div class="buttons">

View file

@ -71,16 +71,6 @@ 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",

View file

@ -20,12 +20,5 @@ 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",",<",".>","/?",
" "
]
}

View file

@ -298,39 +298,10 @@ function updateActiveElement() {
activeWordTop = $("#words .word.active").position().top;
}
function highlightWord(wrdIndex, input, showError){
$($('#words .word')[wrdIndex]).empty();
let currentWord = wordsList[wrdIndex];
let ret = "";
for (let i = 0; i < currentWord.length; i++) {
ret += '<letter class="correct">' + currentWord[i] + "</letter>";
}
$($('#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) {
$($('#words .word')[wrdIndex]).empty();
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 += '<letter class="correct">' + currentWord[i] + "</letter>";
@ -897,8 +868,7 @@ 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")
@ -1309,8 +1279,7 @@ $("#wordsInput").keypress((event) => {
});
$("#wordsInput").on("focus", (event) => {
if (!config.highlightMode)
showCaret();
showCaret();
});
$("#wordsInput").on("focusout", (event) => {
@ -1458,8 +1427,6 @@ $(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;

View file

@ -25,10 +25,8 @@ 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();
@ -267,18 +265,6 @@ $(".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);

View file

@ -19,7 +19,6 @@ let defaultConfig = {
caretStyle: "default",
flipTestColors: false,
layout:"default",
highlightMode:false
showDiscordDot: true
}
@ -56,7 +55,6 @@ 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){
@ -64,22 +62,6 @@ 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];
@ -170,23 +152,6 @@ 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){