Commit 41b11841 authored by 18신대성's avatar 18신대성 Committed by 16이지혜

Input에서 생기는 오류들 싸그리 수정

parent 41957eca
...@@ -63,6 +63,7 @@ Input.convert = function() ...@@ -63,6 +63,7 @@ Input.convert = function()
} }
} }
//console.log(vowels); //console.log(vowels);
//console.log(krInput);
this.convInput = ""; this.convInput = "";
let vowelIdx = 0; let vowelIdx = 0;
...@@ -72,10 +73,20 @@ Input.convert = function() ...@@ -72,10 +73,20 @@ Input.convert = function()
for (let i = 0; i <= vowels[vowelIdx] - 2; i++) this.convInput += krInput[i]; for (let i = 0; i <= vowels[vowelIdx] - 2; i++) this.convInput += krInput[i];
while (vowelIdx < vowels.length) while (vowelIdx < vowels.length)
{ {
if (krInput[vowels[vowelIdx] - 1] >= ''.charCodeAt(0)) // 모음 앞에 모음이 있을때 if (vowels[vowelIdx] - 1 < 0 || krInput[vowels[vowelIdx] - 1].charCodeAt(0) >= ''.charCodeAt(0)) // 모음 앞이 비거나 모음이 있을때
{ {
this.convInput += krInput[vowels[vowelIdx]]; if (vowelIdx + 1 < vowels.length) // 다음 모음이 있을때
vowelIdx++; {
this.convInput += krInput[vowels[vowelIdx]];
for (let i = vowels[vowelIdx] + 1; i <= vowels[vowelIdx + 1] - 2; ++i) this.convInput += krInput[i];
++vowelIdx;
}
else // 다음 모음이 없을때
{
this.convInput += krInput[vowels[vowelIdx]];
for (let i = vowels[vowelIdx] + 1; i < krInput.length; i++) this.convInput += krInput[i];
++vowelIdx;
}
} }
else // 모음 앞에 자음이 있을때 else // 모음 앞에 자음이 있을때
{ {
...@@ -94,27 +105,27 @@ Input.convert = function() ...@@ -94,27 +105,27 @@ Input.convert = function()
last = combLast; last = combLast;
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
for (var i = vowels[vowelIdx] + 3; i < krInput.length; i++) this.convInput += krInput[i]; for (var i = vowels[vowelIdx] + 3; i < krInput.length; i++) this.convInput += krInput[i];
vowelIdx++; ++vowelIdx;
} }
else // 뒤의 두 자음을 합칠수 없을때 else // 뒤의 두 자음을 합칠수 없을때
{ {
last = this.convertToLast(krInput[vowels[vowelIdx] + 1]); last = this.convertToLast(krInput[vowels[vowelIdx] + 1]);
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
for (var i = vowels[vowelIdx] + 2; i < krInput.length; i++) this.convInput += krInput[i]; for (var i = vowels[vowelIdx] + 2; i < krInput.length; i++) this.convInput += krInput[i];
vowelIdx++; ++vowelIdx;
} }
} }
else // 다다음 자음이 없을때 else // 다다음 자음이 없을때
{ {
last = this.convertToLast(krInput[vowels[vowelIdx] + 1]); last = this.convertToLast(krInput[vowels[vowelIdx] + 1]);
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
vowelIdx++; ++vowelIdx;
} }
} }
else // 다음 글자가 없을때 else // 다음 글자가 없을때
{ {
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
vowelIdx++; ++vowelIdx;
} }
} }
else // 다음 모음이 있을때 else // 다음 모음이 있을때
...@@ -122,13 +133,13 @@ Input.convert = function() ...@@ -122,13 +133,13 @@ Input.convert = function()
if (vowels[vowelIdx + 1] - vowels[vowelIdx] <= 2) // 다음 모음 사이에 자음이 0개거나 1개 if (vowels[vowelIdx + 1] - vowels[vowelIdx] <= 2) // 다음 모음 사이에 자음이 0개거나 1개
{ {
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
vowelIdx++; ++vowelIdx;
} }
else if (vowels[vowelIdx + 1] - vowels[vowelIdx] === 3) // 다음 모음 사이에 자음이 2개 else if (vowels[vowelIdx + 1] - vowels[vowelIdx] === 3) // 다음 모음 사이에 자음이 2개
{ {
last = this.convertToLast(krInput[vowels[vowelIdx] + 1]); last = this.convertToLast(krInput[vowels[vowelIdx] + 1]);
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
vowelIdx++; ++vowelIdx;
} }
else // 다음 모음 사이에 자음이 3개 이상 else // 다음 모음 사이에 자음이 3개 이상
{ {
...@@ -138,14 +149,14 @@ Input.convert = function() ...@@ -138,14 +149,14 @@ Input.convert = function()
last = combLast; last = combLast;
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
for (var i = vowels[vowelIdx] + 3; i < vowels[vowelIdx + 1] - 1; i++) this.convInput += krInput[i]; for (var i = vowels[vowelIdx] + 3; i < vowels[vowelIdx + 1] - 1; i++) this.convInput += krInput[i];
vowelIdx++; ++vowelIdx;
} }
else // 뒤의 두 자음을 합칠수 없을때 else // 뒤의 두 자음을 합칠수 없을때
{ {
last = this.convertToLast(krInput[vowels[vowelIdx] + 1]); last = this.convertToLast(krInput[vowels[vowelIdx] + 1]);
this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last)); this.convInput += String.fromCharCode(this.convertToCharCode(first, middle, last));
for (var i = vowels[vowelIdx] + 2; i < vowels[vowelIdx + 1] - 1; i++) this.convInput += krInput[i]; for (var i = vowels[vowelIdx] + 2; i < vowels[vowelIdx + 1] - 1; i++) this.convInput += krInput[i];
vowelIdx++; ++vowelIdx;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment