Fix: double game over event
This commit is contained in:
@@ -113,6 +113,8 @@ var TypingTest = {
|
|||||||
// inputTextContent.canvasInput._onkeyup = function() {
|
// inputTextContent.canvasInput._onkeyup = function() {
|
||||||
this.inputTextContent.canvasInput._onkeyup = function() {
|
this.inputTextContent.canvasInput._onkeyup = function() {
|
||||||
self.checkTypingContents(event);
|
self.checkTypingContents(event);
|
||||||
|
// warning
|
||||||
|
// : checkTypingContents is called onkeyup and onkeydown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -245,6 +247,7 @@ var TypingTest = {
|
|||||||
this.typingIndex = 0;
|
this.typingIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
this.isGameOver = false;
|
||||||
this.isTyping = false;
|
this.isTyping = false;
|
||||||
this.timeTypingStart = 0;
|
this.timeTypingStart = 0;
|
||||||
this.timeTypingEnd = 0;
|
this.timeTypingEnd = 0;
|
||||||
@@ -374,6 +377,9 @@ var TypingTest = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
checkTypingContents: function(event) {
|
checkTypingContents: function(event) {
|
||||||
|
if(this.isGameOver)
|
||||||
|
return;
|
||||||
|
|
||||||
var inputContent = this.inputTextContent.canvasInput.value().trim();
|
var inputContent = this.inputTextContent.canvasInput.value().trim();
|
||||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||||
|
|
||||||
@@ -390,6 +396,7 @@ var TypingTest = {
|
|||||||
console.log("this.typingIndex : " + this.typingIndex);
|
console.log("this.typingIndex : " + this.typingIndex);
|
||||||
console.log("this.typingContentLength : " + this.typingContentLength);
|
console.log("this.typingContentLength : " + this.typingContentLength);
|
||||||
if(this.typingIndex == this.typingContentLength - 1) {
|
if(this.typingIndex == this.typingContentLength - 1) {
|
||||||
|
this.isGameOver = true;
|
||||||
this.gameOver();
|
this.gameOver();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user