Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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-back-link");
	var $headerForward = $(".wst-header-forward-link");

	// 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.find("a").length !== 0) {
		$headerBack.clone()
			.removeAttr("id")
			.removeClass("wst-header-back-link 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.find("a").length !== 0) {
		$headerForward.clone()
			.removeAttr("id")
			.removeClass("wst-header-forward-link 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);
	}
});