반응형

 jquery 사용

 

1
2
3
4
5
6
7
8
9
10
11
$('.form-control').on("keydown"function(e) {
            var keyCode = e.keyCode;
            console.log(e.keyCode);
            if(keyCode === 39){ // Enter key
                if($(this).parent().next().find('input').attr('name'=== 'prdctAmt') {
                    $(this).parent().parent().next().find('input:eq(0)').focus();
                } else {
                    $(this).parent().next().find('input').focus();
                }
            }
        });

원하는 요소(ex. from=control 클래스를 가진 요소들) 에 keydown 이벤트 리스너를 추가 

4번째 if -> keyCode 가 39번(방향키 ->) 인 경우를 찾는다

그 뒤로 8번째 줄에서 내가 이동하고 싶은 input으로 focust(); 를 주면 된다.

 

5번째 줄 if의 경우는 내가 사용하는 경우로 1라인의 input 이 끝나는 지점에서는 다음 라인의 input으로 이동하도록 구현해 놓은 코드

 

 

 

순수 javascript

1
2
3
4
5
6
7
8
9
10
var formControl = document.getElementsByClassName('form-control');
        for(var i=0; i<formControl.length; i++) {
            formControl[i].addEventListener('keydown'function(e){
                var keyCode = e.keyCode;
                console.log('pushed key ' + e.key);
                if(keyCode == 39){ // Enter key
 
                }
            })
        }

 

반응형
반응형

ㅁ 핫딜 모아모아의 개편 

 - 디자인 수정

     -> bootstrap 템플릿 적ㅇㅇ 

 - vue 에서 jsp 로 재 변경

 - 이와중에 스프링부트 jar로 패키징 시 jsp 파일을 인식 못하는 에러 발생 

 -  여러 방법을 써봤지만 어떤 방법에서도 webapp/WEB-INF/jsp 이 경로의 파일을 jar로 패키징 하지 못함

 - 결국 war로 패키징 시 정상 작동 확인 

 

ㅁ 추가 개편 사항

   ㅁ 회원 붙이고, 메일 알림 서비스 

   ㅁ 페이징 기능 추가 

   ㅁ 스케줄러 배치로 분리, 데이터 저장 기능 따로 분리 ( MSA 적용 )

 

반응형
반응형

<input type="checkbox" :id="'prdctFix_'+index" name="prdctfixyn" v-model="prdctFix.fixYn == 'Y' ? true : false" hidden>

 

 

위에거 안됌

 

:checked="prdctFix.fixYn == 'Y' ? true : false"

 

이걸로 써야돼 ㅁ

반응형
반응형

매핑 시켜놨떤 모델을 한번 만 실행하여 모델 값이 변하더라도 그 값이 변하지 않도록 하는 법

v-once

<span v-once>{{test.name}}</span>

 

input 안에 disabled 부여

<input ~~ :disabled="조건식 or boolean 값"

 

:disabled="devCtcsm.ctcsmScore == null "

href에 바인드 시킬때

<a v-bind:href="url"> ... </a>

 

엔티티 내 다른 엔티티를 필드로 가지고 있을 경우 화면에서 엔티티 접근법

<a v-bind:href="prdct.rwmtrlCncptRealFile.path"      X

<a v-bind:href="(prdct.rwmtrlCncptRealFile).path"    O

 

위의 예시처럼 상위 엔티티를 괄호로 감싸주어야 만 접근이 가능하다.

 

 

반응형
반응형
var formData = new FormData();

formData.append('key1', 'value1');

formData.append('key2', 'value2');



for (var pair of formData.entries()) {
console.log(pair[0]+ ', ' + pair[1]);
}

 

반응형
반응형
//사업자등록번호 체크
function checkBizID(that)
{
// bizID는 숫자만 10자리로 해서 문자열로 넘긴다.
var checkID = new Array(1, 3, 7, 1, 3, 7, 1, 3, 5, 1);
var tmpBizID, i, chkSum = 0, c2, remander;
var bizID = $(that).val();
bizID = bizID.replace(/-/gi, '');

for (i = 0; i <= 7; i++) chkSum += checkID[i] * bizID.charAt(i);
c2 = "0" + (checkID[8] * bizID.charAt(8));
c2 = c2.substring(c2.length - 2, c2.length);
chkSum += Math.floor(c2.charAt(0)) + Math.floor(c2.charAt(1));
remander = (10 - (chkSum % 10)) % 10;

if (Math.floor(bizID.charAt(9)) == remander) return true; // OK!
else {
$(that).val("");
Alert.warn("사업자 번호를 확인하세요.");
return false;
}

}


//법인등록번호 체크
function checkCorNo(that) {
var re = /-/g;
var sRegNo = $(that).val();
sRegNo = sRegNo.replace('-', '');
if (sRegNo.length == 13) {
var arr_regno = sRegNo.split("");
var arr_wt = new Array(1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2);
var iSum_regno = 0;
var iCheck_digit = 0;
for (i = 0; i < 12; i++) {
iSum_regno += eval(arr_regno[i]) * eval(arr_wt[i]);
}
iCheck_digit = 10 - (iSum_regno % 10);
iCheck_digit = iCheck_digit % 10;
if (iCheck_digit != arr_regno[12]) {
Alert.warn("법인등록번호를 확인하세요.");
return false;
}
return true;

}
else {
$(that).val("");
return false;
}
}

/* ajax setup */
//Ajax 로딩 페이지
$.ajaxSetup({
// timeout: 10000,
beforeSend: function() {
$('#ajax-loading').show();
}, complete: function() {
$('#ajax-loading').hide();
}, error: function(jqXHR, textStatus, errorThrown) {
if (textStatus === 'abort') {
return false;
} else {
Alert.error(jqXHR.status);
}
}
});

// 3자리 마다 콤마 찍기
function addComma(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}


/**
* 숫자만 입력 함수
* 사용법 : onKeyPress = onlyNum4();
* */
function onlyNum4() {
if (event.keyCode < 48 || event.keyCode > 57)
event.returnValue = false;
}

$(function () {
    //클래스에 number 를 추가해서 컨트롤 하는 방법
$(document).on("keypress", "input[type=text].number", function () {
if((event.keyCode<48)||(event.keyCode>57))
event.returnValue=false;
});

$(document).on("keyup", "input[type=text].number", function () {
var $this = $(this);
var num = $this.val().replace(/[,]/g, "");
var parts = num.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
$this.val(parts.join("."));
});


});

/**
* 자동 콤마 입력
* 사용법 : onKeyPress = onlyNum4();
* */
function inputNumberFormat(obj) {
obj.value = comma(uncomma(obj.value));
}

function comma(str) {
str = String(str);
return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
}

function uncomma(str) {
str = String(str);
return str.replace(/[^\d]+/g, '');
}

/**한글만 입력
* 사용법
* onkeyup="Common2.checkEngNum(this)"
* */
function checkHan(that) {
var reg = /[^가-힣ㄱ-ㅎ]/gi;
var v = String($(that).val());
if (reg.test(v)) {
$(that).val(v.replace(reg, ''));
$(that).focus();
}
}
/**숫자만 입력
* 사용법
* onkeyup="Common2.checkNum(this)"
* */
function checkNum(that) {
var reg = /[^0-9]/gi;
var v = String($(that).val());
if (reg.test(v)) {
$(that).val(v.replace(reg, ''));
$(that).focus();
}
}

/**영어숫자 만 입력
* 사용법
* onkeyup="Common2.checkEngNum(this)"
* */
function checkEngNum(that) {
var reg = /[^0-9a-zA-Z]/gi;
var v = String($(that).val());
if (reg.test(v)) {
$(that).val(v.replace(reg, ''));
$(that).focus();
}
}

/**한글,영어 만 입력
* 사용법
* onkeyup="Common2.checkHanEng(this)"
* */
function checkHanEng(that) {
var reg = /[^가-힣a-zA-Zㄱ-ㅎ]/gi;
var v = String($(that).val());
if (reg.test(v)) {
$(that).val(v.replace(reg, ''));
$(that).focus();
}
}
/**한글,영어, 특수 문자 만 입력
* 사용법
* onkeyup="Common2.checkHanEngSpel(this)"
* */
function checkHanEngSpel(that) {
var reg = /[^가-힣a-zA-Zㄱ-ㅎ~!@\#$%<>^&*\()\-=+_\’]/gi;
var v = String($(that).val());
if (reg.test(v)) {
$(that).val(v.replace(reg, ''));
$(that).focus();
}
}

/** 숫자,- 만 입력
* 사용법
* onkeyup="Common2.checkNumHyphen(this)"
* */
function checkNumHyphen(that) {
var reg = /[^0-9|-]/gi;
var v = String($(that).val());
if (reg.test(v)) {
$(that).val(v.replace(reg, ''));
$(that).focus();
}
}

/**핸드폰 번호 유효성 확인
* 사용법
* onblur="Common2.checkPhoneNum(this)"
* */
function checkPhoneNum(taht) {
var trans_num = $(taht).val();
if (!trans_num) {
return;
}
else {
// 기존 번호에서 - 를 삭제합니다.
var trans_num = String($(taht).val()).replace(/-/gi, '');

if (trans_num != null && trans_num != '') {
// 총 핸드폰 자리수는 11글자이거나, 10자여야 합니다.
if (trans_num.length == 11 || trans_num.length == 10) {
// 유효성 체크
var regExp_ctn = /^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})([0-9]{3,4})([0-9]{4})$/;
if (regExp_ctn.test(trans_num)) {
// 유효성 체크에 성공하면 하이픈을 넣고 값을 바꿔줍니다.
trans_num = trans_num.replace(/^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-?([0-9]{3,4})-?([0-9]{4})$/, "$1-$2-$3");
$(taht).val(trans_num);
}
else {
Alert.warn("유효하지 않은 휴대폰번호 입니다.");
$(taht).val("");
$(taht).focus();
}
}
else {
Alert.warn("유효하지 않은 휴대폰번호 입니다.");
$(taht).val("");
$(taht).focus();
}
}
}

}
/**이메일 유효성 확인
* 사용법
* onblur="Common2.checkEmail(this)"
* */
function checkEmail(taht) {
var trans_num = $(taht).val();
if (!trans_num) {
return;
}
else {
// 유효성 체크
var regExp_ctn = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (regExp_ctn.test(trans_num)) {
$(taht).val(trans_num);
}
else {

Alert.warn("유효하지 않은 Email주소입니다.");
$(taht).val("");
$(taht).focus();
}
}
}


반응형
반응형

1. Quill 에디터

  - Rich Text Editor 이면서 위지윅 에디터라고도 한다.

우리가 보통 인터넷에서 그림을 넣고, 글을 작성 하는 모든 에디터를 위지윅에디터라고 칭 할 수 있다.

오픈 소스 위지윅 에디터이며 modular 구조의 아키텍처이고, 적용하는 웹페이지에 대해서 완벽한 커스텀마이징이 가능하도록 구현 되 있다.

무엇보다 심플하면서 에디터가 가져야되는 최소한의 기능만 딱딱 구현되어 있어서 사용 하였다.


https://quilljs.com


Quill Rich Text Editor


Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need.





2. 적용 환경

- 스프링부트, jquery의 환경에서 구현



3. 적용 방법

1. js, css Import

<!--quilljs editor-->
<script src="//cdn.quilljs.com/1.3.6/quill.min.js"></script>
<link href="//cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">

2. 에디터 공간 생성

<div id="quillEditor"></div>


3. 스크립트 내 선언

/**
* Quilljs 에디터 테스트
* */
function quilljsediterInit() {
var options = {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block']
]
},
placeholder: 'Compose an epic...',
theme: 'snow'
};
quill = new Quill('#quillEditor', options);
quill.getModule('toolbar').addHandler('image', function() {
selectLocalImage();
});
}
/**
* 퀼 이미지 콜백함수
* */

function selectLocalImage() {
const input = document.createElement('input');
input.setAttribute('type', 'file');
input.click();

// Listen upload local image and save to server
input.onchange = function() {
const fd = new FormData();
const file = $(this)[0].files[0];
fd.append('image', file);

$.ajax({
type: 'post',
enctype: 'multipart/form-data',
url: '/upload/image/quilleditor',
data: fd,
processData: false,
contentType: false,
beforeSend: function(xhr) {
xhr.setRequestHeader($("#_csrf_header").val(), $("#_csrf").val());
},
success: function(data) {
const range = quill.getSelection();
quill.insertEmbed(range.index, 'image', 'http://localhost:8080/upload/'+data);
},
error: function(err) {
console.error("Error ::: "+err);
}
});
};
}


콜백 함수는 image 라는 toolbar 내 모듈을 클릭시 selectLocalImage() 함수가 실행 되고, 함수 내에서는 type = file 인 input 을 생성, input에서 받은 값을 form-data 에 넣고 springboot 내 이미지 저장 controller를 타게 한다. controller에서는 서버에 이미지 저장 후 이미지 url를 return 하고, 

콜백 함수에서는 리턴 받은 url 값을 


quill의 insertEmbed() 메소드를 이용하여 에디터에 첨부 한다.




반응형

+ Recent posts