MediaWiki:Gadget-DisplayFooter.js

Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

/* MediaWiki:Gadget-DisplayFooter.js */
/*
 * Automatically generate page footer from values in {{header}}
 * by [[user:GrafZahl]] and [[user:Tpt]]
 */

/* eslint-disable one-var, vars-on-top, no-jquery/no-global-selector */

$(function () {
	// Only active in the main namespace
	// TODO: (for now; need to add Translation:)
	if (mw.config.get('wgNamespaceNumber') !== 0) {
		return;
	}

	// Disabled if explicitly requested.
	if ($("#nofooter").length !== 0) {
		return;
	}

	// Grab the prev/next links from the {{header}}
	var $headerBack = $(".wst-header-backlink");
	var $headerForward = $(".wst-header-forwardlink");

	// If neither of them has content, bail.
	if ($headerBack.length === 0 && $headerForward.length === 0) {
		return;
	}

	// The footer div.
	var $footer = $("<div>").addClass("ws-footer ws-noexport noprint dynlayout-exempt");

	// Copy the previous link and add it to the footer
	if ($headerBack.length !== 0) {
		$headerBack.clone()
			.removeAttr("id")
			.removeClass("wst-header-backlink wst-header-back wst-header-previous")
			.addClass("ws-footer-back")
			.appendTo($footer);
	} else {
		$("<div>").addClass("ws-footer-back ws-footer-empty")
			.appendTo($footer);
	}

	// Add the "return to top" text
	var $footerCenter = $("<div>")
		.addClass("ws-footer-center")
		.append( // TODO: this message name is needlessly cryptic
			$('<a href="#top">' + mw.msg('▲') + '</a>')
		); 
	$footerCenter.appendTo($footer);

	// Copy the next link and add it to the footer
	if ($headerForward.length !== 0) {
		$headerForward.clone()
			.removeAttr("id")
			.removeClass("wst-header-forwardlink wst-header-forward wst-header-next")
			.addClass("ws-footer-forward")
			.appendTo($footer);
	} else {
		$("<div>").addClass("ws-footer-forward ws-footer-empty")
			.appendTo($footer);
	}

	var $printlinksElt = $('.printfooter');
	if ($printlinksElt.length !== 0) { // place footer before category box
		$printlinksElt.after($footer);
	} else {
		$('#mw-content-text').after($footer);
	}
});