// input[type=number]에서 e, E, - 제거하고 maxLength 적용시켜줌 $(document).off("input", "input[type=number]:not(.useMinus)").on("input", "input[type=number]:not(.useMinus)", function(){ this.value = this.value.replace(/e|E|-/g, ''); console.log(this.maxLength); if((this.maxLength || -1) > -1){ if(this.value.length > this.maxLength){ this.value = this.value.slice(0, this.maxLength); } } }); //사업자등록번호 입력 $(document).off("keyup blur", ".compRegNum").on("keyup blur", ".compRegNum", function(){ this.value = this.value.replace(/[^0-9]|-/g, ''); if(this.value.length >= 6){ this.value = this.value.replace(/(\d{3})(\d{2})(\d{1,5})/, '$1-$2-$3'); }else if(this.value.length >= 4){ this.value = this.value.replace(/(\d{3})(\d{1,2})/, '$1-$2'); } }); if($.datepicker){ $.datepicker.setDefaults({ dateFormat: 'yy-mm-dd', prevText: '이전 달', nextText: '다음 달', monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'], monthNamesShort: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'], dayNames: ['일', '월', '화', '수', '목', '금', '토'], dayNamesShort: ['일', '월', '화', '수', '목', '금', '토'], dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'], showMonthAfterYear: true, yearSuffix: '년' }); } if(jQuery.fn.dataTable !== undefined){ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) { var esc = function ( t ) { return t .replace( /&/g, '&' ) .replace( //g, '>' ) .replace( /"/g, '"' ); }; return function ( d, type, row ) { // Order, search and type get the original data if ( type !== 'display' ) { return d; } if ( typeof d !== 'number' && typeof d !== 'string' ) { return d; } d = d.toString(); // cast numbers if ( d.length <= cutoff ) { return d; } var shortened = d.substr(0, cutoff-1); // Find the last white space character in the string if ( wordbreak ) { shortened = shortened.replace(/\s([^\s]*)$/, ''); } // Protect against uncontrolled HTML input if ( escapeHtml ) { shortened = esc( shortened ); } return ''+shortened+'…'; }; }; } $.fn.serializeObject = function() { var obj = null; try { if (this[0].tagName && this[0].tagName.toUpperCase() == "FORM") { var arr = this.serializeArray(); if (arr) { obj = {}; jQuery.each(arr, function() { obj[this.name] = this.value; }); }//if ( arr ) { } } catch (e) { alert(e.message); } finally { } return obj; }; //사업자등록번호 유효성 체크 function checkCompRegNum(number){ var numberMap = number.replace(/-/gi, '').split('').map(function (d){ return parseInt(d, 10); }); if(numberMap.length == 10){ var keyArr = [1, 3, 7, 1, 3, 7, 1, 3, 5]; var chk = 0; keyArr.forEach(function(d, i){ chk += d * numberMap[i]; }); chk += parseInt((keyArr[8] * numberMap[8])/ 10, 10); console.log(chk); return Math.floor(numberMap[9]) === ( (10 - (chk % 10) ) % 10); } return false; } function isNaNV(num, ret){ if(isNaN(num)){ return ret; }else{ return num; } } function isBlank(v, rep){ return v == "" ? rep : (v || rep); } function fup(string) { return string.charAt(0).toUpperCase() + string.slice(1); } function cof(pnum, fixVal) { var num = pnum + ""; var retNum = num.replace(/[^-\.0-9]/gi, ""); if(isNaN(retNum)) return ""; var option = new Object(); option.minimumFractionDigits = fixVal; option.maximumFractionDigits = fixVal; return (+retNum).toLocaleString(undefined, option); } /* * 자바스크립트 64베이스 암호화 */ var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function encode64(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } while (i < input.length); return output; } function decode64(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; // remove all characters that are not A-Z, a-z, 0-9, +, /, or = input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do { enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } while (i < input.length); return output; } function encode64Han(str) { return encode64(escape(str)) } function decode64Han(str) { return unescape(decode64(str)) } /* * 스크립트 1000원 단위마다 , 찍기 */ function commify(n, comm) { var minus = n.toString().substring(0, 1); var reg=/\B(?/g, ">"); } function htmlSpecialChars2(text) { return text.replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'").replace(//g, ">"); } function replaceAll(text,fv,rv) { return text.split(fv).join(rv); } function left(s, c) { return (s+"").substr(0, c); } function right(s, c) { return (s+"").substr(-c); } function mid(s, c, l) { return (s+"").substr(c, l); } function avg(arr){ if(arr.length == 0){ return -10; } var total = arr.reduce(function(a, b){ return +a + +b; }); var avg = (total / arr.length); return avg; } function groupBySum(jsonArr, groupArr, sumArr_opt){ var sumArr = sumArr_opt || []; var newJsonArr = groupArr.length != 0 ? uniq(jsonArr, groupArr) : [{}]; $.each(newJsonArr, function(i, obj){ $.each(sumArr, function(idx, sumCol){ obj[sumCol] = 0; }); obj["groupByCount"] = 0; }); $.each(newJsonArr, function(idx, obj){ $.each($.grep(jsonArr, function(o, i){ var nStr = ""; var pStr = ""; $.each(groupArr, function(ix, groupCol){ nStr += obj[groupCol] + "|"; pStr += o[groupCol] + "|"; }); return nStr == pStr; }), function(i, o){ $.each(sumArr, function(ix, sumCol){ obj[sumCol] += +o[sumCol]; }); obj["groupByCount"]++; }); }); return newJsonArr; } function groupByAvg(jsonArr, groupArr, avgArr_opt, fixedNum){ var fixedVal = fixedNum || 1; var avgArr = avgArr_opt || []; var newJsonArr = groupArr.length != 0 ? uniq(jsonArr, groupArr) : [{}]; $.each(newJsonArr, function(i, obj){ $.each(avgArr, function(idx, avgCol){ obj[avgCol] = 0; }); obj["groupByCount"] = 0; }); $.each(newJsonArr, function(idx, obj){ $.each($.grep(jsonArr, function(o, i){ var nStr = ""; var pStr = ""; $.each(groupArr, function(ix, groupCol){ nStr += obj[groupCol] + "|"; pStr += o[groupCol] + "|"; }); return nStr == pStr; }), function(i, o){ $.each(avgArr, function(ix, avgCol){ obj[avgCol] += +o[avgCol]; }); obj["groupByCount"]++; }); }); $.each(newJsonArr, function(idx, obj){ $.each(avgArr, function(ix, avgCol){ obj[avgCol] = (obj[avgCol] / obj["groupByCount"] * 1.0).toFixed(fixedVal); if(isNaN(obj[avgCol])) obj[avgCol] = 0; }); }); return newJsonArr; } function uniq(arr, item){ var retArr = []; if(Array.isArray(item) == true){ retArr = unique($.map(arr, function(obj){ var tmpArr = []; for(var i=0; i bCol) return orderBy; if(aCol < bCol) return orderBy*-1; return 0; }); } // 넘어온 값이 빈값인지 체크합니다. // !value 하면 생기는 논리적 오류를 제거하기 위해 // 명시적으로 value == 사용 // [], {} 도 빈값으로 처리 function isEmpty(value) { if (value == "" || value == null || value == undefined || (value != null && typeof value == "object" && !Object.keys(value).length)) { return true } else { return false } }; // cutmenu 기능 (팝업으로 쓸 때 주변 모두 제거해버리는 것) function cutmenu(bool){ if(bool == undefined || bool){ $(".main-header, .main-sidebar, .main-footer, .content-header").hide(); $(".content-wrapper").addClass("ml-0"); $(".content-wrapper").css("background-color", "#EFF3F6"); $(".content-wrapper .content-body, .content-wrapper .content").addClass("p-0 py-1"); } } ///////// 이전 common.js에서 가져온 것 ▼▼▼▼▼▼▼▼▼▼▼▼ function new_project_2014(p_sn){ var tmp = p_sn.substring(0,4) if (tmp < '1407' || tmp == '9999') { return 1; } else { return 2; } } function winopn(urlstr) { wins = open(urlstr,"wins","width=210,height=230"); wins.focus(); } function projectwinopn(p_child_sn, p_method_cd) { var tmp_width = 1400; var tmp_height = 800; var p_sn = p_child_sn.substring(0, 7); var p_sub_type = p_child_sn.substring(8, 9); var url = '/project/project_list2_dep_2014.asp?p_sn=' + p_sn; url = url + "&p_sub_type=" + p_sub_type + "&p_method_cd=" + p_method_cd + "&p_child_sn=" + p_child_sn; window.open(url, '', 'left=0,top=0,width=' + tmp_width + ',height=' + tmp_height + ',scrollbars=yes,resizable=yes') } function OnlyNumber(objarg){ if(isNumeral(objarg.value) == false) { if(objarg.value.length <= 1){ objarg.value = ""; }else{ var valName = removeHipun(objarg.value) var cName = new String(); for(i = 0; i < valName.length; i++){ var sName = valName.substr(i,1); if(isNumeral(sName)){ cName = cName + sName.toString(); } } objarg.value = cName; } } } function isNumeral(str){ for(var i=0; i= 48 && uniCode <= 57)) return false; } return true; } function removeHipun(strSrc) { return strSrc.replace(/-/gi,""); } function allTrim(str) { var ch; var len = str.length; var retStr = ""; if (str=="" || len == 0) return retStr; for (var n = 0; n < len; n++) { ch = str.charAt(n); if (ch == " " || ch == "\r" || ch == "\n") continue; retStr += ch; } return retStr; } function vat_auto(i) { if ($("#sebu").val() == "185" || $("#expence_way").val() == "개인카드" || $("#expence_way").val() == "현금") { alert("선택한 세부내용 또는 지출방법은 부가세가 0원으로 고정입니다."); } else { if (i * 1 > 0) { var supply_value = document.getElementById("val_supply"+i).value.replace(/\,/gi, ""); if (supply_value != "" && supply_value * 1 > 9) { check_comma(supply_value.substring(0, supply_value.length - 1), '2', i); } else { check_comma("0", '2', i); } } else { var supply_value = document.getElementById("val_supply").value.replace(/\,/gi, ""); if (supply_value != "" && supply_value * 1 > 9) { check_comma(supply_value.substring(0, supply_value.length - 1), '2'); } else { check_comma("0", '2'); } } } } function vat_check() { if ($("#sebu").val() == "185" || $("#expence_way").val() == "개인카드" || $("#expence_way").val() == "현금") { } else { var supply_value = new Array(); var vat_value = new Array(); if (document.getElementById("expence_vat1") == undefined || document.getElementById("expence_vat1") == null) { supply_value[0] = document.getElementById("val_supply").value.replace(/\,/gi, ""); vat_value[0] = document.getElementById("expence_vat").value.replace(/\,/gi, ""); } else if (document.getElementById("expence_vat1") != undefined && document.getElementById("expence_vat1") != null) { for (var i = 0; i < 50; i++) { if (document.getElementById("expence_vat" + (i + 1)) != undefined && document.getElementById("expence_vat" + (i + 1)) != null) { supply_value[i] = document.getElementById("val_supply" + (i + 1)).value.replace(/\,/gi, ""); vat_value[i] = document.getElementById("expence_vat" + (i + 1)).value.replace(/\,/gi, ""); } } } for (var i = 0; i < supply_value.length; i++) { if (supply_value[i] != "" && supply_value[i] * 1 > 9) { if (supply_value[i].substring(0, supply_value[i].length - 1) != vat_value[i]) { var alert_str = "입력하신 부가세가 " + commify(vat_value[i]) + "원이 맞습니까?"; if (i > 0) { alert_str = (i+1) + "번째 " + alert_str; } if (confirm(alert_str)) { } else { return false; } } } } } return true; }