import.meta.glob([
'../images/**',
'../fonts/**',
]);
const startContent = document.getElementById('startDate') ? document.getElementById('startDate').textContent : null;
const startDate = document.getElementById('startDate') ? document.getElementById('startDate').getAttribute('data-raw') : null;
const endContent = document.getElementById('endDate') ? document.getElementById('endDate').textContent : null;
const endDate = document.getElementById('endDate') ? document.getElementById('endDate').getAttribute('data-raw') : null;
const numEntries = 0; // fix this later to be dynamic
// Date formatting stuff. You probably only need to touch locale and time zone.
const locale = 'en-US';
const timeZone = 'America/Chicago';
// DON'T EDIT BELOW THIS LINE
// unless you know what you're doing.
const start = new Date(startDate);
const end = new Date(endDate);
const now = Date.now();
const dateElt = document.getElementById('dates');
const daysElt = document.getElementById('days');
const hoursElt = document.getElementById('hours');
const minutesElt = document.getElementById('minutes');
const secondsElt = document.getElementById('seconds');
const list = document.getElementById('list');
const dayMult = 24*60*60;
const hourMult = 60*60;
const minuteMult = 60;
const countdownTick = () => {
const now = Date.now();
let diff;
if (now < start.getTime()) {
// Jam hasn't started yet
diff = (start.getTime() - now) / 1000; // get total # of seconds
} else if (now < end.getTime()) {
// Jam has started but not ended
diff = (end.getTime() - now) / 1000;
} else {
// Jam has ended
dates.innerHTML = `The jam is now over. It ran from ${startContent} to ${endContent}. View ${numEntries} ${numEntries !== 1 ? 'entries' : 'entry'}`
}
if (diff) {
const days = Math.floor(diff / dayMult);
diff = diff - (days * dayMult);
const hours = Math.floor(diff / hourMult);
diff = diff - (hours * hourMult);
const minutes = Math.floor(diff / minuteMult);
diff = diff - (minutes * minuteMult);
const seconds = Math.floor(diff);
daysElt.textContent = days;
hoursElt.textContent = hours;
minutesElt.textContent = minutes;
secondsElt.textContent = seconds;
}
}
if (document.querySelector('.clock')) {
countdownTick();
if (now < end.getTime()) {
setInterval(() => {
countdownTick();
}, 1000);
}
}