Jump to content

MediaWiki:Common.js: Difference between revisions

From Once Human Guide
No edit summary
No edit summary
Line 1: Line 1:
mw.loader.using('mediawiki.util').then(function () {
// Add Road Map tab BEFORE Discord
    $(function () {
const tabList = document.querySelector('#p-associated-pages .vector-menu-content-list, #p-namespaces .vector-menu-content-list');
const talkItem = document.querySelector('#ca-talk'); // Discord tab


        // Change Discussion tab to Discord
if (tabList && !document.getElementById('ca-roadmap')) {
        const talkTab = document.querySelector('#ca-talk a');
    const li = document.createElement('li');
    li.id = 'ca-roadmap';


        if (talkTab) {
    const existingTab = talkItem || document.querySelector('#ca-view');
            talkTab.textContent = 'Discord';
            talkTab.href = 'https://discord.gg/FZtkXeGeUA';
            talkTab.target = '_blank';
            talkTab.rel = 'noopener noreferrer';


            talkTab.addEventListener('click', function (e) {
    if (existingTab) {
                e.preventDefault();
        li.className = existingTab.className.replace(/\bselected\b|\bactive\b/g, '').trim();
                window.open('https://discord.gg/FZtkXeGeUA', '_blank');
    } else {
            });
        li.className = 'mw-list-item';
        }
    }


        // Add Road Map tab with matching tab classes
    const a = document.createElement('a');
        const tabList = document.querySelector('#p-associated-pages .vector-menu-content-list, #p-namespaces .vector-menu-content-list');
    a.href = 'https://ohwikiguide.com/index.php/Road_Map';
        const existingTab = document.querySelector('#ca-talk, #ca-view');
    a.title = 'Road Map';


        if (tabList && !document.getElementById('ca-roadmap')) {
    const span = document.createElement('span');
            const li = document.createElement('li');
    span.textContent = 'Road Map';
            li.id = 'ca-roadmap';


            if (existingTab) {
    a.appendChild(span);
                li.className = existingTab.className;
    li.appendChild(a);
                li.removeAttribute('class');
                li.className = existingTab.className.replace(/\bselected\b|\bactive\b/g, '').trim();
            } else {
                li.className = 'mw-list-item';
            }


            const a = document.createElement('a');
    // 🔥 THIS is the important change
            a.href = 'https://ohwikiguide.com/index.php/Road_Map';
    if (talkItem) {
            a.title = 'Road Map';
        tabList.insertBefore(li, talkItem); // puts Road Map BEFORE Discord
 
    } else {
            const span = document.createElement('span');
        tabList.appendChild(li);
            span.textContent = 'Road Map';
     }
 
}
            a.appendChild(span);
            li.appendChild(a);
            tabList.appendChild(li);
        }
 
     });
});

Revision as of 20:07, 8 April 2026

// Add Road Map tab BEFORE Discord
const tabList = document.querySelector('#p-associated-pages .vector-menu-content-list, #p-namespaces .vector-menu-content-list');
const talkItem = document.querySelector('#ca-talk'); // Discord tab

if (tabList && !document.getElementById('ca-roadmap')) {
    const li = document.createElement('li');
    li.id = 'ca-roadmap';

    const existingTab = talkItem || document.querySelector('#ca-view');

    if (existingTab) {
        li.className = existingTab.className.replace(/\bselected\b|\bactive\b/g, '').trim();
    } else {
        li.className = 'mw-list-item';
    }

    const a = document.createElement('a');
    a.href = 'https://ohwikiguide.com/index.php/Road_Map';
    a.title = 'Road Map';

    const span = document.createElement('span');
    span.textContent = 'Road Map';

    a.appendChild(span);
    li.appendChild(a);

    // 🔥 THIS is the important change
    if (talkItem) {
        tabList.insertBefore(li, talkItem); // puts Road Map BEFORE Discord
    } else {
        tabList.appendChild(li);
    }
}