/* * Name : board.js * Version : 1.2.5 * Author : 1px studio * Date : 2023-09-25 * Desc : blog board + search bug fix version. & en * ------ !! This file encoding is "EUC-KR" required. !! ------ */ $(function () { let IS_ENG = $("html").attr("lang") == 'en'; let input_image, btn_img, btn_names; function transEngDate(date, isHyphenFormat) { var monthNames = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"]; if (!isHyphenFormat) { date = date.substr(0,4)+"-"+date.substr(6,2)+"-"+date.substr(10,2); } let d = new Date(date); return monthNames[d.getMonth()]+" "+d.getDate()+", "+d.getFullYear(); } (function allBoardReadPageDateChange(){ if ($(".table-article-common").length == 0 || !IS_ENG) { return false; } let regex = RegExp(/^\d{4}. (0[1-9]|1[012]). (0[1-9]|[12][0-9]|3[01]).$/); let list = $(".table-article-common .board_desc"); list.each(function(_, td) { let txt = td.innerText.trim(); if (regex.test(txt)) { let newDate = transEngDate(txt); td.innerText = newDate; } }) })(); $("#ext_search select").after(''); (function search_select() { let html = "", texts = [], values = [], search = window.location.search, params = new URLSearchParams(search); if ($("select[name=com_board_category_code]").length) { let category_code = params.get("com_board_category_code"), url = $("select[name=com_board_category_code]").attr("onchange").split("'")[1] + "com_board_category_code="; $("select[name=com_board_category_code] option").each(function (i) { let opt = $(this); if (IS_ENG && i==0) {texts.push("All"); } else { texts.push(opt.text()); } values.push(opt.val()); }); for (let j = 0; j < texts.length; j++) html += `${texts[j]}`; $(".category-button-wrapper").empty().append(html); } })(), (input_image = $("input[type=image]")), (btn_img = $("img")), (btn_names = IS_ENG ? ["Search", "Submit", "Write a comment", "Delete", "Move", "Copy", "Prev", "List", "Next", "Spam report", "Edit", "Delete", "Answer", "Writing", "Confirm", "Cancel"] : ["검색", "확인", "댓글작성", "삭제", "이동", "복사", "이전", "목록", "다음", "스팸신고", "수정", "삭제", "답변", "글쓰기", "작성완료", "취소"]), input_image.each(function () { let t = $(this).attr("src"); let search_txt = IS_ENG ? "Search" : "검색"; t.indexOf("search.gif") > -1 && ($(this).before(``), $(document).on("click", "#btn-search", function () { $(this).next("input[type=image]").trigger("click"); }), $(this).hide()), t.indexOf("confirm.gif") > -1 && ($(this).before(``), $(this).hide()), t.indexOf("comment_write.gif") > -1 && ($(this).before(``), $(document).on("click", "#btn-comment-write", function () { $(this).next("input[type=image]").trigger("click"); }), $(this).hide()); }), btn_img.each(function () { let t = $(this).attr("src"), e = $(this).attr("onclick"); t.indexOf("btn_sdel.gif") > -1 && ($(this).before(``), $(this).remove()), t.indexOf("move.gif") > -1 && ($(this).before(``), $(this).remove()), t.indexOf("copy.gif") > -1 && ($(this).before(``), $(this).remove()), t.indexOf("/prev.gif") > -1 && $(this).parent().addClass("button-b button--default move-page").text(btn_names[6]), t.indexOf("list.gif") > -1 && $(this).parent().addClass("button-b button--dark").text(btn_names[7]), t.indexOf("/next.gif") > -1 && $(this).parent().addClass("button-b button--default move-page").text(btn_names[8]), t.indexOf("spam.gif") > -1 && ($(this).before(``), $(this).remove()), t.indexOf("modify.gif") > -1 && $(this).parent().addClass("button-b button--default").text(btn_names[10]), t.indexOf("delete.gif") > -1 && $(this).parent().addClass("button-b button--default board-delete-btn").text(btn_names[11]), t.indexOf("reply.gif") > -1 && $(this).parent().addClass("button-b button--default").text(btn_names[12]), t.indexOf("write.gif") > -1 && $(this).parent().addClass("button-b button--dark size--3").text(btn_names[13]), t.indexOf("btn_confirm.gif") > -1 && $(this).parent().addClass("button-b button--primary").text(btn_names[14]), t.indexOf("cancel.gif") > -1 && $(this).parent().addClass("button-b button--default button--lg").text(btn_names[15]); }), (function t() { if (!$(".board-gallery").length) return !1; let e = [], a = [], i = [], n = [], r = "", l = $(".board-gallery .gallery-list").data("column") ? $(".board-gallery .gallery-list").data("column") : 3, s = ""; switch (l) { case 1: s = "col-xl-12"; break; case 2: s = "col-xl-6"; break; case 3: default: s = "col-xl-4"; break; case 4: s = "col-xl-3"; break; case 5: s = "col-xl-2-5"; break; case 6: s = "col-xl-2"; } if ($(".board-gallery").hasClass("type-a")) { $(".board-gallery .article-wrapper > .photo-article-list > tbody > tr").each(function () { let t = $(this).find(".bbsnewf5"), r = t.find(".gallery_etc").text().split(":")[1]; e.push(t.find("img").attr("src")), a.push(t.find(".gallery_subject>a").attr("href")), i.push(t.find(".gallery_title").text()), n.push(void 0 == r ? "" : '' + r.replace("]", "") + ""); }), (r = '
'); for (let c = 0; c < e.length; c++) r += `
${i[c]}
${n[c]}
${i[c]}
`; (r += "
"), $(".board-gallery .article-wrapper").empty().append(r); } else if ($(".board-gallery").hasClass("type-b")) { $(".board-gallery .article-wrapper > .photo-article-list > tbody > tr").each(function () { let t = $(this).find(".bbsnewf5"), r = t.find(".gallery_etc").text().split(":")[1]; e.push(t.find("img").attr("src")), a.push(t.find(".gallery_subject>a").attr("href")), i.push(t.find(".gallery_title").text()), n.push(void 0 == r ? "" : '' + r.replace("]", "") + ""); }), (r = '
'); for (let o = 0; o < e.length; o++) r += `
${i[o]}
${n[o]}
${i[o]}
`; (r += "
"), $(".board-gallery .article-wrapper").empty().append(r); } })(), (function t() { if (!$(".faq-list .table-article-list .titdesign").length) return !1; let e = `
`; $(".faq-list .table-article-list .bbsnewf5 > a").on("click", (t) => { if (!$('input[name="delete_check_notice[]"]').length) { t.preventDefault(); let a = $(t.currentTarget), i = a.attr("href"), n = ""; $.ajax({ url: i, method: "GET", contentType: "application/x-www-form-urlencoded;charset=euc-kr", dataType: "html", async: !1, success: function (t) { (n = ` ${$(t).find("#post_area").html()} `), a.closest(".titdesign").hasClass("article--open") ? (a.parent().siblings(".reply-content").remove(), a.closest(".titdesign").removeClass("article--open")) : ($(".titdesign").removeClass("article--open"), $(".reply-content").remove(), a.parent().after(n), a.closest(".titdesign").addClass("article--open")); }, error: function (t) { alert(IS_ENG ? "An error has occurred." : "오류가 발생하였습니다."); }, beforeSend: function (t) { t.overrideMimeType("application/x-www-form-urlencoded;charset=euc-kr"), $("body").prepend(e); }, complete: function () { $("#ajax-loader").remove(); }, }); } }); })(), (function event_list() { if (!$(".board-event:not(.stockist-page)").length) return !1 let e = [], a = [], i = [], n = [], l = ""; $(".board-event .article-wrapper > .event-article-list > tbody > tr").each(function () { let t = $(this).find(".bbsnewf5"); let ev_date = t.find(".gallery_etc").text().trim(); let ev_dates = ev_date.split(","); let span_s = ev_dates.length < 2 ? '' : ev_dates[0].split(":")[1].trim(); let span_e = ev_dates.length < 2 ? '' : ev_dates[1].split(":")[1].replace("]", "").trim(); if (IS_ENG) { span_s = transEngDate(span_s); span_e = transEngDate(span_e); } e.push(t.find("img").attr("src")), a.push(t.find(".gallery_subject>a").attr("href")), i.push(t.find(".gallery_title").text()), n.push(ev_date.length == 0 ? '' : ''+span_s+' ~ '+span_e+''); }), (l = '
'); for (let s = 0; s < e.length; s++) l += `
${i[s]}
${n[s]}

${i[s]}

`; (l += "
"), $(".board-event .article-wrapper").empty().append(l); })(), (function stockist_list() { if (!$(".board-event.stockist-page").length) return !1; let e = [], a = [], i = [], n = [], l = ""; $(".board-event .article-wrapper > .event-article-list > tbody > tr").each(function () { let t = $(this).find(".bbsnewf5"); let addr = t.find(".gallery_etc font").text().trim(); addr = addr.match("주소 :") != null ? addr.substr(11, addr.length-1) : addr; e.push(t.find("img").attr("src")), a.push(t.find(".gallery_subject>a").attr("href")), i.push(t.find(".gallery_title").text()), n.push(''+addr+''); }), (l = '
'); for (let s = 0; s < e.length; s++) l += `
${i[s]}
${n[s]}

${i[s]}

`; (l += "
"), $(".board-event .article-wrapper").empty().append(l); })(), (function recruit_list() { if (!$(".board-recruit").length) return !1; let href = [], title = [], date = [], career = [], regular = [], html = ""; $(".board-recruit .article-wrapper > .recruit-article-list > tbody > tr").each(function () { let t = $(this).find(".bbsnewf5"); let etc = t.find(".gallery_etc").text().trim(); let splits = etc.split(","); career.push(splits[0].split(": ")[1]); regular.push(splits[1].split(": ")[1]); let regex = /[^0-9]/g; let date_s = splits[2].replace(regex, ""); date_s = date_s.slice(0,4) + '.' + date_s.slice(4, 6) + '.' + date_s.slice(6,8); let date_e = splits[3].replace(regex, ""); date_e = date_e.slice(0,4) + '.' + date_e.slice(4, 6) + '.' + date_e.slice(6,8); date.push(date_s+' ~ '+date_e); href.push(t.find(".gallery_subject>a").attr("href")), title.push(t.find(".gallery_title").text()); }), (html = '
'); for (let s = 0; s < href.length; s++) html += `

${career[s]}

${title[s]}

${regular[s]}

${date[s]}

${date[s]}

[${career[s]}] ${title[s]}

`; (html += "
"), $(".board-recruit .article-wrapper").empty().append(html); })(), (function event_read_eng(){ var regex = RegExp(/^\d{4}. (0[1-9]|1[012]). (0[1-9]|[12][0-9]|3[01]).$/); var eng_rows = $(".event-eng-read .board_desc"); eng_rows.each(function(_, obj){ let date = obj.innerText.trim(); if (regex.test(date)) { let newDate = transEngDate(date); obj.innerText = newDate; } }); })(), (function bloglist_modify() { if (!$(".board-blog").length) return !1; let no = [], title = [], write_date = [], category = [], desc = [], src = [], link = [], html = ""; $(".board-blog .article-wrapper > .blog-article-list .webzine_type2 > tbody > tr").each(function () { let txt_td = $(this).find(".webzine_type_text_td_left"); if (txt_td.length == 0) { return; } let img_td = $(this).find(".webzine_type_img_td"); no.push(txt_td.find(".webzine_no .obj_value").text().trim()); title.push(txt_td.find(".webzine_subject .news_title").text().trim()); write_date.push(txt_td.find(".webzine_dateof_write .obj_value").text()); category.push(txt_td.find(".webzine_category .obj_value").text().trim()); desc.push(txt_td.find(".webzine_description .obj_value").text().trim()); src.push(img_td.find("img").attr("src")); link.push(img_td.find("a").attr("href")); }), (html = '
'); for (let j = 0; j < src.length; j++) html += `
NO. ${no[j]} #${category[j]} ${write_date[j]}

${title[j]}

${desc[j]}

`; (html += "
"), $(".board-blog .article-wrapper").empty().append(html); })(), (function blog_modify() { if (!$(".board-blog #post_area").length) return !1; let trs = $(".board-blog .table-article-common tr"); let html = '
'; let regex = RegExp(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/); let postTag; trs.each(function(i){ let label, desc; postTag = postTag!==null ? $(this).find("#post_area") : postTag; if (i==0) { desc = $(this).find(".board_desc").text().trim(); html += `

${desc}

`; } else { label = $(this).find(".board_bgcolor").text().trim(); desc = $(this).find(".board_desc").text().trim(); if (regex.test(desc)) { desc = transEngDate(desc, true); } if (label.length == 0) {return;} html += ` ${label}${desc} `; } }); html += '
'; $(".board-blog .table-article-common").replaceWith(html); $(".board-blog").find(".post-body").html(postTag); 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 == "이전" ? "prev" : "next"; let icon; if (IS_ENG) { icon = text == "이전" ? '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 blogwrite_modify() { if ($(".board-blog #post_area").length) return !1; let target = $(".board-blog .table-article-common tr input[name='com_board_notice']"); if (target.length > 0 ) { target.closest("tr").remove(); } })(); });