* @author [[Utente:Rotpunkt]]
*/
/*jslintjshint unparamunused: true, regexp: truefalse */
/*global prompt: false, document: false, mediaWiki: false, jQuery: false */
( function ( mw, $ ) {
'use strict';
// Messaggio di richiesta dell'oggetto della modifica
var msgEdit = 'Inserire l\'oggetto per l\'edit di cancellazione.\n' +
'Se non viene inserito verrà usato quello standard (Sezione "$1" eliminata)';
$( document ).ready( function () {
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
// edit richiamato dallo script stesso per modificare la sezione
var gdsummary = mw.util.getParamValue( 'gdsummary' );
if ( gdsummary && $( '#wpTextbox1' ).length && $( '#wpSummary' ).length && $( '#wpSave' ).length ) {
$( '#wpTextbox1' ).val( '' );
$( '#wpSummary' ).val( function ( i, text ) {
var summary = text.replace( /\/\*\s(.+)\s\*\/.*/, 'Sezione "$1" eliminata' );
return summary + ( gdsummary === 'true' ? '' : ': ' + gdsummary );
} );
});
$( '#wpSave' ).click();
}
}
} else {
$( 'span.mw-editsection > a:not( .mw-editsection-visualeditor )' ).each( function () {
var url, section;
url = $( this ).attr( 'href' );
section = $( this ).attr( 'title' ).split( 'Modifica la sezione ' )[1];
$( '<a>' )
.attr( 'href', '#' )
.attr( 'title', 'Cancella la sezione ' + section )
.text( "cancella" )
.click( function () {
var summary = prompt( msgEdit.replace( '$1', section ) );
if ( summary !== null ) {
document.___location = url + '&gdsummary=' +
( (summary === '' ? 'true' : summary );
}
}
} )
})
.before( ' | ' ).insertAfter( this );
$( this ).after( '<span style="color: #555;"> | </span>' );
} );
});
}
}
} });
}( mediaWiki, jQuery ) );
|