MediaWiki:Common.js: mudanças entre as edições

Sem resumo de edição
Sem resumo de edição
Linha 28: Linha 28:


*/
*/
/**
* Hide prefix in [[Special:PrefixIndex]]
*
* Adds a checkbox to the form on [[Special:PrefixIndex]].
* When the form is submitted with this checkbox ticked,
* the prefix value will be hidden in the output (see also Wikimedia's [[phab:T29131]]).
*
* @source: https://www.mediawiki.org/wiki/Snippets/Hide_prefix_in_SpecialPrefixIndex
* @rev: 2
*/
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Prefixindex' ) {
var prefix = $( '#nsfrom' ).val();
var hideprefixVal = mw.util.getParamValue( 'hideprefix' );
// ^ Works only 1.17+
// Replace with a call to a similar function or create one if you're using 1.16 or lower
var $hideprefixLabel = $( '<label/>', {
'for': 'hideprefix',
'text': 'Hide prefix:'
} );
var $hideprefixInput = $( '<input/>', {
'type': 'checkbox',
'name': 'hideprefix',
'id': 'hideprefix',
'value': '1'
} );
if ( hideprefixVal == '1' ) {
$hideprefixInput.attr( 'checked', 'checked' );
}
var $hideprefixRow = $( '<tr/>' )
.append( $( '<td/>', {
'class': 'mw-label',
'html': $hideprefixLabel
} ) )
.append( $( '<td/>', {
'class': 'mw-input',
'html': $hideprefixInput
} ) );
// Add checkbox
$( '#nsselect' ).find( ' > tbody:first' ).append( $hideprefixRow );
// Do it
if ( prefix && hideprefixVal == '1' ) {
$( '#mw-prefixindex-list-table td a' ).text( function( i, val ) {
return val.replace( prefix, '' );
                } );
}
}

Edição das 12h02min de 19 de outubro de 2022

/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki



/* Sidebar

function ModifySidebar( action, section, name, link ) { try { switch ( section ) { case 'languages': var target = 'p-lang'; break; case 'toolbox': var target = 'p-tb'; break; case 'navigation': var target = 'p-navigation'; break; default: var target = 'p-' + section; break; }

if ( action == 'add' ) { var node = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0];

var aNode = document.createElement( 'a' ); var liNode = document.createElement( 'li' );

aNode.appendChild( document.createTextNode( name ) ); aNode.setAttribute( 'href', link ); liNode.appendChild( aNode ); liNode.className = 'plainlinks'; node.appendChild( liNode ); }

if ( action == 'remove' ) { var list = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0];

var listelements = list.getElementsByTagName( 'li' );

for ( var i = 0; i < listelements.length; i++ ) { if ( listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name || listelements[i].getElementsByTagName( 'a' )[0].href == link ) { list.removeChild( listelements[i] ); } } }

} catch( e ) { // let's just ignore what's happened return; } }

function CustomizeModificationsOfSidebar() { // adds [[Especial:Árvore_de_categorias|Special:CategoryTree]] to toolbox ModifySidebar( 'add', 'toolbox', 'CategoryTree', '[https://en.wikipedia.org/wiki/Special:CategoryTree' https://en.wikipedia.org/wiki/Special:CategoryTree'] ); // removes [[Especial:Carregar_arquivo|Special:Upload]] from toolbox ModifySidebar( 'remove', 'toolbox', 'Upload file', '[https://en.wikipedia.org/wiki/Special:Upload' https://en.wikipedia.org/wiki/Special:Upload'] ); }

jQuery( CustomizeModificationsOfSidebar )

document.getElementById('p-tb').remove()

*/

/**
 * Hide prefix in [[Special:PrefixIndex]]
 *
 * Adds a checkbox to the form on [[Special:PrefixIndex]].
 * When the form is submitted with this checkbox ticked,
 * the prefix value will be hidden in the output (see also Wikimedia's [[phab:T29131]]).
 *
 * @source: https://www.mediawiki.org/wiki/Snippets/Hide_prefix_in_SpecialPrefixIndex
 * @rev: 2
 */
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Prefixindex' ) {
	var prefix = $( '#nsfrom' ).val();
	var hideprefixVal = mw.util.getParamValue( 'hideprefix' );
		// ^ Works only 1.17+
		// Replace with a call to a similar function or create one if you're using 1.16 or lower
	var $hideprefixLabel = $( '<label/>', {
			'for': 'hideprefix',
			'text': 'Hide prefix:'
	} );
	var $hideprefixInput = $( '<input/>', {
		'type': 'checkbox',
		'name': 'hideprefix',
		'id': 'hideprefix',
		'value': '1'
	} );
	if ( hideprefixVal == '1' ) {
		$hideprefixInput.attr( 'checked', 'checked' );
	}
	var $hideprefixRow = $( '<tr/>' )
		.append( $( '<td/>', {
			'class': 'mw-label',
			'html': $hideprefixLabel
			} ) )
		.append( $( '<td/>', {
			'class': 'mw-input',
			'html': $hideprefixInput
			} ) );
	// Add checkbox
	$( '#nsselect' ).find( ' > tbody:first' ).append( $hideprefixRow );
	// Do it
	if ( prefix && hideprefixVal == '1' ) {
		$( '#mw-prefixindex-list-table td a' ).text( function( i, val ) {
			return val.replace( prefix, '' );
                } );
	}
}
Cookies nos ajudam a entregar nossos serviços. Ao usar nossos serviços, você concorda com o uso de cookies.