88 lines
2.3 KiB
JavaScript
88 lines
2.3 KiB
JavaScript
function TypingTextManager() {
|
|
this.init();
|
|
}
|
|
|
|
TypingTextManager.prototype.init = function() {
|
|
this.contents = [];
|
|
}
|
|
|
|
TypingTextManager.prototype.getContents = function() {
|
|
return this.contents;
|
|
}
|
|
|
|
TypingTextManager.prototype.add = function(arr) {
|
|
this.contents = this.contents.concat(arr);
|
|
}
|
|
|
|
TypingTextManager.prototype.slice = function(start, end) {
|
|
this.contents = this.contents.slice(start, end);
|
|
}
|
|
|
|
TypingTextManager.prototype.getShuffledArray = function(arr) {
|
|
return Phaser.ArrayUtils.shuffle(arr);
|
|
}
|
|
|
|
TypingTextManager.prototype.fillLeftRightBasicKey = function() {
|
|
var length = this.contents.length;
|
|
// console.log(length);
|
|
|
|
for(var i = length - 1; i > -1; i--) {
|
|
var char = this.contents[i];
|
|
// console.log(char);
|
|
if(this.isKoreanConsonant(char)) {
|
|
this.contents.splice(i + 1, 0, "ㅓ");
|
|
} else if(this.isKoreanVowel(char)) {
|
|
this.contents.splice(i, 0, "ㄹ");
|
|
}
|
|
}
|
|
}
|
|
|
|
TypingTextManager.prototype.isKoreanConsonant = function(char) {
|
|
if(char.length != 1)
|
|
return false;
|
|
|
|
if(TypingTextManager.rCho.indexOf(char) > -1)
|
|
return true;
|
|
else if(TypingTextManager.rJong.indexOf(char) > -1)
|
|
return;
|
|
}
|
|
|
|
TypingTextManager.prototype.isKoreanVowel = function(char) {
|
|
if(char.length != 1)
|
|
return false;
|
|
|
|
if(TypingTextManager.rJung.indexOf(char) > -1)
|
|
return true;
|
|
}
|
|
|
|
TypingTextManager.prototype.makePracticeContents = function(arr, repeatCount) {
|
|
this.init();
|
|
this.add(arr);
|
|
for(var i = 0; i < repeatCount; i++) {
|
|
this.add(this.getShuffledArray(arr));
|
|
}
|
|
this.fillLeftRightBasicKey();
|
|
}
|
|
|
|
TypingTextManager.prototype.makeTestContents = function(arr) {
|
|
this.init();
|
|
this.add(this.getShuffledArray(arr));
|
|
}
|
|
|
|
|
|
|
|
TypingTextManager.shuffledArray = function(arr) {
|
|
return Phaser.ArrayUtils.shuffle(arr);
|
|
}
|
|
|
|
|
|
TypingTextManager.rCho =
|
|
[ "ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ",
|
|
"ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ" ];
|
|
TypingTextManager.rJung =
|
|
[ "ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ",
|
|
"ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ" ];
|
|
TypingTextManager.rJong =
|
|
[ "", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ",
|
|
"ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ",
|
|
"ㅍ", "ㅎ" ]; |