mirror of
https://github.com/genemecija/learn-morse-code.git
synced 2026-04-06 14:53:54 +00:00
Challenge word coloring progress
This commit is contained in:
parent
87abb2a222
commit
d707f483ce
5 changed files with 108 additions and 46 deletions
|
|
@ -20,7 +20,7 @@ export default React.memo(function ChallengeMode(props) {
|
|||
let morseArray = morseCharBuffer.split('_').filter(l => l !== '')
|
||||
|
||||
let correctCharIndexes = [] // Indexes of correct letters in Challenge Word
|
||||
let incorrectCharIndex = null
|
||||
// let incorrectCharIndex = null
|
||||
let incorrectMorseIndexes = [] // Indexes of incorrect morse characters in morse character buffer
|
||||
|
||||
let offset = 0
|
||||
|
|
@ -45,10 +45,12 @@ export default React.memo(function ChallengeMode(props) {
|
|||
|
||||
if (morseLetter === challengeLetter) {
|
||||
correctCharIndexes.push(index-offset)
|
||||
incorrectCharIndex = null
|
||||
|
||||
document.getElementById('challengeWord').childNodes[index-offset].classList.add('correct')
|
||||
// incorrectCharIndex = null
|
||||
}
|
||||
else {
|
||||
incorrectCharIndex = index-offset
|
||||
// incorrectCharIndex = index-offset
|
||||
incorrectMorseIndexes.push(index)
|
||||
if (incorrectMorseIndexes.length > 0) {
|
||||
setMorseCharBuffer(prev => {
|
||||
|
|
@ -79,6 +81,9 @@ export default React.memo(function ChallengeMode(props) {
|
|||
challengeWordClass = 'correct'
|
||||
setTimeout(() => {
|
||||
setMorseCharBuffer('')
|
||||
morseArray = []
|
||||
incorrectMorseIndexes = []
|
||||
offset = 0
|
||||
}, 800)
|
||||
setTimeout(() => {
|
||||
getNextWord()
|
||||
|
|
@ -88,7 +93,7 @@ export default React.memo(function ChallengeMode(props) {
|
|||
|
||||
return (
|
||||
<>
|
||||
<ChallengeWord className={challengeWordClass} word={word} correctCharIndexes={correctCharIndexes} incorrectCharIndex={incorrectCharIndex} />
|
||||
<ChallengeWord className={challengeWordClass} word={word} />
|
||||
<ChallengeBufferDisplay morseArray={morseArray} incorrectMorseIndexes={incorrectMorseIndexes} />
|
||||
{/* <button onClick={() => console.log(morseCharBuffer)}>morseCharBuffer</button> */}
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue