Widget:AvailableCritters: Difference between revisions
Jump to navigation
Jump to search
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> |
Revision as of 21:29, 26 February 2024
<script> document.addEventListener('DOMContentLoaded', function() {
// Critter availability const critters = [ [ { "name": "Emerald Sunbird", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Golden Sunbird", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Orchid Sunbird", "times": { "Friday": ["09:00", "15:00"] } }, { "name": "Red Sunbird", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Turquoise Sunbird", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Black Squirrel", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Classic Squirrel", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Gray Squirrel", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Red Squirrel", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "White Squirrel", "times": { "Sunday": ["00:00", "06:00"] } }, { "name": "Blue Crocodile", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Classic Crocodile", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Golden Crocodile", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Pink Crocodile", "times": { "Saturday": ["06:00", "12:00"] } }, { "name": "Red Crocodile", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "White Crocodile", "times": { "Sunday": ["18:00", "24:00"] } }, { "name": "Black Rabbit", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Brown Rabbit", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Calico Rabbit", "times": { "Thursday": ["08:00", "14:00"] } }, { "name": "Classic Rabbit", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "White Rabbit", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Blue Raven", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Brown Raven", "times": { "Tuesday": ["18:00", "24:00"] } }, { "name": "Classic Raven", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Red Raven", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "White Raven", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Black Sea Turtle", "times": { "Monday": ["10:00", "16:00"] } }, { "name": "Brown Sea Turtle", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Classic Sea Turtle", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Purple Sea Turtle", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "White Sea Turtle", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Black Fox", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Blue Fox", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Classic Fox", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Red Fox", "times": { "Saturday": ["02:00", "08:00"] } }, { "name": "White Fox", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Black Raccoon", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Blue Raccoon", "times": { "Wednesday": ["16:00", "22:00"] } }, { "name": "Classic Raccoon", "times": { "Sunday": ["12:00", "24:00"], "Monday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Red Raccoon", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "White Raccoon", "times": { "Sunday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Black and White Capybara", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Friday": ["12:00", "24:00"], "Saturday": ["12:00", "24:00"] } }, { "name": "Blue Striped Capybara", "times": { "Monday": ["00:00", "12:00"], "Tuesday": ["00:00", "12:00"], "Wednesday": ["00:00", "12:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Classic Capybara", "times": { "Sunday": ["00:00", "24:00"], "Monday": ["00:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Gray Spotted Capybara", "times": { "Sunday": ["00:00", "24:00"], "Monday": ["12:00", "24:00"], "Tuesday": ["12:00", "24:00"], "Wednesday": ["12:00", "24:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Red and White Striped Capybara", "times": { "Saturday": ["12:00", "18:00"] } }, { "name": "Blue and Red Striped Cobra", "times": { "Sunday": ["00:00", "24:00"], "Monday": ["12:00", "24:00"], "Tuesday": ["12:00", "24:00"], "Thursday": ["00:00", "24:00"], "Saturday": ["12:00", "24:00"] } }, { "name": "Classic Cobra", "times": { "Sunday": ["00:00", "24:00"], "Monday": ["00:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Green and White Striped Cobra", "times": { "Thursday": ["06:00", "12:00"] } }, { "name": "Pink Spotted Cobra", "times": { "Sunday": ["00:00", "12:00"], "Monday": ["00:00", "24:00"], "Wednesday": ["00:00", "12:00"], "Thursday": ["00:00", "12:00"], "Friday": ["00:00", "24:00"] } }, { "name": "Yellow and Purple Striped Cobra", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["12:00", "24:00"], "Thursday": ["12:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Beige Monkey", "times": { "Sunday": ["00:00", "24:00"], "Monday": ["12:00", "24:00"], "Wednesday": ["12:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["12:00", "24:00"] } }, { "name": "Black and Brown Monkey", "times": { "Sunday": ["12:00", "24:00"], "Tuesday": ["12:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Thursday": ["12:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Black and Gray Monkey", "times": { "Tuesday": ["18:00", "24:00"] } }, { "name": "Classic Monkey", "times": { "Sunday": ["00:00", "24:00"], "Monday": ["00:00", "24:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "24:00"], "Thursday": ["00:00", "24:00"], "Friday": ["00:00", "24:00"], "Saturday": ["00:00", "24:00"] } }, { "name": "Red and Beige Monkey", "times": { "Monday": ["00:00", "12:00"], "Tuesday": ["00:00", "24:00"], "Wednesday": ["00:00", "12:00"], "Friday": ["00:00", "12:00"], "Saturday": ["00:00", "24:00"] } }
]
];
function updateGallery() { const now = new Date(); const dayOfWeek = now.toLocaleString('en-US', { weekday: 'long' }); const currentHour = now.getHours(); const gallery = document.getElementById('crittergallery'); // Ensure this ID matches your gallery's ID
let galleryContent = '
- ';
- GalleryContent += '
';
gallery.innerHTML = galleryContent; }
updateGallery(); // Optionally, set an interval to update the gallery periodically // setInterval(updateGallery, 60000); // every minute
}); </script>