<div class="summary">
	<p><span>공백 포함</span><strong class="letter" id="current_msglen">13</strong><span>자</span><strong class="byte" id="current_msg_byte">13</strong><span>byte</span></p>
	<p><span>공백 제외</span><strong class="letter" id="current_msglen_except_blank">13</strong><span>자</span><strong class="byte" id="current_msg_byte_except_blank">13</strong><span>byte</span></p>
</div>

<textarea name="content" id="character_counter_content" cols="70" rows="22" class="checker_input" placeholder="내용을 입력해주세요."></textarea>

 

 

 

(function (window, $, undefined) {
var $character_counter_content = $('#character_counter_content'), $checker_preview = $('#checker_preview'), $spell_check = $("#spell_check"), $spell_completion = $('#spell_completion'),
    $checker_spell = $('.checker_spell'), $result_pre = $('#result_pre'), $title_sub =  $('#title_sub'), $spell_count = $('#spell_count'), $checker_result = $('#checker_result'),
    $layer_suggetion = $('#layer_suggetion'), $spell_form = $('#spell_form'), $st_len = $('#current_msglen'), $st_byte = $('#current_msg_byte'), $steb_len = $('#current_msglen_except_blank'),
    $steb_byte = $('#current_msg_byte_except_blank');

//맞춤법 검사 버튼
$spell_check.on('click', function() {
    spellCheck();
});

//검사완료
$spell_completion.on('click', function() {
    spellCheckDone();
});

//일괄수정
$("#spell_done_all").on('click', function() {
    spellDoneAll();
});
//복사 하기 
$("#copy_all").on('click', function() {
    copyAll();
});
//초기화
$("#spell_reset").on('click', function() {
    SpellReset();
});
//실시간 글자수 세기
$character_counter_content.keyup(function() {
    chkMsgLength(this);
});

//레이어 팝업 
$(document).on('click','.spell_done' ,function(){
    spellDone(this);
});





function copyAll() {
    if($character_counter_content.val() === ''){
        alert('내용을 입력 해주세요.');
        return;
    }

    if($checker_preview.text() === '') { // 맞춤법 검사 여부 확인
        $character_counter_content.select();
        document.execCommand('copy');
    }else{
        var originalText =  $character_counter_content.val();
        var changeText = $checker_preview.text();
        $checker_preview.hide();
        $character_counter_content.val(changeText);
        $character_counter_content.show();
        $character_counter_content.select();
        document.execCommand('copy');
        $character_counter_content.hide();
        $character_counter_content.val(originalText);
        $checker_preview.show();
    }

    alert("입력하신  내용이 복사되었습니다.\n\nCtrl + v 키를 사용하여, 붙여 넣기를 사용하실 수 있습니다.");

    setTimeout(function() {
        try {
            if (document.selection) {
                document.selection.empty();
            } else {
                window.getSelection().removeAllRanges();
            }
        } catch (e) {}
    }, 1);
}


//맞춤법 검사
function spellCheck() {
    if($character_counter_content.val() === ''){
        alert('내용을 입력 해주세요.');
        return;
    }
    $result_pre.addClass('loading');
    $spell_check.prop('disabled', true);
    var $params = $checker_spell.find('textarea').serializeArray();
    $.ajax({
        url: '/zf_user/tools/spell-check',
        data: $params,
        type: 'post',
        dataType: 'json'
    }).success(function (result) {
            $character_counter_content.hide();
            $checker_preview.show();
            $spell_check.prop('disabled', false).hide();
            $spell_completion.show();
            $result_pre.removeClass('loading').hide(); //맞춤법 검사 시작 텍스트 숨김
            $title_sub.show(); //맞춤법 오류 리스트 노출
            $checker_preview.append(result.result_text);
            $spell_count.html('' + result.result_cnt +'개');
            if(result.result_cnt === 0){
                $checker_result.show().append('

검사 결과 맞춤법 오류가 없습니다.

');
            }else{
                $checker_result.show().append(result.speller_list);
            }
            $layer_suggetion.append(result.popup_speller_list);


    }).error(function() {

    });
}

//검사 완료
function  spellCheckDone(){
    var changeText = $checker_preview.text();
    $character_counter_content.val(changeText);
    $checker_preview.html('');
    $checker_preview.css('display','none');
    $character_counter_content.css('display','block');
    $title_sub.hide(); // 맞춤법 오류 리스트 영역 숨김
    $result_pre.show(); // 검사 버튼 눌러주세요 텍스트 노출
    $layer_suggetion.find('dl').remove();//레이어 팝업 초기화
    $checker_result.empty().hide(); //맞춤법 검사 초기화
    $spell_count.html(0 + '개'); //맞춤법 오류 갯수 초기화
    $layer_suggetion.css('display','none');
    $layer_suggetion.find('div').remove();
    $spell_completion.hide();
    $spell_check.show();
}

//초기화
/**
 * @return {boolean}
 */
function SpellReset(){

    if ( $character_counter_content.val() && !confirm('작성한 내용을 모두 삭제하시겠습니까?') ) {
        return false;
    }

    $spell_form[0].reset();
    $checker_preview.html('');
    $checker_preview.css('display','none');
    $character_counter_content.css('display','block');
    $spell_completion.hide();
    $spell_check.show();
    $title_sub.hide(); // 맞춤법 오류 리스트 영역 숨김
    $result_pre.show(); // 검사 버튼 눌러주세요 텍스트 노출
    $layer_suggetion.find('dl').remove();//레이어 팝업 초기화
    $layer_suggetion.css('display','none');
    $layer_suggetion.find('div').remove();
    $checker_result.empty().hide(); //맞춤법 검사 초기화
    $spell_count.html(0 + '개'); //맞춤법 오류 갯수 초기화
    $st_len.html(0);
    $st_byte.html(0);
    $steb_len.html(0);
    $steb_byte.html(0);
    return false;
}
//맞춤법 수정 갯수 확인 후 바꿔 준다.
function spellCheckConut(){
    var eorr_cnt;
    eorr_cnt = $spell_form.find('.wrong').length - $spell_form.find('.wrong.solved').length; //맞춤법 수정 전 - 수정후
    if(eorr_cnt > 0) {
        $spell_count.html('' + eorr_cnt + '개');
    } else {
        $spell_count.html(eorr_cnt + '개');
    }

}

//텍스트 교체
function spellDone(obj) {
    var index = $(obj).attr('value');//바꿀 단어
    var data_index = $(obj).attr('data-value');//단어 index
    $checker_preview.find('span.wrong').eq(data_index).addClass('solved').text(index); //바꿀단어로 텍스트 교체
    $checker_preview.find('span.wrong').eq(data_index).attr('original-text',index); //바꿀단어로 텍스트 교체
    $layer_suggetion.css('display','none');//교체  후 팝업 숨김
    chkMsgLength($checker_preview,'after'); //텍스트 길이 계산
    spellCheckConut();//맞춤법 갯수 확인
}

//일괄 수정
function spellDoneAll() {
    var error_word = $spell_form.find('.wrong');
    var button_first = $checker_result.find('button:first-child');
    error_word.each(function(i){
        $(this).addClass('solved').text(button_first.eq(i).html());
        $(this).attr('original-text',button_first.eq(i).html());
    });
    chkMsgLength($checker_preview,'after'); //텍스트 길이 계산
    spellCheckConut();//맞춤법 갯수 확인
    $layer_suggetion.css('display','none');
}



//텍스트 길이 계산
function chkMsgLength(objMsg,textType) {
    //공백 포함
    var vacuum_pattern = /\r\n/gm;
    var vacuum_text;
    var vacuum_length;
    //공백 미포함
    var vacuum_remove_pattern = /\s/gm;
    var vacuum_remove_text;
    var vacuum_remove_length;

    if(textType === 'after') {
        vacuum_text = $(objMsg).text();
        vacuum_length = lengthMsg(objMsg.text());
        vacuum_remove_length = lengthMsg($.trim(objMsg.text().replace(/ /g, '')));
    }else{
        vacuum_text = $(objMsg).val();
        vacuum_length = lengthMsg($(objMsg).val());
        vacuum_remove_length = lengthMsg(vacuum_text.replace(vacuum_remove_pattern,''));
    }
    vacuum_text = vacuum_text.replace(vacuum_pattern,'\n');
    vacuum_remove_text = vacuum_text.replace(vacuum_remove_pattern,'');

    $st_len.html(vacuum_text.length);//현재 글자수를 넣는다
    $st_byte.html(vacuum_length);//현재 byte수를 넣는다
    $steb_len.html(vacuum_remove_text.length);//현재 글자수를 넣는다
    $steb_byte.html(vacuum_remove_length);//현재 byte수를 넣는다
}

//텍스트 바이트단위 계산
function lengthMsg(obj_msg) {
    var nbytes = 0;
    var i;
    for (i = 0; i < obj_msg.length; i++) {
        var ch = obj_msg.charAt(i);
        if (encodeURIComponent(ch).length > 4) { // 한글일경우
            nbytes += 2;
        } else if (ch === '\n') { // 줄바꿈일경우
            if (obj_msg.charAt(i - 1) !== '\r') { // 하지만 밀려서 줄이 바뀐경우가 아닐때
                nbytes += 1;
            }
        } else { //나머지는 모두 1byte
            nbytes += 1;
        }
    }//END FOR
    return nbytes;
}
})(window, jQuery, undefined);

by 으스스 2019. 4. 14. 21:46

고객사 요청에 따라 <a href="/ekp/docs/manual/phone_directory.mht"~~~~ 식으로 확장자 mht 링크를 걸어줬다.

그런데... 반영 이후 해당 링크를 눌렀을 때 아래와 같이 익스플로러 브라우저에 출력이 되었다.

MIME-Version: 1.0
X-Document-Type: Workbook
Content-Type: multipart/related; boundary="----=_NextPart_01CF2D62.C56FFF10"

이 문서는 웹 보관 파일입니다. 이 메시지가 나타나면 사용자의 브라우저나 편집기에서 웹 보관 파일이 지원되지 않는 것입니다. Windows® Internet Explorer®와 같이 웹 보관 파일을 지원하는 브라우저를 다운로드하십시오.

------=_NextPart_01CF2D62.C56FFF10
Content-Location: file:///C:/506BCAB9/phone_directory.htm
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="us-ascii"


IE10으로도 IE11로도 똑같이 출력되기에 뭐가 문젠지 모르다가 혹시 웹서버 설정이 잘못된게 아닌가 생각이 들었다.

결국 해결했는데 경로는 다음과 같다

웹서버 web.xml에서 아래와 같은 MIME Type Mapping을 해주도록 하자!

<mime-mapping> 

    <extension>mht</extension>

    <mime-type>message/rfc822</mime-type> 

</mime-mapping>

로컬에서 테스트 해보니 잘되더라.. 이걸로 3시간이나 잡아먹었다 하...

해당 문제에 대해 참고할만한 사이트 

http://ko.wikipedia.org/wiki/MIME -위키백과

http://blog.naver.com/hipnos?Redirect=Log&logNo=80180230723 - mht 파일 직접열기 실패


'Programming > 개발 노트' 카테고리의 다른 글

입력값에 null/Empty 있는 경우 처리  (0) 2013.12.24
[iBatis] Dynamic SQL, iterate  (0) 2013.12.24
VirtualBox 다루기!!  (0) 2013.10.29
forward와 redirect의 차이  (0) 2013.10.28
by 으스스 2014. 2. 19. 16:07

iBatis 사용시 NULL 에 대한 주의 할 점.

1. 입력값이 빈 경우 처리

<isNotEmpty property="detailStatsKind">
      AND STATS_DETAIL_SE = #detailStatsKind#
</isNotEmpty>

2. biding 되는 값 중 NULL 이 있을 경우 기본값(default-value)로 치환 하는 법.
    <resultMap>
       <result property="valueObject-Field-Name"     column="Column-NamenullValue='0'/>
    </resultMap>

 와 같이 <result property    /> 에 nullValue= 를 이용하여 기본값을 얻어 올 수 있도록 한다.

위와 같이 하지 않을 경우, int-type 을 return  받길 예상 했으나, 적당한 값이 Bind 되지 않아 NULL 이

반환되면 result-Map 의 Class 에 정의한 int-type 변수와 null 이 만나게 되어 Exception 이 발생합니다.

3. parameter 인자가 NULL 이 전달 될 때, 적절한 값으로 type-casting 이 되지 않아, 예외가 발생.

Inser into table(A, b, c, d) values(#a-value#, #b-value#, #c-value#,#d-value#);

와 같이 sql 을 작성하고 , 파라메터 클래스를 이용하여 파라메터를 전달 할 때, 파라메터가 NULL-value 를 

전달 하게 되면, casting 에 문제가 생길 수 있습니다.

Interger-Class 또한 NULL-value 를 받아 넣을 수 있기 때문에, 그런지 정확한 type명시기 필요 합니다.

비단 insert 의 경우 뿐 아니라, 파라메터를 전달하는 모든 경우에 해당 될 수 있습니다.

따라서 아래와 같이 수정/정리 할 수 있습니다.

Inser into table(A, b, c, d) values(#a-value#, #b-value#, #c-value#,#d-value#);

==> Inser into table(A, b, c, d) values(#a-value:VARCHAR:NO_ENTRY#
                                                , #b-value:VARCHAR:
NO_ENTRY#
                                                 ,#c-value
:VARCHAR:NO_ENTRY#
                                                 ,#d-value
:VARCHAR:NO_ENTRY#);

    설명.
    #{parameter-Name}:{value-type}:{default-value}#

[출처] ibatis nullValue|작성자 tkgotjd


출처 : http://blog.naver.com/PostView.nhn?blogId=mankeys&logNo=161195599

'Programming > 개발 노트' 카테고리의 다른 글

mht가 이상하게 열린다?!  (0) 2014.02.19
[iBatis] Dynamic SQL, iterate  (0) 2013.12.24
VirtualBox 다루기!!  (0) 2013.10.29
forward와 redirect의 차이  (0) 2013.10.28
by 으스스 2013. 12. 24. 10:28
| 1 2 3 |