From 7f6c9a52675fa88f0dfa3ab0b9d54b28171223c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 May 2020 19:39:35 +0100 Subject: [PATCH] added freedom mode --- public/index.html | 5 +++++ public/js/commandline.js | 7 +++++++ public/js/script.js | 4 +--- public/js/settings.js | 16 ++++++++++++++++ public/js/userconfig.js | 15 ++++++++++++++- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/public/index.html b/public/index.html index 2b75ee7b904f..fc795c5de715 100644 --- a/public/index.html +++ b/public/index.html @@ -237,6 +237,11 @@

show key tips

Shows the keybind tips at the bottom of the page.
show
hide
+
+

freedom mode

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

font size

Change the font size of the test words
diff --git a/public/js/commandline.js b/public/js/commandline.js index 31d0e7be5b88..a2e1af07a3cc 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -42,6 +42,13 @@ let commands = { toggleKeyTips(); } }, + { + id: "toggleFreedom", + display: "Toggle freedom mode", + exec: () => { + toggleFreedomMode(); + } + }, { id: "changeTheme", display: "Change theme...", diff --git a/public/js/script.js b/public/js/script.js index 2166d0646fc7..3063fdd26d5c 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -1019,9 +1019,7 @@ $(document).keydown((event) => { if (!testActive) return; if (currentInput == "" && inputHistory.length > 0) { if ( - inputHistory[currentWordIndex - 1] == - wordsList[currentWordIndex - 1] || - $($(".word")[currentWordIndex - 1]).hasClass("hidden") + (inputHistory[currentWordIndex - 1] == wordsList[currentWordIndex - 1] && !config.freedomMode) || $($(".word")[currentWordIndex - 1]).hasClass("hidden") ) { return; } else { diff --git a/public/js/settings.js b/public/js/settings.js index 28ee532011a3..dee79167d3f5 100644 --- a/public/js/settings.js +++ b/public/js/settings.js @@ -14,6 +14,8 @@ function updateSettingsPage(){ setSettingsButton('quickTab', config.quickTab); setSettingsButton('liveWpm', config.showLiveWpm); setSettingsButton('keyTips', config.showKeyTips); + setSettingsButton('freedomMode', config.freedomMode); + setActiveThemeButton(); setActiveLanguageButton(); @@ -92,6 +94,20 @@ $(".pageSettings .section.liveWpm .buttons .button.off").click(e => { setSettingsButton('liveWpm', config.showLiveWpm); }) +//freedom mode +$(".pageSettings .section.freedomMode .buttons .button.on").click(e => { + setFreedomMode(true); + saveConfigToCookie(); + showNotification('Freedom mode on', 1000); + setSettingsButton('freedomMode', config.freedomMode); +}) +$(".pageSettings .section.freedomMode .buttons .button.off").click(e => { + setFreedomMode(false); + saveConfigToCookie(); + showNotification('Freedom mode off', 1000); + setSettingsButton('freedomMode', config.freedomMode); +}) + //keytips $(".pageSettings .section.keyTips .buttons .button.on").click(e => { setKeyTips(true); diff --git a/public/js/userconfig.js b/public/js/userconfig.js index 03320552c7a3..6b8dda522c21 100644 --- a/public/js/userconfig.js +++ b/public/js/userconfig.js @@ -9,7 +9,8 @@ let config = { time: 30, mode: "words", language: "english", - fontSize: 1 + fontSize: 1, + freedomMode: false } //cookies @@ -33,6 +34,7 @@ function loadConfigFromCookie() { changeMode(newConfig.mode); changeLanguage(newConfig.language); changeFontSize(newConfig.fontSize); + setFreedomMode(newConfig.freedomMode); config = newConfig; restartTest(); } @@ -134,6 +136,17 @@ function togglePunctuation() { saveConfigToCookie(); } +//freedom +function setFreedomMode(freedom) { + config.freedomMode = freedom; + saveConfigToCookie(); +} + +function toggleFreedomMode() { + config.freedomMode = !config.freedomMode; + saveConfigToCookie(); +} + function previewTheme(name) { $("#currentTheme").attr("href", `themes/${name}.css`); }