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

Por equipe do Dicionário de Favelas Marielle Franco
(Atualização da Sidebar elaborada por Leonardo Gargano)
 
Sem resumo de edição
 
(10 revisões intermediárias por 3 usuários não estão sendo mostradas)
Linha 1: Linha 1:
/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki
/* Incluir título da seção Referências automático */
$(document).ready(function(){
    $('.mw-references-wrap').before('<h2>Notas e Referências</h2>');
});


/* 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 ) {
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; }
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' ) {
if ( action == 'add' ) { var node = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0];
var node = document.getElementById( target )
  .getElementsByTagName( 'div' )[0]
  .getElementsByTagName( 'ul' )[0];


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


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


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


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


for ( var i = 0; i < listelements.length; i++ ) {
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] ); } } }
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; } }


} catch( e ) {
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'] ); }
// let's just ignore what's happened
return;
}
}
 
function CustomizeModificationsOfSidebar() {
// adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox
ModifySidebar( 'add', 'toolbox', 'CategoryTree', 'https://en.wikipedia.org/wiki/Special:CategoryTree' );
// removes [[Special:Upload|Special:Upload]] from toolbox
ModifySidebar( 'remove', 'toolbox', 'Upload file', 'https://en.wikipedia.org/wiki/Special:Upload' );
}


jQuery( CustomizeModificationsOfSidebar )
jQuery( CustomizeModificationsOfSidebar )


document.getElementById('p-tb').remove()
document.getElementById('p-tb').remove()
*/
/**
* Hide prefix in category
*
* @source https://www.mediawiki.org/wiki/Snippets/Hide_prefix_in_category
* @rev 2020-04-28
*/
$( function () {
    var prefix = $( '#mw-cat-hideprefix' ).text().trim();
    if ( prefix ) {
        $( '#mw-pages a' ).text( function ( i, val ) {
            return val.slice( 0, prefix.length ) === prefix ? val.slice( prefix.length ) : val;
        } );
    }
} );

Edição atual tal como às 14h24min de 18 de agosto de 2023

/* Códigos JavaScript aqui colocados serão carregados por todos aqueles que acessarem alguma página deste wiki
/* Incluir título da seção Referências automático */
$(document).ready(function(){
    $('.mw-references-wrap').before('<h2>Notas e Referências</h2>');
});

/* 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 category
 *
 * @source https://www.mediawiki.org/wiki/Snippets/Hide_prefix_in_category
 * @rev 2020-04-28
 */
$( function () {
    var prefix = $( '#mw-cat-hideprefix' ).text().trim();
    if ( prefix ) {
        $( '#mw-pages a' ).text( function ( i, val ) {
            return val.slice( 0, prefix.length ) === prefix ? val.slice( prefix.length ) : val;
        } );
    }
} );