52,211
edits
Marblemadmax (talk | contribs) No edit summary |
Marblemadmax (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
<script> | <script> | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
// | // Critter availability | ||
const critters = [ | const critters = [ | ||
[ | [ | ||
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 currentTime = now.getHours() + ':' + now.getMinutes(); | const currentTime = now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0'); | ||
const gallery = document.getElementById('crittergallery'); | const gallery = document.getElementById('crittergallery'); | ||
let galleryContent = ''; | let galleryContent = ''; | ||
Line 73: | Line 73: | ||
const availability = critter.times[dayOfWeek]; | const availability = critter.times[dayOfWeek]; | ||
if (availability) { | if (availability) { | ||
const startTime = availability | const [startTime, endTime] = availability.map(time => time.replace('AM', ':00').replace('PM', ':00')); | ||
// assuming times don't cross midnight | |||
if (currentTime >= startTime && currentTime < endTime) { | if (currentTime >= startTime && currentTime < endTime) { | ||
galleryContent += `File:${critter.name.replace(/ /g, '_')}.png|link=${critter.name}\n`; | |||
galleryContent += `File:{critter.name.replace(/ /g, '_')}.png|link=${critter.name}`; | |||
} | } | ||
} | } |