Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to hide previous level letters #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
Word Limit Mode <input class='wordLimitModeButton' type="checkbox" autocomplete="off"checked>
</li>
<li>Show Cheatsheet<input class='showCheatsheetButton' type="checkbox" autocomplete="off" checked></li>
<li>Show Previous Level Letters<input class='showPreviousLevelLetters' type="checkbox" autocomplete="off" checked></li>
<li>Play Sound On Click<input class='playSoundOnClick' type="checkbox" autocomplete="off"></li>
<li>Play Sound On Error<input class='playSoundOnError' type="checkbox" autocomplete="off"></li>
</ul>
Expand Down
24 changes: 24 additions & 0 deletions logic/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var requireBackspaceCorrection = !localStorage.getItem('requireBackspaceCorrecti
var timeLimitMode = localStorage.getItem('timeLimitMode') === 'true';
var wordScrollingMode = !localStorage.getItem('wordScrollingMode') || localStorage.getItem('wordScrollingMode') === 'true'; // true by default.
var showCheatsheet = !localStorage.getItem('showCheatsheet') || localStorage.getItem('showCheatsheet') === 'true'; // true by default.
var showPreviousLevelLetters = !localStorage.getItem('showPreviousLevelLetters') || localStorage.getItem('showPreviousLevelLetters') === 'true'; // true by default.
var playSoundOnClick = localStorage.getItem('playSoundOnClick') === 'true';
var playSoundOnError = localStorage.getItem('playSoundOnError') === 'true';
var deleteFirstLine = false; // make this true every time we finish typing a line
Expand Down Expand Up @@ -106,6 +107,7 @@ timeLimitModeInput = document.querySelector('.timeLimitModeInput')
wordScrollingModeButton = document.querySelector('.wordScrollingModeButton'),
punctuationModeButton = document.querySelector('.punctuationModeButton'),
showCheatsheetButton = document.querySelector('.showCheatsheetButton');
showPreviousLevelLettersButton = document.querySelector('.showPreviousLevelLetters');
playSoundOnClickButton = document.querySelector('.playSoundOnClick');
playSoundOnErrorButton = document.querySelector('.playSoundOnError');

Expand Down Expand Up @@ -149,6 +151,7 @@ function start() {
wordLimitModeButton.checked = !timeLimitMode;
wordLimitModeInput.value = scoreMax;
showCheatsheetButton.checked = showCheatsheet;
showPreviousLevelLettersButton.checked = showPreviousLevelLetters;
playSoundOnClickButton.checked = playSoundOnClick;
playSoundOnErrorButton.checked = playSoundOnError;

Expand Down Expand Up @@ -421,6 +424,17 @@ showCheatsheetButton.addEventListener('click', ()=> {
localStorage.setItem('showCheatsheet', showCheatsheet);
});

showPreviousLevelLettersButton.addEventListener('click', ()=> {
showPreviousLevelLetters = !showPreviousLevelLetters

localStorage.setItem('showPreviousLevelLetters', showPreviousLevelLetters);

createTestSets();
updateCheatsheetStyling(currentLevel);
reset();
});


// play sound on click toggle
playSoundOnClickButton.addEventListener('click', ()=> {
playSoundOnClick = !playSoundOnClick;
Expand Down Expand Up @@ -1265,6 +1279,7 @@ function updateCheatsheetStyling(level) {
for(n of allKeys) {
//reset all keys to default
n.classList.add('inactive');
n.classList.remove('hiddenNonCurrentLevelKeys');
n.classList.remove('active');
n.classList.remove('homeRow');
n.classList.remove('currentLevelKeys');
Expand Down Expand Up @@ -1293,15 +1308,24 @@ function updateCheatsheetStyling(level) {
if(punctuation.includes(letter)){
n.classList.remove('active');
n.classList.add('punctuation');
if (!showPreviousLevelLetters) {
n.classList.add('hiddenNonCurrentLevelKeys');
}
}else if(i==0){
n.classList.add('homeRow');
if (!showPreviousLevelLetters && i != level-1) {
n.classList.add('hiddenNonCurrentLevelKeys');
}
}else if(i==6){
// all words selected
}else if(i == level-1){
n.classList.remove('active');
n.classList.add('currentLevelKeys');
}else {
n.classList.add('active');
if (!showPreviousLevelLetters) {
n.classList.add('hiddenNonCurrentLevelKeys');
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions logic/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ input:checked + .slider:before {
text-transform: uppercase;
}

.hiddenNonCurrentLevelKeys .letter {
opacity: 0;
}

.oneu {
width: 5.4%;
}
Expand Down