/** * °¡»óŰº¸µå ±¸Çö * -------------------------------------------------------------- * 2018-09: this.VKI_show -> VKI_show ¿ÜºÎ¿¡¼­ È£Ãâ * ½ºÅ¸ÀÏÀû¿ë º¯°æ * 2018-10: this.IN * */ function VKI_buildKeyboardInputs() { var self = this; this.VKI_version = "1.10"; this.VKI_target = this.VKI_visible = ""; this.VKI_shift = this.VKI_capslock = this.VKI_alternate = this.VKI_dead = false; this.VKI_deadkeysOn = false; this.VKI_kt = "KR"; // Default keyboard layout this.VKI_range = false; this.VKI_keyCenter = 3; /* ***** Create keyboards **************************************** */ this.VKI_layout = new Object(); this.VKI_layoutDDK = new Object(); // - Lay out each keyboard in rows of sub-arrays. Each sub-array // represents one key. // // - Each sub-array consists of four slots described as follows: // example: ["a", "A", "\u00e1", "\u00c1"] // // a) Normal character // A) Character + Shift or Caps // \u00e1) Character + Alt or AltGr // \u00c1) Character + Shift or Caps + Alt or AltGr // // You may include sub-arrays which are fewer than four slots. In // these cases, the missing slots will be blanked when the // corresponding modifier key (Shift or AltGr) is pressed. // // - If the second slot of a sub-array matches one of the following // strings: // "Tab", "Caps", "Shift", "Enter", "BackSpace", "Alt" OR "AltGr" // then the function of the key will be the following, // respectively: // - Insert a tab // - Toggle Caps Lock (technically a Shift Lock) // - Next entered character will be the shifted character // - Insert a newline (textarea), or close the keyboard // - Delete the previous character // - Next entered character will be the alternate character // // The first slot of this sub-array will be the text to display on // the corresponding key. This allows for easy localisation of key // names. // // - Layout dead keys (diacritic + letter) should be added as arrays // of two item arrays with hash keys equal to the diacritic. See // the "this.VKI_deadkey" object below the layout definitions. In // each two item child array, the second item is what the diacritic // would change the first item to. // // - To disable dead keys for a layout, simply assign true to the // this.VKI_layoutDDK (DDK = disable dead keys) object of the same // name as the layout. See the Numpad layout below for an example. // // - Note that any characters beyond the normal ASCII set should be // entered in escaped Unicode format. (eg \u00a3 = Pound symbol) // You can find Unicode values for characters here: // http://unicode.org/charts/ // // - To remove a keyboard, just delete it, or comment it out of the // source code this.VKI_layout.KR = [ // Korea Standard Keyboard [["`", "~"], ["1", "!"], ["2", "@"], ["3", "#"], ["4", "$"], ["5", "%"], ["6", "^"], ["7", "&"], ["8", "*"], ["9", "("], ["0", ")"], ["-", "_"], ["=", "+"], ["BackSpace", "BackSpace"]], [["Tab", "Tab"], ["¤²", "¤³"], ["¤¸", "¤¹"], ["¤§", "¤¨"], ["¤¡", "¤¢"], ["¤µ", "¤¶"], ["¤Ë", "¤Ë"], ["¤Å", "¤Å"], ["¤Á", "¤Á"], ["¤À", "¤Â"], ["¤Ä", "¤Æ"], ["[", "{"], ["]", "}"], ["\\", "|"]], [["Caps", "Caps"], ["¤±", "¤±"], ["¤¤", "¤¤"], ["¤·", "¤·"], ["¤©", "¤©"], ["¤¾", "¤¾"], ["¤Ç", "¤Ç"], ["¤Ã", "¤Ã"], ["¤¿", "¤¿"], ["¤Ó", "¤Ó"], [";", ":"], ["'", '"'], ["Enter", "Enter"]], [["Shift", "Shift"], ["¤»", "¤»"], ["¤¼", "¤¼"], ["¤º", "¤º"], ["¤½", "¤½"], ["¤Ð", "¤Ð"], ["¤Ì", "¤Ì"], ["¤Ñ", "¤Ñ"], [",", "<"], [".", ">"], ["/", "?"], ["Shift", "Shift"]], [[" ", " "]] ]; this.VKI_layout.US = [ // US Standard Keyboard [["`", "~"], ["1", "!"], ["2", "@"], ["3", "#"], ["4", "$"], ["5", "%"], ["6", "^"], ["7", "&"], ["8", "*"], ["9", "("], ["0", ")"], ["-", "_"], ["=", "+"], ["BackSpace", "BackSpace"]], [["Tab", "Tab"], ["q", "Q"], ["w", "W"], ["e", "E"], ["r", "R"], ["t", "T"], ["y", "Y"], ["u", "U"], ["i", "I"], ["o", "O"], ["p", "P"], ["[", "{"], ["]", "}"], ["\\", "|"]], [["Caps", "Caps"], ["a", "A"], ["s", "S"], ["d", "D"], ["f", "F"], ["g", "G"], ["h", "H"], ["j", "J"], ["k", "K"], ["l", "L"], [";", ":"], ["'", '"'], ["Enter", "Enter"]], [["Shift", "Shift"], ["z", "Z"], ["x", "X"], ["c", "C"], ["v", "V"], ["b", "B"], ["n", "N"], ["m", "M"], [",", "<"], [".", ">"], ["/", "?"], ["Shift", "Shift"]], [[" ", " "]] ]; var kr=Array('¤²','¤³','¤¸','¤¹','¤§','¤¨','¤¡','¤¢','¤µ','¤¶','¤Ë','¤Ë','¤Å','¤Å','¤Á','¤Á','¤À','¤Â','¤Ä','¤Æ','¤±','¤±','¤¤','¤¤','¤·','¤·','¤©','¤©','¤¾','¤¾','¤Ç','¤Ç','¤Ã','¤Ã','¤¿','¤¿','¤Ó','¤Ó','¤»','¤»','¤¼','¤¼','¤º','¤º','¤½','¤½','¤Ð','¤Ð','¤Ì','¤Ì','¤Ñ','¤Ñ'); var us=Array('q','Q','w','W','e','E','r','R','t','T','y','Y','u','U','i','I','o','O','p','P','a','A','s','S','d','D','f','F','g','G','h','H','j','J','k','K','l','L','z','Z','x','X','c','C','v','V','b','B','n','N','m','M'); /* ***** Find tagged input & textarea elements ******************* */ /* ***** Build the keyboard interface **************************** */ this.VKI_keyboard = document.createElement('table'); this.VKI_keyboard.id = "keyboardInputMaster"; this.VKI_keyboard.cellSpacing = this.VKI_keyboard.cellPadding = this.VKI_keyboard.border = "0"; var layouts = 0; for (ktype in this.VKI_layout) if (typeof this.VKI_layout[ktype] == "object") layouts++; var thead = document.createElement('thead'); var tr = document.createElement('tr'); var th = document.createElement('th'); if (layouts > 1) { var kblist = document.createElement('select'); for (ktype in this.VKI_layout) { if (typeof this.VKI_layout[ktype] == "object") { var opt = document.createElement('option'); opt.value = ktype; opt.appendChild(document.createTextNode(ktype)); kblist.appendChild(opt); } } kblist.value = this.VKI_kt; kblist.onchange = function() { self.VKI_kt = this.value; self.VKI_buildKeys(); self.VKI_position(); }; th.appendChild(kblist); } tr.appendChild(th); var td = document.createElement('td'); var clearer = document.createElement('span'); clearer.id = "keyboardInputClear"; clearer.appendChild(document.createTextNode("Clear")); clearer.title = "Clear this input"; clearer.onmousedown = function() { this.className = "pressed"; }; clearer.onmouseup = function() { this.className = ""; }; clearer.onclick = function() { self.VKI_target.value = ""; document.getElementById('eng_text').value=''; self.VKI_target.focus(); return false; }; td.appendChild(clearer); var closer = document.createElement('span'); closer.id = "keyboardInputClose"; closer.appendChild(document.createTextNode('X')); closer.title = "Close this window"; closer.onmousedown = function() { this.className = "pressed"; }; closer.onmouseup = function() { this.className = ""; }; closer.onclick = function() { self.VKI_close(); }; td.appendChild(closer); tr.appendChild(td); thead.appendChild(tr); this.VKI_keyboard.appendChild(thead); var tbody = document.createElement('tbody'); var tr = document.createElement('tr'); var td = document.createElement('td'); td.colSpan = "2"; var div = document.createElement('div'); div.id = "keyboardInputLayout"; td.appendChild(div); var div = document.createElement('div'); /* var ver = document.createElement('var'); ver.appendChild(document.createTextNode("v" + this.VKI_version)); div.appendChild(ver); */ td.appendChild(div); tr.appendChild(td); tbody.appendChild(tr); this.VKI_keyboard.appendChild(tbody); /* ***** Functions ************************************************ */ /* ****************************************************************** * Build or rebuild the keyboard keys * */ this.VKI_buildKeys = function() { this.VKI_shift = this.VKI_capslock = this.VKI_alternate = this.VKI_dead = false; var container = this.VKI_keyboard.tBodies[0].getElementsByTagName('div')[0]; while (container.firstChild) container.removeChild(container.firstChild); for (var x = 0, hasDeadKey = false, lyt; lyt = this.VKI_layout[this.VKI_kt][x++];) { var table = document.createElement('table'); table.cellSpacing = table.cellPadding = table.border = "0"; if (lyt.length <= this.VKI_keyCenter) table.className = "keyboardInputCenter"; var tbody = document.createElement('tbody'); var tr = document.createElement('tr'); for (var y = 0, lkey; lkey = lyt[y++];) { var td = document.createElement('td'); td.appendChild(document.createTextNode(lkey[0])); var alive = false; if (this.VKI_deadkeysOn) for (key in this.VKI_deadkey) if (key === lkey[0]) alive = true; td.className = (alive) ? "alive" : ""; if (lyt.length > this.VKI_keyCenter && y == lyt.length) td.className += " last"; if (lkey[0] == " ") td.style.paddingLeft = td.style.paddingRight = "50px"; td.onmouseover = function() { if (this.className != "dead" && this.firstChild.nodeValue != "\xa0") this.className += " hover"; }; td.onmouseout = function() { if (this.className != "dead") this.className = this.className.replace(/ ?(hover|pressed)/g, ""); }; td.onmousedown = function() { if (this.className != "dead" && this.firstChild.nodeValue != "\xa0") this.className += " pressed"; }; td.onmouseup = function() { if (this.className != "dead") this.className = this.className.replace(/ ?pressed/g, ""); }; td.ondblclick = function() { return false; }; switch (lkey[1]) { case "Caps": case "Shift": case "Alt": case "AltGr": td.onclick = (function(type) { return function() { self.VKI_modify(type); return false; };})(lkey[1]); break; case "Tab": td.onclick = function() { self.VKI_insert("\t"); return false; }; break; case "BackSpace": td.onclick = function() { self.VKI_target.focus(); if (self.VKI_target.setSelectionRange) { var srt = self.VKI_target.selectionStart; var len = self.VKI_target.selectionEnd; if (srt < len) srt++; self.VKI_target.value = self.VKI_target.value.substr(0, srt - 1) + self.VKI_target.value.substr(len); self.VKI_target.setSelectionRange(srt - 1, srt - 1); } else if (self.VKI_target.createTextRange) { try { self.VKI_range.select(); } catch(e) {} self.VKI_range = document.selection.createRange(); if (!self.VKI_range.text.length) self.VKI_range.moveStart('character', -1); self.VKI_range.text = ""; } else self.VKI_target.value = self.VKI_target.value.substr(0, self.VKI_target.value.length - 1); if (self.VKI_shift) self.VKI_modify("Shift"); if (self.VKI_alternate) self.VKI_modify("AltGr"); if(self.VKI_kt=='KR'){ var eng_span=document.getElementById('eng_text'); eng_span.value=eng_span.value.substring(0,eng_span.value.length-1); englishToKorean(self.VKI_target,eng_span); } return true; }; break; case "Enter": td.onclick = function() { //°Ë»ö $('#kwd').val(self.VKI_target.value ); goSearch(); //$('#historyForm').submit(); /* if (self.VKI_target.nodeName == "TEXTAREA") { self.VKI_insert("\n"); } else self.VKI_close(); return true; */ }; break; default: td.onclick = function() { if (self.VKI_deadkeysOn && self.VKI_dead) { if (self.VKI_dead != this.firstChild.nodeValue) { for (key in self.VKI_deadkey) { if (key == self.VKI_dead) { if (this.firstChild.nodeValue != " ") { for (var z = 0, rezzed = false, dk; dk = self.VKI_deadkey[key][z++];) { if (dk[0] == this.firstChild.nodeValue) { self.VKI_insert(dk[1]); rezzed = true; break; } } } else { self.VKI_insert(self.VKI_dead); rezzed = true; } break; } } } else rezzed = true; } self.VKI_dead = false; if (!rezzed && this.firstChild.nodeValue != "\xa0") { if (self.VKI_deadkeysOn) { for (key in self.VKI_deadkey) { if (key == this.firstChild.nodeValue) { self.VKI_dead = key; this.className = "dead"; if (self.VKI_shift) self.VKI_modify("Shift"); if (self.VKI_alternate) self.VKI_modify("AltGr"); break; } } if (!self.VKI_dead) self.VKI_insert(this.firstChild.nodeValue); } else self.VKI_insert(this.firstChild.nodeValue); } self.VKI_modify(""); return false; }; } tr.appendChild(td); tbody.appendChild(tr); table.appendChild(tbody); for (var z = lkey.length; z < 4; z++) lkey[z] = "\xa0"; } container.appendChild(table); } }; this.VKI_buildKeys(); VKI_disableSelection(this.VKI_keyboard); /* ****************************************************************** * Controls modifier keys * */ this.VKI_modify = function(type) { switch (type) { case "Alt": case "AltGr": this.VKI_alternate = !this.VKI_alternate; break; case "Caps": this.VKI_capslock = !this.VKI_capslock; break; case "Shift": this.VKI_shift = !this.VKI_shift; break; } var vchar = 0; if (!this.VKI_shift != !this.VKI_capslock) vchar += 1; var tables = this.VKI_keyboard.getElementsByTagName('table'); for (var x = 0; x < tables.length; x++) { var tds = tables[x].getElementsByTagName('td'); for (var y = 0; y < tds.length; y++) { var lkey = this.VKI_layout[this.VKI_kt][x][y]; switch (lkey[1]) { case "Alt": case "AltGr": if (this.VKI_alternate) dead = true; break; case "Shift": if (this.VKI_shift) dead = true; break; case "Caps": if (this.VKI_capslock) dead = true; break; case "Tab": case "Enter": case "BackSpace": break; default: if (type) tds[y].firstChild.nodeValue = lkey[vchar + ((this.VKI_alternate && lkey.length == 4) ? 2 : 0)]; if (this.VKI_deadkeysOn) { var char = tds[y].firstChild.nodeValue; if (this.VKI_dead) { if (char == this.VKI_dead) dead = true; for (var z = 0; z < this.VKI_deadkey[this.VKI_dead].length; z++) if (char == this.VKI_deadkey[this.VKI_dead][z][0]) { target = true; break; } } for (key in this.VKI_deadkey) if (key === char) { alive = true; break; } } } if (y == tds.length - 1 && tds.length > this.VKI_keyCenter) tds[y].className += " last"; } } this.VKI_target.focus(); }; /* ****************************************************************** * Insert text at the cursor * */ /** * ÀÚÆÇÀÔ·Â * @param text: ÀԷ¹®ÀÚ */ this.VKI_insert = function(text) { this.VKI_target.focus(); if (this.VKI_target.setSelectionRange) { //Ãß°¡, ie¹öÀüüũ var ieversion = $("html").attr("class"); if(ieversion == "ie19" || ieversion == "ie8" || ieversion =="oldIE"){ var temp ="°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä"; if(temp == self.VKI_target.value){ this.VKI_target.value = ""; } this.VKI_target.value = this.VKI_target.value+text; }else{ var srt = this.VKI_target.selectionStart; var len = this.VKI_target.selectionEnd; this.VKI_target.value = this.VKI_target.value.substr(0, srt) + text + this.VKI_target.value.substr(len); //if (text == "\n" && window.opera) srt++; this.VKI_target.setSelectionRange(srt + text.length, srt + text.length); } } else if (this.VKI_target.createTextRange) { try { this.VKI_range.select(); } catch(e) {} this.VKI_range = document.selection.createRange(); this.VKI_range.text = text; this.VKI_range.collapse(true); this.VKI_range.select(); } else this.VKI_target.value += text; if (this.VKI_shift) this.VKI_modify("Shift"); if (this.VKI_alternate) this.VKI_modify("AltGr"); this.VKI_target.focus(); if(this.VKI_kt=='KR'){ for(i=0;i * Űº¸µå ÀÌ¿ëÇÏ¿© obj1°ªÀÌ º¯°æµÉ °æ¿ì obj1À» ¿µ¹®À¸·Î º¯°æÇÏ¿© ÇÑ±Û °ªÀ¸·Î º¯È¯ÇÑ´Ù. * @param obj1 ÇѱÛÀÔ·Â * @param obj2 ¿µ¹®ÀÔ·Â */ function englishToKorean(obj1,obj2) { // ÀÔ·ÂÇÑ ¿µ¹® ÅØ½ºÆ® ÃßÃâ var text = obj1.value; var eng_text=obj2.value; // º¯¼ö ÃʱâÈ­ var initialCode = -1; var medialCode = -1; var finalCode = 0; var temp=''; obj1.value = ""; // Ãß°¡, Űº¸µå»ó¿¡¼­ ¼öÁ¤µÈ °æ¿ì üũ if(text.length == 0 ){ obj2.value = ""; } // Ãß°¡, Űº¸µå»ó¿¡¼­ ¼öÁ¤µÈ °æ¿ì üũ var mod_eng_text=koreanToEnglish(text); // console.log("eng_text:"+eng_text); //console.log("mod_eng_text:"+mod_eng_text); if( mod_eng_text != eng_text ){ eng_text = mod_eng_text; } // ÀÔ·ÂÇÑ ¹®ÀÚ¿­ ±æÀÌ ÃßÃâ var textLength = eng_text.length; for( var idx = 0; idx < textLength; idx++ ) { initialCode=-1; medialCode=-1; finalCode=0; result=''; // Ãʼº ÄÚµå ÃßÃâ initialCode = getCode( 'initial', eng_text.substring( idx, idx + 1 ) ); if(initialCode<0){ medialCode = getCode( 'medial', eng_text.substring( idx, idx + 1 ) ); if(medialCode<0){ //Ãʼº, Áß¼º ´Ù ¾Æ´Ï¸é result=eng_text.substring(idx,idx+1); obj1.value+=result; //ÀÚµ¿¿Ï¼º À̺¥Æ® À§ÇÔ var e = $.Event("keydown",{keyCode: 229}); $('#search-text').trigger(e); continue; } } else{ if(getCode('initial',eng_text.substring(idx+1,idx+2))>=0){ if(getCode('final',eng_text.substring(idx,idx+2))>0&&idx+2<=textLength){ //Á¾¼ºÀ̸é finalCode=getCode('final',eng_text.substring(idx,idx+2)); result=String.fromCharCode(12593+finalCode-(finalCode<7?1:0)); obj1.value+=result; idx++; //ÀÚµ¿¿Ï¼º À̺¥Æ® À§ÇÔ var e = $.Event("keydown",{keyCode: 229}); $('#search-text').trigger(e); } else{ initialCode=initialCode/21/28; result=String.fromCharCode(12593+initialCode+(initialCode<2?0:initialCode<3?1:initialCode<6?3:initialCode<9?10:11)); obj1.value+=result; //ÀÚµ¿¿Ï¼º À̺¥Æ® À§ÇÔ var e = $.Event("keydown",{keyCode: 229}); $('#search-text').trigger(e); } continue } } if(medialCode<0){ //ù ¹®ÀÚ°¡ Áß¼ºÀÌ ¾Æ´Ï¸é idx++; // ´ÙÀ½ ¹®ÀÚ·Î. } /** * ÇöÀç ¹®ÀÚ¿Í ´ÙÀ½ ¹®ÀÚ¸¦ ÇÕÇÑ ¹®ÀÚ¿­ÀÇ Áß¼º ÄÚµå ÃßÃâ * ¤Î ( np ) ¶Ç´Â ¤¬ ( fq ) °°Àº µÎ°³ÀÇ ¹®ÀÚ°¡ µé¾î°¡´Â °ÍÀ» üũÇϱâ À§ÇÔ */ if(idx+2<=textLength){ tempMedialCode = getCode( 'medial', eng_text.substring( idx, idx + 2 ) ); } else{ tempMedialCode=-1; } // ÄÚµå °ªÀÌ ÀÖÀ» °æ¿ì if( tempMedialCode != -1 ) { // ÄÚµå °ªÀ» ÀúÀåÇϰí À妽º°¡ ´Ù´ÙÀ½ ¹®ÀÚ¿­À» °¡¸£Å°°Ô ÇÑ´Ù. medialCode = tempMedialCode; idx += 2; } else // Äڵ尪ÀÌ ¾øÀ» °æ¿ì ÇϳªÀÇ ¹®ÀÚ¿¡ ´ëÇÑ Áß¼º ÄÚµå ÃßÃâ { medialCode = getCode( 'medial', eng_text.substring( idx, idx + 1 ) ); idx++; } // ÇöÀç ¹®ÀÚ¿Í ´ÙÀ½ ¹®ÀÚ¸¦ ÇÕÇÑ ¹®ÀÚ¿­ÀÇ Á¾¼º ÄÚµå ÃßÃâ if(idx+2<=textLength){ tempFinalCode = getCode( 'final', eng_text.substring( idx, idx + 2 ) ); } else{ tempFinalCode=-1; } // ÄÚµå °ªÀÌ ÀÖÀ» °æ¿ì if( tempFinalCode != -1 ) { // ÄÚµå °ªÀ» ÀúÀåÇÑ´Ù. finalCode = tempFinalCode; // ±× ´ÙÀ½ÀÇ Áß¼º ¹®ÀÚ¿¡ ´ëÇÑ Äڵ带 ÃßÃâÇÑ´Ù. tempMedialCode = getCode( 'medial', eng_text.substring( idx + 2, idx + 3 ) ); // ÄÚµå °ªÀÌ ÀÖÀ» °æ¿ì if( tempMedialCode != -1 ) { // Á¾¼º ÄÚµå °ªÀ» ÀúÀåÇÑ´Ù. finalCode = getCode( 'final', eng_text.substring( idx, idx + 1 ) ); } else { idx++; } } else // ÄÚµå °ªÀÌ ¾øÀ» °æ¿ì { // ±× ´ÙÀ½ÀÇ Áß¼º ¹®ÀÚ¿¡ ´ëÇÑ ÄÚµå ÃßÃâ tempMedialCode = getCode( 'medial', eng_text.substring( idx + 1, idx + 2 ) ); // ±× ´ÙÀ½¿¡ Áß¼º ¹®ÀÚ°¡ Á¸ÀçÇÒ °æ¿ì if( tempMedialCode != -1 ) { // Á¾¼º ¹®ÀÚ´Â ¾øÀ½. finalCode = 0; idx--; } else { // Á¾¼º ¹®ÀÚ ÃßÃâ finalCode = getCode( 'final', eng_text.substring( idx, idx + 1 ) ); if(finalCode<0){ //Á¾¼ºÀÌ ¾Æ´Ï°í var tmep_initialCode = getCode( 'initial', eng_text.substring( idx, idx + 1 ) ); if(tmep_initialCode<0){ //Ãʼºµµ ¾Æ´Ï¸é temp=eng_text.substring(idx,idx+1); } else{ idx--; } finalCode=0; } } } // ÃßÃâÇÑ Ãʼº ¹®ÀÚ ÄÚµå, Áß¼º ¹®ÀÚ ÄÚµå, Á¾¼º ¹®ÀÚ Äڵ带 ÇÕÇÑ ÈÄ º¯È¯ÇÏ¿© Ãâ·Â if(initialCode<0){ if(medialCode>=0){ result=String.fromCharCode(12623+medialCode/28); } } else{ if(medialCode<0){ initialCode=initialCode/21/28; result=String.fromCharCode(12593+initialCode+(initialCode<2?0:initialCode<3?1:initialCode<6?3:initialCode<9?10:11)); } else{ result = String.fromCharCode( 44032 + initialCode + medialCode + finalCode ); } } obj1.value += (result+temp); temp=''; //ÀÚµ¿¿Ï¼º À̺¥Æ® À§ÇÔ var e = $.Event("keydown",{keyCode: 229}); $('#search-text').trigger(e); } } /** * ÇØ´ç ¹®ÀÚ¿¡ µû¸¥ Äڵ带 ÃßÃâÇÑ´Ù. * @param type Ãʼº : chosung, Áß¼º : jungsung, Á¾¼º : jongsung ±¸ºÐ * @param char ÇØ´ç ¹®ÀÚ */ function getCode( type, char ) { // Ãʼº var initial = "rRseEfaqQtTdwWczxvg"; // Áß¼º var medial = new Array( 'k', 'o', 'i', 'O', 'j', 'p', 'u', 'P', 'h', 'hk', 'ho', 'hl', 'y', 'n', 'nj', 'np', 'nl', 'b', 'm', 'ml', 'l' ); // Á¾¼º var final = new Array( 'r', 'R', 'rt', 's', 'sw', 'sg', 'e', 'f', 'fr', 'fa', 'fq', 'ft', 'fx', 'fv', 'fg', 'a', 'q', 'qt', 't', 'T', 'd', 'w', 'c', 'z', 'x', 'v', 'g' ); var returnCode; // ¸®ÅÏ ÄÚµå ÀúÀå º¯¼ö var isFind = false; // ¹®ÀÚ¸¦ ã¾Ò´ÂÁö üũ º¯¼ö if( type == 'initial' ) { returnCode = initial.indexOf( char ) * 21 * 28; isFind = true; } else if( type == 'medial' ) { for( var i = 0; i < medial.length; i++ ) { if( medial[i] == char ) { returnCode = i * 28; isFind = true; break; } } } else if( type == 'final' ) { for( var i = 0; i < final.length; i++ ) { if( final[i] == char ) { returnCode = i + 1; isFind = true; break; } } } else { alert("À߸øµÈ ŸÀÔÀÔ´Ï´Ù."); } if( isFind == false ) returnCode = -1; // °ªÀ» ãÁö ¸øÇßÀ» °æ¿ì -1 ¸®ÅÏ return returnCode; } /** * °Ë»ö¾î¸¦ ±âÁØÀ¸·Î ¿µÅ¸ ÃßÃâ * @param src ÇÑ±Û */ function koreanToEnglish(src) { var ENG_KEY = "rRseEfaqQtTdwWczxvgkoiOjpuPhynbml"; var KOR_KEY = "¤¡¤¢¤¤¤§¤¨¤©¤±¤²¤³¤µ¤¶¤·¤¸¤¹¤º¤»¤¼¤½¤¾¤¿¤À¤Á¤Â¤Ã¤Ä¤Å¤Æ¤Ç¤Ë¤Ì¤Ð¤Ñ¤Ó"; var CHO_DATA = "¤¡¤¢¤¤¤§¤¨¤©¤±¤²¤³¤µ¤¶¤·¤¸¤¹¤º¤»¤¼¤½¤¾"; var JUNG_DATA = "¤¿¤À¤Á¤Â¤Ã¤Ä¤Å¤Æ¤Ç¤È¤É¤Ê¤Ë¤Ì¤Í¤Î¤Ï¤Ð¤Ñ¤Ò¤Ó"; var JONG_DATA = "¤¡¤¢¤£¤¤¤¥¤¦¤§¤©¤ª¤«¤¬¤­¤®¤¯¤°¤±¤²¤´¤µ¤¶¤·¤¸¤º¤»¤¼¤½¤¾"; // ÀÔ·ÂÇÑ ¿µ¹® ÅØ½ºÆ® ÃßÃâ //var text = obj1.value; var res =""; // ÀÔ·ÂÇÑ ¹®ÀÚ¿­ ±æÀÌ ÃßÃâ var textLength = src.length; if (textLength == 0) return res; for (var i = 0; i < textLength; i++) { var ch = src.charAt(i); //¹®ÀÚ¿­¸®ÅÏ var nCode = ch.charCodeAt(0); //À¯´ÏÄڵ尪 ¸®ÅÏ var nCho = CHO_DATA.indexOf(ch), nJung = JUNG_DATA.indexOf(ch), nJong = JONG_DATA.indexOf(ch); //Ãʼº var arrKeyIndex = [-1, -1, -1, -1, -1]; // À¯´ÏÄÚµå ÀÌ¿ëÇÏ¿© °ª if (0xac00 <= nCode && nCode <= 0xd7a3) { nCode -= 0xac00; arrKeyIndex[0] = Math.floor(nCode / (21 * 28)); // Ãʼº arrKeyIndex[1] = Math.floor(nCode / 28) % 21; // Áß¼º arrKeyIndex[3] = nCode % 28 - 1; // Á¾¼º } else if (nCho != -1) // Ãʼº ÀÚÀ½ arrKeyIndex[0] = nCho; else if (nJung != -1) // Áß¼º arrKeyIndex[1] = nJung; else if (nJong != -1) // Á¾¼º ÀÚÀ½ arrKeyIndex[3] = nJong; else // ÇѱÛÀÌ ¾Æ´Ô res += ch; // ½ÇÁ¦ Key Index·Î º¯°æ. ÃʼºÀº ¼ø¼­ µ¿ÀÏ if (arrKeyIndex[1] != -1) { if (arrKeyIndex[1] == 9) { // ¤È arrKeyIndex[1] = 27; arrKeyIndex[2] = 19; } else if (arrKeyIndex[1] == 10) { // ¤É arrKeyIndex[1] = 27; arrKeyIndex[2] = 20; } else if (arrKeyIndex[1] == 11) { // ¤Ê arrKeyIndex[1] = 27; arrKeyIndex[2] = 32; } else if (arrKeyIndex[1] == 14) { // ¤Í arrKeyIndex[1] = 29; arrKeyIndex[2] = 23; } else if (arrKeyIndex[1] == 15) { // ¤Î arrKeyIndex[1] = 29; arrKeyIndex[2] = 24; } else if (arrKeyIndex[1] == 16) { // ¤Ï arrKeyIndex[1] = 29; arrKeyIndex[2] = 32; } else if (arrKeyIndex[1] == 19) { // ¤Ò arrKeyIndex[1] = 31; arrKeyIndex[2] = 32; } else { arrKeyIndex[1] = KOR_KEY.indexOf(JUNG_DATA.charAt(arrKeyIndex[1])); arrKeyIndex[2] = -1; } } if (arrKeyIndex[3] != -1) { if (arrKeyIndex[3] == 2) { // ¤£ arrKeyIndex[3] = 0; arrKeyIndex[4] = 9; } else if (arrKeyIndex[3] == 4) { // ¤¥ arrKeyIndex[3] = 2; arrKeyIndex[4] = 12; } else if (arrKeyIndex[3] == 5) { // ¤¦ arrKeyIndex[3] = 2; arrKeyIndex[4] = 18; } else if (arrKeyIndex[3] == 8) { // ¤ª arrKeyIndex[3] = 5; arrKeyIndex[4] = 0; } else if (arrKeyIndex[3] == 9) { // ¤« arrKeyIndex[3] = 5; arrKeyIndex[4] = 6; } else if (arrKeyIndex[3] == 10) { // ¤¬ arrKeyIndex[3] = 5; arrKeyIndex[4] = 7; } else if (arrKeyIndex[3] == 11) { // ¤­ arrKeyIndex[3] = 5; arrKeyIndex[4] = 9; } else if (arrKeyIndex[3] == 12) { // ¤® arrKeyIndex[3] = 5; arrKeyIndex[4] = 16; } else if (arrKeyIndex[3] == 13) { // ¤¯ arrKeyIndex[3] = 5; arrKeyIndex[4] = 17; } else if (arrKeyIndex[3] == 14) { // ¤° arrKeyIndex[3] = 5; arrKeyIndex[4] = 18; } else if (arrKeyIndex[3] == 17) { // ¤´ arrKeyIndex[3] = 7; arrKeyIndex[4] = 9; } else { arrKeyIndex[3] = KOR_KEY.indexOf(JONG_DATA.charAt(arrKeyIndex[3])); arrKeyIndex[4] = -1; } } for (var j = 0; j < 5; j++) { if (arrKeyIndex[j] != -1) res += ENG_KEY.charAt(arrKeyIndex[j]); } } return res; }