Differenze tra le versioni di "MediaWiki:Gadget-QuickResponses.js"

minor tempo possibile fra il controllo di conflitti e l'invio della modifica
(miglioro gestione messaggi per le protezioni)
(minor tempo possibile fra il controllo di conflitti e l'invio della modifica)
*/
function editContent( i, msg, currentrev, updateHandler ) {
var wikitext, newText, revId;
var unchanged = true;
parseContent().then( function( result ) {
revIdvar wikitext = result.parse.revidwikitext[ '*' ];
wikitext = result.parse.wikitext[ '*' ];
return api.get( {
action: 'query',
titles: currentPage,
indexpageids: 1,
prop: 'revisions',
rvprop: 'ids',
format: 'json'
} );
} ).then( function( result ) {
i = i * 2 + 2;
var getSplits = function ( str ) {
return str.split( conf.regex );
};
var splits = getSplits( wikitext );
var unchangedi = truei * 2 + 2;
wikitextrevId = result.parse.wikitext[ '*' ]revid;
var data = result.query.pages[ result.query.pageids[ 0 ] ].revisions[ 0 ];
if ( data.revidrevId !== currentrev.revid ) {
var origsplits = getSplits( currentrev.wikitext[ '*' ] );
var newsplits = Math.max( 0, splits.length - origsplits.length );
} else {
splits = sliceSplits( splits );
}
if ( data.revid !== revId || !unchanged ) {
return $.Deferred().reject( 'editconflict' );
}
wikitext = wikitext.substring( 0, wikitext.lastIndexOf( splits.join( '' ) ) );
var match = splits[ i ].match( /(^[\s\S]+?)(?:(\n:+)(.+))?(\n*$|\n+==[\s\S]+$)/ );
msg = match[ 2 ] ? match[ 2 ] + ':' + msg : '\n:' + msg;
splits[ i ] = match[ 1 ] + ( match[ 2 ] ? match[ 2 ] + match[ 3 ] : '' ) + msg + match[ 4 ];
newText = wikitext + splits.join( '' );
return api.get( {
action: 'query',
titles: currentPage,
indexpageids: 1,
prop: 'revisions',
rvprop: 'ids',
format: 'json'
} );
} ).then( function( result ) {
var query = result.query;
var data = result.query.pages[ result.query.pageids[ 0 ] ].revisions[ 0 ];
if ( data.revid !== revId || !unchanged ) {
return $.Deferred().reject( 'editconflict' );
}
return api.postWithToken( 'csrf', {
action: 'edit',