// 데이터 테이블 한글화
var datatable_kr = {
"sEmptyTable": "조회된 데이터가 없습니다.",
"sInfo": "_START_ - _END_ / _TOTAL_",
"sInfoEmpty": "0 - 0 / 0",
"sInfoFiltered": "(총 _MAX_ 개)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "페이지당 줄수 _MENU_",
"sLoadingRecords": "읽는중...",
"sProcessing": "처리중...",
"sSearch": "검색:",
"sZeroRecords": "검색 결과가 없습니다",
"oPaginate": {
"sFirst": "처음",
"sLast": "마지막",
"sNext": "다음",
"sPrevious": "이전"
},
"oAria": {
"sSortAscending": ": 오름차순 정렬",
"sSortDescending": ": 내림차순 정렬"
}
}
$(document).ready(function() {
//모든 datepicker에 대한 공통 옵션 설정
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd' //Input Display Format 변경
,showOtherMonths: true //빈 공간에 현재월의 앞뒤월의 날짜를 표시
,showMonthAfterYear:true //년도 먼저 나오고, 뒤에 월 표시
,changeYear: true //콤보박스에서 년 선택 가능
,changeMonth: true //콤보박스에서 월 선택 가능
,showOn: "both" //button:버튼을 표시하고,버튼을 눌러야만 달력 표시 ^ both:버튼을 표시하고,버튼을 누르거나 input을 클릭하면 달력 표시
,buttonImage: "/com/web/images/send_calendar.gif" //버튼 이미지 경로
,buttonImageOnly: true //기본 버튼의 회색 부분을 없애고, 이미지만 보이게 함
,buttonText: "선택" //버튼에 마우스 갖다 댔을 때 표시되는 텍스트
,yearSuffix: "년" //달력의 년도 부분 뒤에 붙는 텍스트
,monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'] //달력의 월 부분 텍스트
,monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'] //달력의 월 부분 Tooltip 텍스트
,dayNamesMin: ['일','월','화','수','목','금','토'] //달력의 요일 부분 텍스트
,dayNames: ['일요일','월요일','화요일','수요일','목요일','금요일','토요일'] //달력의 요일 부분 Tooltip 텍스트
,minDate: "0" //최소 선택일자(-1D:하루전, -1M:한달전, -1Y:일년전)
,maxDate: "+13M" //최대 선택일자(+1D:하루후, -1M:한달후, -1Y:일년후)
});
});
//ajax 동작 시 loading 표시 -> 추후 리스트 로딩을 ajax로 처리 변경
$(document)
.ajaxStart(function() {
//$(".wrap-loading").fadeIn(500);
$(".wrap-loading").removeClass('display-none');
})
.ajaxStop(function() {
//$("#loading").fadeOut(500);
$(".wrap-loading").addClass('display-none');
});
// html escape 변환 배열
var entityMap = {
"&": "&",
"<": "<",
">": ">",
'"': '"',
"'": ''',
"/": '/'
};
/*
* @brief 문자열에 들어있는 escape대상 문자 변환
* @param string = 대상 문자열
*/
var escapeHtml = function(str) {
return String(str).replace(/[&<>"'\/]/g, function(s) {
return entityMap[s];
});
}
//위와 반대
function unEscapeHtml(escapedStr) {
return $('').html(escapedStr).text();
}
/*
* 어떤 값이 공백값이거나 undefined 값이면 false 반환
*/
var checkBlank = function(val) {
if (val === ""
|| val === ''
|| val === null
|| typeof val === "undefined") {
return true;
} else {
return false;
}
};
/*
* ajax 호출 공통함수
*/
var ajaxCall = function(url, dataType, data, sucCallback) {
if (checkBlank(url) === true) {
return false;
}
$.ajax({
type : "POST",
url : url,
dataType : dataType,
data : data,
success : function(result) {
return sucCallback(result);
},
error : getAjaxError
});
};
/*
* ajax 호출 에러 출력 함수
*/
var getAjaxError = function(request,status,error) {
alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
};
/*
* datepicker 생성
*/
var setDateValue = function(type) {
if (type == "") {
$("#from").val("");
$("#to").val("");
return false;
}
var nowDate = new Date();
var to_y = nowDate.getFullYear();
var to_m = nowDate.getMonth() + 1;
var to_d = nowDate.getDate();
if (to_m < 10) {
to_m = "0" + to_m;
}
if (to_d < 10) {
to_d = "0" + to_d;
}
var to = to_y + "-" + to_m + "-" + to_d;
$("#to").val(to);
var setDate = nowDate;
if (type != 0) {
setDate = nowDate.getTime() - (Number(type) * 24 * 60 * 60 * 1000);
}
nowDate.setTime(setDate);
var from_y = nowDate.getFullYear();
var from_m = nowDate.getMonth() + 1;
var from_d = nowDate.getDate();
if (from_m < 10) {
from_m = "0" + from_m;
}
if (from_d < 10) {
from_d = "0" + from_d;
}
var from = from_y + "-" + from_m + "-" + from_d;
$("#from").val(from);
$("#from").datepicker('update', from);
$("#to").datepicker('update', to);
}
//전화번호 형식 체크
function phone_number_check(phone) {
var is_rule = false;
var phoneNum = phone.toString().replace(/[^0-9]/gi,"");
var mobile = /^((010-?([0-9]{4})-?([0-9]{4}))|(01[16789]{1}-?([0-9]{3,4})-?[0-9]{4}))$/;
var tel = /^(02|0[3-6]{1}[1-5]{1})-?([0-9]{3,4})-?[0-9]{4}$/;
var rep = /^(15|16|18)[0-9]{2}-?[0-9]{4}$/;
var rep2 = /^(02|0[3-6]{1}[1-5]{1})-?(15|16|18)[0-9]{2}-?[0-9]{4}$/;
var num = /^(070|(050[1-8]{0,1})|080|013)-?([0-9]{3,4})-?[0-9]{4}$/;
if (mobile.test(phoneNum)) {
is_rule = true;
if (phoneNum.length > 11) is_rule = false;
} else if (tel.test(phoneNum)) {
is_rule = true;
if (phoneNum.length > 11) is_rule = false;
} else if (rep.test(phoneNum)) {
is_rule = true;
if (phoneNum.length != 8) is_rule = false;
} else if (num.test(phoneNum)) {
is_rule = true;
if (phoneNum.length > 12) is_rule = false;
} else {
is_rule = false;
}
if (rep2.test(phoneNum)) is_rule = false;
return is_rule;
}
function show_number(num) {
// 휴대전화 번호 형식
const hpRule = /^(010)([1-9]{1}[0-9]{3,4})([0-9]{4})$/;
// 일반 전화번호 형식
const telRule = /^(0[2-6][0-5]?|01[1346-9])([1-9]{1}[0-9]{2,3})([0-9]{4})$|^(010)([1-9]{1}[0-9]{3})([0-9]{4})$|((070|080|16[00|44|61|66|68|70|88]|18[00|11|33|55|77|99]|15[22|44|55|66|77|88|99]|1660)-?([0-9]{4}))$/;
// 4자리 - 4자리 형식
const fourFourRule = /^([0-9]{4})-?([0-9]{4})$/;
// 휴대전화 번호 형식 체크
if (hpRule.test(num)) {
const matches = num.match(hpRule);
return `${matches[1]}-${matches[2]}-${matches[3]}`;
// 4자리-4자리 형식 체크
} else if (fourFourRule.test(num)) {
const matches = num.match(fourFourRule);
return `${matches[1]}-${matches[2]}`;
// 02로 시작 전화번호 형식 체크
} else if (num.startsWith('02')) {
if (num.length === 9) {
return `${num.substring(0, 2)}-${num.substring(2, 5)}-${num.substring(5, 9)}`;
} else if (num.length === 10) {
return `${num.substring(0, 2)}-${num.substring(2, 6)}-${num.substring(6, 10)}`;
}
// 위 형식이 맞지 않으면 3자리-3,4자리-4자리 형식으로 변환
} else if (num.length === 10) {
return `${num.substring(0, 3)}-${num.substring(3, 6)}-${num.substring(6, 10)}`;
} else if (num.length === 11) {
return `${num.substring(0, 3)}-${num.substring(3, 7)}-${num.substring(7, 11)}`;
}
// 형식이 맞지 않으면 원래 번호 반환
return num;
}