diff --git a/src/game/typing/test/game.js b/src/game/typing/test/game.js index db29978..f3ebc7d 100644 --- a/src/game/typing/test/game.js +++ b/src/game/typing/test/game.js @@ -195,6 +195,7 @@ var TypingTest = { this.showTypingTestContents(); this.showPlayingWordNumber(); + this.updateKeyboard(); }, timeOver: function() { @@ -408,12 +409,7 @@ var TypingTest = { } this.showTypingContentHighlight(inputContent, typingContent); - - this.hideHighlightKey(this.highlightKey); - this.highlightKey = this.getHighlioghtKey(inputContent, typingContent); - console.log(this.highlightKey); - this.showHighlightKey(this.highlightKey); - this.moveHands(this.highlightKey); + this.updateKeyboard(); }, showTypingContentHighlight: function(inputContent, typingContent) { @@ -435,21 +431,65 @@ var TypingTest = { } }, + updateKeyboard: function() { + var inputContent = this.inputTextContent.canvasInput.value(); + var typingContent = this.typingRandomContents[this.typingIndex]; + + this.hideHighlightKey(this.highlightKey); + this.highlightKey = this.getHighlioghtKey(inputContent, typingContent); + console.log(this.highlightKey); + this.showHighlightKey(this.highlightKey); + this.moveHands(this.highlightKey); + }, + getHighlioghtKey: function(inputContent, typingContent) { var inputLength = inputContent.length; - var typingtLength = typingContent.length; + var typingLength = typingContent.length; + console.log("inputLength : " + inputLength + " / " + inputContent); + console.log("typingLength : " + typingLength + " / " + typingContent); + if(inputLength == typingLength) + return undefined; + var misspelledIndex = -1; for(var i = 0; i < inputLength; i++) { if(inputContent[i] != typingContent[i]) { misspelledIndex = i; break; } - } + // english typing test + if(isEnglishTypingApp()) { + console.log("===== english"); + console.log("misspelledIndex : " + misspelledIndex); + if(misspelledIndex == -1) + return typingContent[inputLength]; + else if(misspelledIndex > -1) + return "Backspace"; + + return typingContent[misspelledIndex]; + } + + // korean typing test if(misspelledIndex > -1) return "Backspace"; + var inputIndex = inputContent.length - 1; + var inputLetter = inputContent[inputIndex]; + var typingLetter = typingContent[inputIndex]; + console.log("inputLetter : " + inputLetter); + console.log("typingLetter : " + typingLetter); + + var typingAlphabet = ""; + if(isKoreanTypingApp()) { + // var inputLetterAlphabets = StringUtil.toKoreanAlphabets(inputContent[inputIndex]); + // var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingContent[inputIndex]); + // console.log("inputLetterAlphabets : " + inputLetterAlphabets); + // console.log("typingLetterAlphabets : " + typingLetterAlphabets); + } else { + + } + return "a"; }, @@ -548,6 +588,7 @@ var TypingTest = { this.showTypingTestContents(); this.showPlayingWordNumber(); this.resetTypingContent(); + this.updateKeyboard(); }, showPlayingWordNumber: function() {