function refreshComments() {
  var maxPage = computeMaxPage();
  if(pg > maxPage) {
    pg = maxPage;
  } else if (pg < 1) {
    pg = 1;
  }
  const pageCount = document.getElementById("page-count");
  const target = document.getElementById("comment-list");
  target.textContent = "";

  if(js.length == 0 || totalElems == 0) {
    const p = document.createElement("p");
    p.innerText = "No comments to see!";
    target.appendChild(p);
    pageCount.innerHTML = "/";
  } else {  
    for(var i = (pg-1)*numElemsPerPage; i < Math.min(js.length, totalElems) && i < pg*numElemsPerPage; i++) {
      target.appendChild(
          createElement(
              js[i].propertyMap.content, 
              js[i].propertyMap.timestamp, 
              js[i].propertyMap.upvotes, 
              js[i].propertyMap.name, 
              js[i].propertyMap.author,
              js[i].propertyMap.language,
              i
          )
        );
    }
    pageCount.innerHTML = pg + "/" + maxPage;
  }
  
  var icon = document.getElementById("plus-comment");
  var text = document.getElementById("comment-wrapper");
  var textContent = document.getElementById("comment-box");
  if(icon.classList.contains("clicked")) {
    text.style.height = (textContent.clientHeight + 60) + "px";
  }
}
/* Refreshes the comment display div using the corresponding global variables. */
Refreshes the comment display div using the corresponding global variables.
Refreshes the comment display div using the corresponding global variables .
function refreshComments() {
  var maxPage = computeMaxPage();
  if(pg > maxPage) {
    pg = maxPage;
  } else if (pg < 1) {
    pg = 1;
  }
  const pageCount = document.getElementById("page-count");
  const target = document.getElementById("comment-list");
  target.textContent = "";
  if(js.length == 0 || totalElems == 0) {
    const p = document.createElement("p");
    p.innerText = "No comments to see!";
    target.appendChild(p);
    pageCount.innerHTML = "/";
  } else {  
    for(var i = (pg-1)*numElemsPerPage; i < Math.min(js.length, totalElems) && i < pg*numElemsPerPage; i++) {
      target.appendChild(
          createElement(
              js[i].propertyMap.content, 
              js[i].propertyMap.timestamp, 
              js[i].propertyMap.upvotes, 
              js[i].propertyMap.name, 
              js[i].propertyMap.author,
              js[i].propertyMap.language,
              i
          )
        );
    }
    pageCount.innerHTML = pg + "/" + maxPage;
  }
  var icon = document.getElementById("plus-comment");
  var text = document.getElementById("comment-wrapper");
  var textContent = document.getElementById("comment-box");
  if(icon.classList.contains("clicked")) {
    text.style.height = (textContent.clientHeight + 60) + "px";
  }
}
function refreshComments ( ) { var maxPage = computeMaxPage ( ) ; if ( pg > maxPage ) { pg = maxPage ; } else if ( pg < 1 ) { pg = 1 ; } const pageCount = document . getElementById ( "page-count" ) ; const target = document . getElementById ( "comment-list" ) ; target . textContent = "" ; if ( js . length == 0 || totalElems == 0 ) { const p = document . createElement ( "p" ) ; p . innerText = "No comments to see!" ; target . appendChild ( p ) ; pageCount . innerHTML = "/" ; } else { for ( var i = ( pg - 1 ) * numElemsPerPage ; i < Math . min ( js . length , totalElems ) && i < pg * numElemsPerPage ; i ++ ) { target . appendChild ( createElement ( js [ i ] . propertyMap . content , js [ i ] . propertyMap . timestamp , js [ i ] . propertyMap . upvotes , js [ i ] . propertyMap . name , js [ i ] . propertyMap . author , js [ i ] . propertyMap . language , i ) ) ; } pageCount . innerHTML = pg + "/" + maxPage ; } var icon = document . getElementById ( "plus-comment" ) ; var text = document . getElementById ( "comment-wrapper" ) ; var textContent = document . getElementById ( "comment-box" ) ; if ( icon . classList . contains ( "clicked" ) ) { text . style . height = ( textContent . clientHeight + 60 ) + "px" ; } }
Refreshes the comment display div using the corresponding global variables.
Refreshes the comment display div using the corresponding global variables .