portfolio/src/main/webapp/comments.js
// in the comments diff with the offset = sqrt(depth * 100)
in the comments diff with the offset = sqrt(depth * 100)
in the comments diff with the offset = sqrt ( depth * 100 )
function addCommentToDOM(comment, depth, authState) {
  const commentDiv = document.createElement('div');
  commentDiv.classList.add('comment')
  commentDiv.style = 'margin-left: ' + Math.sqrt(Number(depth * 100)) + 'px';
  commentDiv.id = comment.key;
  const commentText = document.createElement('p');
  commentText.innerText = comment.text;
  commentDiv.appendChild(getCommentHeader(comment));
  commentDiv.appendChild(commentText);
  if (comment.imageUrl) {
    commentDiv.appendChild(getCommentImage(comment));
    commentDiv.appendChild(document.createElement('br'));
  }
  if (authState.authenticated === true) {
    commentDiv.appendChild(getCommentReplyForm(comment));
    commentDiv.appendChild(createShowReplyFormButton(comment));
    if (comment.username === authState.username) {
      commentDiv.appendChild(createDeleteButton(comment));
    }
  }
  document.getElementById('comments').appendChild(commentDiv);
}
function addCommentToDOM ( comment , depth , authState ) { const commentDiv = document . createElement ( 'div' ) ; commentDiv . classList . add ( 'comment' ) commentDiv . style = 'margin-left: ' + Math . sqrt ( Number ( depth * 100 ) ) + 'px' ; commentDiv . id = comment . key ; const commentText = document . createElement ( 'p' ) ; commentText . innerText = comment . text ; commentDiv . appendChild ( getCommentHeader ( comment ) ) ; commentDiv . appendChild ( commentText ) ; if ( comment . imageUrl ) { commentDiv . appendChild ( getCommentImage ( comment ) ) ; commentDiv . appendChild ( document . createElement ( 'br' ) ) ; } if ( authState . authenticated === true ) { commentDiv . appendChild ( getCommentReplyForm ( comment ) ) ; commentDiv . appendChild ( createShowReplyFormButton ( comment ) ) ; if ( comment . username === authState . username ) { commentDiv . appendChild ( createDeleteButton ( comment ) ) ; } } document . getElementById ( 'comments' ) . appendChild ( commentDiv ) ; }
in the comments diff with the offset = sqrt(depth * 100)
in the comments diff with the offset = sqrt ( depth * 100 )
// creates a div with two paragraph, one for username and one for comment text // append everything to the comment div // if the user is authenticated then allow replies // if the user is authenticated && they are author of the comment => they can delete their comments // attach created comment to the comments div