MediaWiki:DisplayFooter.js

From Wikisource
Jump to navigation Jump to search

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**********************
*** Automatically generate page footer from values in {{header}}
*** by [[user:GrafZahl]] and [[user:Tpt]]
**********************/

$( function() {
	mw.loader.using( 'mediawiki.util', function() {
		if( mw.config.get( 'wgNamespaceNumber' ) !== 0 || mw.util.getParamValue( 'match' ) !== null ) {
			return;
		}
		var $nofooterElt = $( '#nofooter' );
		var $hp = $( '#headerprevious' );
		var $hn = $( '#headernext' );
	 	var $contentElt = $( '#mw-content-text' );
		if( $contentElt.length === 0 || ($hp.length === 0 && $hn.length === 0) || $nofooterElt.length !== 0 ) {
			return; 
		}
	
		var footer = '<div class="footertemplate ws-noexport" id="footertemplate" style="margin-top:1em; clear:both;">';
		footer += '<div style="width: 100%; padding-left:0px; padding-right:0px; background-color:transparent;">';
		if( $hp.length !== 0 ) {
			footer += '<div style="text-align:left; float:left; max-width:40%;"><span id="footerprevious">' + $hp.html() + '</span></div>';
		}
		if( $hn.length !== 0 ) {
			footer += '<div style="text-align:right; float:right; max-width:40%;"><span id="footernext">' + $hn.html() + '</span></div>';
		}
		footer += '<div style="text-align:center; margin-left: 25%; margin-right: 25%;"><a href="#top">' + ws_msg( '▲' ) + '</a></div>';
		footer += '</div><div style="clear:both;"></div></div>';
	
		$contentElt.append( footer );
	} );
} );