MediaWiki:Common.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Creature Infobox Image Toggle */
(function () {
function initCreatureInfoboxes() {
document.querySelectorAll('.infobox-creature').forEach(function (box) {
var tabs = box.querySelectorAll('.ci-tab');
var imgs = box.querySelectorAll('.ci-img');
tabs.forEach(function (tab, index) {
tab.addEventListener('click', function () {
// Hide all images, deactivate all tabs
imgs.forEach(function (img) { img.style.display = 'none'; });
tabs.forEach(function (t) { t.classList.remove('ci-tab-active'); });
// Show selected image, activate selected tab
if (imgs[index]) imgs[index].style.display = 'block';
tab.classList.add('ci-tab-active');
});
});
});
}
// Run after the DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initCreatureInfoboxes);
} else {
initCreatureInfoboxes();
}
}());