`;
$(".faq-list .table-article-list .bbsnewf5 > a").on("click", (e) => {
if (!$('input[name="delete_check_notice[]"]').length) {
e.preventDefault();
let $this = $(e.currentTarget);
let articleLink = $this.attr("href");
let replyContent = "";
$.ajax({
url: articleLink,
method: "GET",
contentType: "application/x-www-form-urlencoded;charset=euc-kr",
dataType: "html",
async: !1,
success: function (data) {
let content = $(data).find("#post_area").html();
replyContent = `
${content}
`;
if ( !$this.closest('.titdesign').hasClass('article--open') ) {
$('.titdesign').removeClass('article--open');
$('.reply-content').remove();
$this.parent().after(replyContent);
$this.closest('.titdesign').addClass('article--open');
} else {
$this.parent().siblings('.reply-content').remove();
$this.closest('.titdesign').removeClass('article--open');
}
},
error: function (t) {
alert(IS_ENG ? "An error has occurred." : "오류가 발생하였습니다.");
},
beforeSend: function (jqXHR) {
jqXHR.overrideMimeType("application/x-www-form-urlencoded;charset=euc-kr");
$("body").prepend(loader);
},
complete: function () {
$("#ajax-loader").remove();
},
});
}
});
}
// 이벤트 목록 스타일링
function event_init() {
if (!$(".board-event").length) return !1;
let articleMarkup = '
';
$(".board-event .article-wrapper > .event-article-list > tbody > tr").each(function () {
let article = $(this).find(".bbsnewf5");
let articleThumb = article.find("img").attr("src");
let articleLink = article.find(".gallery_subject>a").attr("href");
let articleTitle = article.find(".gallery_title").text();
let articleDesc = "";
let descTag = article.find(".gallery_cont");
if (descTag.length) {
articleDesc = "
"+descTag.text()+"
";
}
let articleDate = "";
let articleEtc = "";
let etcExtract = board_etc_extract(article);
let dateList = etcExtract.dateList;
let etcList = etcExtract.etcList;
if (dateList.length > 0) {
let dateSpan = '';
dateList.forEach(function(item, idx){
let text = item.text;
if (IS_ENG) {
text = board_date_init(item.text);
text = !text ? item.text : text;
}
if (idx > 0 && (item.name.match("종료") || item.name.match("마감") || item.name.match("Finish") || item.name.match("finish") || item.name.match("End") || item.name.match("end"))) {
text = " ~ "+text;
}
dateSpan += `${item.name}${text}`;
});
dateSpan += '';
articleDate = dateSpan;
}
if (etcList.length > 0) {
let etcSpan = '';
etcList.forEach(function(item, idx){
etcSpan += `${item.name}${item.text}`;
});
etcSpan += '';
articleEtc = etcSpan;
}
articleMarkup += `
${articleEtc}
${articleDate}
${articleTitle}
${articleDesc}
`;
});
articleMarkup += "
";
$(".board-event .article-wrapper").empty().append(articleMarkup);
}
// 블로그 스타일링 - 리스트 페이지
function blog_list_init() {
if (!$(".board-blog").length) return !1;
let no, title, write_date, category, desc, src, link;
let articleItems = "";
let html = '
';
$(".board-blog .article-wrapper > .blog-article-list .webzine_type2 > tbody > tr").each(function () {
let textTd = $(this).find(".webzine_type_text_td_left");
if (textTd.length == 0) { return; }
let imgTd = $(this).find(".webzine_type_img_td");
let _no = textTd.find(".webzine_no .obj_value").text();
no = _no.length ? 'NO. '+_no+'' : '';
textTd.find(".webzine_no").remove();
title = textTd.find(".webzine_subject .obj_value").text().trim();
textTd.find(".webzine_subject").remove();
let _date = textTd.find(".webzine_dateof_write .obj_value").text().trim();
_date = board_date_init(_date);
write_date = _date.length ? ''+_date+'' : '';
textTd.find(".webzine_dateof_write").remove();
let _category = textTd.find(".webzine_category .obj_value").text().trim();
category = _category.length ? '#'+_category+'' : '';
textTd.find(".webzine_category").remove();
let _desc = textTd.find(".webzine_description .obj_value").text().trim();
desc = _desc.length ? '
'+_desc+'
' : '';
textTd.find(".webzine_description").remove();
src = imgTd.find("img").attr("src");
link = imgTd.find("a").attr("href");
let ddList = $(this).find(".webzine_type_text_td_left dd");
if (ddList.length > 0) {
let items = '
";
$(".board-blog .article-wrapper").empty().append(html);
}
// 블로그 스타일링 - 읽기 페이지
function blog_read_init() {
if (!$(".board-blog #post_area").length) return !1;
let trs = $(".board-blog .table-article-common tr");
let headHtml = '
';
let tailHtml = '
';
let tailExist = false;
let postTag;
// let blogHead = $("#post_area").parents("tr").prevUntil();
let postBefore = true;
let list = $(".table-article-common .board_desc");
list.each(function(_, td) {
let txt = td.innerText.trim();
let res = board_date_init(txt);
if (res) td.innerText = res;
})
trs.each(function(i){
let label, desc;
if ($(this).find("#post_area").length > 0) {
postTag = $(this).find("#post_area");
postBefore = false;
}
if (i==0) {
desc = $(this).find(".board_desc").text().trim();
headHtml += `
';
$(".board-blog .table-article-common").replaceWith(headHtml);
let post = $(".board-blog").find(".post-body").html(postTag);
if (tailExist) {
post.after(tailHtml);
}
let thumbnails = $(".board-view-thumbnails").find("a");
let html2 = `
Previous posts
`;
thumbnails.each(function(){
let href = $(this).attr("href");
let src = $(this).find("img").attr("src");
html2 += `
`;
});
html2 += '
';
$(".board-blog").find(".post-body").append(html2);
$(".board-view-thumbnails").remove();
let html3 = `
`;
let move_btns = $(".board-blog .move-page");
move_btns.each(function(){
let text = $(this).text().trim();
let direction = text == "이전" || text == "Prev" ? "prev" : "next";
let icon;
if (IS_ENG) {
icon = text == "Prev" ? 'Prev' : 'Next';
} else {
icon = text == "이전" ? '이전글' : '다음글';
}
let link = $(this).attr("href");
html3 += `${icon}`;
});
html3 += `
`;
move_btns.remove();
$(".board-blog").find(".post-wrap").append(html3);
$(".board-blog").find(".move-btn").on("mouseover", function(){
$(this).addClass('on');
});
$(".board-blog").find(".move-btn").on("mouseout", function(){
$(this).removeClass('on');
});
}
// 문의하기 폼메일 스타일링
function formmail_init() {
let writeForm = $(".contact-form");
if (!writeForm.length) return !1;
let items = $(".contact-form .table-form > tbody > tr .formmail_cell_bgcolor");
write_form_replace(items, writeForm);
}
// 글쓰기 양식 스타일링 OK
function write_form_replace(descList, writeForm) {
let idIdx = 1;
let isFormmail = writeForm[0].className == 'contact-form';
if ($('#privacy_terms_context').length) {
const termsContext = $('.formmail_cell_bgcolor textarea[readonly]').val();
const modalTermsContext = $('#privacy_terms_context');
modalTermsContext.val(termsContext);
}
descList.each(function(idx, desc) {
// 날짜, 전화번호 td
let flexChild = $(desc).find("input[type=text], select");
if (flexChild.length >= 3) {
$(desc).addClass("flex-line");
}
// 주소 우편번호 td
let zipcodeChild = $(desc).find(".button-zipcode");
if (zipcodeChild.length) {
$(desc).addClass("zipcode-line");
}
// 체크박스, 라디오 있는 td
let checkRadioChild = $(desc).find("input[type=checkbox], input[type=radio]");
if (checkRadioChild.length) {
let brTags = $(desc).find("br");
let group = {count: brTags.eq(0).index()};
if (isFormmail) {
group.count = $(desc).find("tr").eq(0).find("input").length;
}
// 태그 교체
checkRadioChild.each(function(idx){
let inputId = 'labelfor'+idIdx;
this.id = inputId;
// select + checkbox (음력 사용시 해당)
if (this.name.match("_lunar")) {
let replaceTag = $(desc).find("select");
let newHtml = '
';
$(desc).html(newHtml); }
// 그 외 체크박스, 라디오 버튼
else {
let labelClass = "label-group";
labelClass += idx > 0 && idx % group.count == 0 ? " end" : "";
let text = this.value;
if (this.name == "com_board_notice") {
if (IS_ENG) {
text = "Set this as a notice";
$(this).parents("tr.board").find(".board_bgcolor").text("Notice");
} else {
text = "이 글을 공지글로 설정합니다.";
}
}
$(this).replaceWith('
'+this.outerHTML + `
`);
}
idIdx++;
});
$(desc).addClass("flex-line");
// 일반 텍스트 삭제 (위에서 label로 대체됨)
let childTags = $(desc).find(".label-group, .select-group, input[type=hidden]");
$(desc).html(childTags);
// 세부항목 가로 표시개수 설정 (br -> div로 묶기)
if (group.count > -1) {
let labelGroup = $(desc).find(".label-group");
labelGroup.each(function(i){
if (i % group.count == 0) {
let start = $(this);
let end = start.nextUntil(".label-group.end");
$.merge(start,end).wrapAll('');
}
})
$(desc).addClass("change-direction");
}
}
// 첨부파일 td
let fileChild = $(desc).find("input[type=file");
if (fileChild.length) {
let innerText = $(desc).text();
let allFileName = innerText.split(/[\n\t]+/g).filter((word) => word.length > 0 && word != "삭제");
$(desc).addClass("file-desc");
let fileIdx = 0;
// 태그 교체
fileChild.each(function(){
let inputId = 'labelfor'+idIdx;
this.id = inputId;
this.className = "upload-hidden";
let $this = $(this);
$this.wrap('');
let parent = $this.closest(".file-upload");
let prependHtml = ``;
parent.prepend(prependHtml);
idIdx++;
fileIdx++;
});
// 업로드된 파일명 셋팅
let delList = $(desc).find(".file_attach_del");
if (delList.length) {
delList.each(function(i){
$(this).closest("a").prev(".file-upload").find(".upload-name").addClass("exist").val(allFileName[i]);
});
}
// 일반 텍스트 삭제
let childTags = $(desc).children();
$(desc).html(childTags);
// 파일선택 시 파일명 셋팅 이벤트
let fileTarget = writeForm.find('.file-upload .upload-hidden');
fileTarget.on('change', function(){
let filename = $(this)[0].files[0].name;
$(this).siblings('.upload-name').val(filename);
});
}
});
}
// 게시판 gallery_etc 재료 추출
function board_etc_extract(article, type) {
let galleryEtcFonts = article.find(".gallery_etc font");
let dateList = [];
let etcList = [];
let allList = [];
galleryEtcFonts.each(function(idx, tag) {
let subject = $(tag).text().split(" : ");
let subjectText = subject[1];
let subjectName = subject[0];
let isSecret = tag.style.fontSize == "486px" ? true : false; // 비밀글은 관리자 항목관리에서 font-size를 486px로 설정하여 구분하고 있음.
if (tag.children.length > 0) {
etcList.push({name: subjectName, text: tag.children[0].outerHTML});
allList.push({name: subjectName, text: tag.children[0].outerHTML});
} else {
let dateRegex1 = RegExp(/^\d{4}년 (0[1-9]|1[012])월 (0[1-9]|[12][0-9]|3[01])일$/);
let dateRegex2 = RegExp(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/);
if (dateRegex1.test(subjectText)) {
let date = subjectText;
date = date.replace(/[(가-힣)]/g, "").replaceAll(" ", "."); // Tip : 년월일 -> . 으로 변경
dateList.push({name: subjectName, text: date});
} else if (dateRegex2.test(subjectText)) {
let writeDate = subjectText.replaceAll("-", "."); // Tip : - 를 -> . 으로 변경
dateList.push({name: subjectName, text: writeDate, secret: isSecret});
allList.push({name: subjectName, text: writeDate, secret: isSecret});
} else {
etcList.push({name: subjectName, text: subjectText, secret: isSecret});
allList.push({name: subjectName, text: subjectText, secret: isSecret});
}
}
});
if (type==1) {
return allList;
} else {
return {dateList: dateList, etcList: etcList};
}
}
// string 내에 html 주석 삭제
function getPureHtml(str) {
while(true) {
if (str.indexOf('');
str = str.substring(0, start) + str.substring(end+3, str.length);
} else {
break;
}
}
return str;
}
});