Difference between revisions 237217 and 240009 on ptwikibooks

/**
 * Add some extra links
 * @author: [[User:Helder.wiki]]
 * @tracking: [[Special:GlobalUsage/User:Helder.wiki/Tools/Ligações extras.js]] ([[File:User:Helder.wiki/Tools/Ligações extras.js]])
 */
/*jslint browser: true, white: true, regexp: true, todo: true */
/*global jQuery, mediaWiki, jQuery */
( function ( $, mw /* , undefined */mw, $ ) {
'use strict';

var link, $link, encodedBookName, user, proj, code, d, mes, ano;

if ( $.inArray( mw.config.get( 'wgDBname' ), [ 'ptwikibooks', 'wikilocaldb' ] ) !== -1 && mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
	encodedBookName = mw.util.wikiUrlencode( mw.config.get( 'wgBookName' ) );
	link = '//toolserver.org/~pathoschild/catanalysis/?title='
(contracted; show full)		'ca-recentchangeslinked',
		'Exibir mudanças recentes nas páginas que apontam para esta',
		null,
		'#n-recentchanges + li'
	);
}

//
  Adiciona uma ligação para as contribuições globais de um usuário
if ( $.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 2, 3 ] ) !== -1
	|| 'Contributions' === mw.config.get('wgCanonicalSpecialPageName') ){
	if ( mw.config.get('wgNamespaceNumber') === -1 ){
			user = $('#contentSub a:first').textinput[name="target"]').val();
	} else {
			user = mw.config.get( 'wgTitle' ).split( '/' )[0];
	}
	mw.util.addPortletLink( 'p-tb', '//toolserver.org/~luxo/contributions/contributions.php?user=' + mw.util.wikiUrlencode( user ), 'Contribuições globais', 't-global', 'Ver as contribuições globais de ' + user, 'g', '#t-contributions + li' );

	// Rename default link
	$( '#t-contributions  ' ).find( 'a' ).text( 'Contribuições');
}


//Adiciona ao topo das mensagens de sistema uma aba com ligação para o Translatewiki
if (8 === mw.config.get( 'wgNamespaceNumber' ) ) {
	mw.util.addPortletLink(
		'p-namespaces',
(contracted; show full)
		//TODO: Não inserir se for o '.templatesUsed'
		.after( $( '<a>' ).attr( 'href', url + 'edit' ).text( 'edit' ) ).after( ' | ' );
});

//Adiciona ligações editar, links e hist à tela exibida depois de mover uma página
if ( 'Movepage' === mw.config.get( 'wgCanonicalSpecialPageName' ) ) {
	if ( 'Página movida com sucesso' === $( '#firstHeading' ).text() ){
		//
  Ficará obsoleto se e quando for possível usar [[MediaWiki:Movepage-page-moved]] com $3 e $4 (ver translatewiki)
		$( '#bodyContent ul:eq(1) li' ).each( function() {
			var	$mov = $(this).find( 'a' ),
				url = [
					mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( $mov.eq(0).text() ) + '&action=',
					mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( $mov.eq(1).text() ) + '&action='
				];
(contracted; show full)	'Ver estatísticas sobre a visualização desta página',
	't',
	'#t-whatlinkshere'
);



//
  Subpáginas
if (document.getElementById('p-tb') && $.inArray( mw.config.get( 'wgNamespaceNumber' ), [ -1, 6] ) === -1){
	link = mw.util.wikiGetlink( 'Special:PrefixIndex/' + mw.config.get( 'wgPageName' ) );
	mw.util.addPortletLink('p-tb', link, 'Subpáginas', 't-subpages', 'Subpáginas desta página');
}

// Add a short permanent link (without 'title=...')
$link = $( '#t-permalink  ' ).find( 'a' ).text('Link perm.');
if ( $link.size() ) {
	$link.after( $( '<a>' )
		.attr( 'href', $link.attr( 'href' ).replace( /title=[^&]*&/, '' ) )
		.text( 'Link curto' )
	).after( ' / ' );
}

}( jQuery, mediaWiki, jQuery ) );