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() {
function initCompendiumDropdowns() {
var compendiumPortal = document.getElementById('p-Compendium');
if (!compendiumPortal) return;
// 1. The World Dropdown
var worldLi = compendiumPortal.querySelector('li#n-The-World') ||
compendiumPortal.querySelector('a[href*="/wiki/index.php/The_World"]')?.closest('li');
if (worldLi && !worldLi.querySelector('.uor-world-dropdown-wrap')) {
var worldWrap = document.createElement('div');
worldWrap.className = 'uor-world-dropdown-wrap';
worldWrap.innerHTML = '<select class="uor-world-dropdown-select" aria-label="Select World Section">' +
'<option value="/wiki/index.php/The_World">World Sections...</option>' +
'<option value="/wiki/index.php/The_World#Towns">Towns</option>' +
'<option value="/wiki/index.php/The_World#Dungeons">Dungeons</option>' +
'<option value="/wiki/index.php/The_World#Points_of_Interest">Points of Interest</option>' +
'</select>';
var worldSelect = worldWrap.querySelector('select');
var currentPath = window.location.pathname + window.location.hash;
for (var i = 0; i < worldSelect.options.length; i++) {
if (worldSelect.options[i].value && currentPath.indexOf(worldSelect.options[i].value) !== -1) {
worldSelect.selectedIndex = i;
break;
}
}
worldSelect.addEventListener('change', function() {
if (this.value) {
window.location.href = this.value;
}
});
worldLi.appendChild(worldWrap);
}
// 2. Skills Dropdown
var skillsLi = compendiumPortal.querySelector('li#n-Skills') ||
compendiumPortal.querySelector('li#n-Skills-Overview') ||
compendiumPortal.querySelector('a[href*="/wiki/index.php/Skills"]')?.closest('li');
if (skillsLi && !skillsLi.querySelector('.uor-skills-dropdown-wrap')) {
var wrap = document.createElement('div');
wrap.className = 'uor-skills-dropdown-wrap';
wrap.innerHTML = '<select class="uor-skills-dropdown-select" aria-label="Select Skill Section">' +
'<option value="/wiki/index.php/Skills">Skill Sections...</option>' +
'<option value="/wiki/index.php/Skills#Combat">Combat</option>' +
'<option value="/wiki/index.php/Skills#Crafting">Crafting</option>' +
'<option value="/wiki/index.php/Skills#Creatures">Creatures</option>' +
'<option value="/wiki/index.php/Skills#Lore_&_Knowledge">Lore & Knowledge</option>' +
'<option value="/wiki/index.php/Skills#Miscellaneous">Miscellaneous</option>' +
'<option value="/wiki/index.php/Skills#Rogue">Rogue</option>' +
'<option value="/wiki/index.php/Spells">Spells & Magic</option>' +
'</select>';
var select = wrap.querySelector('select');
var currentPath = window.location.pathname + window.location.hash;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i].value && currentPath.indexOf(select.options[i].value) !== -1) {
select.selectedIndex = i;
break;
}
}
select.addEventListener('change', function() {
if (this.value) {
window.location.href = this.value;
}
});
skillsLi.appendChild(wrap);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initCompendiumDropdowns);
} else {
initCompendiumDropdowns();
}
})();