MediaWiki:Gadget-TurnBackAnchors.js

Da Semi del Verbo, l'enciclopedia dell'influenza del Vangelo sulla cultura
Versione del 30 ago 2020 alle 22:40 di Johnrdorazio (discussione | contributi) (una versione importata)
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
/**
 * For people without access to the home key :)
 *
 * @license [[WFTPL]] COMING WITH ABSOLUTELY NO WARRANTY
 * @author [[Utente:Valerio Bozzolan]] and history contributors
 */
window.turnBackAnchors = {};
window.turnBackAnchors.opts = {
	prependMsg: '[Vai giù ↓]',
	appendMsg: '[Torna su ↑]',
	append:  true,
	prepend: true
};
window.turnBackAnchors.init = function () {
	var ns = mw.config.get('wgNamespaceNumber');
	if(ns === -1 || ns % 2 === 0) {
		return; // Discussions are even
	}

	function $anchor( href, msg ) {
		return $('<div>').css('text-align', 'right').append(
			$('<a>').attr('href', href)
			        .html( msg )
		);
	}

	var $content = $('#bodyContent');
	var opts = window.turnBackAnchors.opts;

	opts.append && $content.append(
		$anchor('#', opts.appendMsg)
	);
	opts.prepend && $content.prepend(
		$anchor('#footer', opts.prependMsg)
	);
};
window.turnBackAnchors.init();