portfolio/src/main/webapp/comments.js
// toggles visibility of the reply form
toggles visibility of the reply form
toggles visibility of the reply form
function toggleReplyField(commentId) {
  const showReplyFormButtonId = commentId + '_button'; 
  const replyFormId = commentId + '_form';             
  const button = document.getElementById(showReplyFormButtonId);
  button.innerText = (button.innerText === 'Cancel' ? 'Reply' : 'Cancel'); 
  const replyForm = document.getElementById(replyFormId);
  if (replyForm.classList.contains('hidden')) {
    replyForm.classList.remove('hidden');
    replyForm.classList.add('shown');
  } else {
    replyForm.classList.remove('shown');
    replyForm.classList.add('hidden');
  }
}
function toggleReplyField ( commentId ) { const showReplyFormButtonId = commentId + '_button' ; const replyFormId = commentId + '_form' ; const button = document . getElementById ( showReplyFormButtonId ) ; button . innerText = ( button . innerText === 'Cancel' ? 'Reply' : 'Cancel' ) ; const replyForm = document . getElementById ( replyFormId ) ; if ( replyForm . classList . contains ( 'hidden' ) ) { replyForm . classList . remove ( 'hidden' ) ; replyForm . classList . add ( 'shown' ) ; } else { replyForm . classList . remove ( 'shown' ) ; replyForm . classList . add ( 'hidden' ) ; } }
toggles visibility of the reply form
toggles visibility of the reply form
// generate button's id // generate reply form id // change text depending on the mode // if the form is hidden, show it // otherwis hide the form