imported>Dawning
(by SublimeText.Mediawiker)
imported>Dawning
(by SublimeText.Mediawiker)
Line 1: Line 1:
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {
$(document).ready(function() {
     var api = new mw.Api();
     // Hide default footer
    $('#p-lang, .minerva-footer-logo, #footer-info, #footer-places').hide();
      
      
     // Fetch MediaWiki:Footer content
     // Add custom footer sections
     api.get({
     addFooterSection('About', [
         action: 'parse',
         { url: mw.util.getUrl('Main_Page'), text: 'Home' },
         page: 'MediaWiki:Footer',
         { url: mw.util.getUrl('Telos_Realms_Wiki:About'), text: 'About' },
         prop: 'wikitext',
         { url: mw.util.getUrl('Help:Contents'), text: 'Help' }
        formatversion: 2
     ]);
     }).done(function(data) {
   
         if (data.parse && data.parse.wikitext) {
    addFooterSection('Legal', [
            var footerText = data.parse.wikitext;
        { url: mw.util.getUrl('Telos_Realms_Wiki:Privacy'), text: 'Privacy Policy' },
            parseFooterLinks(footerText);
         { url: mw.util.getUrl('Telos_Realms_Wiki:Terms'), text: 'Terms of Service' }
         }
    ]);
     });
   
    addFooterSection('Community', [
        { url: 'https://discord.gg/yourserver', text: 'Discord' },
         { url: 'https://twitter.com/yourhandle', text: 'Twitter' }
     ]);
});
});


function parseFooterLinks(text) {
function addFooterSection(title, links) {
     var lines = text.split('\n');
     var portletId = 'footer-' + title.toLowerCase();
     var currentPortlet = null;
   
    var section = $('<div>').attr('id', portletId).addClass('footer-section');
     var heading = $('<h4>').text(title);
    section.append(heading);
   
    $('.post-content.footer-content').append(section);
      
      
     lines.forEach(function(line) {
     links.forEach(function(link) {
         line = line.trim();
         mw.util.addPortletLink(portletId, link.url, link.text);
       
        // Skip empty lines and comments
        if (!line || line[0] === '#') return;
       
        // Section header: * SectionName
        if (line.match(/^\*\s*[^*]/)) {
            var sectionName = line.replace(/^\*\s*/, '');
            currentPortlet = 'footer-' + sectionName.toLowerCase().replace(/\s+/g, '-');
           
            // Create section container if needed
            if (!document.getElementById(currentPortlet)) {
                var section = document.createElement('div');
                section.id = currentPortlet;
                section.className = 'footer-section';
               
                var title = document.createElement('h4');
                title.textContent = sectionName;
                section.appendChild(title);
               
                var list = document.createElement('ul');
                list.className = 'footer-section-links';
                section.appendChild(list);
               
                $('.post-content.footer-content').append(section);
            }
        }
        // Link item: ** target|text
        else if (line.match(/^\*\*/)) {
            var linkText = line.replace(/^\*\*\s*/, '');
            var parts = linkText.split('|');
            var target = parts[0].trim();
            var text = parts.length > 1 ? parts[1].trim() : target;
           
            // Determine URL
            var url;
            if (target.match(/^https?:\/\//)) {
                url = target;
            } else if (target.indexOf('Special:') === 0) {
                url = mw.util.getUrl(target);
            } else {
                url = mw.util.getUrl(target);
            }
           
            if (currentPortlet) {
                mw.util.addPortletLink(currentPortlet, url, text);
            }
        }
     });
     });
}
}

Revision as of 06:39, 19 October 2025

$(document).ready(function() {
    // Hide default footer
    $('#p-lang, .minerva-footer-logo, #footer-info, #footer-places').hide();
    
    // Add custom footer sections
    addFooterSection('About', [
        { url: mw.util.getUrl('Main_Page'), text: 'Home' },
        { url: mw.util.getUrl('Telos_Realms_Wiki:About'), text: 'About' },
        { url: mw.util.getUrl('Help:Contents'), text: 'Help' }
    ]);
    
    addFooterSection('Legal', [
        { url: mw.util.getUrl('Telos_Realms_Wiki:Privacy'), text: 'Privacy Policy' },
        { url: mw.util.getUrl('Telos_Realms_Wiki:Terms'), text: 'Terms of Service' }
    ]);
    
    addFooterSection('Community', [
        { url: 'https://discord.gg/yourserver', text: 'Discord' },
        { url: 'https://twitter.com/yourhandle', text: 'Twitter' }
    ]);
});

function addFooterSection(title, links) {
    var portletId = 'footer-' + title.toLowerCase();
    
    var section = $('<div>').attr('id', portletId).addClass('footer-section');
    var heading = $('<h4>').text(title);
    section.append(heading);
    
    $('.post-content.footer-content').append(section);
    
    links.forEach(function(link) {
        mw.util.addPortletLink(portletId, link.url, link.text);
    });
}