async function loadCards(startIndex, elementCount, timeCapsule) {
  let cardListHtml = "";

  for (i = 0; i < elementCount; i++) {
    try {
      const capsuleId = startIndex + i;
      const capsuleLabel = await timeCapsule.getCapsuleLabel(capsuleId);

      // concat html of cards holding capsules information
      cardListHtml += createCardHtml(capsuleId, capsuleLabel);
    } catch(error) {
      console.log("can't load more cards:", error);
      // if error it means that probably there is no more cards to load
      $('#loading-div').loading('stop');
      // disable next link
      $(".next-link").attr("href", null);

      break;
    }
  }

  $('#loading-div').loading('stop');
  $('#card-list').html(cardListHtml);
}
/**
 * Load the capsule labels in HTML cards
 * 
 * @param {number} startIndex The index of the first card to load
 * @param {number} elementCount The amount of cards to load
 * @param {Contract} timeCapsule The smart contract
 */
Load the capsule labels in HTML cards

@param {number} startIndex The index of the first card to load
@param {number} elementCount The amount of cards to load
@param {Contract} timeCapsule The smart contract
Load the capsule labels in HTML cards @param { number } startIndex The index of the first card to load @param { number } elementCount The amount of cards to load @param { Contract } timeCapsule The smart contract
async function loadCards(startIndex, elementCount, timeCapsule) {
  let cardListHtml = "";
  for (i = 0; i < elementCount; i++) {
    try {
      const capsuleId = startIndex + i;
      const capsuleLabel = await timeCapsule.getCapsuleLabel(capsuleId);
      cardListHtml += createCardHtml(capsuleId, capsuleLabel);
    } catch(error) {
      console.log("can't load more cards:", error);
      $('#loading-div').loading('stop');
      $(".next-link").attr("href", null);
      break;
    }
  }
  $('#loading-div').loading('stop');
  $('#card-list').html(cardListHtml);
}
async function loadCards ( startIndex , elementCount , timeCapsule ) { let cardListHtml = "" ; for ( i = 0 ; i < elementCount ; i ++ ) { try { const capsuleId = startIndex + i ; const capsuleLabel = await timeCapsule . getCapsuleLabel ( capsuleId ) ; cardListHtml += createCardHtml ( capsuleId , capsuleLabel ) ; } catch ( error ) { console . log ( "can't load more cards:" , error ) ; $ ( '#loading-div' ) . loading ( 'stop' ) ; $ ( ".next-link" ) . attr ( "href" , null ) ; break ; } } $ ( '#loading-div' ) . loading ( 'stop' ) ; $ ( '#card-list' ) . html ( cardListHtml ) ; }
Load the capsule labels in HTML cards
Load the capsule labels in HTML cards
// concat html of cards holding capsules information // if error it means that probably there is no more cards to load // disable next link