let slideList = []; let articleCategory = ""; let nowArticeIndex = 0; const renderContent = (index) => { const element = slideList[index]; $("#articleTitle").html(element.title); $("#articleDate").html(`날짜 : ${element.view_indate}:00`); $("#articleImage").html( `img` ); $("#articleSubTitle").html(`${element.sub_title}`); $("#articleContents").html(`${element.contents.replace(/\n/g, "
")}`); }; const initialize = (e) => { if (e.state === false) { alert(e.message); return false; } slideList = e.result; renderContent(nowArticeIndex); $("#articleLoadingBar").hide(); $("#articeBox").removeClass("hidden"); }; const initializeListBox = (e) => { if (e.state === false) { alert(e.message); return false; } const itemList = e.result; $("#listBox").empty(); var listHtml = ""; itemList.forEach((element) => { listHtml += ``; listHtml += `
`; listHtml += `img`; listHtml += `
`; listHtml += `

`; listHtml += `${element.title}`; listHtml += `

`; // listHtml += `

`; // listHtml += `${element.contents}`; // listHtml += `

`; listHtml += `
`; listHtml += `
`; listHtml += ``; }); $("#listBox").html(listHtml); $("#listLoadingBar").hide(); $("#listBox").removeClass("hidden"); }; (function ($) { if (articleIdx === "") { location.href = `/`; } commonFunction.aJax({ url: service_url + "/get-slide-detail.php", data: { articleIdx: articleIdx, pageCategory: pageCategory, }, type: "POST", done: initialize, }); commonFunction.aJax({ url: service_url + "/get-slide-detail-list.php", data: { pageidx: articleIdx, pageCategory: pageCategory, }, type: "POST", done: initializeListBox, }); $(document).on("click", "[name=click-left-button]", function () { if (nowArticeIndex > 0) { nowArticeIndex = nowArticeIndex - 1; renderContent(nowArticeIndex); } else { nowArticeIndex = slideList.length - 1; renderContent(nowArticeIndex); } }); $(document).on("click", "[name=click-right-button]", function () { if (nowArticeIndex > slideList.length - 1) { nowArticeIndex = 0; renderContent(nowArticeIndex); } else { nowArticeIndex = nowArticeIndex + 1; if (nowArticeIndex > slideList.length - 1) { nowArticeIndex = 0; } renderContent(nowArticeIndex); } }); $(document).on("click", "[name=click-list-item]", function () { var idx = $(this).data("idx"); location.href = `/pages/detail.html?category=${pageCategory}&idx=${idx}`; }); })(jQuery);