x x x
Only portrait mode is currently supported - please rotate your device.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Show If
useralex@gsvlabs.com


HTML
 <script>
  const getMinutesUntilEventStart = (startDate) => {
    let nowDate = new Date();
    let eventStartDate = new Date(startDate);

    let diffMilliseconds = eventStartDate.getTime() - nowDate.getTime();
    let diffMinutes =  (diffMilliseconds / 60000);
    console.log("Difference in Minutes:", diffMinutes);

    return diffMinutes;
  }

  window.addEventListener('load', () => {
    let upcomingEvents = document.getElementById('scroll-section-1');
    let upcomingCards = Array.from(upcomingEvents.getElementsByClassName('eventcard'));

    for (let i = 0; i < upcomingCards.length; i++) {
      let currCard = upcomingCards[i];
      let currCardStart = currCard.dataset.startdate;
      let minsTilStart = getMinutesUntilEventStart(currCardStart);
      if (minsTilStart < 0) {
        let liveEl = document.createElement("div");
        liveEl.classList.add('live-circle');
        liveEl.innerText = "LIVE";
        currCard.insertAdjacentElement('afterbegin', liveEl);
      }  
    }
  });
</script>
<style>
  .live-circle {
    font-size: 14px13px;
    padding: 4px 10px14px;
    text-transform: uppercase;
    font-weight: bold;
    background-color: brown#dc2e2e;
    border-radius: 40%50px;
    color: white;
    position: absolute;
    z-index: 2;
    margin: 8px 8px;
    border: 1px solid white;
    box-shadow: 1px 1px 5px black;
  }
</style>