Changes between Version 40 and Version 41 of 한영타변환기


Ignore:
Timestamp:
Feb 19, 2021, 9:47:19 AM (3 years ago)
Author:
YT Hwang
Comment:

입력란 비우기, 결과 복사 버튼을 추가

Legend:

Unmodified
Added
Removed
Modified
  • 한영타변환기

    v40 v41  
    1313
    1414 * (12/09/19) 여러 브라우저에서 사용할 수 있도록 JavaScript로 변환하였습니다.
     15 * (21/02/19) 입력란 비우기, 결과 복사 버튼을 추가했습니다.
    1516
    1617{{{#!html
     
    2324}}}
    2425{{{#!table id="convform"
    25 ||= 문장 입력:=||[[html(<textarea id="txtSource" rows="4" cols="60" onKeyUp="doConvert();"></textarea>)]]||
    26 ||||  [[html(<input type="radio" id="optEtoH" name="Mode" checked="checked" onClick="doConvert();"><label for="optEtoH">영타 → 한글</label>)]][[span( )]][[html(<input type="radio" id="optHtoE" name="Mode"><label for="optHtoE" onClick="doConvert();">한타 → 영문</label>)]]  ||
    27 ||= 변환 결과:=||[[html(<textarea id="txtConv" rows="4" cols="60" readonly="readonly"></textarea>)]]||
     26||= 문장 입력:=||[[html(<textarea id="txtSource" rows="4" cols="60" onKeyUp="doConvert();"></textarea>)]]||  [[html(<button onClick="clearText();">비우기</button>)]]  ||
     27||||||  [[html(<input type="radio" id="optEtoH" name="Mode" checked="checked" onClick="doConvert();"><label for="optEtoH">영타 → 한글</label>)]][[span( )]][[html(<input type="radio" id="optHtoE" name="Mode" onClick="doConvert();"><label for="optHtoE">한타 → 영문</label>)]]  ||
     28||= 변환 결과:=||[[html(<textarea id="txtConv" rows="4" cols="60" readonly="readonly"></textarea>)]]||  [[html(<button onClick="copyResult();">복사</button>)]]  ||
    2829}}}
    2930{{{#!html
     
    3738
    3839function doConvert() {
    39         if (optEtoH.checked)
    40                 txtConv.value = engTypeToKor(txtSource.value);
    41         else
    42                 txtConv.value = korTypeToEng(txtSource.value);
     40        const srcElem = document.getElementById("txtSource");
     41        const destElem = document.getElementById("txtConv");
     42
     43        if (optEtoH.checked) {
     44                destElem.value = engTypeToKor(srcElem.value);
     45        } else {
     46                destElem.value = korTypeToEng(srcElem.value);
     47        }
    4348}
    4449
     
    359364        return res;
    360365}
     366
     367function clearText() {
     368        const srcElem = document.getElementById("txtSource");
     369        const destElem = document.getElementById("txtConv");
     370
     371        srcElem.value = "";
     372        destElem.value = "";
     373}
     374
     375function copyResult() {
     376        const destElem = document.getElementById("txtConv");
     377        destElem.select();
     378        const res = document.execCommand("copy");
     379        if (!res) {
     380                window.alert("결과를 복사할 수 없습니다.");
     381        }
     382}
    361383-->
    362384</script>