해당 게시글은 개인 프로젝트인 "데이트 장소 다이어리 제작" 중
#36 "HTML/CSS 수정 및 기타 기능 수정" 이슈를 다루고 있습니다.
const maxSize = 1 * 1024 * 1024;
// 파일 업로드 버튼 클릭 시
document.querySelector(".uploadBtn").addEventListener("click", function (e) {
// 결과창에 있는 요소를 선택, 몇 개 존재하는지 확인
if (document.querySelectorAll(".imageCard").length < 2) {
const formObj = new FormData();
const fileInput = document.querySelector("input[name='files']")
const fileSize = fileInput.files[0].size;
if(fileSize > maxSize) {
alert("첨부할 수 있는 이미지 파일은 1MB 이하여야 합니다.");
return
}
let hasAuth = false // 댓글의 작성자와 currentUser의 일치 여부
// 댓글 클릭 시 단건 조회
commentList.addEventListener("click", function (e) {
e.preventDefault()
e.stopPropagation()
const target = e.target
if (!target || target.tagName != 'P') {
return
}
const cid = target.getAttribute("data-cid")
if (!cid) {
return
}
getComment(cid).then(comment => { //댓글의 내용을 모달창에 채워서 보여주는
hasAuth = currentUser === comment.commentUid //댓글의 작성자와 현재 사용자 일치 여부 확인
console.log(comment)
console.log(hasAuth)
if (hasAuth) {
commentHeader.innerHTML = comment.cid
modifyCommentDescription.value = comment.commentDescription
modifyModal.show()
} else {
return
}
}).catch(e => alert('error'))
}, false)