Open main menu

MediaWiki:DisplayFooter2.js

Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Note: This is a proof of concept, and will need some minor rewriting before implementation. */
	while (true) {
		/* elements */
		var df = {
			'prev':document.getElementById('headerprevious'),
			'next':document.getElementById('headernext'),
			'content':document.getElementById('bodyContent'),
			'cats':document.getElementById('catlinks'),
			'hide':document.getElementById('nofooter2'), // temporarily use different id, for demonstration purposes
			'show':document.getElementById('showfooter')
		};

		/* remove header added by the script in monobook.js */
		if(window.document.getElementById('footertemplate')) {
			document.getElementById('bodyContent').removeChild(document.getElementById('footertemplate'));
		}

		/* check conditions */
		if(mw.config.get('wgNamespaceNumber')!==0 && mw.config.get('wgNamespaceNumber')!==114)
			break;
		else if(df.hide)
			break;
		else if(!df.show && !df.prev && !df.next)
			break;

		

		/* generate footer */
		var footer = document.createElement('table');
		footer.setAttribute('class', 'headertemplate');
 
		var tr = document.createElement('tr');
		var td = document.createElement('td');
		td.setAttribute('align', 'left');
		td.setAttribute('width', '33%');

		if(df.prev) {
			fp = df.prev.cloneNode(true);
			fp.setAttribute('id', 'footerprevious');
			td.appendChild(fp);
		}
		tr.appendChild(td);
 
		var td = document.createElement('td');
		td.setAttribute('align', 'center');
		td.setAttribute('width', '34%');
		var a = document.createElement('a');
		a.setAttribute('href', '#top');
		a.appendChild(document.createTextNode('Return to the top of the page.'));
		td.appendChild(a);
		tr.appendChild(td);
 
		var td = document.createElement('td');
		td.setAttribute('align', 'right');
		td.setAttribute('width', '33%');
 
		if(df.next) {
			var fn = df.next.cloneNode(true);
			fn.setAttribute('id', 'footernext');
			td.appendChild(fn);
		}
		tr.appendChild(td);
 
		footer.appendChild(tr);
 
		/* place footer */
		if(df.cats) // before category box
			df.content.insertBefore(footer, catlinks);
		else
			df.content.appendChild(footer);

		/* terminate loop */
		break;
	}