Skip to content

Commit

Permalink
added freedom mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed May 22, 2020
1 parent cb5f8cb commit 7f6c9a5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ <h1>show key tips</h1>
<div class="text">Shows the keybind tips at the bottom of the page.</div>
<div class="buttons"><div class="button on" tabindex="0">show</div><div class="button off" tabindex="0">hide</div></div>
</div>
<div class="section freedomMode">
<h1>freedom mode</h1>
<div class="text">Allows you to delete any word, even if it was typed correctly.</div>
<div class="buttons"><div class="button on" tabindex="0">on</div><div class="button off" tabindex="0">off</div></div>
</div>
<div class="section fontSize">
<h1>font size</h1>
<div class="text">Change the font size of the test words</div>
Expand Down
7 changes: 7 additions & 0 deletions public/js/commandline.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ let commands = {
toggleKeyTips();
}
},
{
id: "toggleFreedom",
display: "Toggle freedom mode",
exec: () => {
toggleFreedomMode();
}
},
{
id: "changeTheme",
display: "Change theme...",
Expand Down
4 changes: 1 addition & 3 deletions public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions public/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function updateSettingsPage(){
setSettingsButton('quickTab', config.quickTab);
setSettingsButton('liveWpm', config.showLiveWpm);
setSettingsButton('keyTips', config.showKeyTips);
setSettingsButton('freedomMode', config.freedomMode);


setActiveThemeButton();
setActiveLanguageButton();
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion public/js/userconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ let config = {
time: 30,
mode: "words",
language: "english",
fontSize: 1
fontSize: 1,
freedomMode: false
}

//cookies
Expand All @@ -33,6 +34,7 @@ function loadConfigFromCookie() {
changeMode(newConfig.mode);
changeLanguage(newConfig.language);
changeFontSize(newConfig.fontSize);
setFreedomMode(newConfig.freedomMode);
config = newConfig;
restartTest();
}
Expand Down Expand Up @@ -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`);
}
Expand Down

0 comments on commit 7f6c9a5

Please sign in to comment.