|
|
|
@ -62,8 +62,8 @@
|
|
|
|
|
<div class="comment-box"> |
|
|
|
|
<span class="total"></span> |
|
|
|
|
<div class="comment-input"> |
|
|
|
|
<textarea placeholder="댓글을 입력해주세요"></textarea> |
|
|
|
|
<button type="button">등록</button> |
|
|
|
|
<textarea id="cmtContent" name="cmtContent" placeholder="댓글을 입력해주세요"></textarea> |
|
|
|
|
<button id="cmtSave" type="button">등록</button> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<!-- <div class="comment-view" id="test3"> |
|
|
|
@ -82,11 +82,6 @@
|
|
|
|
|
class="date">05.02 13:00</span></span> <span class="text">여기는 댓글의 |
|
|
|
|
댓글(답글)정보!3333</span> |
|
|
|
|
</div> |
|
|
|
|
<div class="reply-view"> |
|
|
|
|
<span class="user"><span class="id">익명6</span><span |
|
|
|
|
class="date">05.02 13:00</span></span> <span class="text">여기는 댓글의 |
|
|
|
|
댓글(답글)정보!3333</span> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
** |
|
|
|
|
</div> --> |
|
|
|
@ -186,29 +181,29 @@
|
|
|
|
|
success: function(response) { |
|
|
|
|
console.log(response) |
|
|
|
|
|
|
|
|
|
/* comment */ |
|
|
|
|
/* comment (each를 역으로 가져와서 idx는 거꾸로.. 엉망)*/ |
|
|
|
|
$($(response).get().reverse()).each( function(i, item) { |
|
|
|
|
if(item.targetId==0) { |
|
|
|
|
var comment = |
|
|
|
|
"<div class='comment-view' id='user" + (i+1) + "'>" + |
|
|
|
|
"<div class='comment-view' id='comment-view" + (i+1) + "'>" + |
|
|
|
|
"<span class='user'>" + |
|
|
|
|
"<span class='id'>" + item.regUser + "</span>" + |
|
|
|
|
"<span class='date'>" + item.regDate + "</span>" + |
|
|
|
|
"<span>답글</span>" + |
|
|
|
|
"<span onclick='replyInputCreate("+ (i+1) + "," + item.id +")'>답글</span>" + |
|
|
|
|
"<input type='checkbox' name='replyCheck" + (i+1) + "' style='display:none'/>" + |
|
|
|
|
"</span>" + |
|
|
|
|
"<span class='text' id='text'>" + item.content + "</span>" + |
|
|
|
|
"<span class='text'>" + item.content + "</span>" + |
|
|
|
|
"</div>" |
|
|
|
|
|
|
|
|
|
$(".comment-input").after(comment) |
|
|
|
|
|
|
|
|
|
/* reply */ |
|
|
|
|
$.each(item.targetReplys, function(idx, it) { |
|
|
|
|
/* onclick으로 답글다는곳 나타나면 걔는 $('.reply-box').prepend(머시기) 하면 될듯 */ |
|
|
|
|
var rb = $("<div class='reply-box' id='user" + (i+1) + "'/>"); |
|
|
|
|
var rb = $("<div class='reply-box' id='reply-box" + (i+1) + "'/>"); |
|
|
|
|
$(".comment-view").append(rb); |
|
|
|
|
|
|
|
|
|
/* reply */ |
|
|
|
|
$.each(item.targetReplys, function(idx, it) { |
|
|
|
|
var reply = |
|
|
|
|
"<div class='reply-view' id='user" + (i+1) + "'>" + |
|
|
|
|
"<div class='reply-view' id='reply-view" + (i+1) + "'>" + |
|
|
|
|
"<span class='user'>" + |
|
|
|
|
"<span class='id'>" + it.regUser + "</span>" + |
|
|
|
|
"<span class='date'>" + it.regDate + "</span>" + |
|
|
|
@ -216,12 +211,11 @@
|
|
|
|
|
"<span class='text'>" + it.content + "</span>" + |
|
|
|
|
"</div>" |
|
|
|
|
|
|
|
|
|
$('#user' + (i+1)).append(reply) |
|
|
|
|
$('#reply-box' + (i+1)).append(reply) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 댓글 개수 */ |
|
|
|
|
var count = response.length |
|
|
|
|
$('.total').text('댓글 ' + count); |
|
|
|
@ -229,6 +223,82 @@
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 답글 클릭시 답글 입력창 생성 */ |
|
|
|
|
function replyInputCreate(index, id) { |
|
|
|
|
var chk = document.querySelector("input[name=replyCheck" + index + "]").checked; |
|
|
|
|
|
|
|
|
|
if(chk) { |
|
|
|
|
document.querySelector("input[name=replyCheck" + index + "]").checked = false; |
|
|
|
|
$('.reply-input').remove(); |
|
|
|
|
} else { |
|
|
|
|
document.querySelector("input[name=replyCheck" + index + "]").checked = true; |
|
|
|
|
var replyInput = |
|
|
|
|
"<div class='reply-input'>" + |
|
|
|
|
"<textarea id='replyContent' name='replyContent' placeholder='댓글을 입력해주세요'></textarea>" + |
|
|
|
|
"<button class='reply-button' id='replySave' type='button'>등록</button>" + |
|
|
|
|
"<span id='targetNum' style='display:none'>" + id + "</span>"+ |
|
|
|
|
"</div>" |
|
|
|
|
$('#reply-box' + index).before(replyInput) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* comment 작성 */ |
|
|
|
|
$(document).on("click", "#cmtSave", function() { |
|
|
|
|
var boardNum = '<%=boardId%>'; |
|
|
|
|
|
|
|
|
|
var boardId = boardNum; |
|
|
|
|
var content = $('.comment-input').find('textarea[id="cmtContent"]').val(); |
|
|
|
|
|
|
|
|
|
var obj = { |
|
|
|
|
boardId: boardId, |
|
|
|
|
content: content |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
url: "/api/jh/reply/commentWrite", |
|
|
|
|
type: "POST", |
|
|
|
|
data: obj, |
|
|
|
|
dataType: 'JSON', |
|
|
|
|
success: function(res) { |
|
|
|
|
if(res == '1') { |
|
|
|
|
alert("등록 성공") |
|
|
|
|
location.href="/view/jh/board/detailView/" + boardNum |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
/* reply 작성 */ |
|
|
|
|
$(document).on("click", "#replySave", function() { |
|
|
|
|
var boardNum = '<%=boardId%>'; |
|
|
|
|
|
|
|
|
|
var boardId = boardNum; |
|
|
|
|
var targetId = $('.reply-input').find('span[id="targetNum"]').text(); |
|
|
|
|
var content = $('.reply-input').find('textarea[id="replyContent"]').val(); |
|
|
|
|
|
|
|
|
|
var obj = { |
|
|
|
|
boardId: boardId, |
|
|
|
|
targetId: targetId, |
|
|
|
|
content: content |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
url: "/api/jh/reply/replyWrite", |
|
|
|
|
type: "POST", |
|
|
|
|
data: obj, |
|
|
|
|
dataType: 'JSON', |
|
|
|
|
success: function(res) { |
|
|
|
|
if(res == '1') { |
|
|
|
|
alert("등록 성공") |
|
|
|
|
location.href="/view/jh/board/detailView/" + boardNum |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 글 삭제 */ |
|
|
|
|
$(document).on("click", "#delete", function() { |
|
|
|
|
var id = $('#idSpan').find('span[id="boardId"]').text(); |
|
|
|
|