function displayCatalog() {
  // get current list of <dl> exercises
  let catalogChildren = document.querySelectorAll('dl');
  // remove existing children to start fresh
  if (catalogChildren) {
    catalogChildren.forEach(function (child) {
      catalogBox.removeChild(child);
    });
  }

  for (const item in localCatalog) {

    if (typeof localCatalog[item] !== 'function') {

      let exerciseSet = document.createElement('dl'),
        nameBox = document.createElement('dt'),
        repsBox = document.createElement('dd'),
        ctrlBox = document.createElement('dd'),
        removeBtn = document.createElement('button');

      exerciseSet.setAttribute('data-item', item);
      exerciseSet.setAttribute('id', item);

      nameBox.contentEditable = true;
      repsBox.contentEditable = true;

      //select text by default on focus
      nameBox.onfocus = ev => selectText(ev.target)
      repsBox.onfocus = ev => selectText(ev.target)

      nameBox.setAttribute('data-item', 'name');
      repsBox.setAttribute('data-item', 'reps');
      repsBox.setAttribute('class', 'reps-box');
      ctrlBox.setAttribute('class', 'ctrl-box');

      nameBox.textContent = localCatalog[item].name;
      repsBox.textContent = localCatalog[item].reps;
      
      removeBtn.textContent = '➖';
      removeBtn.onclick = () => removeExercise(item);
      ctrlBox.appendChild(removeBtn)

      exerciseSet.appendChild(nameBox);
      exerciseSet.appendChild(repsBox);
      exerciseSet.appendChild(ctrlBox);

      catalogBox.appendChild(exerciseSet);
    }
  };
}
// create html elements for each exercises + reps based on data from localStorage
create html elements for each exercises + reps based on data from localStorage
create html elements for each exercises + reps based on data from localStorage
function displayCatalog() {
  let catalogChildren = document.querySelectorAll('dl');
  if (catalogChildren) {
    catalogChildren.forEach(function (child) {
      catalogBox.removeChild(child);
    });
  }
  for (const item in localCatalog) {
    if (typeof localCatalog[item] !== 'function') {
      let exerciseSet = document.createElement('dl'),
        nameBox = document.createElement('dt'),
        repsBox = document.createElement('dd'),
        ctrlBox = document.createElement('dd'),
        removeBtn = document.createElement('button');
      exerciseSet.setAttribute('data-item', item);
      exerciseSet.setAttribute('id', item);
      nameBox.contentEditable = true;
      repsBox.contentEditable = true;
      nameBox.onfocus = ev => selectText(ev.target)
      repsBox.onfocus = ev => selectText(ev.target)
      nameBox.setAttribute('data-item', 'name');
      repsBox.setAttribute('data-item', 'reps');
      repsBox.setAttribute('class', 'reps-box');
      ctrlBox.setAttribute('class', 'ctrl-box');
      nameBox.textContent = localCatalog[item].name;
      repsBox.textContent = localCatalog[item].reps;
      removeBtn.textContent = '➖';
      removeBtn.onclick = () => removeExercise(item);
      ctrlBox.appendChild(removeBtn)
      exerciseSet.appendChild(nameBox);
      exerciseSet.appendChild(repsBox);
      exerciseSet.appendChild(ctrlBox);
      catalogBox.appendChild(exerciseSet);
    }
  };
}
function displayCatalog ( ) { let catalogChildren = document . querySelectorAll ( 'dl' ) ; if ( catalogChildren ) { catalogChildren . forEach ( function ( child ) { catalogBox . removeChild ( child ) ; } ) ; } for ( const item in localCatalog ) { if ( typeof localCatalog [ item ] !== 'function' ) { let exerciseSet = document . createElement ( 'dl' ) , nameBox = document . createElement ( 'dt' ) , repsBox = document . createElement ( 'dd' ) , ctrlBox = document . createElement ( 'dd' ) , removeBtn = document . createElement ( 'button' ) ; exerciseSet . setAttribute ( 'data-item' , item ) ; exerciseSet . setAttribute ( 'id' , item ) ; nameBox . contentEditable = true ; repsBox . contentEditable = true ; nameBox . onfocus = ev => selectText ( ev . target ) repsBox . onfocus = ev => selectText ( ev . target ) nameBox . setAttribute ( 'data-item' , 'name' ) ; repsBox . setAttribute ( 'data-item' , 'reps' ) ; repsBox . setAttribute ( 'class' , 'reps-box' ) ; ctrlBox . setAttribute ( 'class' , 'ctrl-box' ) ; nameBox . textContent = localCatalog [ item ] . name ; repsBox . textContent = localCatalog [ item ] . reps ; removeBtn . textContent = '➖'; removeBtn . onclick = ( ) => removeExercise ( item ) ; ctrlBox . appendChild ( removeBtn ) exerciseSet . appendChild ( nameBox ) ; exerciseSet . appendChild ( repsBox ) ; exerciseSet . appendChild ( ctrlBox ) ; catalogBox . appendChild ( exerciseSet ) ; } } ; }
create html elements for each exercises + reps based on data from localStorage
create html elements for each exercises + reps based on data from localStorage
// get current list of <dl> exercises // remove existing children to start fresh //select text by default on focus