Jump to content

MediaWiki:Common.js: Difference between revisions

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


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


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


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


    const a = document.createElement('a');
        // Add Road Map BEFORE Discord
    a.href = 'https://ohwikiguide.com/index.php/Road_Map';
        const tabList = document.querySelector('#p-associated-pages .vector-menu-content-list, #p-namespaces .vector-menu-content-list');
    a.title = 'Road Map';


    const span = document.createElement('span');
        if (tabList && !document.getElementById('ca-roadmap')) {
    span.textContent = 'Road Map';
            const li = document.createElement('li');
            li.id = 'ca-roadmap';
            li.className = talkItem ? talkItem.className.replace(/\bselected\b|\bactive\b/g, '').trim() : 'mw-list-item';


    a.appendChild(span);
            const a = document.createElement('a');
    li.appendChild(a);
            a.href = 'https://ohwikiguide.com/index.php/Road_Map';


    // 🔥 THIS is the important change
            const span = document.createElement('span');
    if (talkItem) {
            span.textContent = 'Road Map';
        tabList.insertBefore(li, talkItem); // puts Road Map BEFORE Discord
 
    } else {
            a.appendChild(span);
        tabList.appendChild(li);
            li.appendChild(a);
     }
 
}
            if (talkItem) {
                tabList.insertBefore(li, talkItem);
            } else {
                tabList.appendChild(li);
            }
        }
 
     });
});

Revision as of 20:08, 8 April 2026

mw.loader.using('mediawiki.util').then(function () {
    $(function () {

        // Rename Discussion → Discord
        const talkTab = document.querySelector('#ca-talk a');
        const talkItem = document.querySelector('#ca-talk');

        if (talkTab) {
            talkTab.textContent = 'Discord';
            talkTab.href = 'https://discord.gg/FZtkXeGeUA';
            talkTab.target = '_blank';
            talkTab.rel = 'noopener noreferrer';

            talkTab.addEventListener('click', function (e) {
                e.preventDefault();
                window.open('https://discord.gg/FZtkXeGeUA', '_blank');
            });
        }

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

        if (tabList && !document.getElementById('ca-roadmap')) {
            const li = document.createElement('li');
            li.id = 'ca-roadmap';
            li.className = talkItem ? talkItem.className.replace(/\bselected\b|\bactive\b/g, '').trim() : 'mw-list-item';

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

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

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

            if (talkItem) {
                tabList.insertBefore(li, talkItem);
            } else {
                tabList.appendChild(li);
            }
        }

    });
});