Add: updateKeyboard (incomplete)

This commit is contained in:
2019-05-16 08:51:18 +09:00
parent f57a7bc9f3
commit beec67a1e9
+49 -8
View File
@@ -195,6 +195,7 @@ var TypingTest = {
this.showTypingTestContents(); this.showTypingTestContents();
this.showPlayingWordNumber(); this.showPlayingWordNumber();
this.updateKeyboard();
}, },
timeOver: function() { timeOver: function() {
@@ -408,12 +409,7 @@ var TypingTest = {
} }
this.showTypingContentHighlight(inputContent, typingContent); this.showTypingContentHighlight(inputContent, typingContent);
this.updateKeyboard();
this.hideHighlightKey(this.highlightKey);
this.highlightKey = this.getHighlioghtKey(inputContent, typingContent);
console.log(this.highlightKey);
this.showHighlightKey(this.highlightKey);
this.moveHands(this.highlightKey);
}, },
showTypingContentHighlight: function(inputContent, typingContent) { 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) { getHighlioghtKey: function(inputContent, typingContent) {
var inputLength = inputContent.length; 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; var misspelledIndex = -1;
for(var i = 0; i < inputLength; i++) { for(var i = 0; i < inputLength; i++) {
if(inputContent[i] != typingContent[i]) { if(inputContent[i] != typingContent[i]) {
misspelledIndex = i; misspelledIndex = i;
break; 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) if(misspelledIndex > -1)
return "Backspace"; 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"; return "a";
}, },
@@ -548,6 +588,7 @@ var TypingTest = {
this.showTypingTestContents(); this.showTypingTestContents();
this.showPlayingWordNumber(); this.showPlayingWordNumber();
this.resetTypingContent(); this.resetTypingContent();
this.updateKeyboard();
}, },
showPlayingWordNumber: function() { showPlayingWordNumber: function() {