MediaWiki:Common.js: Difference between revisions
Blanked the page |
Add custom three-column community footer (JS injection) |
||
| Line 1: | Line 1: | ||
/* Marspedia custom footer injection */ | |||
/* URLs adapted to Marspedia's root URL layout (no /wiki prefix) and verified | |||
sister-wiki layouts: Lunarpedia = root, Spacepedia = spacepedia.wiki with /w/ paths. */ | |||
(function () { | |||
'use strict'; | |||
function buildFooter() { | |||
// Grab last-edited text from the native footer before hiding it | |||
var lastmodEl = document.getElementById('footer-info-lastmod'); | |||
var lastmod = lastmodEl | |||
? lastmodEl.textContent.replace(/^\s*This page was last edited on\s*/i, '').trim() | |||
: ''; | |||
var lastmodText = lastmod | |||
? 'This page was last edited on ' + lastmod + '.' | |||
: ''; | |||
var html = [ | |||
'<div id="mp-custom-footer">', | |||
' <div class="mp-footer-card">', | |||
/* CTA bar */ | |||
' <div class="mp-footer-cta">', | |||
' <div class="mp-footer-cta-text">', | |||
' <h2>Help build the Marspedia knowledge base</h2>', | |||
' <p>Anyone can contribute — edit articles, add references, or start a new topic on Mars settlement.</p>', | |||
' </div>', | |||
' <a href="/Marspedia:Contributing" class="mp-footer-cta-btn">Start contributing</a>', | |||
' </div>', | |||
' <hr class="mp-footer-divider">', | |||
/* Three columns */ | |||
' <div class="mp-footer-columns">', | |||
/* LEFT — Marspedia */ | |||
' <div class="mp-footer-col mp-footer-col-left">', | |||
' <p class="mp-col-label">Marspedia</p>', | |||
' <p class="mp-col-tagline">Settling Mars</p>', | |||
' <ul class="mp-footer-links">', | |||
' <li><a href="/Main_Page">Main Page</a></li>', | |||
' <li><a href="/Special:RecentChanges">Recent Changes</a></li>', | |||
' <li><a href="/Marspedia:Community_Portal">Community Portal</a></li>', | |||
' <li><a href="/Special:Random">Random Article</a></li>', | |||
' <li><a href="/Help:Contents">Help</a></li>', | |||
' <li><a href="/Special:RequestAccount">Request an Account</a></li>', | |||
' </ul>', | |||
' </div>', | |||
/* MIDDLE — Sister wikis */ | |||
' <div class="mp-footer-col mp-footer-col-mid">', | |||
' <p class="mp-col-label">Sister Wikis</p>', | |||
' <div class="mp-subsection">', | |||
' <p class="mp-subhead">Lunarpedia</p>', | |||
' <p class="mp-subhead-tagline">Settling the Moon</p>', | |||
' <ul class="mp-footer-links">', | |||
' <li><a href="https://lunarpedia.org/Main_Page">Main Page</a></li>', | |||
' <li><a href="https://lunarpedia.org/Special:RecentChanges">Recent Changes</a></li>', | |||
' <li><a href="https://lunarpedia.org/Lunarpedia:Community_Portal">Community Portal</a></li>', | |||
' </ul>', | |||
' </div>', | |||
' <div class="mp-subsection">', | |||
' <p class="mp-subhead">Spacepedia</p>', | |||
' <p class="mp-subhead-tagline">Exploring space</p>', | |||
' <ul class="mp-footer-links">', | |||
' <li><a href="https://spacepedia.wiki/w/Home">Main Page</a></li>', | |||
' <li><a href="https://spacepedia.wiki/w/Special:RecentChanges">Recent Changes</a></li>', | |||
' <li><a href="https://spacepedia.wiki/w/Special:Random">Random Article</a></li>', | |||
' </ul>', | |||
' </div>', | |||
' </div>', | |||
/* RIGHT — Partners + Volunteer */ | |||
' <div class="mp-footer-col mp-footer-col-right">', | |||
' <p class="mp-col-label">Partners & Volunteering</p>', | |||
' <div class="mp-subsection">', | |||
' <p class="mp-subhead">The Mars Society</p>', | |||
' <ul class="mp-footer-links">', | |||
' <li><a href="https://www.marssociety.org/get-involved/volunteer/">How to Volunteer</a></li>', | |||
' <li><a href="https://www.marssociety.org/get-involved/projects/">Find a Project</a></li>', | |||
' <li><a href="https://www.marssociety.org/about/chapters/">Local Chapters</a></li>', | |||
' <li><a href="https://www.marssociety.org/">marssociety.org</a></li>', | |||
' </ul>', | |||
' </div>', | |||
' <div class="mp-subsection">', | |||
' <p class="mp-subhead">The Moon Society</p>', | |||
' <ul class="mp-footer-links">', | |||
' <li><a href="https://www.moonsociety.org/join/">How to Volunteer</a></li>', | |||
' <li><a href="https://www.moonsociety.org/projects/">Find a Project</a></li>', | |||
' <li><a href="https://www.moonsociety.org/working-groups/">Working Groups</a></li>', | |||
' <li><a href="https://www.moonsociety.org/">moonsociety.org</a></li>', | |||
' </ul>', | |||
' </div>', | |||
' </div>', | |||
' </div>', /* end .mp-footer-columns */ | |||
/* Bottom strip */ | |||
' <div class="mp-footer-bottom">', | |||
' <p class="mp-footer-bottom-timestamp">' + lastmodText + '</p>', | |||
' <ul class="mp-footer-bottom-links">', | |||
' <li><a href="/Marspedia:Privacy_policy">Privacy policy</a></li>', | |||
' <li><a href="/Marspedia:About">About Marspedia</a></li>', | |||
' <li><a href="/Marspedia:General_disclaimer">Disclaimers</a></li>', | |||
' </ul>', | |||
' </div>', | |||
' </div>', /* end .mp-footer-card */ | |||
'</div>' /* end #mp-custom-footer */ | |||
].join('\n'); | |||
// Insert after the native footer | |||
var nativeFooter = document.getElementById('footer'); | |||
if (nativeFooter && nativeFooter.parentNode) { | |||
var wrapper = document.createElement('div'); | |||
wrapper.innerHTML = html; | |||
nativeFooter.parentNode.insertBefore(wrapper.firstChild, nativeFooter.nextSibling); | |||
} | |||
} | |||
// Run after DOM is ready | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', buildFooter); | |||
} else { | |||
buildFooter(); | |||
} | |||
}()); | |||
Revision as of 06:29, 2 July 2026
/* Marspedia custom footer injection */
/* URLs adapted to Marspedia's root URL layout (no /wiki prefix) and verified
sister-wiki layouts: Lunarpedia = root, Spacepedia = spacepedia.wiki with /w/ paths. */
(function () {
'use strict';
function buildFooter() {
// Grab last-edited text from the native footer before hiding it
var lastmodEl = document.getElementById('footer-info-lastmod');
var lastmod = lastmodEl
? lastmodEl.textContent.replace(/^\s*This page was last edited on\s*/i, '').trim()
: '';
var lastmodText = lastmod
? 'This page was last edited on ' + lastmod + '.'
: '';
var html = [
'<div id="mp-custom-footer">',
' <div class="mp-footer-card">',
/* CTA bar */
' <div class="mp-footer-cta">',
' <div class="mp-footer-cta-text">',
' <h2>Help build the Marspedia knowledge base</h2>',
' <p>Anyone can contribute — edit articles, add references, or start a new topic on Mars settlement.</p>',
' </div>',
' <a href="/Marspedia:Contributing" class="mp-footer-cta-btn">Start contributing</a>',
' </div>',
' <hr class="mp-footer-divider">',
/* Three columns */
' <div class="mp-footer-columns">',
/* LEFT — Marspedia */
' <div class="mp-footer-col mp-footer-col-left">',
' <p class="mp-col-label">Marspedia</p>',
' <p class="mp-col-tagline">Settling Mars</p>',
' <ul class="mp-footer-links">',
' <li><a href="/Main_Page">Main Page</a></li>',
' <li><a href="/Special:RecentChanges">Recent Changes</a></li>',
' <li><a href="/Marspedia:Community_Portal">Community Portal</a></li>',
' <li><a href="/Special:Random">Random Article</a></li>',
' <li><a href="/Help:Contents">Help</a></li>',
' <li><a href="/Special:RequestAccount">Request an Account</a></li>',
' </ul>',
' </div>',
/* MIDDLE — Sister wikis */
' <div class="mp-footer-col mp-footer-col-mid">',
' <p class="mp-col-label">Sister Wikis</p>',
' <div class="mp-subsection">',
' <p class="mp-subhead">Lunarpedia</p>',
' <p class="mp-subhead-tagline">Settling the Moon</p>',
' <ul class="mp-footer-links">',
' <li><a href="https://lunarpedia.org/Main_Page">Main Page</a></li>',
' <li><a href="https://lunarpedia.org/Special:RecentChanges">Recent Changes</a></li>',
' <li><a href="https://lunarpedia.org/Lunarpedia:Community_Portal">Community Portal</a></li>',
' </ul>',
' </div>',
' <div class="mp-subsection">',
' <p class="mp-subhead">Spacepedia</p>',
' <p class="mp-subhead-tagline">Exploring space</p>',
' <ul class="mp-footer-links">',
' <li><a href="https://spacepedia.wiki/w/Home">Main Page</a></li>',
' <li><a href="https://spacepedia.wiki/w/Special:RecentChanges">Recent Changes</a></li>',
' <li><a href="https://spacepedia.wiki/w/Special:Random">Random Article</a></li>',
' </ul>',
' </div>',
' </div>',
/* RIGHT — Partners + Volunteer */
' <div class="mp-footer-col mp-footer-col-right">',
' <p class="mp-col-label">Partners & Volunteering</p>',
' <div class="mp-subsection">',
' <p class="mp-subhead">The Mars Society</p>',
' <ul class="mp-footer-links">',
' <li><a href="https://www.marssociety.org/get-involved/volunteer/">How to Volunteer</a></li>',
' <li><a href="https://www.marssociety.org/get-involved/projects/">Find a Project</a></li>',
' <li><a href="https://www.marssociety.org/about/chapters/">Local Chapters</a></li>',
' <li><a href="https://www.marssociety.org/">marssociety.org</a></li>',
' </ul>',
' </div>',
' <div class="mp-subsection">',
' <p class="mp-subhead">The Moon Society</p>',
' <ul class="mp-footer-links">',
' <li><a href="https://www.moonsociety.org/join/">How to Volunteer</a></li>',
' <li><a href="https://www.moonsociety.org/projects/">Find a Project</a></li>',
' <li><a href="https://www.moonsociety.org/working-groups/">Working Groups</a></li>',
' <li><a href="https://www.moonsociety.org/">moonsociety.org</a></li>',
' </ul>',
' </div>',
' </div>',
' </div>', /* end .mp-footer-columns */
/* Bottom strip */
' <div class="mp-footer-bottom">',
' <p class="mp-footer-bottom-timestamp">' + lastmodText + '</p>',
' <ul class="mp-footer-bottom-links">',
' <li><a href="/Marspedia:Privacy_policy">Privacy policy</a></li>',
' <li><a href="/Marspedia:About">About Marspedia</a></li>',
' <li><a href="/Marspedia:General_disclaimer">Disclaimers</a></li>',
' </ul>',
' </div>',
' </div>', /* end .mp-footer-card */
'</div>' /* end #mp-custom-footer */
].join('\n');
// Insert after the native footer
var nativeFooter = document.getElementById('footer');
if (nativeFooter && nativeFooter.parentNode) {
var wrapper = document.createElement('div');
wrapper.innerHTML = html;
nativeFooter.parentNode.insertBefore(wrapper.firstChild, nativeFooter.nextSibling);
}
}
// Run after DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', buildFooter);
} else {
buildFooter();
}
}());