<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: 14px;
padding: 10px;
text-transform: uppercase;
font-weight: bold;
background-color: brown;
border-radius: 40%;
color: white;
}
</style> |