MediaWiki:Common.js
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.
/* UO Renaissance Wiki Common.js */
(function() {
// Add Hover Flyout Submenus for The World & Skills inside Compendium
var compendiumPortal = document.getElementById('p-Compendium');
if (compendiumPortal) {
function attachSidebarSubmenu(liSelector, titleMatch, items) {
var li = compendiumPortal.querySelector(liSelector) ||
compendiumPortal.querySelector('a[href*="' + titleMatch + '"]')?.closest('li');
if (!li || li.querySelector('.uor-sidebar-submenu')) return;
li.classList.add('uor-sidebar-has-submenu');
var link = li.querySelector(':scope > a');
if (link && !link.querySelector('.uor-submenu-arrow')) {
var arrow = document.createElement('span');
arrow.className = 'uor-submenu-arrow';
arrow.innerHTML = '▸';
arrow.title = 'View Sections';
arrow.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
li.classList.toggle('is-open');
});
link.appendChild(arrow);
}
var submenu = document.createElement('ul');
submenu.className = 'uor-sidebar-submenu';
var html = '';
for (var i = 0; i < items.length; i++) {
html += '<li><a href="' + items[i].href + '">' + items[i].label + '</a></li>';
}
submenu.innerHTML = html;
li.appendChild(submenu);
}
// 1. The World Submenu
attachSidebarSubmenu('li#n-The-World', '/wiki/index.php/The_World', [
{ label: 'Towns', href: '/wiki/index.php/The_World#Towns' },
{ label: 'Dungeons', href: '/wiki/index.php/The_World#Dungeons' },
{ label: 'Points of Interest', href: '/wiki/index.php/The_World#Points_of_Interest' }
]);
// 2. Skills Submenu
attachSidebarSubmenu('li#n-Skills', '/wiki/index.php/Skills', [
{ label: 'Combat', href: '/wiki/index.php/Skills#Combat' },
{ label: 'Crafting', href: '/wiki/index.php/Skills#Crafting' },
{ label: 'Creatures', href: '/wiki/index.php/Skills#Creatures' },
{ label: 'Lore & Knowledge', href: '/wiki/index.php/Skills#Lore_&_Knowledge' },
{ label: 'Miscellaneous', href: '/wiki/index.php/Skills#Miscellaneous' },
{ label: 'Rogue', href: '/wiki/index.php/Skills#Rogue' },
{ label: 'Spells & Magic', href: '/wiki/index.php/Spells' }
]);
document.addEventListener('click', function(e) {
if (!e.target.closest('.uor-sidebar-has-submenu')) {
var openMenus = document.querySelectorAll('.uor-sidebar-has-submenu.is-open');
for (var i = 0; i < openMenus.length; i++) {
openMenus[i].classList.remove('is-open');
}
}
});
}
})();