mirror of
https://github.com/genemecija/learn-morse-code.git
synced 2026-04-21 06:03:56 +00:00
Wordlist addition, file cleanup
This commit is contained in:
parent
91bca8c545
commit
1e25c16a3c
31 changed files with 92 additions and 612 deletions
|
|
@ -1,7 +1,5 @@
|
|||
import React, {useState, useContext} from "react"
|
||||
import { GameClockContext } from "./gameClockContext"
|
||||
import { WordFeederContext } from "./wordFeederContext"
|
||||
import { KeyTypeContext } from "./keyTypeContext";
|
||||
import { MorseBufferContext } from "./morseBufferContext";
|
||||
import morseCode from '../data/morse-reverse.json'
|
||||
|
||||
|
|
@ -9,7 +7,6 @@ import morseCode from '../data/morse-reverse.json'
|
|||
const ChallengeContext = React.createContext()
|
||||
|
||||
function ChallengeContextProvider(props) {
|
||||
console.log('ChallengeContextProvider');
|
||||
|
||||
const [challengeState, setChallengeState] = useState('ready')
|
||||
const {resetFeeder} = useContext(WordFeederContext)
|
||||
|
|
@ -28,7 +25,6 @@ function ChallengeContextProvider(props) {
|
|||
|
||||
|
||||
function startChallenge() {
|
||||
console.log('STARTCHALLENGE');
|
||||
|
||||
let countdown
|
||||
let count = 3
|
||||
|
|
@ -94,13 +90,10 @@ function ChallengeContextProvider(props) {
|
|||
|
||||
if (morseLetter === challengeLetter) {
|
||||
correctCharIndexes.push(index-offset)
|
||||
console.log('morseCharBuffer', morseCharBuffer);
|
||||
|
||||
document.getElementById('challengeWord').childNodes[index-offset].classList.add('correct')
|
||||
// incorrectCharIndex = null
|
||||
}
|
||||
else {
|
||||
// incorrectCharIndex = index-offset
|
||||
incorrectMorseIndexes.push(index)
|
||||
if (incorrectMorseIndexes.length > 0) {
|
||||
setMorseCharBuffer(prev => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import React, {useState, useContext, useEffect} from "react"
|
||||
import { ChallengeContext } from "./challengeContext"
|
||||
// import { KeyTypeContext } from "./keyTypeContext"
|
||||
const GameClockContext = React.createContext()
|
||||
|
||||
function GameClockContextProvider(props) {
|
||||
|
|
@ -12,9 +11,7 @@ function GameClockContextProvider(props) {
|
|||
|
||||
|
||||
function startGameClock() {
|
||||
console.log('before clock');
|
||||
if (!clockIsRunning) {
|
||||
console.log('after clock');
|
||||
setClockIsRunning(true)
|
||||
setIntervals(prev => [...prev, (setInterval(() => {
|
||||
if (document.getElementById('gameClock') === null) {
|
||||
|
|
@ -61,6 +58,7 @@ function GameClockContextProvider(props) {
|
|||
default:
|
||||
return
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [challengeState])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import React, {useState} from "react"
|
|||
const KeyTypeContext = React.createContext()
|
||||
|
||||
function KeyTypeContextProvider(props) {
|
||||
console.log('KeyTypeContextProvider');
|
||||
|
||||
const [keyType, setKeyType] = useState('straight')
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import numbers from '../data/numbers.json'
|
|||
import common100 from '../data/common100.json'
|
||||
import boys from '../data/names_boys.json'
|
||||
import girls from '../data/names_girls.json'
|
||||
import trek from '../data/startrek.json'
|
||||
|
||||
|
||||
const WordListPickerContext = React.createContext()
|
||||
|
|
@ -23,6 +24,8 @@ function WordListPickerContextProvider(props) {
|
|||
wordList = boys.words
|
||||
} else if (wordListCategory === 'girls') {
|
||||
wordList = girls.words
|
||||
} else if (wordListCategory === 'startrek') {
|
||||
wordList = trek.words
|
||||
} else if (wordListCategory === 'common100') {
|
||||
wordList = common100.words
|
||||
} else if (wordListCategory === 'test') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue