
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
/**
* 공통 JS
*/
//$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
$.unblockUI();
// console.log(event, jqxhr, settings, thrownError);
});
/*
* 로딩
*/
//$(function() {
// jQuery('form').submit(function() {
// $.blockUI({baseZ:99999});
// });
//});
//BackSpace 키 방지 이벤트
//$(document).keydown(function(e){
// if(e.target.nodeName != "INPUT" && e.target.nodeName != "TEXTAREA"){
// if(e.keyCode === 8){
// if( confirm("이전 페이지로 이동 하시겠습니까?") ) {
// window.histroy.go(-1);
// } else {
// return false;
// }
// }
// }
//});
$(function() {
// 달력 선언
initDatePicker();
var $inputCheckbox = $('.inputCheckbox');
var $onlyNumber = $('.onlyNumber');
var $onlyStopPointNumber = $('.onlyStopPointNumber');
var $onlyApostrophePointNumber = $('.onlyApostrophePointNumber');
var $onlyNumberComma = $('.onlyNumberComma');
// 체크박스
if ($inputCheckbox.length > 0) {
$inputCheckbox.toggleCheckbox([
'<i class="fa fa-square-o" style="font-size:17px; color:#666;" aria-hidden="true"></i>',
'<i class="fa fa-check-square" style="font-size:17px; color:#666;" aria-hidden="true"></i>'
]);
}
/* 숫자만 입력 */
if ($onlyNumber.length > 0) {
$onlyNumber.on('keydown keyup focusout', function() {
onlyNumber(this);
});
}
/* 숫자만 입력 */
if ($onlyStopPointNumber.length > 0) {
$onlyStopPointNumber.on('keydown keyup focusout', function() {
onlyStopPointNumber(this);
});
}
/* 숫자 . ' " 입력 */
if ($onlyApostrophePointNumber.length > 0) {
$onlyApostrophePointNumber.on('keydown keyup focusout', function() {
onlyApostrophePointNumber(this);
});
}
/* 숫자만 입력(세자리 콤마) */
if ($onlyNumberComma.length > 0) {
$onlyNumberComma.on('keydown keyup focusout', function() {
onlyNumberComma(this);
});
$onlyNumberComma.each(function() {
$(this).val(setComma($(this).val()));
});
}
// 권한 체크
fncAuthoChecker();
/**
* input 24Hours 시간 Mask
* class - inputTime
*/
initInputTimeMask();
});
//달력 선언
function initDatePicker() {
var $datepicker = $(".datepicker");
if ($datepicker.length < 1) {
return;
}
$datepicker.prop("autocomplete", "off").datepicker({
dateFormat: "yy-mm-dd",
changeYear: true,
changeMonth: true,
showMonthAfterYear: true,
selectOtherMonths: true,
showOtherMonths: true,
showButtonPanel: true,
nextText: '다음 달',
prevText: '이전 달',
dayNames: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
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월'],
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 9999999);
}, 0);
}
}).inputmask("9999-99-99");
$datepicker.focusout(function(){
var date = $(this).val();
if(date != '') {
var year = date.split("-")[0].replace(/[^0-9]/g,"");
var month = date.split("-")[1].replace(/[^0-9]/g,"");
var day = date.split("-")[2].replace(/[^0-9]/g,"");
if(year != '') {
for(var i = year.length; i < 4; i++) {
year = "0" + year;
}
}
if(month != '') {
if(month > 12) {
month = "12";
}else if(month < 1) {
month = "01";
}
for(var i = month.length; i < 2; i++) {
month = "0" + month;
}
}else {
month = "01";
}
if(day != '') {
if(month == "01" || month == "03" || month == "05" || month == "07" || month == "08" || month == "10" || month == "12") {
if(day > 31) {
day = "31";
}else if(day < 1) {
day = "01";
}
}else if(month == "04" || month == "06" || month == "09" || month == "11") {
if(day > 30) {
day = "30";
}else if(day < 1) {
day = "01";
}
}else if(month == "02") {
if(day > 29) {
day = "28";
}else if(day < 1) {
day = "01";
}
}
for(var i = day.length; i < 2; i++) {
day = "0" + day;
}
}else {
day = "01";
}
date = year + "-" + month + "-" + day;
$(this).val(date);
}
});
}
// minDate, maxDate 필요할 때
// 시작일 셀렉터 : bgnde , 종료일 셀렉터 : endde, 시작 종료 상위 셀렉터 : groupTag
function initDatePickerMulti(start, end, groupTag) {
var $start = $(start);
var $end = $(end);
var $startEnd = $(start + "," + end);
if ($start.length < 1) {
return;
}
$start.prop("autocomplete", "off").datepicker({
dateFormat: "yy-mm-dd",
changeYear: true,
changeMonth: true,
showMonthAfterYear: true,
selectOtherMonths: true,
showOtherMonths: true,
showButtonPanel: true,
nextText: '다음 달',
prevText: '이전 달',
dayNames: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
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월'],
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 9999999);
}, 0);
},
onClose: function (selectedDate) {
$(this).closest(groupTag).find(end).datepicker( "option", "minDate", selectedDate );
},
});
var minDate = $(start).closest(groupTag).find(start).val();
$end.prop("autocomplete", "off").datepicker({
dateFormat: "yy-mm-dd",
changeYear: true,
changeMonth: true,
showMonthAfterYear: true,
selectOtherMonths: true,
showOtherMonths: true,
showButtonPanel: true,
nextText: '다음 달',
prevText: '이전 달',
dayNames: ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일'],
dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
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월'],
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 9999999);
}, 0);
},
minDate: minDate
});
$startEnd.focusout(function(){
var date = $(this).val();
if(date != '') {
var year = date.split("-")[0].replace(/[^0-9]/g,"");
var month = date.split("-")[1].replace(/[^0-9]/g,"");
var day = date.split("-")[2].replace(/[^0-9]/g,"");
if(year != '') {
for(var i = year.length; i < 4; i++) {
year = "0" + year;
}
}
if(month != '') {
if(month > 12) {
month = "12";
}else if(month < 1) {
month = "01";
}
for(var i = month.length; i < 2; i++) {
month = "0" + month;
}
}else {
month = "01";
}
if(day != '') {
if(month == "01" || month == "03" || month == "05" || month == "07" || month == "08" || month == "10" || month == "12") {
if(day > 31) {
day = "31";
}else if(day < 1) {
day = "01";
}
}else if(month == "04" || month == "06" || month == "09" || month == "11") {
if(day > 30) {
day = "30";
}else if(day < 1) {
day = "01";
}
}else if(month == "02") {
if(day > 29) {
day = "28";
}else if(day < 1) {
day = "01";
}
}
for(var i = day.length; i < 2; i++) {
day = "0" + day;
}
}else {
day = "01";
}
date = year + "-" + month + "-" + day;
$(this).val(date);
}
});
}
// input 시간 마스크 설정
function initInputTimeMask() {
var $inputTime = $('.inputTime');
var $inputTimeSec = $('.inputTimeSec');
if ($inputTime.length < 1 && $inputTimeSec.length < 1) {
return;
}
$inputTime.inputmask('datetime',{'inputFormat':'HH:MM', 'hourFormat' : '24', 'showMaskOnHover' : false, 'placeholder' : "__:__"});
$inputTimeSec.inputmask('datetime',{'inputFormat':'HH:MM:ss', 'hourFormat' : '24', 'showMaskOnHover' : false, 'placeholder' : "__:__:__"});
//시간 자동 완성
$inputTime.focusout(function(){
var time = $(this).val();
if(time != "") {
var hour = time.split(":")[0];
var minute = time.split(":")[1];
if(hour != "") {
if(hour.replace(/[^0-9]/g,"") >= 24) {
hour = "";
}else{
var first = hour.substring(0,1).replace(/[^0-9]/g,"");
var second = hour.substring(1,2).replace(/[^0-9]/g,"");
if(first == "") {
first = 0;
}
if(second == "") {
second = 0;
}
hour = first + second;
}
}
if(minute.replace(/[^0-9]/g,"") != "") {
if(minute.replace(/[^0-9]/g,"") >= 60) {
minute = "";
}else{
var first = minute.substring(0,1).replace(/[^0-9]/g,"");
var second = minute.substring(1,2).replace(/[^0-9]/g,"");
if(first == "") {
first = 0;
}
if(second == "") {
second = 0;
}
minute = first + second;
}
}else {
if(hour != "") {
minute = "00";
}
}
$(this).val(hour + ":" + minute);
}
});
//시간 자동 완성 시:분:초
$inputTimeSec.focusout(function(){
var time = $(this).val();
if(time != "") {
var hour = time.split(":")[0];
var minute = time.split(":")[1];
var sec = time.split(":")[2];
if(hour != "") {
if(hour.replace(/[^0-9]/g,"") >= 24) {
hour = "";
}else{
var first = hour.substring(0,1).replace(/[^0-9]/g,"");
var second = hour.substring(1,2).replace(/[^0-9]/g,"");
if(first == "") {
first = 0;
}
if(second == "") {
second = 0;
}
hour = first + second;
}
}
if(minute.replace(/[^0-9]/g,"") != "") {
if(minute.replace(/[^0-9]/g,"") >= 60) {
minute = "";
}else{
var first = minute.substring(0,1).replace(/[^0-9]/g,"");
var second = minute.substring(1,2).replace(/[^0-9]/g,"");
if(first == "") {
first = 0;
}
if(second == "") {
second = 0;
}
minute = first + second;
}
}else {
if(hour != "") {
minute = "00";
}
}
if(sec.replace(/[^0-9]/g,"") != "") {
if(sec.replace(/[^0-9]/g,"") >= 60) {
sec = "";
}else{
var first = sec.substring(0,1).replace(/[^0-9]/g,"");
var second = sec.substring(1,2).replace(/[^0-9]/g,"");
if(first == "") {
first = 0;
}
if(second == "") {
second = 0;
}
sec = first + second;
}
}else {
if(minute != "") {
sec = "00";
}
}
$(this).val(hour + ":" + minute + ":" + sec);
}
});
}
/*
* 서브밋시 콤마제외
*/
function submitNummberComma() {
$('.onlyNumberComma').each(function() {
$(this).val($(this).val().replace(/[^0-9-]/g,""));
});
}
function submitNummberComma(str) {
var result = parseInt(str.replace(/[^0-9-]/g,""));
if(isNaN(result)){
result = null;
}
return result;
}
/*
* 숫자만 입력
*/
function onlyNumber(obj){
$(obj).val($(obj).val().replace(/[^0-9]/g,""));
}
/*
* 숫자만 입력
*/
function onlyStopPointNumber(obj){
$(obj).val($(obj).val().replace(/[^0-9.]/g,""));
}
function onlyApostrophePointNumber(obj){
$(obj).val($(obj).val().replace(/[^0-9.\"\'Φ/*]/g,""));
}
/*
* 숫자만 입력(세자리 콤마)
*/
function onlyNumberComma(obj){
$(obj).val(setComma($(obj).val().replace(/[^0-9-]/g,"")));
}
function setComma(number) {
// 정규표현식 : (+- 존재하거나 존재 안함, 숫자가 1개 이상), (숫자가 3개씩 반복)
var reg = /(^[+-]?\d+)(\d{3})/;
// 스트링변환
number += '';
while (reg.test(number)) {
// replace 정규표현식으로 3자리씩 콤마 처리
number = number.replace(reg,'$1'+','+'$2');
}
return number;
}
/*
* object의 name 속성을 재정의한다.(배열로 만들기 위함)
*/
function fncRename(obj, i) {
var names = $(obj).attr('name').split('.');
var rname = names[0] + '[' + i + '].' + names[1];
$(obj).attr('name', rname);
}
// formSerializeObject Json 변환
$.fn.serializeObject = function () {
"use strict";
var result = {};
var extend = function (i, element) {
var node = result[element.name];
if ('undefined' !== typeof node && node !== null) {
if ($.isArray(node)) {
node.push(element.value);
} else {
result[element.name] = [node, element.value];
}
} else {
result[element.name] = element.value;
}
};
$.each(this.serializeArray(), extend);
return result;
};
//-- 프린트 설정 시작
var beforePrint = function() {
// $('button').css('display', 'none');
$('#printSection button').css('display', 'none');
}
var afterPrint = function() {
// setTimeout(function() {
// if( this.opener != null ) {
// this.close();
// }
// $('button').css('display', '');
// }, 50);
setTimeout(function() {
if( this.opener != null ) {
this.close();
}
$('#printSection').remove();
}, 50);
// 인쇄 취소나 완료시 팝업창 닫기
}
// chrome 63이후 부터 onbeforeprint 이벤트가 지원됨에 따라 아래 주석
// firefox for android 빼고 모든 브라우저 지원
//if( window.matchMedia ) {
// var mQuery = window.matchMedia('print');
// mQuery.addListener(function(mql) {
// if( mql.matches ) {
// beforePrint();
// } else {
// afterPrint();
// }
// });
//}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
//-- 프린트 설정 완료
//-- 팝업 프린트 영역 dom 생성
function printElement(elem) {
var domClone = elem.cloneNode(true);
var id = domClone.getAttribute('id');
$(domClone).removeAttr('id');
var $printSection = document.getElementById("printSection");
if (!$printSection) {
var $printSection = document.createElement("div");
$printSection.id = "printSection";
document.body.appendChild($printSection);
}
$printSection.innerHTML = "";
$printSection.appendChild(domClone);
window.print();
}
// Dom 데이터 초기화
function resetDomData(obj) {
obj.each(function() {
$(this).find('input[type="text"], textarea').val('');
});
}
function itoStr($num)
{
$num < 10 ? $num = '0'+$num : $num;
return $num.toString();
}
/*
* 엑셀다운로드
* tblId : $(tableId)
* fileNm : 다운로드 파일명
*/
function excelDownloads(tblId, fileNm) {
var dt = new Date();
var year = itoStr( dt.getFullYear() );
var month = itoStr( dt.getMonth() + 1 );
var day = itoStr( dt.getDate() );
var hour = itoStr( dt.getHours() );
var mins = itoStr( dt.getMinutes() );
var postfix = year + month + day + "_" + hour + mins;
var fileName = fileNm + postfix + ".xls";
TXLManager(tblId).exportTableToExcel(fileNm + postfix);
}
/* 이미지 preImgView
* img : img tag Id
* input : input file tag object
* hidden : hidden input Id
*/
function preImgView(img, input, hidden) {
var preview = document.getElementById(img);
var hiddenInput = document.getElementById(hidden);
var file = input.files[0];
var reader = new FileReader();
reader.addEventListener("load", function () {
preview.src = reader.result;
if( hiddenInput != null ) {
hiddenInput.innerHTML = reader.result;
}
}, false);
if (file) {
reader.readAsDataURL(file);
}
}
/*
* replaceALl 함수
* str 문자열
* searchStr 찾을문자열
* replaceStr 바꿀문자열
*/
function replaceAll(str, searchStr, replaceStr) {
return str.split(searchStr).join(replaceStr);
}
/*
* enter(\r\n)를 br로 치환
*/
function changeEnterBr(str) {
return replaceAll(str.replace(/(?:\r\n|\r|\n)/g, "<br>"), ' ', ' ')
}
/*
* br을 enter(\r\n)로 치환
*/
function changeBrEnter(str) {
return replaceAll(str, "<br>", "\r\n");
}
/*
* 팝업 프로그래스 바
* ctx 컨텍스트패스
* popupId 팝업ID
* url 리다이렉트할 url(한글파라메터시 encodeURI("한글", "UTF-8"))
*/
function popupProgress(ctx, popupId, url) {
var retVal;
retVal = window.open("", popupId, "width=1000, height=800, left=100, top=100");
var data = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
data += '<script src="'+ctx+'/js/egovframework/com/cmm/jquery-1.12.4.min.js"><\/script>';
data += '<script src="'+ctx+'/js/com/jquery.blockUI.js" ><\/script>';
data += '<body><script>$.blockUI({baseZ:2000});location.href="'+url+'";<\/script><\/body>';
retVal.document.write(data);
}
//날짜 포맷 변경 (yyyy-MM-dd)
function formatDate (date) {
var d;
if (date != "") {
d = new Date(date);
} else {
d = new Date();
}
var month = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear();
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
return [year, month, day].join('-');
}
//날짜 포맷 변경 시간 (yyyy-MM-dd hh24:mi:ss)
function formatDateTime (date) {
var d;
if (date != "") {
d = new Date(date);
} else {
d = new Date();
}
var month = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear();
var hours = d.getHours();
var minutes = d.getMinutes();
var seconds = d.getSeconds();
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
return [year, month, day].join('-') + ' ' + hours + ':' + minutes + ':' + seconds;
}
//값 비어있는지 체크
function isEmpty(str) {
if (typeof str == "undefined" || str == null || str == "")
return true;
else
return false;
}
/**
* 팝업
*/
function fn_popupOpen(url, width, height, params, loadingYn, callback) {
// 호출한 객체
var targetEl = event.target || event.srcElement;
// 팝업 일련번호 생성
var today = new Date();
var popUID = today.getDate() + '' + today.getHours() + '' + today.getMinutes() + '' + today.getSeconds();
let popupId = 'popup' + popUID;
// 팝업 wrapper dom
var dom = '<div id="'+popupId+'" class="modal">'
+ ' <div class="modal_wrap">'
+ ' <div class="modal_box width'+width+' height'+height+'"></div>'
+ ' </div>'
+ '</div>';
var $popupWrapper = null;
$popupWrapper = $(dom).appendTo('body');
// 팝업 div dom
var $popDom = $popupWrapper.find('.modal_box');
// 팝업 생성
$popDom.fncLoad(url, params, loadingYn, function( response, status, xhr ) {
if( status == 'success' ) {
// 팝업오픈
$popupWrapper.addClass('open');
// 팝업 닫기 이벤트 등록
$popDom.on('click', '.close', function() {
// 팝업이 없을 때
$popupWrapper.remove();
// 호출한 객체로 포커스
targetEl.focus();
});
// 마지막 텝
$popDom.on('keydown', 'button.btn_s.close', function() {
if (event.keyCode === 9) {
event.preventDefault();
$popDom.find('button.btn_close').focus();
}
});
// 팝업 첫 포커스
$popDom.find('button.btn_close').focus();
// 팝업 콜백 함수
if (typeof callback == 'function') {
callback(popupId);
}
} else {
alert('에러가 발생하였습니다. \n' + xhr.status + '\n' + xhr.statusText);
}
});
}
/**
* jQuery load 공통함수
* $(element).fncLoad(url, params, [callback])
*/
$.fn.fncLoad = function(url, params, loadingYn, callback) {
if (loadingYn == null || loadingYn == 'Y') {
$.blockUI();
}
$(this).load(url, params, function(response, status, xhr) {
// 권한 체크
fncAuthoChecker();
if( callback ) callback(response, status, xhr);
if (loadingYn == null || loadingYn == 'Y') {
$.unblockUI();
}
});
}
/**
* 권한 체크
* @returns
*/
function fncAuthoChecker(element) {
if (typeof FUNCTION_AUTHO) { // 변수 존재 여부 확인.
return;
}
if( element != undefined && element != null ) {
var autho = element.data('autho');
if (autho == null) {
return;
}
if(FUNCTION_AUTHO.indexOf('ROLE_ADMIN') > -1 ) {
return;
}
if(FUNCTION_AUTHO.indexOf(autho) == -1 ) {
element.off().prop('disabled', true).addClass("disabled");
}
} else {
var $checkList = $('[data-autho]'); // 권한 속성 확인.
$.each($checkList, function() {
var $this = $(this);
var autho = $this.data('autho');
if(FUNCTION_AUTHO.indexOf('ROLE_ADMIN') > -1 ) {
return;
}
if(FUNCTION_AUTHO.indexOf(autho) == -1 ) {
$this.off().prop('disabled', true).addClass("disabled");
}
});
}
}
/**
* 배열의 요소를 모두 조합한 경우의 수를 뽑아내는 경우
* @returns
*/
function permute(permutation) {
var length = permutation.length,
result = [permutation.slice()],
c = new Array(length).fill(0),
i = 1, k, p;
while (i < length) {
if (c[i] < i) {
k = i % 2 && c[i];
p = permutation[i];
permutation[i] = permutation[k];
permutation[k] = p;
++c[i];
i = 1;
result.push(permutation.slice());
} else {
c[i] = 0;
++i;
}
}
return result;
}
//multi Input 검색조건 만들기
function createSplitSearch(data) {
var searchVal = '';
for (var i = 0; i < data.length; i++) {
searchVal += '(';
for (var j = 0; j < data[i].length; j++) {
if (j == data[i].length-1) {
searchVal += '(' + data[i][j] + ')+';
} else {
searchVal += '(' + data[i][j] + ')+.*';
}
}
searchVal += ')';
if (i != data.length-1) {
searchVal += '|';
}
}
return searchVal;
}
/**
* 브라우저 확인
* @returns
*/
function browserInfo() {
var browser = "";
var userAgent = window.navigator.userAgent.toLowerCase();
var isChrome = userAgent.indexOf('chrome');
var isEdge = userAgent.indexOf('edge');
var isEdge2 = userAgent.indexOf('edg');
var isWhale = userAgent.indexOf('whale');
var isFirefox = userAgent.indexOf('firefox');
//Edge는 Chrome과 Edge 모두의 값을 가지고 있기 때문에
if (isChrome > -1) {
if(isEdge > -1 || isEdge2 > -1) {
browser = "edge";
} else if(isWhale > -1) {
browser = "whale";
} else {
browser = "chrome";
}
} else if(isFirefox > -1){
browser = "firefox";
} else {
browser = "ie";
}
return browser;
}
/**
* 다운로드 프로그래스
* @returns
*/
function progressDownload() {
$.blockUI();
$.removeCookie('fileDownloadToken', {path : '/'});
FILEDOWNLOAD_INTERVAL = setInterval(function() {
if ($.cookie("fileDownloadToken") != null) {
clearInterval(FILEDOWNLOAD_INTERVAL);
$.unblockUI();
}
}, 500);
}
/**
* 계산 후 데이터 길이 확인
* @param obj
* @param result
* @returns
*/
function fncChkCalDataLength(obj, result) {
var length = result.attr('maxlength');
// maxlength에 따른 정수 범위 표시 변수
var plusMaxValue = "";
var minusMinValue = "-";
// 0 이상의 최댓값
for(var i = 0; i < length; i++){
plusMaxValue += "9";
}
// 0 이하의 최솟값
for(var i = 0; i < length - 1; i++){
minusMinValue += "9";
}
if((length != "" && typeof length != "undefined" && result.val() != "" && typeof result.val() != "undefined" && result.val().length > length)
|| Number(result.val()) > Number(plusMaxValue)+1 || Number(result.val()) < Number(minusMinValue)-1){
alert("결과값의 데이터 길이를 초과하였습니다.");
$.each(obj, function(i) {
$(this).val("");
});
result.val("");
return false;
}
return true;
}
/**
* 개인정보 체크 함수.
*/
function fnPrivacyCheck(str) {
var result = 0;
str = str.replace(/\s/gi, ''); // 공백제거.
var reg = /[01][0-9]{5}[~-]+[1-4][0-9]{6}|[2-9][0-9]{5}[~-]+[1-2][0-9]{6}/; // 주민등록번호
var reg2 = /([a-zA-Z]{1}|[a-zA-Z]{2})\d{8}/; // 여권번호
var reg3 = /[0-9]{2}[-~.][0-9]{6}[-~.[0-9]{2}/; // 운전면허번호
var reg4 = /01[016789][-~.][0-9]{3,4}[-~.][0-9]{4}/; // 핸드폰번호
var reg5 = /[34569][0-9]{3}[-~.][0-9]{4}[-~.][0-9]{4}[-~.][0-9]{4}/; // 신용카드번호
var reg6 = /[1257][-~.][0-9]{10}/; // 건강보험번호
var reg7 = /[0-9]{2}[-~.][0-9]{2}[-~.][0-9]{6}|[0-9]{3}[-~.]([0-9]{5,6}[-~][0-9]{3}|[0-9]{6}[-~.][0-9]{5}|[0-9]{2,3}[-~.][0-9]{6}|[0-9]{2}[-~.][0-9]{7}|[0-9]{2}[-~.][0-9]{4,6}[-~.][0-9]|[0-9]{5}[-~.][0-9]{3}[-~.][0-9]{2}|[0-9]{2}[-~.][0-9]{5}[-~.][0-9]{3}|[0-9]{4}[-~.][0-9]{4}[-~.][0-9]{3}|[0-9]{6}[-~.][0-9]{2}[-~.][0-9]{3}|[0-9]{2}[-~.][0-9]{2}[-~.][0-9]{7})|[0-9]{4}[-~.]([0-9]{3}[-~.][0-9]{6}|[0-9]{2}[-~.][0-9]{6}[-~.][0-9])|[0-9]{5}[-~.][0-9]{2}[-~.][0-9]{6}|[0-9]{6}[-~.][0-9]{2}[-~.][0-9]{5,6}/; // 계좌번호
var reg8 = /[0-9]{11}/; // 핸드폰 번호 추가
var reg9 = /[0-9]{13}/; // 주민 번호 추가
str = str.replace(/\s/g, ''); // 모든 공백 제거
str = str.replace(/(<([^>]+)>)/gi, ''); // 모든 태그 제거
if (reg.test(str) || reg9.test(str)) {
if (confirm('주민등록번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
if (reg2.test(str)) {
if (confirm('여권번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
if (reg3.test(str)) {
if (confirm('운전면허번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
if (reg4.test(str) || reg8.test(str)) {
if (confirm('핸드폰 번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
if (reg5.test(str)) {
if (confirm('신용카드 번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
if (reg6.test(str)) {
if (confirm('건강보험번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
if (reg7.test(str)) {
if (confirm('계좌번호를 입력하셨는지 확인 바랍니다. 저장하시겠습니까?')) {
return true;
} else {
return false;
}
}
return true;
}
/**
* 글자 확대 축소
* 사용법 zoomInOut('in');
* param : in, out, init
*/
var nowZoom = 100;
var maxZoom = 120;
var minZoom = 90;
function zoomInOut(how) {
var browser = navigator.userAgent;
var Browser = {
chk : navigator.userAgent.toLowerCase()
}
Browser = {
ie : Browser.chk.indexOf('msie') != -1,
ie6 : Browser.chk.indexOf('msie 6') != -1,
ie7 : Browser.chk.indexOf('msie 7') != -1,
ie8 : Browser.chk.indexOf('msie 8') != -1,
ie9 : Browser.chk.indexOf('msie 9') != -1,
ie10 : Browser.chk.indexOf('msie 10') != -1,
opera : !!window.opera,
safari : Browser.chk.indexOf('safari') != -1,
safari3 : Browser.chk.indexOf('applewebkir/5') != -1,
mac : Browser.chk.indexOf('mac') != -1,
chrome : Browser.chk.indexOf('chrome') != -1,
firefox : Browser.chk.indexOf('firefox') != -1
}
if (how == 'in' && nowZoom < maxZoom) {
nowZoom += 5;
} else if (how == 'out' && nowZoom > minZoom) {
nowZoom -= 5;
} else if (how == 'init') {
nowZoom = 100;
}else {
return false;
}
document.body.style.zoom = nowZoom + "%";
if ((Browser.ie6) || (Browser.ie7)) {
document.body.style.position = "absolute";
}else if(Browser.ie8 || Browser.ie10 || Browser.chrome || Browser.safari){
//document.body.style.width = "100%";
//document.body.style.position = "absolute";
}else if(Browser.opera || Browser.firefox){
tmpZoom = nowZoom/100;
$('body').css('-webkit-transform','scale(' + (tmpZoom) + ')');
$('body').css('-webkit-transform-origin','0 0');
$('body').css('-moz-transform','scale(' + (tmpZoom) + ')');
$('body').css('-moz-transform-origin','0 0');
$('body').css('-o-transform','scale(' + (tmpZoom) + ')');
$('body').css('-o-transform-origin','0 0');
}
if((navigator.appName == 'Netscape' && navigator.userAgent.search('Trident') != -1) && (agent.indexOf("msie") != -1)){
}
return false;
}
/**
* 카테고리 출력
* 사용법 selectLclasList('대분류 셀렉터', '소분류 셀렉터', '카테고리유형')
* param : lclas, sclas, clasType
* 수정 화면 시 select태그에 data-id로 값 매칭
*/
function selectLclasList($lclas, $sclas, clasType){
if(clasType != '' && typeof clasType != 'undefined'){
if( $.blockUI != null ) {
$.blockUI();
}
var url = CONTEXT_PATH + "/cmm/code/unityCodeList/selectJson.do";
var lclasVal = $lclas.data('id');
$.post(url , {'unityCodeNm' : clasType, 'useAt' : 'Y'}, function(data){
if(data.sttus = 'success'){
var result = data.result;
var option = '';
var i = 0;
for(i=0; i < result.length; i++ ){
option += '<option value="'+result[i].unityCode+'">'+result[i].unityCodeNm+'</option>';
}
$lclas.append(option);
}
})
.done(function() {
$lclas.on('change', function(){
$sclas.find('option:not(:first)').remove();
var searchSclas = $lclas.val();
if(searchSclas != '' && typeof searchSclas != 'undefined' && searchSclas != 0){
$.post(url, { 'unityCode' : searchSclas ,'useAt' : 'Y', 'unityCodeNm' : ''}, function(data){
if(data.sttus = 'success'){
var result = data.result;
var option = '';
var i = 0;
for(i=0; i < result.length; i++ ){
option += '<option value="'+result[i].unityCode+'">'+result[i].unityCodeNm+'</option>';
}
$sclas.append(option);
}
})
.done(function() {
var sclasVal = $sclas.data('id');
if (sclasVal != null) {
// 소분류 값이 있을 경우 값 셋팅 후 강제 이벤트 발생
$sclas.val(sclasVal).trigger('change');
$sclas.data('id', null)
}
});
}
});
// 대분류 값이 있을 경우 값 셋팅 후 강제 이벤트 발생
if (lclasVal != null && lclasVal != '') {
$lclas.val(lclasVal).trigger('change');
}
})
.always(function() {
if( $.unblockUI != null ) {
$.unblockUI();
}
});
}
}
/**
* 클립보드 복사
* 사용법 copyToClipboard('복사할 input')
* 복사할 input type은 text나 textArea만 가능 (hidden X, visiblity X)
* -->input에 style="position:absolute; left:-9999px" 속성추가
*/
function copyToClipboard($copyInputTxt){
$copyInputTxt.focus();
$copyInputTxt.select();
document.execCommand('copy');
alert('클립보드로 복사되었습니다.');
}
/**
* 주소API 팝업 호출
* 사용법: 사용자 - <button onclick="openAdresPopup();">, 관리자 - <button onclick="openAdresPopup('Y');">
* 콜백함수: adresCallback(zipNo, roadAddrPart1, roadAddrPart2, addrDetail);
* */
function openAdresPopup(isMng){
window.name="jusoPopup";
var url = CONTEXT_PATH + "/searchapi/jusoPopup.jsp";
if (isMng != null) {
url += "?isMng=" + isMng;
}
var pop = window.open(url,"pop","width=570,height=420, scrollbars=yes, resizable=yes");
}
/**
* 크로스사이트 스크립트 대응
* @Author : 임종호
* @Date : 2021. 11. 16.
* @Method Name : XSSCheck
* @return : any
*/
function XSSCheck(str, level) {
if (level == undefined || level == 0) {
str = str.replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+\-/g, "");
} else if (level != undefined && level == 1) {
str = str.replace(/\</g, "<");
str = str.replace(/\>/g, ">");
}
return str;
}
/**
* 동영상 공유링크
* @Author : 임종호
* @Date : 2021. 11. 29.
* @Method Name : insertByVideoURL(e), e:element혹은string, 유튜브, 네이버, 카카오 가능
* @return : str
*/
function insertByVideoURL($el) {
var e;
if (typeof $el == 'object') {
e = $el.val().trim();
} else {
e = $el;
}
if (e == '') {
alert('영상링크를 복사해 주세요.\n영상은 유튜브, 네이버티비, 카카오티비만 가능합니다.');
$el.focus();
return false;
}
const VIDEO_PROVIDERS = [
{
test_regex: /^.*((youtu.be)|(youtube.com))\/((v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))?\??v?=?([^#\&\?]*).*/,
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|embed\/)?([0-9a-zA-Z_\-]+)(.+)?/g,
url_text: "https://www.youtube.com/embed/$1",
html: '<iframe width="640" height="360" src="{url}?wmode=opaque" frameborder="0" allowfullscreen></iframe>',
provider: "youtube",
},
{
test_regex: /^.*(?:vimeo.com)\/(?:channels(\/\w+\/)?|groups\/*\/videos\/\u200b\d+\/|video\/|)(\d+)(?:$|\/|\?)/,
url_regex: /(?:https?:\/\/)?(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?(\/[a-zA-Z0-9_\-]+)?/i,
url_text: "https://player.vimeo.com/video/$1",
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>',
provider: "vimeo",
},
{
test_regex: /^.+(dailymotion.com|dai.ly)\/(video|hub)?\/?([^_]+)[^#]*(#video=([^_&]+))?/,
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:dailymotion\.com|dai\.ly)\/(?:video|hub)?\/?(.+)/g,
url_text: "https://www.dailymotion.com/embed/video/$1",
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>',
provider: "dailymotion",
},
{
test_regex: /^.+(screen.yahoo.com)\/[^_&]+/,
url_regex: "",
url_text: "",
html: '<iframe width="640" height="360" src="{url}?format=embed" frameborder="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true"></iframe>',
provider: "yahoo",
},
{
test_regex: /^.+(rutube.ru)\/[^_&]+/,
url_regex: /(?:https?:\/\/)?(?:www\.)?(?:rutube\.ru)\/(?:video)?\/?(.+)/g,
url_text: "https://rutube.ru/play/embed/$1",
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true"></iframe>',
provider: "rutube",
},
{
test_regex: /^(?:.+)vidyard.com\/(?:watch)?\/?([^.&/]+)\/?(?:[^_.&]+)?/,
url_regex: /^(?:.+)vidyard.com\/(?:watch)?\/?([^.&/]+)\/?(?:[^_.&]+)?/g,
url_text: "https://play.vidyard.com/$1",
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>',
provider: "vidyard",
},
{
test_regex: /^.*(naver.com)\/[^_&]+/,
url_regex: /(?:https?:\/\/)?(?:tv\.)?(?:m\.)?naver.com\/v\/?([0-9a-zA-Z_\-]+)(.+)?/g,
url_text: "https://tv.naver.com/embed/$1",
html: '<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>',
provider: "naver",
},
{
test_regex: /^.*(kakao.com)\/[^_&]+/,
url_regex: /(?:https?:\/\/)?(?:tv\.)?(?:m\.)?kakao.com\/v\/?([0-9a-zA-Z_\-]+)(.+)?/g,
url_text: "https://play-tv.kakao.com/embed/player/cliplink/$1",
html: '<iframe width="640" height="360" src="{url}?service=player_share" frameborder="0" allowfullscreen></iframe>',
provider: "kakao",
},
];
function isURL(e) {
const LinkRegExCommon = "[a-z\\u0080-\\u009f\\u00a1-\\uffff0-9-_.]{1,}"
, LinkRegExEnd = "((:[0-9]{1,5})|)(((\\/|\\?|#)[a-z\\u00a1-\\uffff0-9@?\\|!^=%&/~+#-\\'*-_{}]*)|())"
, LinkRegExHTTP = "((ftp|http|https):\\/\\/" + LinkRegExCommon + ")";
return (
!!/^(https?:|ftps?:|)\/\//i.test(e) &&
((e = String(e).replace(/</g, "%3C").replace(/>/g, "%3E").replace(/"/g, "%22").replace(/ /g, "%20")), new RegExp("^" + LinkRegExHTTP + LinkRegExEnd + "$", "gi").test(e))
);
};
var t = null;
if ((/^http/.test(e) || (e = "https://" + e), isURL(e)))
for (var n = 0; n < VIDEO_PROVIDERS.length; n++) {
var r = VIDEO_PROVIDERS[n];
if (r.test_regex.test(e)) {
(t = e.replace(r.url_regex, r.url_text)), (t = r.html.replace(/\{url\}/, t));
break;
}
}
if (t == null) {
alert('허용되지 않은 URL 입니다.');
$el.val('');
$el.focus();
return false;
}
return t;
};