MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Add Factions hover flyout submenu to Compendium sidebar |
Add Champion Spawns hover submenu |
||
| Line 57: | Line 57: | ||
{ label: 'Order & Chaos', href: '/wiki/index.php/Factions#Order_&_Chaos' }, | { label: 'Order & Chaos', href: '/wiki/index.php/Factions#Order_&_Chaos' }, | ||
{ label: 'Player run Guilds', href: '/wiki/index.php/Factions#Player_run_Guilds' } | { label: 'Player run Guilds', href: '/wiki/index.php/Factions#Player_run_Guilds' } | ||
]); | |||
// 4. Champion Spawns Submenu | |||
attachSidebarSubmenu('li#n-Champion-Spawns', '/wiki/index.php/Champion_Spawns', [ | |||
{ label: 'Overview & Altars', href: '/wiki/index.php/Champion_Spawns#Altars' }, | |||
{ label: 'The Six Champions', href: '/wiki/index.php/Champion_Spawns#Champions' }, | |||
{ label: 'The Harrower', href: '/wiki/index.php/Champion_Spawns#The_Harrower' }, | |||
{ label: 'Rewards & Titles', href: '/wiki/index.php/Champion_Spawns#Rewards' } | |||
]); | ]); | ||
Revision as of 14:02, 8 September 2026
/* UO Renaissance Wiki Common.js */
(function() {
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' }
]);
// 3. Factions Submenu
attachSidebarSubmenu('li#n-Factions', '/wiki/index.php/Factions', [
{ label: 'Factions', href: '/wiki/index.php/Factions#Factions' },
{ label: 'Order & Chaos', href: '/wiki/index.php/Factions#Order_&_Chaos' },
{ label: 'Player run Guilds', href: '/wiki/index.php/Factions#Player_run_Guilds' }
]);
// 4. Champion Spawns Submenu
attachSidebarSubmenu('li#n-Champion-Spawns', '/wiki/index.php/Champion_Spawns', [
{ label: 'Overview & Altars', href: '/wiki/index.php/Champion_Spawns#Altars' },
{ label: 'The Six Champions', href: '/wiki/index.php/Champion_Spawns#Champions' },
{ label: 'The Harrower', href: '/wiki/index.php/Champion_Spawns#The_Harrower' },
{ label: 'Rewards & Titles', href: '/wiki/index.php/Champion_Spawns#Rewards' }
]);
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');
}
}
});
}
})();