MediaWiki:Gadget-AvvCatSpecializzate.js

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
//<nowiki>
$( function() {
	/**
	 * AGGIUNGE IL TEMPLATE PER LE CATEGORIA DELLA TERMINOLOGIA SPECIALIZZATA
	 */
	function addTemplate() {
		var Template = 'Avviso categoria specializzata',
			Fatto = '      <span style="color:#00A050; font-size:20px">√</span> ',
			summary = 'Script: Aggiungo {{[[Template:Avviso categoria specializzata|Avviso categoria specializzata]]}}';

		var params = {
			action: 'edit',
			title: "Categoria:" + mw.config.get( 'wgTitle' ),
			prependtext: "{{" + Template + "}}\n",
			summary: summary,
			minor: '1',
			bot: '1',
		};
		new mw.Api().postWithEditToken( params )
			.done( function() {
				$( 'h1' ).append( Fatto + '' );
			} )
			.fail( function() {
				mw.log.error( 'Impossibile modificare la pagina.' );
			} );
	}

	if ( ( /^Categoria:(.+)-[A-Z]+$/ ).test( "Categoria:" + mw.config.get( 'wgTitle' ) ) &&
		$( '#AvvCatSpe' ).length === 0 &&
		( /new/ ).test( $( '#ca-nstab-category' ).attr( 'class' ) ) !== 1 &&
		( /action\=(edit|submit|history|delete|protect|view|info|rollback)/ ).test( window.location.href ) !== true
	) {
		$( '#siteSub' ).append( ' • Creazione automatica categoria specializzata è attivo' );
		addTemplate();
	}
} );
//</nowiki>