TIL

286일차(모험 195일차) - 게시글, 댓글 작성자 구분하기

haedal-uni 2022. 6. 28. 22:52
728x90

팀원에게 여태까지 한 페이지 기능들을 보여주다가 꺠달은게 있다.

댓글 작성자와 그렇지 않은 사람으로 구분했었는데 게시글 작성자와도 구분을 했어야 했다.

 

게시글 작성자 o 댓글 작성자 x

게시글 작성자 o 댓글 작성자 o

게시글 작성자 x 댓글 작성자 x

게시글 작성자 x 댓글 작성자 o

 

 

게시글 작성자 인 경우

   댓글 작성자가 아닌 경우

   댓글 작성자인 경우

댓글 작성자가 아닌 경우

   댓글 작성자가 아닌 경우

   댓글 작성자인 경우


if (writerRegistry == commentName) { // 게시글 작성자인 경우

    // 댓글 작성자인 경우

    // 댓글 작성자가 아닌 경우

}

else{ // 댓글 작성자가 아닌 경우

    // 댓글 작성자인 경우

    // 댓글 작성자가 아닌 경우


}

 

 

기존 코드는 댓글 작성자와 아닌 경우만 분리했다.

                temp_html= `<div id="commentParent" class="${commentId}" style="display:block;"><a id="${commentId}-commentName" class="commentName">${commentName} </a><a id="${commentId}-comment">${comment}</a></div> <br><input id="updateCommentBtn" style="display: none">`
                if (nickname == commentName) { // 댓글 작성자인 경우
                    temp_html = `<div id="commentParent" class="${commentId}" ><a id="${commentId}-commentName" class="writerCommentName">${commentName} </a><a id="${commentId}-comment">${comment}</a>
<button id="updateBtn-${commentId}" class="updateBtn" type="button" onclick="updateCommentBtn(${commentId})">수정</button>
<button id="deleteBtn-${commentId}" class="deleteBtn" type="button" onclick="checkDelete(${commentId})">삭제</button></div> 
<a><input id="updateCommentInput-${commentId}" class="updateCommentInput" style="display: none"><button id="updateAftersaveBtn-${commentId}" class="updateAftersaveBtn" style="display: none" type="button" onclick="afterUpdateComment(${commentId})">저장</button> </a><br>`
                }
                $("#commentList").append(temp_html)

 

 

 

게시글 작성자가 a이고 댓글 쓰는 사람은 s

 

게시글 작성자와 댓글 작성자가 s

 

[add] 게시글, 댓글 작성자 구분하기 [#90] #91

728x90