2022-09-19 09:20:49 +00:00
|
|
|
$(document).on('click', '#commentSaveBtn', function (){
|
|
|
|
|
if(!$("#comment").val()) {
|
|
|
|
|
alert("댓글을 입력해주세요.")
|
|
|
|
|
}else{
|
|
|
|
|
if (confirm("등록하시겠습니까?")) {
|
|
|
|
|
contentFade("in")
|
|
|
|
|
const formData = new FormData($("#commentForm")[0]);
|
|
|
|
|
$.ajax({
|
|
|
|
|
type : 'POST',
|
|
|
|
|
data : formData,
|
|
|
|
|
url : "/publicBoard/saveComment",
|
|
|
|
|
processData: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
beforeSend: function (xhr){
|
|
|
|
|
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
|
|
|
},
|
|
|
|
|
success : function(result) {
|
|
|
|
|
alert("저장되었습니다.");
|
|
|
|
|
contentFade("out");
|
|
|
|
|
},
|
|
|
|
|
error : function(xhr, status) {
|
|
|
|
|
alert("저장에 실패하였습니다.")
|
|
|
|
|
contentFade("out");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '.childCommentBtn', function (){
|
|
|
|
|
const childCommentDiv = $(this).parents(".commentRow").find(".childCommentDiv")
|
|
|
|
|
childCommentDiv.show();
|
|
|
|
|
$("#parentComment").val($(this).parents(".commentRow").find(".commentKey").val());
|
|
|
|
|
childCommentDiv.empty().append($("#commentForm"))
|
|
|
|
|
})
|
|
|
|
|
$(document).on('click', '.deleteCommentBtn', function (){
|
|
|
|
|
const publicKey = $(this).parents(".commentRow").find(".publicKey");
|
|
|
|
|
const commentKey = $(this).parents(".commentRow").find(".commentKey");
|
|
|
|
|
$.ajax({
|
|
|
|
|
type : 'POST',
|
|
|
|
|
data : {publicKey: publicKey, commentKey: commentKey},
|
|
|
|
|
url : "/publicBoard/deleteComment",
|
|
|
|
|
beforeSend: function (xhr){
|
|
|
|
|
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
|
|
|
},
|
|
|
|
|
success : function(result) {
|
|
|
|
|
alert("삭제되었습니다.");
|
|
|
|
|
contentFade("out");
|
|
|
|
|
},
|
|
|
|
|
error : function(xhr, status) {
|
|
|
|
|
alert("삭제를 실패하였습니다.")
|
|
|
|
|
contentFade("out");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
function getEditModal(publicKey, publicType){
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/publicBoard/editModal',
|
|
|
|
|
data: {publicKey: publicKey, publicType: publicType},
|
|
|
|
|
type: 'GET',
|
|
|
|
|
dataType:"html",
|
|
|
|
|
success: function(html){
|
|
|
|
|
$("#editContent").empty().append(html)
|
|
|
|
|
$("#content").summernote({
|
|
|
|
|
lang:'ko-KR',
|
|
|
|
|
height: 350,
|
|
|
|
|
disableDragAndDrop: true,
|
|
|
|
|
toolbar: [
|
|
|
|
|
['style', ['style']],
|
|
|
|
|
['font', ['bold', 'underline', 'clear']],
|
|
|
|
|
['color', ['color']],
|
|
|
|
|
['para', ['ul', 'ol', 'paragraph']],
|
|
|
|
|
['table', ['table']]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
setUploadDiv();
|
|
|
|
|
$("#editModal").modal('show');
|
|
|
|
|
},
|
|
|
|
|
error:function(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getViewModal(publicKey, publicType){
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/publicBoard/viewModal',
|
|
|
|
|
data: {publicKey: publicKey, publicType: publicType},
|
|
|
|
|
type: 'GET',
|
|
|
|
|
dataType:"html",
|
|
|
|
|
success: function(html){
|
|
|
|
|
$("#viewContent").empty().append(html)
|
|
|
|
|
$("#comment").summernote({
|
|
|
|
|
lang:'ko-KR',
|
|
|
|
|
height: 100,
|
|
|
|
|
disableDragAndDrop: true,
|
|
|
|
|
toolbar: [
|
|
|
|
|
['style', ['style']],
|
|
|
|
|
['font', ['bold', 'underline', 'clear']],
|
|
|
|
|
['color', ['color']],
|
|
|
|
|
['para', ['ul', 'ol', 'paragraph']],
|
|
|
|
|
['table', ['table']]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
$("#viewModal").modal('show');
|
|
|
|
|
},
|
|
|
|
|
error:function(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function savePublicBoard(formId){
|
|
|
|
|
if(contentCheck(formId)){
|
|
|
|
|
if(confirm("저장하시겠습니까?")){
|
|
|
|
|
contentFade("in");
|
|
|
|
|
const formData = new FormData($("#"+formId)[0]);
|
|
|
|
|
for(const file of files) {
|
|
|
|
|
if(!file.isDelete)
|
|
|
|
|
formData.append('uploadFiles', file, file.name);
|
|
|
|
|
}
|
|
|
|
|
$(".text-decoration-line-through").each(function (idx, el){
|
|
|
|
|
formData.append('fileSeq', $(el).attr("data-fileseq"));
|
|
|
|
|
})
|
|
|
|
|
$.ajax({
|
|
|
|
|
type : 'POST',
|
|
|
|
|
data : formData,
|
|
|
|
|
url : "/publicBoard/saveContent",
|
|
|
|
|
processData: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
success : function(result) {
|
|
|
|
|
alert("저장되었습니다.");
|
|
|
|
|
contentFade("out");
|
|
|
|
|
$("#editModal").modal('hide');
|
|
|
|
|
getViewModal(result);
|
|
|
|
|
},
|
|
|
|
|
error : function(xhr, status) {
|
|
|
|
|
alert("저장에 실패하였습니다.")
|
|
|
|
|
contentFade("out");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function contentCheck(formId){
|
|
|
|
|
let flag = true;
|
|
|
|
|
if(!$("#title").val()){
|
|
|
|
|
alert("제목을 입력해주세요.")
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
let totalSize = 0;
|
|
|
|
|
for(const file of files) {
|
|
|
|
|
if(!file.isDelete){
|
|
|
|
|
totalSize+=file.size;
|
|
|
|
|
if(file.size>209715200){
|
|
|
|
|
alert("파일당 사이즈는 200MB을 넘길 수 없습니다.")
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(totalSize>524288000){
|
|
|
|
|
alert("첨부파일의 용량 합은 500MB를 넘길 수 없습니다.")
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|