MediaWiki:Gadget-cambusa.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m fix lettura titolo
aggiunto il supporto per il link alla nuova sezione nel template cambusa
Riga 85:
* Aggiunge una sezione a una pagina di discussione.
*/
function addSection( title, sectiontitle, text, handlerSuccesssuccessHandler ) {
api.newSection( title, sectiontitle, text )
.done( function ( data ) {
successHandler( data.edit.newrevid );
handlerSuccess();
} )
.fail ( function ( code, data ) {
alert( 'Errore nel creare la discussione: ' + data.error.info );
} );
}
/**
* Ottiene l'anchor dell'ultima discussione di una data versione di una pagina.
*/
function getSectionAnchor( oldid, anchorHandler ) {
api.get( {
action: 'parse',
format: 'json',
oldid: oldid,
prop: 'sections',
} ).done ( function ( data ) {
anchorHandler( data.parse.sections[data.parse.sections.length - 1].anchor );
} ).fail ( function ( code, data ) {
alert( 'Errore nel leggere l\'anchor della sezione: ' + code );
} );
}
 
Riga 197 ⟶ 213:
text = '{{Cambusada|' + from + '|--~~' + '~~}}\n' + text;
alert( 'Spostamento in corso...', true );
addSection( dest, desttitle, text, function ( newrevid ) {
getSectionAnchor( newrevid, function ( anchor ) {
text = '==' + sectiontitle + '==\n\n' + '{{Cambusa|' + incipit + '|' + dest + '|--~~' + '~~}}';
setSection( section, text, 'cambusata discussione in= [['==' + destsectiontitle + ']]==\n\n' );+
text = '=={{Cambusa|' + sectiontitleincipit + '==\n\n' + '{{Cambusa|' + incipitdest + '|#' + destanchor + '|--~~' + '~~}}';
setSection( section, text, 'cambusata discussione in [[' + dest + ']]' );
} );
} );
}