Fix: checkTypingContents duplicated execution bug
This commit is contained in:
@@ -16,7 +16,8 @@ var TypingTest = {
|
||||
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// keyboard shortcut
|
||||
/*
|
||||
// keyboard shortcut - useless. this.keyboard is chargning for ESC event
|
||||
this.keyboardShortcut = new KeyboardShortcut();
|
||||
this.keyboardShortcut.addCallback(
|
||||
Phaser.KeyCode.ESC, // keyCode
|
||||
@@ -24,6 +25,7 @@ var TypingTest = {
|
||||
(function() { this.back(); }).bind(this), // keyUpHandler
|
||||
"keyboard_test" // callerClassName
|
||||
);
|
||||
*/
|
||||
|
||||
// top ui
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
@@ -125,17 +127,9 @@ var TypingTest = {
|
||||
Phaser.KeyCode.ESC, // keyCode
|
||||
null, // keyDownHandler
|
||||
(function() { this.back(); }).bind(this), // keyUpHandler
|
||||
"typing_practice" // callerClassName
|
||||
"keyboard_test" // callerClassName
|
||||
);
|
||||
|
||||
game.input.keyboard.processKeyPress = (function(event) {
|
||||
if(self.isOnStage === false)
|
||||
return;
|
||||
|
||||
self.checkTypingContents(event);
|
||||
});
|
||||
this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
|
||||
|
||||
// hands
|
||||
this.leftHand = new LeftHand(this.keyMapper);
|
||||
this.rightHand = new RightHand(this.keyMapper);
|
||||
@@ -379,15 +373,14 @@ var TypingTest = {
|
||||
},
|
||||
|
||||
checkTypingContents: function(event) {
|
||||
// var inputContent = this.inputTextContent.canvasInput.value().trim();
|
||||
var inputContent = this.inputTextContent.canvasInput.value();
|
||||
var inputContent = this.inputTextContent.canvasInput.value().trim();
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER ||
|
||||
event.keyCode == Phaser.Keyboard.SPACEBAR) {
|
||||
// console.log("### enter ###");
|
||||
// console.log("inputContent : " + inputContent);
|
||||
// console.log("typingContent : " + typingContent);
|
||||
console.log("### enter ###");
|
||||
console.log("inputContent : " + inputContent);
|
||||
console.log("typingContent : " + typingContent);
|
||||
|
||||
if(inputContent === typingContent) {
|
||||
this.calculateTypingRecord(typingContent);
|
||||
@@ -400,7 +393,6 @@ var TypingTest = {
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(this.inputTextContent.canvasInput.value());
|
||||
if(this.isTyping == false) {
|
||||
// console.log(event);
|
||||
this.setTimeTypingStart();
|
||||
@@ -447,9 +439,6 @@ var TypingTest = {
|
||||
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]) {
|
||||
@@ -462,7 +451,9 @@ var TypingTest = {
|
||||
if(isEnglishTypingApp()) {
|
||||
// console.log("===== english");
|
||||
// console.log("misspelledIndex : " + misspelledIndex);
|
||||
if(misspelledIndex == -1)
|
||||
if(inputLength == typingLength)
|
||||
highlightKey = "Enter";
|
||||
else if(misspelledIndex == -1)
|
||||
highlightKey = typingContent[inputLength];
|
||||
else if(misspelledIndex > -1)
|
||||
highlightKey = "Backspace";
|
||||
|
||||
Reference in New Issue
Block a user