Fix: multiAlphabet (incompleted)
This commit is contained in:
@@ -91,6 +91,96 @@ StringUtil.getUnicodeAlphabetCount = function(text) {
|
||||
return alphabetCount;
|
||||
};
|
||||
|
||||
StringUtil.chosung = function(letter) {
|
||||
var alphabets = StringUtil.toKoreanAlphabets(letter);
|
||||
return alphabets[0];
|
||||
}
|
||||
|
||||
StringUtil.jungsung = function(letter) {
|
||||
var alphabets = StringUtil.toKoreanAlphabets(letter);
|
||||
return alphabets[1];
|
||||
}
|
||||
|
||||
StringUtil.jongsung = function(letter) {
|
||||
if(!StringUtil.hasJongsung(letter))
|
||||
return "";
|
||||
|
||||
var alphabets = StringUtil.toKoreanAlphabets(letter);
|
||||
return alphabets[2];
|
||||
}
|
||||
|
||||
StringUtil.isSameKoreanAlphabet = function(firstAlphabet, secondAlphabet) {
|
||||
if(firstAlphabet == secondAlphabet)
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
StringUtil.isMultiLetterJungsung = function(alphabet) {
|
||||
var cMultiJung = [ 'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ' ];
|
||||
for(var i = 0; i < cMultiJung.length; i++) {
|
||||
if(cMultiJung[i] == alphabet)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
StringUtil.getMultiLettersFromJongsung = function(alphabet) {
|
||||
var multiJungsungList = new Object();
|
||||
multiJungsungList['ㅘ'] = ['ㅗ', 'ㅏ'];
|
||||
multiJungsungList['ㅙ'] = ['ㅗ', 'ㅐ'];
|
||||
multiJungsungList['ㅚ'] = ['ㅗ', 'ㅣ'];
|
||||
multiJungsungList['ㅝ'] = ['ㅜ', 'ㅓ'];
|
||||
multiJungsungList['ㅞ'] = ['ㅜ', 'ㅔ'];
|
||||
multiJungsungList['ㅢ'] = ['ㅡ', 'ㅣ'];
|
||||
|
||||
return multiJungsungList[alphabet];
|
||||
};
|
||||
|
||||
StringUtil.isMultiLetterJongsung = function(alphabet) {
|
||||
var cMultiJong = [ 'ㄲ', 'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ', 'ㅆ' ];
|
||||
for(var i = 0; i < cMultiJong.length; i++) {
|
||||
if(cMultiJong[i] == alphabet)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
StringUtil.getMultiLettersFromJongsung = function(alphabet) {
|
||||
var multiJongsungList = new Object();
|
||||
multiJongsungList['ㄲ'] = ['ㄱ', 'ㄱ'];
|
||||
multiJongsungList['ㄳ'] = ['ㄱ', 'ㅅ'];
|
||||
multiJongsungList['ㄵ'] = ['ㄴ', 'ㅈ'];
|
||||
multiJongsungList['ㄶ'] = ['ㄴ', 'ㅎ'];
|
||||
multiJongsungList['ㄺ'] = ['ㄹ', 'ㄱ'];
|
||||
multiJongsungList['ㄻ'] = ['ㄹ', 'ㅁ'];
|
||||
multiJongsungList['ㄼ'] = ['ㄹ', 'ㅂ'];
|
||||
multiJongsungList['ㄽ'] = ['ㄹ', 'ㅅ'];
|
||||
multiJongsungList['ㄾ'] = ['ㄹ', 'ㅌ'];
|
||||
multiJongsungList['ㄿ'] = ['ㄹ', 'ㅍ'];
|
||||
multiJongsungList['ㅀ'] = ['ㄹ', 'ㅎ'];
|
||||
multiJongsungList['ㅄ'] = ['ㅂ', 'ㅅ'];
|
||||
multiJongsungList['ㅆ'] = ['ㅅ', 'ㅅ'];
|
||||
|
||||
return multiJongsungList[alphabet];
|
||||
}
|
||||
|
||||
StringUtil.hasJongsung = function(alphabet) {
|
||||
var alphabets = StringUtil.toKoreanAlphabets(alphabet);
|
||||
if(alphabets.length == 3)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
StringUtil.isSameKoreanAlphabet = function(firstAlphabet, secondAlphabet) {
|
||||
if(firstAlphabet == secondAlphabet)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
StringUtil.getScoreUnit = function(playingAppID) {
|
||||
if(playingAppID == 104)
|
||||
return " 초";
|
||||
|
||||
@@ -378,9 +378,9 @@ var TypingTest = {
|
||||
|
||||
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);
|
||||
@@ -440,7 +440,8 @@ var TypingTest = {
|
||||
// console.log("inputLength : " + inputLength + " / " + inputContent);
|
||||
// console.log("typingLength : " + typingLength + " / " + typingContent);
|
||||
var misspelledIndex = -1;
|
||||
for(var i = 0; i < inputLength; i++) {
|
||||
for(var i = 0; i < typingLength; i++) {
|
||||
// console.log("inputContent[i] : " + inputContent[i] + ", typingContent[i] : " + typingContent[i]);
|
||||
if(inputContent[i] != typingContent[i]) {
|
||||
misspelledIndex = i;
|
||||
break;
|
||||
@@ -462,21 +463,94 @@ var TypingTest = {
|
||||
}
|
||||
// korean typing test
|
||||
else {
|
||||
// console.log(misspelledIndex + " / " + typingContent[misspelledIndex]);
|
||||
if(inputContent == typingContent)
|
||||
highlightKey = "Enter";
|
||||
else if(typingContent[misspelledIndex] == " ")
|
||||
highlightKey = " ";
|
||||
else {
|
||||
var inputIndex = inputContent.length - 1;
|
||||
var inputLetter = "";
|
||||
var typingLetter = "";
|
||||
var typingNextLetter = "";
|
||||
|
||||
if(misspelledIndex > -1)
|
||||
return "Backspace";
|
||||
console.log("-----");
|
||||
console.log("inputConent : '" + inputContent + "'");
|
||||
console.log("inputIndex : " + inputIndex);
|
||||
console.log("misspelledIndex : " + misspelledIndex);
|
||||
|
||||
var inputIndex = inputContent.length - 1;
|
||||
var inputLetter = inputContent[inputIndex];
|
||||
var typingLetter = typingContent[inputIndex];
|
||||
// console.log("inputLetter : " + inputLetter);
|
||||
// console.log("typingLetter : " + typingLetter);
|
||||
if(inputIndex < 0)
|
||||
inputLetter = "";
|
||||
else if(misspelledIndex > inputIndex)
|
||||
inputLetter = "";
|
||||
else
|
||||
inputLetter = inputContent[misspelledIndex];
|
||||
typingLetter = typingContent[misspelledIndex];
|
||||
if(inputContent.length < typingContent.length)
|
||||
typingNextLetter = typingContent[misspelledIndex + 1];
|
||||
|
||||
var typingAlphabet = "";
|
||||
// var inputLetterAlphabets = StringUtil.toKoreanAlphabets(inputContent[inputIndex]);
|
||||
// var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingContent[inputIndex]);
|
||||
// console.log("inputLetterAlphabets : " + inputLetterAlphabets);
|
||||
// console.log("typingLetterAlphabets : " + typingLetterAlphabets);
|
||||
console.log("inputLetter : '" + inputLetter + "'");
|
||||
console.log("typingLetter : '" + typingLetter + "'");
|
||||
console.log("typingNextLetter : '" + typingNextLetter + "'");
|
||||
|
||||
var typingAlphabet = "";
|
||||
var inputLetterAlphabets = StringUtil.toKoreanAlphabets(inputLetter);
|
||||
var typingLetterAlphabets = StringUtil.toKoreanAlphabets(typingLetter);
|
||||
var typingNextLetterAlphabets = StringUtil.toKoreanAlphabets(typingNextLetter);
|
||||
console.log("inputLetterAlphabets : " + inputLetterAlphabets);
|
||||
console.log("typingLetterAlphabets : " + typingLetterAlphabets);
|
||||
console.log("typingNextLetterAlphabets : " + typingNextLetterAlphabets);
|
||||
|
||||
if(inputLetterAlphabets.length == 0) {
|
||||
highlightKey = typingLetterAlphabets[0];
|
||||
}
|
||||
else if(inputLetterAlphabets.length == 1) {
|
||||
if(inputLetterAlphabets[0] != typingLetterAlphabets[0])
|
||||
highlightKey = "Backspace";
|
||||
else
|
||||
highlightKey = typingLetterAlphabets[1];
|
||||
}
|
||||
else if(inputLetterAlphabets.length == 2) {
|
||||
if(StringUtil.isMultiLetterJongsung(typingLetterAlphabets[1])) {
|
||||
var jungsungAlphabets = StringUtil.getMultiLettersFromJongsung(typingLetterAlphabets[1]);
|
||||
if(inputLetterAlphabets[1] == jungsungAlphabets[0])
|
||||
highlightKey = jungsungAlphabets[1];
|
||||
else
|
||||
highlightKey = "Backspace";
|
||||
}
|
||||
else {
|
||||
if(inputLetterAlphabets[1] != typingLetterAlphabets[1])
|
||||
highlightKey = "Backspace";
|
||||
else {
|
||||
if(typingLetterAlphabets.length == 3)
|
||||
highlightKey = typingLetterAlphabets[2];
|
||||
else
|
||||
highlightKey = typingNextLetterAlphabets[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(inputLetterAlphabets.length == 3) {
|
||||
if(StringUtil.hasJongsung(typingLetterAlphabet)) {
|
||||
if(inputLetterAlphabets[2] == typingLetterAlphabets[2])
|
||||
highlightKey = typingNextLetterAlphabet[0]; // next letter chosung
|
||||
else {
|
||||
// 알바 -> 앏
|
||||
if(StringUtil.isMultiLetterJongsung(inputLetterAlphabets[2])) {
|
||||
var jongsungAlphabets = StringUtil.getMultiLettersFromJongsung(inputLetterAlphabets[2]);
|
||||
if(typingLetterAlphabet[2] == jongsungAlphabets[0] && typingNextLetterAlphabet[0] == jongsungAlphabets[1])
|
||||
highlightKey = typingNextLetterAlphabet[1]; // next letter jungsung
|
||||
else
|
||||
highlightKey = "Backspace";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
highlightKey = "`";
|
||||
}
|
||||
|
||||
// highlightKey = "ㄱ";
|
||||
}
|
||||
}
|
||||
|
||||
if(highlightKey == " ")
|
||||
|
||||
Reference in New Issue
Block a user