MediaWiki:Gadget-twinklebatchundelete.js: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
m (1 revision)
imported>Mlpearc
m (1 revision: See if we're missing something)
Line 1: Line 1:
//<nowiki>
//<nowiki>


(function($){
(function($){


/*
/*
****************************************
****************************************
Line 13: Line 13:
* Config directives in: TwinkleConfig
* Config directives in: TwinkleConfig
*/
*/


Twinkle.batchundelete = function twinklebatchundelete() {
Twinkle.batchundelete = function twinklebatchundelete() {
if( mw.config.get("wgNamespaceNumber") !== mw.config.get("wgNamespaceIds").user ||
if( mw.config.get("wgNamespaceNumber") !== mw.config.get("wgNamespaceIds").user ||
Line 24: Line 24:
}
}
};
};

Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() {
Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() {
var Window = new Morebits.simpleWindow( 800, 400 );
var Window = new Morebits.simpleWindow( 800, 400 );
Line 35: Line 35:
label: 'Reason: '
label: 'Reason: '
} );
} );

var query = {
var query = {
'action': 'query',
'action': 'query',
Line 58: Line 58:
);
);
self.params.form.append( { type:'submit' } );
self.params.form.append( { type:'submit' } );

var result = self.params.form.render();
var result = self.params.form.render();
self.params.Window.setContent( result );
self.params.Window.setContent( result );


} );
} );
wikipedia_api.params = { form:form, Window:Window };
wikipedia_api.params = { form:form, Window:Window };
Line 76: Line 76:
Morebits.wiki.actionCompleted.notice = 'Status';
Morebits.wiki.actionCompleted.notice = 'Status';
Morebits.wiki.actionCompleted.postfix = 'batch undeletion is now completed';
Morebits.wiki.actionCompleted.postfix = 'batch undeletion is now completed';

var pages = event.target.getChecked( 'pages' );
var pages = event.target.getChecked( 'pages' );
var reason = event.target.reason.value;
var reason = event.target.reason.value;
Line 85: Line 85:
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init( event.target );
Morebits.status.init( event.target );

if( !pages ) {
if( !pages ) {
Morebits.status.error( 'Error', 'nothing to undelete, aborting' );
Morebits.status.error( 'Error', 'nothing to undelete, aborting' );
return;
return;
}
}

var work = Morebits.array.chunk( pages, Twinkle.getPref('batchUndeleteChunks') );
var work = Morebits.array.chunk( pages, Twinkle.getPref('batchUndeleteChunks') );
Morebits.wiki.addCheckpoint();
Morebits.wiki.addCheckpoint();
Twinkle.batchundelete.currentundeletor = window.setInterval( Twinkle.batchundelete.callbacks.main, 1000, work, reason );
Twinkle.batchundelete.currentundeletor = window.setInterval( Twinkle.batchundelete.callbacks.main, 1000, work, reason );
};
};

Twinkle.batchundelete.callbacks = {
Twinkle.batchundelete.callbacks = {
main: function( work, reason ) {
main: function( work, reason ) {
Line 121: Line 121:
link.appendChild( document.createTextNode(self.itsTitle) );
link.appendChild( document.createTextNode(self.itsTitle) );
self.statelem.info( ['completed (',link,')'] );
self.statelem.info( ['completed (',link,')'] );

});
});
wikipedia_api.itsTitle = title;
wikipedia_api.itsTitle = title;
wikipedia_api.post();
wikipedia_api.post();

}
}
}
}
Line 131: Line 131:
};
};
})(jQuery);
})(jQuery);


//</nowiki>
//</nowiki>