You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
8.8 KiB
JavaScript

2 years ago
$(function() {
var ww = window.innerWidth;
$('.open-menu').click(function(){
$('#sidebar').addClass('open')
$('body').addClass('open-sidebar')
});
$('#close-menu').click(function(){
$('#sidebar').removeClass('open')
$('body').removeClass('open-sidebar')
});
$('.back-button').click(function(e) {
e.preventDefault();
window.history.back();
})
// var indexPageable = null;
// if(ww > 992){
// indexPageable = createPageable();
// }
// function createPageable() {
// return new Pageable('#index-container', {
// animation: 500,
// delay: 0,
// orientation: "horizontal",
// onInit: function(data){
// console.log(data)
// if(data.index == 4){
// $('.scroll').hide()
// }else {
// $('.scroll').show()
// }
// }
// })
// }
var itemSwiper = new Swiper('#item-page', {
loop: true,
speed: 400,
autoplay: {
delay: 4000,
disableOnInteraction: false,
},
})
// indexPageable.on("scroll.end", function(data) {
// if(data.index == 4){
// $('.scroll').hide()
// }else {
// $('.scroll').show()
// }
// })
// $(window).resize(function () {
// ww = window.innerWidth;
// if(ww>992){
// if(!indexPageable){
// console.log('call')
// indexPageable = createPageable();
// }
// }else{
// if(indexPageable){
// console.log('destory')
// indexPageable.destroy()
// }
// console.log(indexPageable)
// }
// });
$('.info-term').click(function() {
$('#termModal').find('.term-title').html("개인정보처리방침");
$.get('/pages/privacy', {}, function(result) {
if (result) {
$("#termModal .term-content").html(result);
}
});
$('#termModal').modal('show');
})
$('.service-term').click(function() {
$('#termModal').find('.term-title').html("서비스 이용약관");
$.get('/pages/terms', {}, function(result) {
if (result) {
$("#termModal .term-content").html(result);
}
});
$('#termModal').modal('show');
})
$('.term-modal-close').click(function() {
$('#termModal').modal('hide')
$('#termModal').find('.term-title').html("")
})
});
var extExecutes = "php,php3,php4,phps,phtm,phtml,htm,html,sh,ph,inc,cgi,pl,tpl,exe,com,bat,dll,cpl,asp,aspx,vbs,java,jsp";
var extImages = "gif,jpg,jpeg,png,bmp";
$(document).ready(function() {
var checkMessage = function (result, msg, obj) {
if (!result) {
if (msg != undefined) alert(msg);
if (obj != undefined) obj.focus();
return false;
} else {
return true;
}
}
// 양쪽 공백 제거
$.fn.trim = function () {
var pattern = /(^\s*)|(\s*$)/g;
return this.val().replace(pattern, "");
}
// 공백 검사
$.fn.checkNull = function () {
var pattern = /^\s+|\s+$/g;
return (this.val() == null || this.val().replace(pattern, '') == '');
}
// 입력값이 비어 있는지 체크
$.fn.checkEmpty = function (msg) {
return checkMessage(!this.checkNull(), msg, this);
}
// 숫자인지 검사
$.fn.checkNumber = function (msg) {
var pattern = /^[0-9]+$/;
return checkMessage(pattern.test(this.val()), msg, this);
}
// 영문자인지 검사
$.fn.checkEnglish = function (msg) {
if (this.checkNull()) return false;
var pattern = /(^[a-zA-Z]+$)/;
return checkMessage(pattern.test(this.val()), msg, this);
}
// 한글인지 검사(자음, 모음만 있는 한글은 불가)
$.fn.checkKorean = function (msg) {
if (this.checkNull()) return false;
var pattern = /([^가-힣\x20])/i;
return checkMessage(!pattern.test(this.val()), msg, this);
}
// 영문자와 숫자 검사
$.fn.checkEngNumber = function (msg) {
if (this.checkNull()) return false;
var pattern = /(^[a-zA-Z0-9]+$)/;
return checkMessage(pattern.test(this.val()), msg, this);
}
// 최소입력숫자 제한
$.fn.checkCount = function (cnt, msg) {
if (this.checkNull()) return false;
if (!this.checkNumber()) return false;
if (this.val() < cnt) {
return checkMessage(false, msg, this);
} else {
return true;
}
}
// 입력길이 체크
$.fn.checkLength = function (len, ctype, msg) {
var str = this.val();
var str_len = 0;
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 255) {
str_len += 2;
} else {
str_len++;
}
}
if (ctype == 'max') {
return checkMessage((str_len <= len), msg, this);
} else if (ctype == 'min') {
return checkMessage((str_len >= len), msg, this);
} else {
return false;
}
}
$.fn.disableNumber = function () {
this.val(this.val().replace(/[^0-9]/g, ""));
};
$.fn.setComma = function (options) {
var opts = $.extend({}, {delimiter: ','}, options);
return this.each(function () {
$this = $(this);
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
var str = $this.html();
$this.html($this.html().toString().replace(new RegExp("(^\\d{" + ($this.html().toString().length % 3 || -1) + "})(?=\\d{3})"), "$1" + o.delimiter).replace(/(\d{3})(?=\d)/g, "$1" + o.delimiter));
});
};
$.fn.checkEmail = function (msg) {
var pattern = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return checkMessage(pattern.test(this.val()), msg, this);
}
// 전화번호 형식 검사
$.fn.checkPhone = function (check, msg) {
if (this.checkNull() || check == undefined) {
checkMessage(false, msg, this);
return false;
}
var str = this.val();
var pattern1, pattern2;
var result = false;
if (check == "phone") { //유선전화번호
pattern1 = /^(0[2-8][0-5]?)-?([1-9]{1}[0-9]{2,3})-?([0-9]{4})$/;
pattern2 = /^(1544|1566|1577|1588|1644|1688)-?([0-9]{4})$/;
result = (pattern1.test(str) || pattern2.test(str));
} else if (check == "mobile") { //휴대전화번호
pattern1 = /^(01[01346-9])-?([1-9]{1}[0-9]{2,3})-?([0-9]{4})$/;
result = pattern1.test(str);
} else { //유선전화,휴대전화 모두..
pattern1 = /^(0[2-8][0-5]?|01[01346-9])-?([1-9]{1}[0-9]{2,3})-?([0-9]{4})$/;
pattern2 = /^(1544|1566|1577|1588|1644|1688)-?([0-9]{4})$/;
result = (pattern1.test(str) || pattern2.test(str));
}
return checkMessage(result, msg, this);
}
//전화번호인지 검사
$.fn.checkPhoneNumber = function(msg) {
var pattern = /^[-0-9]*$/;
return checkMessage(pattern.test(this.val()), msg, this);
}
$.fn.autoHyphen = function() {
this.val(convertHyphen(this.val()));
}
// 파일확장자 검사
$.fn.checkExtension = function (check, msg) {
if (this.checkNull() || check == undefined) return true;
var str = this.val();
var exts = '';
var ext = str.substring(str.lastIndexOf(".") + 1).toLowerCase();
var result = false;
if (check == "image") { //이미지
exts = extImages;
} else if (check == "movie") { //동영상
exts = "asx,asf,wmv,wma,mpg,mpeg,mov,avi,flv,mp4";
} else if (check == "execute") { //실행파일
exts = extExecutes;
} else {
exts = check.toLowerCase();
}
result = (exts.indexOf(ext) != -1);
return checkMessage(result, msg, this);
}
$(".number").keyup(function () {
$(this).disableNumber();
});
$(".hyphen").keyup(function() {
$(this).autoHyphen();
});
autosize($(".autosize"));
});
$(window).on('load', function(){
// var options = {
// strings: ['CHEONG DAM'],
// typeSpeed: 40
// };
// var typed = new Typed('.typing', options);
setTimeout(function() {
$(".loader-page").fadeOut();
// typed.destroy()
}, 1000)
});
$(window).on('resize', function() {
$('.loader-page').addClass('d-none');
// resizeImages($(".board-content img"), $(".board-content").width());
});