Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

/**
 * Tool for mass-blocking a list of IPs/users.
 * Adapted from [[:en:User:Timotheus Canens/massblock.js]] to work a bit better
 * with local config.
 */
function doMassBlock() {
	document.getElementById( "wpMassBlockSubmit" ).disabled = true;
	var users = document.getElementById( "wpMassBlockUsers" ).value.split( "\n" );
	if ( users.length === 0 ) {
		return;
	}
	var wpMassBlockReasons = document.getElementById( "wpMassBlockReasons" ).value.trim(),
		wpMassBlockReason = document.getElementById( "wpMassBlockReason" ).value.trim(),
		blocked = 0,
		talkpageedited = 0,
		userpageedited = 0,
		failed = [],
		error = [];
	var wpMassBlockAnononly = document.getElementById( "wpMassBlockAnononly" ).checked,
		wpMassBlockNocreate = document.getElementById( "wpMassBlockNocreate" ).checked,
		wpMassBlockEmail = document.getElementById( "wpMassBlockEmail" ).checked,
		wpMassBlockAutoblock = document.getElementById( "wpMassBlockAutoblock" ).checked,
		wpMassBlockTalkpage = document.getElementById( "wpMassBlockTalkpage" ).checked || false,
		wpMassBlockReblock = document.getElementById( "wpMassBlockReblock" ).checked;
	var wpMassBlockMessage = document.getElementById( "wpMassBlockMessage" ).value.trim(),
		wpMassBlockTag = document.getElementById( "wpMassBlockTag" ).value.trim(),
		wpMassBlockExpiry = document.getElementById( "wpMassBlockExpiry" ).value.trim();
	var wpMassBlockSummaryTalk = document.getElementById( "wpMassBlockSummaryTalk" ).value.trim(),
		wpMassBlockSummaryUser = document.getElementById( "wpMassBlockSummaryUser" ).value.trim();

	for ( i = 0; i < users.length; i++ ) {
		var user = users[ i ];
		if ( user.length > 0 ) {
			var api = new mw.Api();
			api.postWithToken( "block", {
					action: 'block',
					allowusertalk: wpMassBlockTalkpage,
					autoblock: wpMassBlockAutoblock,
					nocreate: wpMassBlockNocreate,
					expiry: wpMassBlockExpiry === "" ? "indefinite" : wpMassBlockExpiry,
					anononly: wpMassBlockAnononly,
					noemail: wpMassBlockEmail,
					reblock: wpMassBlockReblock,
					reason: wpMassBlockReasons === "other" ? wpMassBlockReason : wpMassBlockReasons + ( wpMassBlockReason ? ": " + wpMassBlockReason : "" ),
					user: user
				} )
				.then(
					function( data ) {
						blocked++;
						if ( wpMassBlockMessage !== "" ) {
							doEditTalk();
						}
						if ( wpMassBlockTag !== "" ) {
							doEditUserPage();
						}
					},
					function( e ) {
						// If not blocked, add the title to the "failed" array and a description of the error to the "error" array.
						failed.push( "Special:Block/" + user );
						error.push( e );
					}
				);
		}
	}

	document.getElementById( "wpMassBlockSubmit" ).value = "(" + blocked + "/" + talkpageedited + "/" + userpageedited + ")";
	if ( failed.length > 0 ) {
		var linkedList = "";
		for ( x = 0; x < failed.length; x++ ) {
			linkedList += "<li><a href=\"" + wgScript + "?title=" + encodeURIComponent( failed[ x ] ) + "\">" + failed[ x ] + "</a>: " + error[ x ] + "</li>"; //Links the titles in the "failed" array
		}
		document.getElementById( "wpMassBlockFailedContainer" ).innerHTML += '<br /><b>Failed actions:</b><ul>' + linkedList + '</ul>';
	}
}

function doEditUserPage() {
	new mw.Api().postWithEditToken( {
		action: 'edit',
		title: 'User:' + user,
		text: wpMassBlockTag,
		summary: wpMassBlockSummaryUser,
		watchlist: 'nochange'
	} ).done( function( data ) {
		userpageedited++;
	} ).fail( function( e ) {
		//If not edited, add the title to the "failed" array and a description of the error to the "error" array.
		failed.push( "User talk:" + user );
		error.push( e );
	} );
}

function doEditTalk() {
	new mw.Api().postWithEditToken( {
		action: 'edit',
		title: 'User talk:' + user,
		text: wpMassBlockMessage,
		summary: wpMassBlockSummaryTalk,
		watchlist: 'nochange'
	} ).done( function( data ) {
		talkpageedited++;
	} ).fail( function( e ) {
		//If not edited, add the title to the "failed" array and a description of the error to the "error" array.
		failed.push( "User talk:" + user );
		error.push( e );
	} );
}

function getMessages() {
	var defaultMsg = {
		'document-title': 'Tim\'s mass-blocking tool - Wikipedia, the free encyclopedia',
		'page-title': 'Tim\'s mass-blocking tool',
		'abuse-disclaimer': '<b>If you abuse this tool, it\'s <i>your</i> fault, not mine.</b>',
		'blockusers': 'Users to block (one on each line, please):',
		'talkmsg': 'Replace talk page with (leave blank to leave no message):',
		'upmsg': 'Replace user page text with (leave blank for no change):',
		'common-reasons': 'Common reasons:',
		'other-reason': 'Other reason',
		'extra-reason': 'Other/additional reason:',
		'exptime': 'Expiration time (blank for indefinite):',
		'talksummary': 'Edit summary for talk page edit:',
		'upsummary': 'Edit summary for user page edit:',
		'anononly': 'Block anonymous users only (IPs only):',
		'autoblock': 'Enable autoblock (accounts only):',
		'nocreate': 'Block account creation:',
		'noemail': 'Block email:',
		'notalk': 'Remove talk page access:',
		'override': 'Override existing blocks:',
		'submit-text': 'Block'
	};

	var ret = [];
	for ( var msg in defaultMsg ) {
		ret[msg] = getLocalMessage( msg ) || defaultMsg[msg];
	}
	return ret;
}

function getLocalMessage( msg ) {
	// Not an optimal way to localise, but better than hardcoded inside the HTML
	localMsg = {
		'document-title': 'Il mass-blocker attira-trote',
		'page-title': 'L\'attira-trote',
		'abuse-disclaimer': '<b>Se abusi di questo strumento, è colpa tua e non mia!</b>',
		'blockusers': 'Utenti da bloccare (uno per riga):',
		'talkmsg': 'Sostituisci la talk con (lasciare vuoto per non modificare la talk):',
		'upmsg': 'Sostituisci la pagina utente con (lasciare vuoto per non modificare la pagina utente):',
		'common-reasons': 'Motivazioni comuni:',
		'other-reason': 'Altra motivazione',
		'extra-reason': 'Motivazione aggiuntiva:',
		'exptime': 'Durata del blocco (lasciare vuoto per blocco infinito):',
		'talksummary': 'Oggetto per la modifica della talk:',
		'upsummary': 'Oggetto per la modifica della pagina utente:',
		'anononly': 'Blocca solo utenti anonimi:',
		'autoblock': 'Attiva autoblocco (solo utenti registrati):',
		'nocreate': 'Blocca la creazione di utenze:',
		'noemail': 'Blocca email:',
		'notalk': 'Blocca anche la modifica della talk:',
		'override': 'Sovrascrivi eventuali blocchi:',
		'submit-text': 'Scatena l\'inferno!'
	};

	return localMsg[msg] || null;
}

function massblockform() {
	var bodyContent = ( mw.config.get( 'skin' ) === "cologneblue" ? "article" : "bodyContent" );
	var reasons = mw.msg( 'Ipbreason-dropdown' ).split( '\*\*' ),
		msg = getMessages();

	document.getElementsByTagName( "h1" )[ 0 ].textContent = msg['page-title'];
	document.title = msg['document-title'];

	var content =
		'<form id="wpMassBlock" name="wpMassBlock">' +
		msg['abuse-disclaimer'] +
		'<div id="wpMassBlockFailedContainer"></div>' +
		'<br /><br />' +
		msg['blockusers'] + '<br />' +
		'<textarea tabindex="1" accesskey="," name="wpMassBlockUsers" id="wpMassBlockUsers" rows="10" cols="80"></textarea>' +
		msg['talkmsg'] + '<br />' +
		'<textarea tabindex="2" accesskey="," name="wpMassBlockMessage" id="wpMassBlockMessage" rows="10" cols="80"></textarea>' +
		msg['upmsg'] + '<br />' +
		'<textarea tabindex="3" accesskey="," name="wpMassBlockTag" id="wpMassBlockTag" rows="10" cols="80"></textarea>' +
		'<br /><br /><table style="background-color:transparent">' +
		'<tr><td>'+ msg['common-reasons'] + '</td>' +
		'<td><select id="wpMassBlockReasons">' +
		'<optgroup label="' + msg['other-reason'] + '">' +
		'<option value="other">' + msg['other-reason'] + '</option>' +
		'</optgroup>' +
		'<optgroup label="' + msg['common-reasons'] + '">';

	for ( var i = 1, j = reasons.length; i < j; i++ ) {
		content += '<option value="' + reasons[ i ] + '">' + reasons[ i ] + '</option>';
	}

	content +=
		'</optgroup>' +
		'</select></td></tr>' +
		'<tr><td>' + msg['extra-reason'] + '</td>' +
		'<td><input type="text" id="wpMassBlockReason" name="wpMassBlockReason" maxlength="255" /></td></tr>' +
		'<tr><td>' + msg['exptime'] + '</td>' +
		'<td><input type="text" id="wpMassBlockExpiry" name="wpMassBlockExpiry" maxlength="255" /></td></tr>' +
		'<tr><td>' + msg['talksummary'] + '</td>' +
		'<td><input type="text" id="wpMassBlockSummaryTalk" name="wpMassBlockSummaryTalk" maxlength="255" /></td></tr>' +
		'<tr><td>' + msg['upsummary'] + '</td>' +
		'<td><input type="text" id="wpMassBlockSummaryUser" name="wpMassBlockSummaryUser" maxlength="255" /></td></tr>' +
		'<tr><td>' + msg['anononly'] + '</td><td><input type="checkbox" id="wpMassBlockAnononly" name="wpMassBlockAnononly" /></td></tr>' +
		'<tr><td>' + msg['autoblock'] + '</td><td><input type="checkbox" id="wpMassBlockAutoblock" name="wpMassBlockAutoblock" checked="checked" /></td></tr>' +
		'<tr><td>' + msg['nocreate'] + '</td><td><input type="checkbox" id="wpMassBlockNocreate" name="wpMassBlockNocreate" checked="checked" /></td></tr>' +
		'<tr><td>' + msg['noemail'] + '</td><td><input type="checkbox" id="wpMassBlockEmail" name="wpMassBlockEmail" /></td></tr>';

	if ( mw.config.get( 'wgBlockAllowsUTEdit' ) === true ) {
		content += '<tr><td>' + msg['notalk'] + '</td><td><input type="checkbox" id="wpMassBlockTalkpage" name="wpMassBlockTalkpage" /></td></tr>';
	}

	content += '<tr><td>' + msg['override'] + '</td><td><input type="checkbox" id="wpMassBlockReblock" name="wpMassBlockReblock" checked="checked" /></td></tr>' +
		'<tr><td><input type="button" id="wpMassBlockSubmit" name="wpMassBlockSubmit" value="' + msg['submit-text'] + '" onclick="doMassBlock()" /></td></tr>' +
		'</form>';

	document.getElementById( bodyContent ).innerHTML = content;

	document.getElementById( "wpMassBlockReasons" ).onchange = function() {
		var maxlength = ( document.getElementById( "wpMassBlockReasons" ).value === "other" ? 255 : ( 255 - ': '.length ) - document.getElementById( "wpMassBlockReasons" ).value.length );

		document.getElementById( "wpMassBlockReason" ).setAttribute( "maxlength", maxlength );
	};
}

if ( mw.config.get( "wgNamespaceNumber" ) === -1 &&
	( mw.config.get( "wgTitle" ) == "Massblock" || mw.config.get( "wgTitle" ) === "MassBlock" ) &&
	/sysop/.test( mw.config.get( "wgUserGroups" ) )
) {
	mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'mediawiki.jqueryMsg' ], $.ready )
		.then( function loadMsg() {
			return new mw.Api().loadMessagesIfMissing( [ 'Ipbreason-dropdown' ] );
		} )
		.then( massblockform );
}