// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
TwinkleConfig = function() {};
}
/**
TwinkleConfig.summaryAd (string)
If ad should be added or not to summary, default [[WP:TWINKLE|TWINKLE]]
*/
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
TwinkleConfig.summaryAd = " using [[WP:TWINKLE|TW]]";
}
/**
TwinkleConfig.toolboxButtons (string)
If id defined in this array, the button of the action is located inthe toolbox instead of in
the actions bar.
*/
if( typeof( TwinkleConfig.toolboxButtons ) == 'undefined' ) {
TwinkleConfig.toolboxButtons = [];
}
function twinkleXfdButton() {
if( wgNamespaceNumber < 0 || wgCurRevisionId == false ) {
return;
}
addPortletLink( chooseBox( 'tw-xfd', TwinkleConfig.toolboxButtons ), "javascript:twinklexfd()", "xfd", "tw-xfd", "X for deletion", "");
}
$(twinkleXfdButton);
function num2order( num ) {
switch( num ) {
case 1: return '';
case 2: return '2nd';
case 3: return '3rd';
default: return num + 'th';
}
}
function createOption( data ) {
var option = document.createElement( 'option' );
option.setAttribute( 'value', data.value );
if( data.selected ) {
option.setAttribute( 'selected', 'selected' );
}
option.setAttribute( 'label', data.label );
option.appendChild( document.createTextNode( data.label ) );
return option;
}
function createInput( data ) {
var div = document.createElement( data.elem || 'span' );
var input = document.createElement( 'input' );
input.setAttribute( 'value', data.value );
input.setAttribute( 'name', data.name );
input.setAttribute( 'id', data.id );
input.setAttribute( 'type', data.type );
if( data.size ) {
input.setAttribute( 'size', data.size );
}
if( data.checked ) {
input.setAttribute( 'checked', 'checked' );
}
if( data.disabled ) {
input.setAttribute( 'disabled', 'disabled' );
}
if( data.event && data.type == 'button' ){
input.addEventListener( 'click', data.event, true );
}
if( data.type == 'button' || data.type == 'submit' || data.type == 'reset' ) {
div.appendChild( input );
} else {
var label = document.createElement( 'label' );
label.setAttribute( 'for', data.id );
label.appendChild( document.createTextNode( data.text ) );
if( [ 'radio', 'checkbox' ].indexOf( data.type ) != -1 ) {
div.appendChild( input );
div.appendChild( label );
} else {
div.appendChild( label );
div.appendChild( input );
}
}
return div;
}
function twinklexfd() {
twinklexfd.Window = new SimpleWindow( 600, 300 );
twinklexfd.Window.setTitle( "Enter what kind of action is wanted" );
twinklexfd.form = document.createElement( 'form' );
twinklexfd.form.setAttribute( 'action', 'javascript:void(0);');
twinklexfd.form.addEventListener( 'submit',twinklexfd.evaluate , true );
var main_choices = document.createElement( 'select' );
main_choices.addEventListener( 'change',twinklexfd.choose , true );
main_choices.setAttribute('name', 'main_choices');
main_choices.setAttribute('id', 'twXfdMainChoices');
main_choices.appendChild( createOption( { label: 'Afd', selected: wgNamespaceNumber == 0, value: 'afd' } ) );
main_choices.appendChild( createOption( { label: 'Tfd', selected: wgNamespaceNumber == 10, value: 'tfd' } ) );
main_choices.appendChild( createOption( { label: 'Ifd', selected: wgNamespaceNumber == 6, value: 'ifd' } ) );
main_choices.appendChild( createOption( { label: 'Cfd', selected: wgNamespaceNumber == 14, value: 'cfd' } ) );
main_choices.appendChild( createOption( { label: 'UCfd', selected: false, value: 'ucfd' } ) );
main_choices.appendChild( createOption( { label: 'Rfd', selected: false, value: 'rfd' } ) );
main_choices.appendChild( createOption( { label: 'Sfd', selected: false, value: 'sfd' } ) );
main_choices.appendChild( createOption( { label: 'Mfd', selected: [0, 10, 6, 14].indexOf(wgNamespaceNumber) == -1, value: 'mfd' } ) );
label = document.createElement( 'label' );
label.setAttribute( 'for', 'main_choices' );
label.appendChild( document.createTextNode( 'Type of XfD' ) );
twinklexfd.form.appendChild( label );
twinklexfd.form.appendChild( main_choices );
twinklexfd.form.appendChild( document.createElement( 'br' ) );
twinklexfd.choices = document.createElement( 'fieldset' );
twinklexfd.form.appendChild( twinklexfd.choices );
twinklexfd.Window.setContent( twinklexfd.form );
twinklexfd.choose();
twinklexfd.Window.display();
}
twinklexfd.choose = function(e) {
while( twinklexfd.choices.hasChildNodes() ){
twinklexfd.choices.removeChild( twinklexfd.choices.firstChild );
}
switch( twinklexfd.form.main_choices.value ) {
case 'afd':
var afdcat = document.createElement( 'select' );
afdcat.setAttribute('name', 'afdcat');
afdcat.setAttribute('id', 'twAfdCat');
var afdcat_legend = document.createElement( 'legend' );
afdcat_legend.appendChild( document.createTextNode( 'Fill in reason for Afd and what category' ) );
twinklexfd.choices.appendChild( afdcat_legend );
twinklexfd.choices.appendChild( afdcat );
afdcat.appendChild( createOption( { label: 'Unknown', selected:true, value: '?' } ) );
afdcat.appendChild( createOption( { label: 'Media and music', value: 'M' } ) );
afdcat.appendChild( createOption( { label: 'Organisation, corporation, or product', value: 'O' } ) );
afdcat.appendChild( createOption( { label: 'Biographical', value: 'B' } ) );
afdcat.appendChild( createOption( { label: 'Society topics', value: 'S' } ) );
afdcat.appendChild( createOption( { label: 'Web or internet', value: 'W' } ) );
afdcat.appendChild( createOption( { label: 'Games or sports', value: 'T' } ) );
afdcat.appendChild( createOption( { label: 'Science and technology', value: 'T' } ) );
afdcat.appendChild( createOption( { label: 'Fiction and the arts', value: 'F' } ) );
afdcat.appendChild( createOption( { label: 'Places and transportation', value: 'P' } ) );
afdcat.appendChild( createOption( { label: 'Indiscernible or unclassifiable topic', value: 'I' } ) );
afdcat.appendChild( createOption( { label: 'Debate not yet sorted', value: 'U' } ) );
twinklexfd.choices.appendChild( document.createElement( 'br' ) );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdReason',
value:'',
text:'Reason ',
type:'text',
name:'xfdreason',
size:80
} ) );
twinklexfd.choices.appendChild( document.createElement( 'br' ) );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdSubmit',
value: 'Submit',
name:'submit',
type:'submit'
} ) );
break;
case 'tfd':
var legend = document.createElement( 'legend' );
legend.appendChild( document.createTextNode( 'Give reason for TfD' ) );
twinklexfd.choices.appendChild( legend );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdReason',
value:'',
text:'Reason ',
type:'text',
name:'xfdreason',
size:80
} ) );
twinklexfd.choices.appendChild( document.createElement( 'br' ) );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdSubmit',
value: 'Submit',
name:'submit',
type:'submit'
} ) );
break;
case 'mfd':
var legend = document.createElement( 'legend' );
legend.appendChild( document.createTextNode( 'Give reason for MfD' ) );
twinklexfd.choices.appendChild( legend );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdReason',
value:'',
text:'Reason ',
type:'text',
name:'xfdreason',
size:80
} ) );
twinklexfd.choices.appendChild( document.createElement( 'br' ) );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdSubmit',
value: 'Submit',
name:'submit',
type:'submit'
} ) );
break;
case 'ifd':
var legend = document.createElement( 'legend' );
legend.appendChild( document.createTextNode( 'Give reason for IfD' ) );
twinklexfd.choices.appendChild( legend );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdReason',
value:'',
text:'Reason ',
type:'text',
name:'xfdreason',
size:80
} ) );
twinklexfd.choices.appendChild( document.createElement( 'br' ) );
twinklexfd.choices.appendChild( createInput( {
id:'twXfdSubmit',
value: 'Submit',
name:'submit',
type:'submit'
} ) );
break;
case 'cfd':
case 'ucfd':
case 'rfd':
case 'sfd':
var legend = document.createElement( 'legend' );
legend.appendChild( document.createTextNode( 'Not implemented' ) );
var div = document.createElement( 'legend' );
div.style.color = 'red';
div.style.fontSize = 'large';
div.style.fontWeight = 'bold';
div.appendChild( document.createTextNode( 'This function is not yet implemented' ) );
twinklexfd.choices.appendChild( legend );
twinklexfd.choices.appendChild( div );
break;
}
}
twinklexfd.evaluate = function(e) {
twinklexfd.type = twinklexfd.form.main_choices.value;
twinklexfd.reason = twinklexfd.form.xfdreason.value;
if( twinklexfd.type == 'afd' ) {
twinklexfd.afdcat = twinklexfd.form.afdcat.value;
}
Status.init( twinklexfd.form );
if( twinklexfd.type == null ) {
Status.error( 'no action given' );
return;
}
switch( twinklexfd.type ) {
case 'afd': // AFD
Status.status( 'Grabbing data of eventual previous nominations' );
var query = {
'title': 'Special:Prefixindex',
'from': 'Articles for deletion/' + wgTitle,
'namespace': 4
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ), true);
xmlhttp.onload = function() {
var a_tags = this.responseXML.getElementsByTagName('a');
var re = new RegExp( RegExp.escape( 'Articles for deletion/' + wgTitle ) );
var number = 0;
for( var i in a_tags ) {
var title = a_tags[i].title;
if( re.exec( title ) ) {
var n = /\(\s*(\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\s*\)\s*$/.exec( title );
if( n && n[1] > number ) {
number = n[1];
} else if( number == 0 ) {
number = 1;
}
}
}
if( number == 0 ) {
twinklexfd.numbering = number = '';
} else {
number = num2order( parseInt( number ) + 1);
twinklexfd.numbering = ' (' + number + ' nomination)';
}
Status.info( 'next in order is [[Wikipedia:Articles for deletion/' + wgTitle + twinklexfd.numbering + ']]');
// Tagging article
Status.status( 'Putting the deletion tag on the article...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': wgTitle,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': false, // Per memo
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Nominated for deletion; see [[Wikipedia:Articles for deletion/" + wgTitle + twinklexfd.numbering + ']].'+ TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{" + ( number == '' ? "subst:afd\}\}\n" : 'subst:afdx|' + number + "\}\}\n" ) + form.wpTextbox1.value
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Article tagged.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Discussion page
Status.status( 'Creating the article\'s deletion discussion page...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'Wikipedia:Articles for deletion/' + wgTitle + twinklexfd.numbering,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Creating deletion discussion page for \[\[" + wgTitle + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{subst:afd2|pg=" + wgTitle + "|cat=" + twinklexfd.afdcat + "|text=" + twinklexfd.reason + " \~\~\~\~\}\}\n"
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Discussion page created.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Todays list
Status.status( 'Adding AFD discussion to the todays list...' );
var date = new Date();
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'Wikipedia:Articles for deletion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate(),
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Adding \[\[Wikipedia:Articles for deletion/" + wgTitle + twinklexfd.numbering + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': form.wpTextbox1.value + "\n\{\{subst:afd3|pg=" + wgTitle + twinklexfd.numbering + "\}\}"
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Notification complete.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Notification to first contributor
Status.status( 'Getting data for first contributor...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'action': 'query',
'prop': 'revisions',
'titles': wgPageName,
'rvlimit': 1,
'rvprop': 'user',
'rvdir': 'newer',
'format': 'xml'
}
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var user = this.responseXML.documentElement.getElementsByTagName('rev')[0].getAttribute('user');
Status.info( 'found user ' + user + ' as first contributor, proceeding to notify user...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'User talk:' + user,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var form = this.responseXML.getElementById( 'editform' );
var text = form.wpTextbox1.value;
text += "\n\{\{subst:AFDWarning|1=" + wgTitle + ( twinklexfd.numbering != '' ? '|order= ' + twinklexfd.numbering : '' ) + "\}\} \~\~\~\~";
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'AfD nomination of \[\[' + wgTitle + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'User notification complete.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
}
xmlhttp.send( null );
}
xmlhttp.send( null );
break;
case 'tfd': // TFD
// Tagging article
Status.status( 'Putting the deletion tag on the template...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': wgPageName,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': false, // Per
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Nominated for deletion; see \[\[Wikipedia:Templates for deletion#" + wgPageName + '\]\].'+ TwinkleConfig.summaryAd,
'wpTextbox1': "<noinclude>\{\{tfd|" + wgTitle + "\}\}\n</noinclude>" + form.wpTextbox1.value
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Article tagged.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Adding discussion
Status.status( 'Adding TfD discussion to the todays page...' );
var date = new Date();
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'Wikipedia:Templates for deletion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate(),
'action': 'submit',
'section': 1
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
text = form.wpTextbox1.value;
text = text.replace( '-->', "-->\n\{\{subst:tfd2|" + wgTitle + "|text=" + twinklexfd.reason + ". \~\~\~\~\}\}");
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Adding [[Template:" + wgTitle + ']].' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Notification complete.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Notifying first contributor
Status.status( 'Getting data for first contributor...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'action': 'query',
'prop': 'revisions',
'titles': wgPageName,
'rvlimit': 1,
'rvprop': 'user',
'rvdir': 'newer',
'format': 'xml'
}
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var user = this.responseXML.documentElement.getElementsByTagName('rev')[0].getAttribute('user');
Status.info( 'found user ' + user + ' as first contributor, proceeding to notify user...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'User talk:' + user,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var form = this.responseXML.getElementById( 'editform' );
var text = form.wpTextbox1.value;
text += "\n\{\{subst:tfdnotice|1=" + wgTitle + "\}\} \~\~\~\~";
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'TfD nomination of \[\[Template:' + wgTitle + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'User notification complete.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
}
xmlhttp.send( null );
break;
case 'mfd': // MFD
wgPageName = wgPageName.replace( '_', ' ' ); // for queen/king/whatever and country!
Status.status( 'Grabbing data of eventual previous nominations' );
var query = {
'title': 'Special:Prefixindex',
'from': 'Miscellany for deletion/' + wgPageName,
'namespace': 4
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ), true);
xmlhttp.onload = function() {
var a_tags = this.responseXML.getElementsByTagName('a');
var re = new RegExp( RegExp.escape( 'Miscellany for deletion/' + wgPageName ) );
var number = 0;
for( var i in a_tags ) {
var title = a_tags[i].title;
if( re.exec( title ) ) {
var n = /\(\s*(\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\s*\)\s*$/.exec( title );
if( n && n[1] > number ) {
number = n[1];
} else if( number == 0 ) {
number = 1;
}
}
}
if( number == 0 ) {
twinklexfd.numbering = number = '';
} else {
number = num2order( parseInt( number ) + 1);
twinklexfd.numbering = ' (' + number + ' nomination)';
}
Status.info( 'next in order is [[Wikipedia:Miscellany for deletion/' + wgPageName + twinklexfd.numbering + ']]');
// Tagging article
Status.status( 'Putting the deletion tag on the article...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': wgPageName,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': false, // Per memo
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Nominated for deletion; see [[Wikipedia:Miscellany for deletion/" + wgPageName + twinklexfd.numbering + ']].'+ TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{" + ( number == '' ? "subst:mfd\}\}\n" : 'subst:mfdx|' + number + "\}\}\n" ) + form.wpTextbox1.value
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Article tagged.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Discussion page
Status.status( 'Creating the article\'s deletion discussion page...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'Wikipedia:Miscellany for deletion/' + wgPageName + twinklexfd.numbering,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Creating deletion discussion page for \[\[" + wgPageName + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{subst:mfd2|pg=" + wgPageName + "|text=" + twinklexfd.reason + " \~\~\~\~\}\}\n"
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Discussion page created.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Todays list
Status.status( 'Adding MFD discussion to the todays list...' );
var date = new Date();
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'Wikipedia:Miscellany for deletion',
'action': 'submit',
'section': 2
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var text = form.wpTextbox1.value;
var month = date.getUTCMonth() + 1;
var today_date = date.getUTCFullYear() + '-' + ( month < 10 ? '0' : '' ) + month + '-' + date.getUTCDate();
Status.info( 'todays date: ' + today_date );
var today_regex = new RegExp( "(\\=\\=\\=\\[\\[" + RegExp.escape( today_date ) + "\\]\\]\\=\\=\\=)" );
var new_data = "\n\{\{subst:mfd3|pg=" + wgPageName + twinklexfd.numbering + "\}\}";
if( today_regex.test( text ) ) { // we have a section allready
Status.info( 'Found todays section, proceeding to add new entry' );
text = text.replace( today_regex, "$1\n" + new_data );
} else { // we need to create a new section
Status.info( 'No section for today found, proceeding to ccreate one' );
text = text.replace( '-->', "-->\n===\[\[" + today_date + "\]\]===\n" + new_data );
}
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Adding \[\[Wikipedia:Miscellany for deletion/" + wgPageName + twinklexfd.numbering + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Notification complete.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Notification to first contributor
Status.status( 'Getting data for first contributor...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'action': 'query',
'prop': 'revisions',
'titles': wgPageName,
'rvlimit': 1,
'rvprop': 'user',
'rvdir': 'newer',
'format': 'xml'
}
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var user = this.responseXML.documentElement.getElementsByTagName('rev')[0].getAttribute('user');
Status.info( 'found user ' + user + ' as first contributor, proceeding to notify user...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'User talk:' + user,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var form = this.responseXML.getElementById( 'editform' );
var text = form.wpTextbox1.value;
text += "\n\{\{subst:MFDWarning|1=" + wgPageName + ( twinklexfd.numbering != '' ? '|order= ' + twinklexfd.numbering : '' ) + "\}\} \~\~\~\~";
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'MfD nomination of \[\[' + wgPageName + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'User notification complete.' );}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
}
xmlhttp.send( null );
}
xmlhttp.send( null );
break;
case 'ifd': // IFD
twinklexfd.ifdProgess = {
'tagging' : false,
'discussion': false,
'note': false
};
var fun = function() {
for( var i in twinklexfd.ifdProgess ) {
if( !twinklexfd.ifdProgess[i] ) {
return;
}
}
window.clearInterval(twinklexfd.ifdTimeout); // Safty?
Status.status( 'All done' );
var date = new Date();
window.location = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace( '$1', 'Wikipedia:Images and media for deletion#' + date.getUTCMonthName() + ' ' + date.getUTCDate() );
}
twinklexfd.ifdTimeout = setInterval( fun, 1000);
wgPageName = wgPageName.replace( '_', ' ' ); // for queen/king/whatever and country!
// Tagging image
Status.status( 'Putting the deletion tag on the image page...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': wgPageName,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': false, // Per
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "This image is being considered for deletion in accordance with Wikipedia's [[Wikipedia:Deletion policy|Deletion policy]]; See \[\[Wikipedia:Images for deletion#" + wgPageName + '\]\].'+ TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{ifd\}\}\n" + form.wpTextbox1.value
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Image tagged.' );twinklexfd.ifdProgess['tagging'] = true; }
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
// Grabbing uploader
Status.status( 'Getting data for uploader...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'action': 'query',
'prop': 'revisions',
'titles': wgPageName,
'rvlimit': 1,
'rvprop': 'user',
'rvdir': 'newer',
'format': 'xml'
}
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
twinklexfd.uploader = this.responseXML.documentElement.getElementsByTagName('rev')[0].getAttribute('user');
Status.info( 'Found user ' + twinklexfd.uploader + ' as uploader.' );
// Todays list
Status.status( 'Adding IFD discussion to the todays list...' );
var date = new Date();
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'Wikipedia:Images and media for deletion/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate(),
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true);
xmlhttp.onload = function() {
var form = this.responseXML.getElementById('editform');
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Adding discussion for \[\[:" + wgPageName + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': form.wpTextbox1.value + "\n\{\{subst:ifd2|1=" + wgTitle + "|Uploader=" + twinklexfd.uploader + "|Reason=" + twinklexfd.reason + "\}\} \~\~\~\~"
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'Notification complete.' );twinklexfd.ifdProgess['discussion'] = true;}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
Status.status( 'Notifying uploader...' );
var xmlhttp = sajax_init_object();
xmlhttp.query = {
'title': 'User talk:' + twinklexfd.uploader,
'action': 'submit'
};
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( xmlhttp.query ), true );
xmlhttp.onload = function() {
var form = this.responseXML.getElementById( 'editform' );
var text = form.wpTextbox1.value;
text += "\n\{\{subst:idw|1=" + wgPageName + "\}\} \~\~\~\~";
var postData = {
'wpMinoredit': form.wpMinoredit.checked,
'wpWatchthis': form.wpWatchthis.checked,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'Notification: IfD nomination of \[\[' + wgPageName + '\]\].' + TwinkleConfig.summaryAd,
'wpTextbox1': text
};
var xmlhttp = sajax_init_object();
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onload = function() { Status.info( 'User notification complete.' );twinklexfd.ifdProgess['note'] = true;}
xmlhttp.send( QueryString.create( postData ) );
}
xmlhttp.send( null );
}
xmlhttp.send( null );
break;
}
}