kcgFileManager/src/main/resources/static/js/board/contentList.js

96 lines
2.6 KiB
JavaScript
Raw Normal View History

2021-12-15 09:33:47 +00:00
$(function(){
setSearchCondition();
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
})
$(document).on('click', '.contentTr', function (){
$(".contentCheckBox").prop('checked', false);
const target = $(this).find(".contentCheckBox")[0];
target.checked = true;
const selectedTab = $(".nav-tabs").find(".active")[0].id;
if(selectedTab === "contentTab"){
getBoardContent(target.value);
}else if(selectedTab === "logTab"){
getBoardLog(target.value);
}
})
$(document).on('change', '#fileCheckAll', function (){
$(".fileCheckBox").prop("checked", this.checked);
})
2021-12-15 09:33:47 +00:00
$(document).on('click', '#contentTab', function (){
getBoardContent(getContentSeq())
})
$(document).on('click', '#logTab', function (){
getBoardLog(getContentSeq())
})
$(document).on('click', '.fileDownLink', function (){
let url = "/board/fileDownload?"
url += "contentSeq="+Number($("#detailViewContentSeq").val());
url += "&fileSeq="+$(this).attr("data-fileseq");
window.open(encodeURI(url));
})
$(document).on('click', '#zipDownBtn', function (){
const checkFiles = $(".fileCheckBox:checked");
if(checkFiles.length>0){
let url = "/board/fileDownloadToZip?"
url += "contentSeq="+Number($("#detailViewContentSeq").val());
checkFiles.each(function (idx, el){
url += "&fileSeq="+Number($(el).attr("data-fileseq"))
});
window.open(encodeURI(url));
}else{
alert("선택된 파일이 없습니다.")
}
})
2021-12-15 09:33:47 +00:00
function getContentSeq(){
return $(".contentCheckBox:checked").val();
}
function getBoardContent(contentSeq){
if(contentSeq !== undefined){
const viewContentSeq = $("#detailViewContentSeq").val();
if(contentSeq !== viewContentSeq){
$.ajax({
url: '/board/selectBoardContent',
data: {contentSeq: contentSeq},
type: 'GET',
dataType:"html",
success: function(html){
$("#contentDiv").empty().append(html)
const viewCntTd = $(".contentCheckBox:checked").parents("tr").find(".viewCntTd");
viewCntTd.text(Number(viewCntTd.text())+1);
},
error:function(){
2021-12-15 09:33:47 +00:00
}
});
}
2021-12-15 09:33:47 +00:00
}
}
function getBoardLog(contentSeq){
if(contentSeq !== undefined){
const viewContentSeq = $("#logViewContentSeq").val();
if(contentSeq !== viewContentSeq){
$.ajax({
url: '/board/selectBoardLog',
data: {contentSeq: contentSeq},
type: 'GET',
dataType:"html",
success: function(html){
$("#logDiv").empty().append(html)
},
error:function(){
2021-12-15 09:33:47 +00:00
}
});
}
2021-12-15 09:33:47 +00:00
}
}