Widget:AvailableCritters: Difference between revisions
Jump to navigation
Jump to search
Marblemadmax (talk | contribs) mNo edit summary |
Marblemadmax (talk | contribs) mNo edit summary |
||
Line 87: | Line 87: | ||
const hour = now.getHours(); // Get current hour in 24-hour format | const hour = now.getHours(); // Get current hour in 24-hour format | ||
let galleryContent = ''; | let galleryContent = '<gallery>'; | ||
for (const [critter, _] of Object.entries(critters)) { | for (const [critter, _] of Object.entries(critters)) { | ||
if (isAvailable(critter, dayOfWeek, hour)) { | if (isAvailable(critter, dayOfWeek, hour)) { | ||
galleryContent += `File:${critter.replace(/ /g, '_')}.png| | galleryContent += `File:${critter.replace(/ /g, '_')}.png|${critter}\n`; | ||
} | } | ||
} | } | ||
galleryContent += '</gallery>'; | |||
const galleryContainer = document.getElementById('critterGallery'); | const galleryContainer = document.getElementById('critterGallery'); | ||
if (galleryContainer) { | if (galleryContainer) { | ||
galleryContainer.innerHTML = | galleryContainer.innerHTML = galleryContent; | ||
} else { | |||
console.log('Gallery container not found'); | |||
} | } | ||
} | } | ||
// | // Ensure script runs after MediaWiki and its modules are available | ||
window.addEventListener('load', function() { | window.addEventListener('load', function() { | ||
if (typeof mw === 'object' && typeof mw.hook === 'function') { | if (typeof mw === 'object' && typeof mw.hook === 'function') { | ||
Line 112: | Line 114: | ||
}); | }); | ||
// | // Attempt to update gallery immediately on script load | ||
updateGallery(); | updateGallery(); | ||
</script> | </script> |