From 09df26a42c6c184d5c9b7d271f495b7973b4e1f3 Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 12 Sep 2020 02:29:54 +0100 Subject: [PATCH] added two settings groups, renamed group to danger zone --- public/css/style.scss | 2 +- public/index.html | 256 ++++++++++++++++++++++----------------- public/js/commandline.js | 10 +- public/js/script.js | 2 +- public/js/settings.js | 4 + public/js/userconfig.js | 18 ++- 6 files changed, 177 insertions(+), 115 deletions(-) diff --git a/public/css/style.scss b/public/css/style.scss index 7c97b9aec..56947c858 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -1828,7 +1828,7 @@ key { align-items: center; .button.danger { - background: #d00; + background: var(--error-color); color: #eee; &:hover { background: var(--main-color); diff --git a/public/index.html b/public/index.html index 42a52bc01..57a4e7ea2 100644 --- a/public/index.html +++ b/public/index.html @@ -1498,89 +1498,9 @@ -
-

freedom mode

-
- Allows you to delete any word, even if it was typed correctly. -
-
-
- off -
-
- on -
-
-
-
-

confidence mode

-
- When enabled, you will not be able to go back to previous words - to fix mistakes. When turned up to the max, you won't be able to - backspace at all. -
-
-
- off -
-
- on -
-
- max -
-
-
-
-

stop on error

-
- Letter mode will stop input when pressing any incorrect letters. - Word mode will not allow you to continue to the next word until - you correct all mistakes. -
-
-
- off -
-
- word -
-
- letter -
-
-
+ +

blind mode

@@ -1643,6 +1563,145 @@
+
+

language

+
+
+
+

funbox

+
+
+
+ + +
+ input + +
+
+
+

freedom mode

+
+ Allows you to delete any word, even if it was typed correctly. +
+
+
+ off +
+
+ on +
+
+
+
+

stop on error

+
+ Letter mode will stop input when pressing any incorrect letters. + Word mode will not allow you to continue to the next word until + you correct all mistakes. +
+
+
+ off +
+
+ word +
+
+ letter +
+
+
+
+

confidence mode

+
+ When enabled, you will not be able to go back to previous words + to fix mistakes. When turned up to the max, you won't be able to + backspace at all. +
+
+
+ off +
+ +
+ on +
+
+ max +
+
+
+
+

swap esc and tab

+
+ Swap the behaviour of tab and escape keys. +
+
+
+ off +
+
+ on +
+
+
+
+

caps lock backspace

+
+ Makes caps lock act like backspace. +
+
+
+ off +
+
+ on +
+
+
+
+

layout override

+
+
+
+
+ +
+ sound + +
+

play sound on click

@@ -1706,32 +1765,6 @@
-
-

caps lock backspace

-
- Makes caps lock act like backspace. -
-
-
- off -
-
- on -
-
-
-
-

layout override

-
-
-
-

language

-
-
-
-

funbox

-
-
@@ -2331,12 +2364,13 @@ +
-
- danger section +
+ danger zone
-
+

reset settings

diff --git a/public/js/commandline.js b/public/js/commandline.js index 77d91e86d..b78c05f7e 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -179,6 +179,13 @@ let commands = { toggleAlwaysShowDecimalPlaces(); }, }, + { + id: "toggleSwapEscAndTab", + display: "Toggle swap esc and tab", + exec: () => { + toggleSwapEscAndTab(); + }, + }, { id: "toggleShowAllLines", display: "Toggle show all lines", @@ -1110,7 +1117,8 @@ $("#commandLine input").keyup((e) => { $(document).ready((e) => { $(document).keydown((event) => { //escape - if (event.keyCode == 27) { + if ((event.keyCode == 27 && !config.swapEscAndTab) || (event["keyCode"] == 9 && config.swapEscAndTab)) { + event.preventDefault(); if ($("#commandLineWrapper").hasClass("hidden")) { currentCommands = [commands]; showCommandLine(); diff --git a/public/js/script.js b/public/js/script.js index feae2fa9f..005bec73e 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -3916,7 +3916,7 @@ $(document).keydown((event) => { keypressStats.spacing.current = now; //tab - if (event["keyCode"] == 9) { + if ((event["keyCode"] == 9 && !config.swapEscAndTab) || (event["keyCode"] == 27 && config.swapEscAndTab)) { if ( !event.ctrlKey && config.quickTab && diff --git a/public/js/settings.js b/public/js/settings.js index 8c60389ab..9c89c643b 100644 --- a/public/js/settings.js +++ b/public/js/settings.js @@ -150,6 +150,10 @@ settingsGroups.flipTestColors = new SettingsGroup( "flipTestColors", setFlipTestColors ); +settingsGroups.swapEscAndTab = new SettingsGroup( + "swapEscAndTab", + setSwapEscAndTab +); settingsGroups.colorfulMode = new SettingsGroup( "colorfulMode", setColorfulMode diff --git a/public/js/userconfig.js b/public/js/userconfig.js index 7e4dc395b..586f254a1 100644 --- a/public/js/userconfig.js +++ b/public/js/userconfig.js @@ -52,7 +52,8 @@ let defaultConfig = { alwaysShowWordsHistory: false, playSoundOnError: false, playSoundOnClick: "off", - startGraphsAtZero: true + startGraphsAtZero: true, + swapEscAndTab: false }; let cookieConfig = null; @@ -185,6 +186,7 @@ function applyConfig(configObj) { setFavThemes(configObj.favThemes, true); setRandomTheme(configObj.randomTheme, true); setShowAllLines(configObj.showAllLines, true); + setSwapEscAndTab(configObj.swapEscAndTab, true); // if ( // configObj.resultFilters !== null && // configObj.resultFilters !== undefined @@ -341,6 +343,20 @@ function setAlwaysShowDecimalPlaces(val, nosave) { if (!nosave) saveConfigToCookie(); } +//swap esc and tab +function toggleSwapEscAndTab() { + config.swapEscAndTab = !config.swapEscAndTab; + saveConfigToCookie(); +} + +function setSwapEscAndTab(val, nosave) { + if (val == undefined) { + val = false; + } + config.swapEscAndTab = val; + if (!nosave) saveConfigToCookie(); +} + //always show words history function setAlwaysShowWordsHistory(val, nosave) { if (val == undefined) {