// noinspection JSUnusedGlobalSymbols window.addEventListener('error', (event) => { alert(`오류가 발생했어요!\n메시지: ${event.message}\n위치: ${event.filename}:${event.lineno}`); }); String.prototype.startsWith = function (search, pos) { return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; }; //자리수 채우기 String.prototype.fill = Number.prototype.fill = function (fix) { let len = String(this).length; if (len >= fix) return this; let spec = '0000'; while (fix > String(spec).length) spec += '0000'; return spec.substring(0, (fix - len)) + this; }; Date.prototype.date = function (fmt) { if (!this.valueOf()) return ''; if (!fmt) fmt = 'yyyy-MM-dd HH:mm:ss'; let weekName = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일']; let d = this; return fmt.replace(/(yyyy|yy|MM|dd|E|HH|hh|mm|ss|a\/p)/gi, function ($1) { switch ($1) { case 'yyyy': return d.getFullYear(); case 'yy': return (d.getFullYear() % 1000).fill(2); case 'MM': return (d.getMonth() + 1).fill(2); case 'dd': return d.getDate().fill(2); case 'E': return weekName[d.getDay()]; case 'HH': return d.getHours().fill(2); case 'hh': return ((h = d.getHours() % 12) ? h : 12).fill(2); case 'mm': return d.getMinutes().fill(2); case 'ss': return d.getSeconds().fill(2); case 'a/p': return d.getHours() < 12 ? '오전' : '오후'; default: return $1; } }); }; function changeDate(dt) { if (!dt) return ''; try { return dt.date(); } catch (e) { return dt; } } $(function () { // placeholder 지원 안하는 브라우저는 js로 처리 $('input, textarea').placeholder(); $('.numonly').on('keypress', function (e) { let key = window.event ? window.event.keyCode : e.which; if (!(key > 47 && key < 58) && !(key > 95 && key < 106) && !(key == 8 || key == 9 || key == 37 || key == 39 || key == 46)) { e.preventDefault; } }).on('keyup', function () { $(this).val($(this).val().replace(/[^0-9]/g, '')); }); wtypeCheck(true); }); //각 영역 변경 function change(id) { $('div.body-container').hide(); $('#' + id).show(); $('html,body').scrollTop(0); stepOn(id); changeFooter(); } function stepOn(id) { let no = 0; switch (id) { case 'notice' : no = 0; break; case 'agreement': no = 1; break; case 'sub-notice-agreement' : no = 1; break; case 'question' : no = 1; break; case 'residence': no = 1; break; case 'private' : $('#noticeAgreementYn').attr('checked', true); $('#agreementYn').attr('checked', true); no = 2; break; case 'apply' : no = 3; break; case 'result' : no = 4; break; } for (let i = 0; i <= 4; i++) { if (i > no) $('.step li').eq(i).removeClass('on'); else if (i == no) $('.step li').eq(i).addClass('on'); } } function changeFooter() { if ($(window).height() > $('body').height() + 60) { $('#footer').css({ 'position': 'fixed', 'bottom': 0, 'margin-top': 0 }); } else { $('#footer').css({ 'position': 'relative', 'margin-top': '50px' }); } } //쿠키저장 function setCookie(name, value, expireMinute) { let todayDate = new Date(); todayDate.setTime(todayDate.getTime() + (expireMinute * 60 * 1000)); document.cookie = name + '=' + escape(value) + '; path=/; expires=' + todayDate.toGMTString() + ';'; } //쿠키값읽어오기 function getCookie(name) { let arg = name + '='; let alen = arg.length; let clen = document.cookie.length; let i = 0; while (i < clen) { let j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal(j); i = document.cookie.indexOf(' ', i) + 1; if (i == 0) break; } return null; } //쿠키값읽어오기 function getCookieVal(offset) { let endstr = document.cookie.indexOf(';', offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } //쿠키삭제 // noinspection JSUnusedGlobalSymbols function deleteCookie(name) { let expireDate = new Date(); expireDate.setDate(expireDate.getDate() - 1); if ('' != getCookie(name)) { document.cookie = name + '=' + ';expires=' + expireDate.toGMTString() + ';path=/'; } } // noinspection JSUnusedGlobalSymbols function closePopupToday() { if ($('#popupAlwaysYn').is(':checked')) { let minute = 24 * 60; setCookie('POPUP', 'Y', minute); showPopup('N'); } } function showPopup(yn) { if (yn == 'N') $('#popupAlways').hide(); else $('#popupAlways').show(); } let isMobile = false; function wtypeCheck(flag) { let filter = 'win16|win32|win64|mac|macintel'; isMobile = false; if (navigator.platform) { isMobile = filter.indexOf(navigator.platform.toLowerCase()) < 0; } if (flag) { if (isMobile) { $('.wtype-pc').hide(); $('.wtype-mobile').show(); $('.browser-guide').hide(); } else { $('.wtype-pc').show(); $('.wtype-mobile').hide(); let browser = getBrowserType(); if (!(browser == 'IE11' || browser == 'Chrome')) $('.browser-guide').show(); else $('.browser-guide').hide(); } } } function getBrowserType() { let _ua = navigator.userAgent; //IE 11,10,9,8 let trident = _ua.match(/Trident\/(\d.\d)/i); if (trident != null) { if (trident[1] == '7.0') return 'IE' + 11; if (trident[1] == '6.0') return 'IE' + 10; if (trident[1] == '5.0') return 'IE' + 9; if (trident[1] == '4.0') return 'IE' + 8; } //IE 7... if (navigator.appName == 'Microsoft Internet Explorer') return 'IE' + 7; //other let agt = _ua.toLowerCase(); if (agt.indexOf('chrome') != -1) return 'Chrome'; if (agt.indexOf('opera') != -1) return 'Opera'; if (agt.indexOf('staroffice') != -1) return 'Star Office'; if (agt.indexOf('webtv') != -1) return 'WebTV'; if (agt.indexOf('beonex') != -1) return 'Beonex'; if (agt.indexOf('chimera') != -1) return 'Chimera'; if (agt.indexOf('netpositive') != -1) return 'NetPositive'; if (agt.indexOf('phoenix') != -1) return 'Phoenix'; if (agt.indexOf('firefox') != -1) return 'Firefox'; if (agt.indexOf('safari') != -1) return 'Safari'; if (agt.indexOf('skipstone') != -1) return 'SkipStone'; if (agt.indexOf('netscape') != -1) return 'Netscape'; if (agt.indexOf('mozilla/5.0') != -1) return 'Mozilla'; } function applyLink() { wtypeCheck(false); //if (page == 'templates.demo.index') document.location.href = '/apply.do'; //else if (page == 'info') document.location.href = '/applyInfo.do'; } // 본인인증 호출 function privateCall() { let windowW = 430; let windowH = 590; let left = Math.ceil((window.screen.width - windowW) / 2); let top = Math.ceil((window.screen.height - windowH) / 2) - 55; window.open('', 'auth_popup', 'width=' + windowW + ',height=' + windowH + ',scrollbar=yes,left=' + left + ',top=' + top + ',screenX=' + left + ',screenY= ' + top); let form = document.privateForm; form.target = 'auth_popup'; form.submit(); } function btnColorChange(obj, id) { if (obj.checked) $('#' + id + ' .bk').addClass('activationColor'); else $('#' + id + ' .bk').removeClass('activationColor'); } //번호 출력 - 4자리 단위 데시 구분 function mobileView(n) { let reg = /(^[+-]?\d+)(\d{4})/; let len = n.length; let i = 0; while (reg.test(n)) { if ((i > 0 && (len <= 10))) { reg = /(^[+-]?\d+)(\d{3})/; } n = n.replace(reg, '$1' + '-' + '$2'); i++; } return n; } function birthdayView(n) { let reg = /(\d{4})(\d{2})(\d{2})/; n = n.replace(reg, '$1-$2-$3'); return n; } function moneyView(money) { return money.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + '원'; } function dateView(date) { return date.substring(0, 4) + '년 ' + date.substring(4, 6) + '월 ' + date.substring(6, 8) + '일'; } // noinspection JSUnusedGlobalSymbols function dateTimeView(datetime) { return datetime.substring(0, 4) + '년 ' + datetime.substring(4, 6) + '월 ' + datetime.substring(6, 8) + '일 ' + datetime.substring(8, 10) + ':' + datetime.substring(10, 12); } function goWaitConfirm() { //if(confirm("대기창으로 이동합니다.")) location.href = '/'; //return; } function goLanding() { location.href = '/landing/index.do'; } function copyToClipboard() { let copyText = $('#cyberAccountNo'); copyText.select(); document.execCommand('Copy'); $('#cyber_account_no').focus(); } function multiDeposit(type) { $('.js-depositSite').addClass('blind'); if (type) { const types = type.split(';'); for (let i = 0; i < types.length; i++) { const type = types[i]; const typeItems = type.split('-'); if ($.isArray(typeItems) && typeItems.length > 0) { let groupName = typeItems[0].replace(/\s/gi, ''); if (MULTI_GROUP_NAME) groupName = MULTI_GROUP_NAME[groupName] ? MULTI_GROUP_NAME[groupName] : groupName; if ($('#' + groupName)) $('#deposit' + groupName).removeClass('blind'); } } } } function showYn(yn) { return yn == 'Y' ? '예' : yn == 'N' ? '아니오' : yn.includes(';') ? yn.replaceAll(';', ', ') : yn; } function showResidentialAreaName(yn, residentialAreaName) { if (residentialAreaName) return yn == 'Y' ? residentialAreaName : '기타'; else return yn == 'Y' ? '예' : yn == 'N' ? '아니오' : yn; } let TYPE_RESULT_SEPARATOR = '-'; // 다른 구분자를 사용해야할 경우 청약 폴더에 common.js 생성, apply.html, applyInfo.html에 common.js 추가하고 정의한다. function showApplyResultInfo(info) { let resultAddress; if (info['addressDetail']) resultAddress = '(' + info['zipcode'] + ')
' + info['address'] + ' ' + info['addressDetail']; else resultAddress = info['address']; // 청약신청정보 $('#result-seq').html(info['seq']); // 타입과 신청유형을 분리해야할 경우 사용 if ($('#custom-result-type').length > 0) { let infoTypes = info['type'].split(';'); let atype = []; // 주택형 let itype = []; // 신청유형 for (let t = 0; t < infoTypes.length; t++) { let infoType = infoTypes[t]; let applyTypes = infoType.split(TYPE_RESULT_SEPARATOR); let applyType = applyTypes.shift(); atype.push(applyType); if (applyTypes && applyTypes.length > 0) itype.push(applyTypes.join(TYPE_RESULT_SEPARATOR)); } $('#result-type').html(atype.join($('#typeNewLineYn').val() == 'Y' ? '
' : ', ')); $('#custom-result-type').html(itype.join($('#typeNewLineYn').val() == 'Y' ? '
' : ', ')); console.log('itype', itype, itype.length); if (itype.length < 1) { $('#custom-result-type').parents('dl').addClass('blind'); } else { $('#custom-result-type').parents('dl').removeClass('blind'); } } else { $('#result-type').html(info['type'].replace(/;/g, $('#typeNewLineYn').val() == 'Y' ? '
' : ', ')); } $('#result-name').html(info['name']); $('#result-mobile').html(mobileView(info['mobile'])); $('#result-birthday').html(birthdayView(info['birthday'])); $('#result-gender').html(info['gender'] == '0' ? '여' : '남'); $('#result-address').html(resultAddress); $('#result-refund').html(info['refundBank'] + ' / ' + info['refundBankAccountHolder'] + ' / ' + info['refundBankAccountNumber']); for (let i = 1; i <= 5; i++) { const checkValue = info['check' + i]; if (checkValue) { if (i == 1) $('#result-check' + i).html(showResidentialAreaName(checkValue, $('#residentialAreaName').val())); else $('#result-check' + i).html(checkValue); $('#result-custom-check' + i).text(showYn(checkValue)).parents('dl').removeClass('blind'); } else { $('#result-check' + i).parents('dl').addClass('blind'); $('#result-custom-check' + i).parents('dl').addClass('blind'); } } // 결과 출력 후 작업이 필요할 경우 (대치 등) if (typeof showApplyInfoAfter === 'function') showApplyInfoAfter(); /*// custom check1 let check1 = info['check1']; if (check1) { $('#result-check1').html(showResidentialAreaName(check1, $('#residentialAreaName').val())); $('#result-custom-check1').text(showYn(check1)).parents('dl').removeClass('blind'); } else { $('#result-check1').parents('dl').addClass('blind'); $('#result-custom-check1').parents('dl').addClass('blind'); } // custom check2 let check2 = info['check2']; if (check2) { $('#result-check2').html(check2); $('#result-custom-check2').text(showYn(check2)).parents('dl').removeClass('blind'); } else { $('#result-check2').parents('dl').addClass('blind'); $('#result-custom-check2').parents('dl').addClass('blind'); } // custom check3 let check3 = info['check3']; if (check3) { $('#result-check3').html(check3); $('#result-custom-check3').text(showYn(check3)).parents('dl').removeClass('blind'); } else { $('#result-check3').parents('dl').addClass('blind'); $('#result-custom-check3').parents('dl').addClass('blind'); } // custom check4 let check4 = info['check4']; if (check4) { $('#result-check4').html(check4); $('#result-custom-check4').text(showYn(check4)).parents('dl').removeClass('blind'); } else { $('#result-check4').parents('dl').addClass('blind'); $('#result-custom-check4').parents('dl').addClass('blind'); } // custom check5 let check5 = info['check5']; if (check5) { $('#result-check5').html(check5); $('#result-custom-check5').text(showYn(check5)).parents('dl').removeClass('blind'); } else { $('#result-check5').parents('dl').addClass('blind'); $('#result-custom-check5').parents('dl').addClass('blind'); }*/ } // 휴대폰번호 체크 function regExpMobile(str) { const regExp = /^(01[016789]{1})-?[0-9]{3,4}-?[0-9]{4}$/; return regExp.test(str); } function isEmail(text) { const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return pattern.test(text); } function changeRequestNo(request_no) { $('#request_no').val(request_no); }