async function loadCapsuleContent(capsuleId, timeCapsule) {
  try {
    $('#loading-div').loading('start');

    const capsuleContent = await timeCapsule.getCapsuleContent(capsuleId);
    console.log("capsuleContent:", capsuleContent);

    // gets the IPFS stored encrypted message
    const ipfsMessage = await getIpfsMessage(capsuleContent.ipfsHash);

    // use the key stored in the contract to decrypt the message
    const decryptedMessage = CryptoJS.AES.decrypt(
      ipfsMessage,
      capsuleContent.aesKey
    ).toString(CryptoJS.enc.Utf8);

    $('#loading-div').loading('stop');
    $('#markdown-viewer').show();

    // load the message in the Markdown viewer
    new toastui.Editor({
      el: document.querySelector('#markdown-viewer'),
      initialValue: decryptedMessage,
      usageStatistics: false
    });

    // show since when the capsule has been unlocked
    $('#unlock-date-div').show();
  } catch(error) {
    $('#loading-div').loading('stop');
    console.log("error:", error);

    // let the user know until when the capsule will remain locked
    displayMessage('#alert-danger', `This message is still locked until <span class="font-weight-bold">${$('#unlock-date').val()}</span>`)
  }
}
/**
 * Loads the capsule content, i.e. the secret message is revealed if the
 * capsule can be unlocked, otherwise lets the user know until when the
 * capsule can be unlocked
 * 
 * @param {string} capsuleId The capsule id
 * @param {Contract} timeCapsule The Ethereum contract
 */
Loads the capsule content, i.e. the secret message is revealed if the
capsule can be unlocked, otherwise lets the user know until when the
capsule can be unlocked

@param {string} capsuleId The capsule id
@param {Contract} timeCapsule The Ethereum contract
Loads the capsule content i . e . the secret message is revealed if the capsule can be unlocked otherwise lets the user know until when the capsule can be unlocked @param { string } capsuleId The capsule id @param { Contract } timeCapsule The Ethereum contract
async function loadCapsuleContent(capsuleId, timeCapsule) {
  try {
    $('#loading-div').loading('start');
    const capsuleContent = await timeCapsule.getCapsuleContent(capsuleId);
    console.log("capsuleContent:", capsuleContent);
    const ipfsMessage = await getIpfsMessage(capsuleContent.ipfsHash);
    const decryptedMessage = CryptoJS.AES.decrypt(
      ipfsMessage,
      capsuleContent.aesKey
    ).toString(CryptoJS.enc.Utf8);
    $('#loading-div').loading('stop');
    $('#markdown-viewer').show();
    new toastui.Editor({
      el: document.querySelector('#markdown-viewer'),
      initialValue: decryptedMessage,
      usageStatistics: false
    });
    $('#unlock-date-div').show();
  } catch(error) {
    $('#loading-div').loading('stop');
    console.log("error:", error);
    displayMessage('#alert-danger', `This message is still locked until <span class="font-weight-bold">${$('#unlock-date').val()}</span>`)
  }
}
async function loadCapsuleContent ( capsuleId , timeCapsule ) { try { $ ( '#loading-div' ) . loading ( 'start' ) ; const capsuleContent = await timeCapsule . getCapsuleContent ( capsuleId ) ; console . log ( "capsuleContent:" , capsuleContent ) ; const ipfsMessage = await getIpfsMessage ( capsuleContent . ipfsHash ) ; const decryptedMessage = CryptoJS . AES . decrypt ( ipfsMessage , capsuleContent . aesKey ) . toString ( CryptoJS . enc . Utf8 ) ; $ ( '#loading-div' ) . loading ( 'stop' ) ; $ ( '#markdown-viewer' ) . show ( ) ; new toastui . Editor ( { el : document . querySelector ( '#markdown-viewer' ) , initialValue : decryptedMessage , usageStatistics : false } ) ; $ ( '#unlock-date-div' ) . show ( ) ; } catch ( error ) { $ ( '#loading-div' ) . loading ( 'stop' ) ; console . log ( "error:" , error ) ; displayMessage ( '#alert-danger' , ` ${ $ ( '#unlock-date' ) . val ( ) } ` ) } }
Loads the capsule content, i.e.
Loads the capsule content i . e .
// gets the IPFS stored encrypted message // use the key stored in the contract to decrypt the message // load the message in the Markdown viewer // show since when the capsule has been unlocked // let the user know until when the capsule will remain locked