MediaWiki:Common.js

Fonte: Wikinotícias

Nota: Depois de publicar, deve limpar o cachê do seu navegador para ver as alterações.

  • Firefox e Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Internet Explorer e Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
/* Código Javascript colocado aqui será carregado para todos os utilizadores em cada carregamento de página */

mw.loader.using( ['mediawiki.util'], function () {
	var extraCSS = mw.util.getParamValue( 'withCSS' ),
		extraJS = mw.util.getParamValue( 'withJS' );

	if ( extraCSS ) {
		// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
		if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) {
			mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
		} else {
			mw.notify( 'Só são permitidas páginas do domínio MediaWiki.', { title: 'Valor withCSS inválido' } );
		}
	}

	if ( extraJS ) {
		// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
		if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) {
			mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
		} else {
			mw.notify( 'Só são permitidas páginas do domínio MediaWiki.', { title: 'Valor withJS inválido' } );
		}
	}
} );

/**
 * Transforma determinadas páginas em páginas de discussão
 * Origem: fr:w:MediaWiki:Common.js
 */

if ( mw.config.get( 'wgNamespaceNumber' ) >= 2 ) {
	$( function ( $ ) {
		if (
			/^Wikinotícias:(Tire suas dúvidas|Redação)/.test( mw.config.get( 'wgPageName' ) ) ||
			$( '#transformeEnPageDeDiscussion' ).length
		) {
			$( 'body' ).removeClass( 'ns-subject' ).addClass( 'ns-talk' );
		}
	} );
}