MediaWiki:Gadget-page-numbers.js

Z Wikiźródeł, wolnej biblioteki

Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.

  • Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
  • Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
  • Internet Explorer / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
  • Opera: Naciśnij klawisze Ctrl+F5.
/**
 * Link w postaci książki do pokazywania/ukrywania numerów stron.
 * Link "Koryguj" jeśli liczba dołączanych stron == 1
 */

function addTogglePageNumbersButton() {
	var a = document.getElementById( "ca-nstab-main" );
	if ( !a ) {
		return;
	}

	var spans = $( "span.ws-pagenum" );
	if ( !spans.length ) {
		return;
	}

	var link = document.createElement( "a" );
	link.setAttribute( "title", "Pokaż/ukryj numery stron" );

	if ( mw.config.get( 'skin' ) == "monobook" || mw.config.get( 'skin' ) == "vector" || mw.config.get( 'skin' ) == "vector-2022" ) {
		var img = document.createElement( "img" );
		img.src = "//upload.wikimedia.org/wikipedia/commons/thumb/9/92/Open_book_nae_02.svg/20px-Open_book_nae_02.svg.png";
		link.appendChild( img );
	} else {
		var text = document.createTextNode( "Numeracja stron" );
		link.appendChild( text );
	}
	link.onclick = function() {
		$(spans).toggle();
	};
	link.href = '#';
	var li = document.createElement( "li" );
	li.appendChild( link );
	li.setAttribute( 'class', 'mw-list-item vector-tab-noicon' );	
	a.parentNode.insertBefore( li, a.nextSibling );

	// Dodaj link "Koryguj"
	link = document.createElement( "a" );
	link.appendChild( document.createTextNode( "Koryguj" ) );

	li = document.createElement( "li" );
	li.appendChild( link );
	li.setAttribute( 'id', 'ca-proofread' );
	li.setAttribute( 'class', 'mw-list-item vector-tab-noicon' );	

	var historyLink = document.getElementById( "ca-history" );
	historyLink.parentNode.insertBefore( li, historyLink );

	link.href = (( $(spans).length == 1 ) ? ($(spans).find("a").attr("href") + "?action=edit") : '#');
	
	if ( $(spans).length == 1 ) { return; }
	link.onclick = function() {
		mw.notify( 'W tekście zostały pokazane numery stron. Kliknij na numer strony, którą chcesz poprawić.', { tag: 'tpnb_gadget' } );
		$(spans).find("a").attr("href", function(i, origValue){
			return origValue + (origValue.endsWith("?action=edit")? "" : "?action=edit"); 
		});
		$(spans).show();
	};
}

if ( mw.config.get( 'wgNamespaceNumber' ) == 0 ) {
	$( document ).ready( addTogglePageNumbersButton );
}