52,243
edits
Marblemadmax (talk | contribs) No edit summary |
Marblemadmax (talk | contribs) No edit summary |
||
Line 66: | Line 66: | ||
const now = new Date(); | const now = new Date(); | ||
const dayOfWeek = now.toLocaleString('en-US', { weekday: 'long' }); | const dayOfWeek = now.toLocaleString('en-US', { weekday: 'long' }); | ||
const | const currentHour = now.getHours(); | ||
const gallery = document.getElementById('crittergallery'); | const gallery = document.getElementById('crittergallery'); // Ensure this ID matches your gallery's ID | ||
let galleryContent = ''; | let galleryContent = '<gallery widths=60px heights=60px class="clothesgallery">'; | ||
crittersAvailability.forEach(critter => { | |||
const | const times = critter.available[dayOfWeek]; | ||
if ( | if (times) { | ||
const [ | times.forEach(time => { | ||
const [start, end] = time.split('-').map(t => parseInt(t.split(':')[0], 10)); // assuming times don't cross midnight | |||
if ((currentHour >= start && currentHour < end) || end === 24 && currentHour === 0) { | |||
galleryContent += `File:${critter.name.replace(/ /g, '_')}.png|link=${critter.name}\n`; | |||
} | } | ||
}); | |||
} | } | ||
}); | }); | ||
galleryContent += '</gallery>'; | |||
gallery.innerHTML = galleryContent; | gallery.innerHTML = galleryContent; | ||
} | } | ||
updateGallery(); | updateGallery(); | ||
setInterval(updateGallery, 60000); | // Optionally, set an interval to update the gallery periodically | ||
// setInterval(updateGallery, 60000); // every minute | |||
}); | }); | ||
</script> | </script> |