"மீடியாவிக்கி:Gadget-twinklexfd.js" பக்கத்தின் திருத்தங்களுக்கிடையேயான வேறுபாடு

21,961 பைட்டுகள் சேர்க்கப்பட்டது ,  2 மாதங்களுக்கு முன்
update from enwiki
("//<nowiki> (function($){ /* *********************************..."-இப்பெயரில் புதிய பக்கம் உருவாக்கப்பட்டுள்ளது)
 
(update from enwiki)
 
// <nowiki>
 
 
(function($) {
 
 
* Mode of invocation: Tab ("XFD")
* Active on: Existing, non-special pages, except for file pages with no local (non-Commons) file which are not redirects
* Config directives in: TwinkleConfig
*/
 
// * special pages
// * non-existent pages
// * files on Commons, whether there is a local page or not (unneeded local pages of files on Commons are eligible for CSD F2, or R4 if it's a redirect)
if (mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId') || (mw.config.get('wgNamespaceNumber') === 6 && document.getElementById('mw-sharedupload'))) {
// * file pages without actual files (these are eligible for CSD G8)
if ( mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId') || (mw.config.get('wgNamespaceNumber') === 6 && (document.getElementById('mw-sharedupload') || (!document.getElementById('mw-imagepage-section-filehistory') && !Morebits.wiki.isPageRedirect()))) ) {
return;
}
 
Twinkle.addPortletLink( Twinkle.xfd.callback, "XFD", "tw-xfd", "Nominate for deletion" );
var tooltip = 'Start a discussion for deleting';
if (mw.config.get('wgIsRedirect')) {
tooltip += ' or retargeting this redirect';
} else {
switch (mw.config.get('wgNamespaceNumber')) {
case 0:
tooltip += ' or moving this article';
break;
case 10:
tooltip += ' or merging this template';
break;
case 828:
tooltip += ' or merging this module';
break;
case 6:
tooltip += ' this file';
break;
case 14:
tooltip += ', merging or renaming this category';
break;
default:
tooltip += ' this page';
break;
}
}
Twinkle.addPortletLink(Twinkle.xfd.callback, 'XFD', 'tw-xfd', tooltip);
};
 
 
Twinkle.xfd.num2order = function twinklexfdNum2order( num ) {
switch(var numutils )= {
/** Get ordinal number figure */
case 1: return '';
num2order: function(num) {
case 2: return '2nd';
switch (num) {
case 3: return '3rd';
default case 1: return num + 'th';
case 2: return '2nd';
case 3: return '3rd';
default: return num + 'th';
}
},
 
/**
* Remove namespace name from title if present
* Exception-safe wrapper around mw.Title
* @param {string} title
*/
stripNs: function(title) {
var title_obj = mw.Title.newFromUserInput(title);
if (!title_obj) {
return title; // user entered invalid input; do nothing
}
return title_obj.getNameText();
},
 
/**
* Add namespace name to page title if not already given
* CAUTION: namespace name won't be added if a namespace (*not* necessarily
* the same as the one given) already is there in the title
* @param {string} title
* @param {number} namespaceNumber
*/
addNs: function(title, namespaceNumber) {
var title_obj = mw.Title.newFromUserInput(title, namespaceNumber);
if (!title_obj) {
return title; // user entered invalid input; do nothing
}
return title_obj.toText();
},
 
/**
* Provide Wikipedian TLA style: AfD, RfD, CfDS, RM, SfD, etc.
* @param {string} venue
* @returns {string}
*/
toTLACase: function(venue) {
return venue
.toString()
// Everybody up, inclduing rm and the terminal s in cfds
.toUpperCase()
// Lowercase the central f in a given TLA and normalize sfd-t and sfr-t
.replace(/(.)F(.)(?:-.)?/, '$1f$2');
}
};
Twinkle.xfd.printRationale = function twinklexfdPrintRationale() {
if (Twinkle.xfd.currentRationale) {
Morebits.status.printUserText(Twinkle.xfd.currentRationale, "'Your deletion rationale is provided below, which you can copy and paste into a new XFD dialog if you wish to try again:"');
// only need to print the rationale once
Twinkle.xfd.currentRationale = null;
 
Twinkle.xfd.callback = function twinklexfdCallback() {
var Window = new Morebits.simpleWindow( 600700, 350 400);
Window.setTitle('Start "Nominate fora deletion discussion (XfD)" ');
Window.setScriptName( "'Twinkle" ');
Window.addFooterLink( "'About deletion discussions"', "'WP:XFD" ');
Window.addFooterLink('XfD "Twinkle help"prefs', "'WP:TW/DOCPREF#xfd" ');
Window.addFooterLink('Twinkle help', 'WP:TW/DOC#xfd');
Window.addFooterLink('Give feedback', 'WT:TW');
 
var form = new Morebits.quickForm( Twinkle.xfd.callback.evaluate );
var categories = form.append( {
type: 'select',
name: 'categoryvenue',
label: 'Deletion discussion venue:',
tooltip: 'When activated, a default choice is made, based on what namespace you are in. This default should be the most appropriate.',
event: Twinkle.xfd.callback.change_category
} );
var namespace = mw.config.get('wgNamespaceNumber');
categories.append( {
 
type: 'option',
categories.append({
label: 'AfD (Articles for deletion)',
type: 'option',
selected: mw.config.get('wgNamespaceNumber') === 0, // Main namespace
label: 'AfD (Articles for deletion)',
value: 'afd'
selected: namespace === 0, // Main namespace
} );
value: 'afd'
categories.append( {
});
type: 'option',
categories.append({
label: 'TfD (Templates for discussion)',
type: 'option',
selected: mw.config.get('wgNamespaceNumber') === 10, // Template namespace
label: 'TfD (Templates for discussion)',
value: 'tfd'
selected: [ 10, 828 ].indexOf(namespace) !== -1, // Template and module namespaces
} );
value: 'tfd'
categories.append( {
});
type: 'option',
categories.append({
label: 'FfD (Files for discussion)/PUF (Possibly unfree files)',
type: 'option',
selected: mw.config.get('wgNamespaceNumber') === 6, // File namespace
label: 'FfD (Files for discussion)',
value: 'ffd'
selected: namespace === 6, // File namespace
} );
value: 'ffd'
categories.append( {
});
type: 'option',
categories.append({
label: 'CfD (Categories for discussion)',
type: 'option',
selected: mw.config.get('wgNamespaceNumber') === 14, // Category namespace
label: 'CfD (Categories for discussion)',
value: 'cfd'
selected: namespace === 14 || (namespace === 10 && /-stub$/.test(Morebits.pageNameNorm)), // Category namespace and stub templates
} );
value: 'cfd'
categories.append( {
});
type: 'option',
categories.append({
label: 'CfD/S (Categories for speedy renaming)',
valuetype: 'cfdsoption',
label: 'CfD/S (Categories for speedy renaming)',
} );
value: 'cfds'
categories.append( {
});
type: 'option',
categories.append({
label: 'MfD (Miscellany for deletion)',
type: 'option',
selected: [ 0, 6, 10, 14 ].indexOf( mw.config.get('wgNamespaceNumber') ) === -1,
label: 'MfD (Miscellany for deletion)',
value: 'mfd'
selected: [ 0, 6, 10, 14, 828 ].indexOf(namespace) === -1 || Morebits.pageNameNorm.indexOf('Template:User ', 0) === 0,
} );
// Other namespaces, and userboxes in template namespace
categories.append( {
typevalue: 'optionmfd',
});
label: 'RfD (Redirects for discussion)',
categories.append({
selected: Morebits.wiki.isPageRedirect(),
valuetype: 'rfdoption',
label: 'RfD (Redirects for discussion)',
} );
selected: mw.config.get('wgIsRedirect'),
form.append( {
typevalue: 'checkboxrfd',
});
list: [
categories.append({
{
type: 'option',
label: 'Notify page creator if possible',
label: 'RM (Requested moves)',
value: 'notify',
nameselected: 'notify'false,
value: 'rm'
tooltip: "A notification template will be placed on the creator's talk page if this is true.",
});
checked: true
 
}
form.append({
]
type: 'div',
}
id: 'wrong-venue-warn',
);
style: 'color: red; font-style: italic'
form.append( {
});
type: 'field',
 
label:'Work area',
form.append({
name: 'work_area'
type: 'checkbox',
} );
list: [
form.append( { type:'submit' } );
{
label: 'Notify page creator if possible',
value: 'notify',
name: 'notifycreator',
tooltip: "A notification template will be placed on the creator's talk page if this is true.",
checked: true
}
]
});
form.append({
type: 'field',
label: 'Work area',
name: 'work_area'
});
 
var previewlink = document.createElement('a');
$(previewlink).click(function() {
Twinkle.xfd.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = 'pointer';
previewlink.textContent = 'Preview';
form.append({ type: 'div', id: 'xfdpreview', label: [ previewlink ] });
form.append({ type: 'div', id: 'twinklexfd-previewbox', style: 'display: none' });
 
form.append({ type: 'submit' });
 
var result = form.render();
Window.setContent( result );
Window.display();
result.previewer = new Morebits.wiki.preview($(result).find('div#twinklexfd-previewbox').last()[0]);
 
// We must init the controls
var evt = document.createEvent( "'Event" ');
evt.initEvent( 'change', true, true );
result.categoryvenue.dispatchEvent( evt );
};
 
Twinkle.xfd.callback.wrongVenueWarning = function twinklexfdWrongVenueWarning(venue) {
Twinkle.xfd.previousNotify = true;
var text = '';
var namespace = mw.config.get('wgNamespaceNumber');
 
switch (venue) {
case 'afd':
if (namespace !== 0) {
text = 'AfD is generally appropriate only for articles.';
} else if (mw.config.get('wgIsRedirect')) {
text = 'Please use RfD for redirects.';
}
break;
case 'tfd':
if (namespace === 10 && /-stub$/.test(Morebits.pageNameNorm)) {
text = 'Use CfD for stub templates.';
} else if (Morebits.pageNameNorm.indexOf('Template:User ') === 0) {
text = 'Please use MfD for userboxes';
}
break;
case 'cfd':
if ([ 10, 14 ].indexOf(namespace) === -1) {
text = 'CfD is only for categories and stub templates.';
}
break;
case 'cfds':
if (namespace !== 14) {
text = 'CfDS is only for categories.';
}
break;
case 'ffd':
if (namespace !== 6) {
text = 'FFD is selected but this page doesn\'t look like a file!';
}
break;
case 'rm':
if (namespace === 14) { // category
text = 'Please use CfD or CfDS for category renames.';
}
break;
 
default: // mfd or rfd
break;
}
 
$('#wrong-venue-warn').text(text);
 
};
 
Twinkle.xfd.callback.change_category = function twinklexfdCallbackChangeCategory(e) {
var value = e.target.value;
var form = e.target.form;
var old_area = Morebits.quickForm.getElements(e.target.form, "'work_area"')[0];
var work_area = null;
 
var oldreasontextbox = form.getElementsByTagName('textarea')[0];
var oldreason = (oldreasontextbox ? oldreasontextbox.value : '');
 
var appendReasonBox = function twinklexfdAppendReasonBox() {
work_area.append( {
type: 'textarea',
name: 'xfdreasonreason',
label: 'Reason: ',
value: oldreason,
tooltip: 'You can use wikimarkup in your reason. Twinkle will automatically sign your post.'
} );
// TODO possible future "preview" link here
};
 
Twinkle.xfd.callback.wrongVenueWarning(value);
switch( value ) {
 
case 'afd':
form.previewer.closePreview();
work_area = new Morebits.quickForm.element( {
 
switch (value) {
case 'afd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'Articles for deletion',
name: 'work_area'
} );
 
work_area.append( {
work_area.append({
type: 'div',
label: Twinkle.makeFindSourcesDiv(),
style: 'margin-bottom: 5px;'
});
 
work_area.append({
type: 'checkbox',
list: [
{
label: 'Wrap deletion tag with <noinclude>',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in &lt;noinclude&gt; tags, so that it won\'t transclude. This option is not normally required.'
}
]
} );
var afd_category = work_area.append( {
type: 'select',
name: 'xfdcat',
label: 'Choose what category this nomination belongs in:',
} list: );[
{ type: 'option', label: 'Unknown', value: '?', selected: true },
{ type: 'option', label: 'Media and music', value: 'M' },
{ type: 'option', label: 'Organisation, corporation, or product', value: 'O' },
{ type: 'option', label: 'Biographical', value: 'B' },
{ type: 'option', label: 'Society topics', value: 'S' },
{ type: 'option', label: 'Web or internet', value: 'W' },
{ type: 'option', label: 'Games or sports', value: 'G' },
{ type: 'option', label: 'Science and technology', value: 'T' },
{ type: 'option', label: 'Fiction and the arts', value: 'F' },
{ type: 'option', label: 'Places and transportation', value: 'P' },
{ type: 'option', label: 'Indiscernible or unclassifiable topic', value: 'I' },
{ type: 'option', label: 'Debate not yet sorted', value: 'U' }
]
});
 
// delsort categories taken from [[WP:DS/C]], inspired by off [[User:Enterprisey/delsort.js]]
afd_category.append( { type:'option', label:'Unknown', value:'?', selected:true } );
var delsortCategories = {
afd_category.append( { type:'option', label:'Media and music', value:'M' } );
'People': ['People', 'Academics and educators', 'Actors and filmmakers', 'Artists', 'Authors', 'Bands and musicians', 'Businesspeople', 'Politicians', 'Sportspeople', 'Women', 'Lists of people'],
afd_category.append( { type:'option', label:'Organisation, corporation, or product', value:'O' } );
'Arts': ['Arts', 'Fictional elements', 'Science fiction and fantasy'],
afd_category.append( { type:'option', label:'Biographical', value:'B' } );
'Arts/Culinary': ['Food and drink', 'Wine'],
afd_category.append( { type:'option', label:'Society topics', value:'S' } );
'Arts/Language': ['Language', 'Academic journals', 'Bibliographies', 'Journalism', 'Literature', 'Logic', 'News media', 'Philosophy', 'Poetry'],
afd_category.append( { type:'option', label:'Web or internet', value:'W' } );
'Arts/Performing': ['Albums and songs', 'Dance', 'Film', 'Magic', 'Music', 'Radio', 'Television', 'Theatre', 'Video games'],
afd_category.append( { type:'option', label:'Games or sports', value:'G' } );
'Arts/Visual arts': ['Visual arts', 'Architecture', 'Fashion', 'Photography'],
afd_category.append( { type:'option', label:'Science and technology', value:'T' } );
'Arts/Comics and animation': ['Comics and animation', 'Anime and manga', 'Webcomics'],
afd_category.append( { type:'option', label:'Fiction and the arts', value:'F' } );
'Places of interest': ['Museums and libraries', 'Shopping malls'],
afd_category.append( { type:'option', label:'Places and transportation', value:'P' } );
'Topical': ['Animal', 'Bilateral relations', 'Conservatism', 'Conspiracy theories', 'Crime', 'Disability', 'Discrimination', 'Entertainment', 'Ethnic groups', 'Events', 'Finance', 'Games', 'Health and fitness', 'History', 'Law', 'Military', 'Organizations', 'Paranormal', 'Piracy', 'Politics', 'Terrorism'],
afd_category.append( { type:'option', label:'Indiscernible or unclassifiable topic', value:'I' } );
'Topical/Business': ['Business', 'Advertising', 'Companies', 'Management', 'Products'],
afd_category.append( { type:'option', label:'Debate not yet sorted', value:'U' } );
'Topical/Culture': ['Beauty pageants', 'Fashion', 'Mythology', 'Popular culture', 'Sexuality and gender'],
'Topical/Education': ['Education', 'Fraternities and sororities', 'Schools'],
'Topical/Religion': ['Religion', 'Atheism', 'Bible', 'Buddhism', 'Christianity', 'Islam', 'Judaism', 'Hinduism', 'Paganism', 'Sikhism', 'Spirituality'],
'Topical/Science': ['Science', 'Archaeology', 'Astronomy', 'Behavioural science', 'Biology', 'Economics', 'Engineering', 'Environment', 'Geography', 'Mathematics', 'Medicine', 'Organisms', 'Psychiatry', 'Psychology', 'Social science'],
'Topical/Sports': ['Sports', 'American football', 'Baseball', 'Basketball', 'Bodybuilding', 'Boxing', 'Cricket', 'Cycling', 'Football', 'Golf', 'Handball', 'Horse racing', 'Ice hockey', 'Motorsport', 'Rugby union', 'Softball', 'Martial arts', 'Wrestling'],
'Topical/Technology': ['Technology', 'Aviation', 'Computing', 'Firearms', 'Internet', 'Software', 'Transportation', 'Websites'],
'Wikipedia page type': ['Disambiguations', 'Lists'],
'Geographic/Africa': ['Africa', 'Algeria', 'Democratic Republic of the Congo', 'Egypt', 'Ethiopia', 'Ghana', 'Kenya', 'Libya', 'Mauritius', 'Morocco', 'Nigeria', 'Somalia', 'South Africa', 'Zimbabwe'],
'Geographic/Asia': ['Asia', 'Afghanistan', 'Bangladesh', 'Brunei', 'Cambodia', 'China', 'Hong Kong', 'Indonesia', 'Japan', 'Korea', 'Laos', 'Malaysia', 'Maldives', 'Mongolia', 'Myanmar', 'Nepal', 'Pakistan', 'Philippines', 'Singapore', 'South Korea', 'Sri Lanka', 'Taiwan', 'Thailand', 'Vietnam'],
'Geographic/Asia/Central Asia': ['Central Asia', 'Kazakhstan', 'Kyrgyzstan', 'Tajikistan', 'Turkmenistan', 'Uzbekistan'],
'Geographic/Asia/Middle East': ['Middle East', 'Bahrain', 'Iran', 'Iraq', 'Israel', 'Jordan', 'Kuwait', 'Lebanon', 'Libya', 'Palestine', 'Qatar', 'Saudi Arabia', 'Syria', 'United Arab Emirates', 'Yemen'],
'Geographic/Asia/India': ['India', 'Kerala'],
'Geographic/Europe': ['Europe', 'Albania', 'Armenia', 'Austria', 'Azerbaijan', 'Belarus', 'Belgium', 'Bosnia and Herzegovina', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Georgia (country)', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland', 'Italy', 'Jersey', 'Kosovo', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Moldova', 'Montenegro', 'Netherlands', 'North Macedonia', 'Norway', 'Poland', 'Portugal', 'Romania', 'Russia', 'Serbia', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 'Switzerland', 'Turkey', 'Ukraine', 'Yugoslavia'],
'Geographic/Europe/United Kingdom': ['United Kingdom', 'England', 'Northern Ireland', 'Scotland', 'Wales'],
'Geographic/Oceania': ['Oceania', 'Antarctica', 'Australia', 'New Zealand'],
'Geographic/Americas/Canada': ['Canada', 'Alberta', 'British Columbia', 'Manitoba', 'Nova Scotia', 'Ontario', 'Quebec'],
'Geographic/Americas/Latin America': ['Latin America', 'Caribbean', 'South America', 'Argentina', 'Barbados', 'Belize', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Costa Rica', 'Cuba', 'Ecuador', 'El Salvador', 'Grenada', 'Guatemala', 'Haiti', 'Mexico', 'Nicaragua', 'Panama', 'Paraguay', 'Peru', 'Puerto Rico', 'Trinidad and Tobago', 'Uruguay', 'Venezuela'],
'Geographic/Americas/USA': ['United States of America', 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia (U.S. state)', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'Washington, D.C.', 'West Virginia', 'Wisconsin', 'Wyoming'],
'Geographic/Unsorted': ['Islands']
};
 
var delsort = work_area.append({
appendReasonBox();
type: 'select',
work_area = work_area.render();
multiple: true,
old_area.parentNode.replaceChild( work_area, old_area );
name: 'delsortCats',
break;
label: 'Choose deletion sorting categories: ',
case 'tfd':
tooltip: 'Select a few categories that are specifically relevant to the subject of the article. Be as precise as possible; categories like People and USA should only be used when no other categories apply.'
work_area = new Morebits.quickForm.element( {
});
 
$.each(delsortCategories, function(groupname, list) {
var group = delsort.append({ type: 'optgroup', label: groupname });
list.forEach(function(item) {
group.append({ type: 'option', label: item, value: item });
});
});
 
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
 
$(work_area).find('[name=delsortCats]')
.attr('data-placeholder', 'Select delsort pages')
.select2({
width: '100%',
matcher: Morebits.select2.matcher,
templateResult: Morebits.select2.highlightSearchMatches,
language: {
searching: Morebits.select2.queryInterceptor
},
// Link text to the page itself
templateSelection: function(choice) {
return $('<a>').text(choice.text).attr({
href: mw.util.getUrl('Wikipedia:WikiProject_Deletion_sorting/' + choice.text),
target: '_blank'
});
}
});
 
mw.util.addCSS(
// Remove black border
'.select2-container--default.select2-container--focus .select2-selection--multiple { border: 1px solid #aaa; }' +
 
// Reduce padding
'.select2-results .select2-results__option { padding-top: 1px; padding-bottom: 1px; }' +
'.select2-results .select2-results__group { padding-top: 1px; padding-bottom: 1px; } ' +
 
// Adjust font size
'.select2-container .select2-dropdown .select2-results { font-size: 13px; }' +
'.select2-container .selection .select2-selection__rendered { font-size: 13px; }' +
 
// Make the tiny cross larger
'.select2-selection__choice__remove { font-size: 130%; }'
);
break;
 
case 'tfd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'Templates for discussion',
name: 'work_area'
} );
 
work_area.append( {
var templateOrModule = mw.config.get('wgPageContentModel') === 'Scribunto' ? 'module' : 'template';
type: 'div',
work_area.append({
label: 'Stub types and userboxes are not eligible for TfD. Stub types go to CfD, and userboxes go to MfD.'
} );
var tfd_category = work_area.append( {
type: 'select',
label: 'Choose type of action wanted: ',
name: 'xfdcat',
event: function(e) {
var target = e.target;,
tfdtarget = target.form.tfdtarget;
// add/remove extra input box
if( (target.value === 'tfm' && !target.form.xfdtarget ) { //$(target.parentNode).find("input[name='xfdtarget']").length === 0 tfdtarget) {
var xfdtargettfdtarget = new Morebits.quickForm.element( {
name: 'xfdtargettfdtarget',
type: 'input',
label: 'Other template' + templateOrModule + ' to be merged: ',
tooltip: 'Required. Should not include the ' + Morebits.string.toUpperCaseFirstChar(templateOrModule) + ': namespace prefix.',
} );
required: true
target.parentNode.appendChild(xfdtarget.render());
});
target.parentNode.appendChild(tfdtarget.render());
} else {
$(Morebits.quickForm.getElementContainer(target.form.xfdtargettfdtarget)).remove();
target.form.xfdtargettfdtarget = null;
//$(target.parentNode).find("input[name='xfdtarget']").remove();
}
},
} list: );[
tfd_category.append( { type: 'option', label: 'Deletion', value: 'tfd', selected: true } );,
tfd_category.append( { type: 'option', label: 'Merge', value: 'tfm' } );
]
});
work_area.append({
type: 'select',
name: 'templatetype',
label: 'Deletion tag display style: ',
tooltip: 'Which <code>type=</code> parameter to pass to the TfD tag template.',
list: templateOrModule === 'module' ? [
{ type: 'option', value: 'module', label: 'Module', selected: true }
] : [
{ type: 'option', value: 'standard', label: 'Standard', selected: true },
{ type: 'option', value: 'sidebar', label: 'Sidebar/infobox', selected: $('.infobox').length },
{ type: 'option', value: 'inline', label: 'Inline template', selected: $('.mw-parser-output > p .Inline-Template').length },
{ type: 'option', value: 'tiny', label: 'Tiny inline' }
]
});
 
var tfd_template_type = work_area.append( {
type: 'selectcheckbox',
list: [
name: 'templatetype',
{
label: 'Deletion tag display style: ',
label: 'Wrap deletion tag with <noinclude> (for substituted templates only)',
tooltip: 'Which <code>type=</code> parameter to pass to the TfD tag template.'
value: 'noinclude',
} );
name: 'noinclude',
tfd_template_type.append( { type: 'option', value: 'standard', label: 'Standard', selected: true } );
tooltip: 'Will wrap the deletion tag in &lt;noinclude&gt; tags, so that it won\'t get substituted along with the template.',
tfd_template_type.append( { type: 'option', value: 'sidebar', label: 'Sidebar/infobox' } );
disabled: templateOrModule === 'module',
tfd_template_type.append( { type: 'option', value: 'inline', label: 'Inline template' } );
checked: !!$('.box-Subst_only').length // Default to checked if page carries {{subst only}}
tfd_template_type.append( { type: 'option', value: 'tiny', label: 'Tiny inline' } );
}
]
});
 
work_area.append( {
type: 'checkbox',
list: [
{
label: 'WrapNotify deletionusers tagof withthe <noinclude> (for substituted templates only)template',
value: 'noincludedevpages',
name: 'noincludedevpages',
tooltip: 'WillA wrapnotification thetemplate deletionwill tagbe insent &lt;noinclude&gt;to tagsTwinkle, soAWB, thatand itRedWarn won\'tif getthis substitutedis along with the templatetrue.',
}checked: true
]}
} ); ]
});
 
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
 
case 'mfd':
appendReasonBox();
work_area = work_areanew Morebits.quickForm.renderelement();{
old_area.parentNode.replaceChild( work_area, old_area );
break;
case 'mfd':
work_area = new Morebits.quickForm.element( {
type: 'field',
label: 'Miscellany for deletion',
name: 'work_area'
} );
work_area.append( {
type: 'checkbox',
list: [
{
label: 'Wrap deletion tag with <noinclude>',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in &lt;noinclude&gt; tags, so that it won\'t transclude. Select this option for userboxes.'
}
]
});
if ((mw.config.get('wgNamespaceNumber') === 2 /* User: */ || mw.config.get('wgNamespaceNumber') === 3 /* User talk: */) && mw.config.exists('wgRelevantUserName')) {
work_area.append({
type: 'checkbox',
list: [
{
label: 'WrapNotify deletionowner tagof withuserspace <noinclude>(if they are not the page creator)',
value: 'noinclude',
name: 'noinclude',
tooltip: 'Will wrap the deletion tag in &lt;noinclude&gt; tags, so that it won\'t transclude. Select this option for userboxes.'
}
]
} );
if (mw.config.get('wgNamespaceNumber') === 2 /* User: */ || mw.config.get('wgNamespaceNumber') === 3 /* User talk: */) {
work_area.append( {
type: 'checkbox',
list: [
{
label: 'Also notify owner of userspace if they are not the page creator',
value: 'notifyuserspace',
name: 'notifyuserspace',
tooltip: 'If the user in whose userspace this page is located, is not the page creator (for example, the page is a rescued article stored as a userspace draft), notify the userspace owner as well.',
checked: true
}
]
} );
}
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
case 'ffd':
work_area = new Morebits.quickForm.element( {
type: 'field',
label: 'Discussion venues for files',
name: 'work_area'
} );
appendReasonBox();
work_area.append( {
work_area = work_area.render();
type: 'radio',
old_area.parentNode.replaceChild(work_area, old_area);
name: 'ffdvenue',
list: [break;
 
{
case 'cfd':
label: 'File for discussion',
work_area = new Morebits.quickForm.element({
value: 'ffd',
tooltip: 'File may need to be deleted, or the file\'s compliance with non-free content criteria ([[WP:NFCC]]) is disputed.',
checked: true
},
{
label: 'Possibly unfree file',
value: 'puf',
tooltip: 'File has disputed source or licensing information'
}
]
} );
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
case 'cfd':
work_area = new Morebits.quickForm.element( {
type: 'field',
label: 'Categories for discussion',
name: 'work_area'
} );
var isCategory = mw.config.get('wgNamespaceNumber') === 14;
var cfd_category = work_area.append( {
work_area.append({
type: 'select',
label: 'Choose type of action wanted: ',
name: 'xfdcat',
event: function(e) {
var value = e.target.value;,
var target cfdtarget = e.target.form.xfdtarget;cfdtarget,
cfdtarget2 = e.target.form.cfdtarget2;
 
// update enabled status
if(cfdtarget.disabled = value === 'cfd' )|| {value === 'sfd-t';
 
target.disabled = true;
}if else(isCategory) {
target.disabled// =update false;label
if (value === 'cfs') {
Morebits.quickForm.setElementLabel(cfdtarget, 'Target categories: ');
} else if (value === 'cfc') {
Morebits.quickForm.setElementLabel(cfdtarget, 'Target article: ');
} else {
Morebits.quickForm.setElementLabel(cfdtarget, 'Target category: ');
}
// add/remove extra input box
if (value === 'cfs') {
if (cfdtarget2) {
cfdtarget2.disabled = false;
$(cfdtarget2).show();
} else {
cfdtarget2 = document.createElement('input');
cfdtarget2.setAttribute('name', 'cfdtarget2');
cfdtarget2.setAttribute('type', 'text');
cfdtarget2.setAttribute('required', 'true');
cfdtarget.parentNode.appendChild(cfdtarget2);
}
} else {
$(cfdtarget2).prop('disabled', true);
$(cfdtarget2).hide();
}
} else { // Update stub template label
Morebits.quickForm.setElementLabel(cfdtarget, 'Target stub template: ');
}
},
// update label
if(list: valueisCategory ===? 'cfs' ) {[
{ type: 'option', label: 'Deletion', value: 'cfd', selected: true },
target.previousSibling.textContent = "Target categories: ";
}{ elsetype: if('option', value ===label: 'cfcMerge', )value: {'cfm' },
{ type: 'option', label: 'Renaming', value: 'cfr' },
target.previousSibling.textContent = "Target article: ";
{ type: 'option', label: 'Split', value: 'cfs' },
} else {
{ type: 'option', label: 'Convert into article', value: 'cfc' }
target.previousSibling.textContent = "Target category: ";
}] : [
{ type: 'option', label: 'Stub Deletion', value: 'sfd-t', selected: true },
// add/remove extra input box
{ type: 'option', label: 'Stub Renaming', value: 'sfr-t' }
if( value === 'cfs' && $(target.parentNode).find("input[name='xfdtarget2']").length === 0 ) {
]
var xfdtarget2 = document.createElement("input");
});
xfdtarget2.setAttribute("name", "xfdtarget2");
xfdtarget2.setAttribute("type", "text");
target.parentNode.appendChild(xfdtarget2);
} else {
$(target.parentNode).find("input[name='xfdtarget2']").remove();
}
}
} );
cfd_category.append( { type: 'option', label: 'Deletion', value: 'cfd', selected: true } );
cfd_category.append( { type: 'option', label: 'Merge', value: 'cfm' } );
cfd_category.append( { type: 'option', label: 'Renaming', value: 'cfr' } );
cfd_category.append( { type: 'option', label: 'Split', value: 'cfs' } );
cfd_category.append( { type: 'option', label: 'Convert into article', value: 'cfc' } );
 
work_area.append( {
type: 'input',
name: 'xfdtargetcfdtarget',
label: 'Target pagecategory: ', // default, changed above
disabled: true,
required: true, // only when enabled
value: ''
} );
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
 
case 'cfds':
case 'cfds':
work_area = new Morebits.quickForm.element( {
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'Categories for speedy renaming',
name: 'work_area'
} );
var cfds_category = work_area.append( {
type: 'select',
label: 'C2 sub-criterion: ',
name: 'xfdcat',
tooltip: 'See WP:CFDS for full explanations.',
eventlist: function(e) {[
{ type: 'option', label: 'C2A: Typographic and spelling fixes', value: 'C2A', selected: true },
var value = e.target.value;
{ type: 'option', label: 'C2B: Naming conventions and disambiguation', value: 'C2B' },
var target = e.target.form.xfdtarget;
{ type: 'option', label: 'C2C: Consistency with names of similar categories', value: 'C2C' },
if( value === 'cfd' ) {
{ type: 'option', label: 'C2D: Rename to match article name', value: 'C2D' },
target.disabled = true;
{ type: 'option', label: 'C2E: Author request', value: 'C2E' },
} else {
{ type: 'option', label: 'C2F: One eponymous article', value: 'C2F' }
target.disabled = false;
}]
});
} );
cfds_category.append( { type: 'option', label: 'C2A: Typographic and spelling fixes', value: 'C2A', selected: true } );
cfds_category.append( { type: 'option', label: 'C2B: Naming conventions and disambiguation', value: 'C2B' } );
cfds_category.append( { type: 'option', label: 'C2C: Consistency with names of similar categories', value: 'C2C' } );
cfds_category.append( { type: 'option', label: 'C2D: Rename to match article name', value: 'C2D' } );
cfds_category.append( { type: 'option', label: 'C2E: Author request', value: 'C2E' } );
 
work_area.append( {
type: 'input',
name: 'xfdtargetcfdstarget',
label: 'New name: ',
value: '',
} required: );true
});
appendReasonBox();
appendReasonBox();
work_area = work_area.render();
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
old_area.parentNode.replaceChild(work_area, old_area);
break;
break;
case 'rfd':
 
work_area = new Morebits.quickForm.element( {
case 'rfd':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'Redirects for discussion',
name: 'work_area'
} );
 
appendReasonBox();
work_area = work_area.renderappend();{
type: 'checkbox',
old_area.parentNode.replaceChild( work_area, old_area );
list: [
break;
{
default:
label: 'Notify target page if possible',
work_area = new Morebits.quickForm.element( {
value: 'relatedpage',
name: 'relatedpage',
tooltip: "A notification template will be placed on the talk page of this redirect's target if this is true.",
checked: true
}
]
});
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
 
case 'rm':
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'Requested moves',
name: 'work_area'
});
work_area.append({
type: 'checkbox',
list: [
{
label: 'Uncontroversial technical request',
value: 'rmtr',
name: 'rmtr',
tooltip: 'Use this option when you are unable to perform this uncontroversial move yourself because of a technical reason (e.g. a page already exists at the new title, or the page is protected)',
checked: false,
event: function() {
form.newname.required = this.checked;
}
}
]
});
work_area.append({
type: 'input',
name: 'newname',
label: 'New title: ',
tooltip: 'Required for technical requests. Otherwise, if unsure of the appropriate title, you may leave it blank.'
});
 
appendReasonBox();
work_area = work_area.render();
old_area.parentNode.replaceChild(work_area, old_area);
break;
 
default:
work_area = new Morebits.quickForm.element({
type: 'field',
label: 'Nothing for anything',
name: 'work_area'
} );
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
}
 
// NoReturn to checked state when switching, but no creator notification for CFDS or RM
ifform.notifycreator.disabled = (value === "'cfds")' || value === {'rm';
form.notifycreator.checked = !form.notifycreator.disabled;
Twinkle.xfd.previousNotify = form.notify.checked;
form.notify.checked = false;
form.notify.disabled = true;
} else {
form.notify.checked = Twinkle.xfd.previousNotify;
form.notify.disabled = false;
}
};
 
 
Twinkle.xfd.callbacks = {
// Requires having the tag text (params.tagText) set ahead of time
autoEditRequest: function(pageobj, params) {
var talkName = new mw.Title(pageobj.getPageName()).getTalkPage().toText();
if (talkName === pageobj.getPageName()) {
pageobj.getStatusElement().error('Page protected and nowhere to add an edit request, aborting');
} else {
pageobj.getStatusElement().warn('Page protected, requesting edit');
 
var editRequest = '{{subst:Xfd edit protected|page=' + pageobj.getPageName() +
'|discussion=' + params.discussionpage + (params.venue === 'rfd' ? '|rfd=yes' : '') +
'|tag=<nowiki>' + params.tagText + '\u003C/nowiki>}}'; // U+003C: <
 
var talk_page = new Morebits.wiki.page(talkName, 'Automatically posting edit request on talk page');
talk_page.setNewSectionTitle('Edit request to complete ' + utils.toTLACase(params.venue) + ' nomination');
talk_page.setNewSectionText(editRequest);
talk_page.setCreateOption('recreate');
talk_page.setWatchlist(Twinkle.getPref('xfdWatchPage'));
talk_page.setFollowRedirect(true); // should never be needed, but if the article is moved, we would want to follow the redirect
talk_page.setChangeTags(Twinkle.changeTags);
talk_page.setCallbackParameters(params);
talk_page.newSection(null, function() {
talk_page.getStatusElement().warn('Unable to add edit request, the talk page may be protected');
});
}
},
getDiscussionWikitext: function(venue, params) {
if (venue === 'cfds') { // CfD/S takes a completely different style
return '* [[:' + Morebits.pageNameNorm + ']] to [[:' + params.cfdstarget + ']]\u00A0\u2013 ' +
params.xfdcat + (params.reason ? ': ' + Morebits.string.formatReasonText(params.reason) : '.') + ' ~~~~';
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
if (venue === 'rm') {
// even if invoked from talk page, propose the subject page for move
var pageName = new mw.Title(Morebits.pageNameNorm).getSubjectPage().toText();
return (params.rmtr ?
'{{subst:RMassist|1=' + pageName + '|2=' + params.newname :
'{{subst:Requested move|current1=' + pageName + '|new1=' + params.newname)
+ '|reason=' + params.reason + '}}';
}
 
var text = '{{subst:' + venue + '2';
var reasonKey = venue === 'ffd' ? 'Reason' : 'text';
// Add a reason unconditionally, so that at least a signature is added
text += '|' + reasonKey + '=' + Morebits.string.formatReasonText(params.reason, true);
 
if (venue === 'afd' || venue === 'mfd') {
text += '|pg=' + Morebits.pageNameNorm;
if (venue === 'afd') {
text += '|cat=' + params.xfdcat;
}
} else if (venue === 'rfd') {
text += '|redirect=' + Morebits.pageNameNorm;
} else {
text += '|1=' + mw.config.get('wgTitle');
if (mw.config.get('wgPageContentModel') === 'Scribunto') {
text += '|module=Module:';
}
}
 
if (params.rfdtarget) {
text += '|target=' + params.rfdtarget + (params.section ? '#' + params.section : '');
} else if (params.tfdtarget) {
text += '|2=' + params.tfdtarget;
} else if (params.cfdtarget) {
text += '|2=' + params.cfdtarget;
if (params.cfdtarget2) {
text += '|3=' + params.cfdtarget2;
}
} else if (params.uploader) {
text += '|Uploader=' + params.uploader;
}
 
text += '}}';
 
if (params.delsortCats) { // Only for AFDs
params.delsortCats.forEach(function (cat) {
text += '\n{{subst:delsort|' + cat + '|~~~~}}';
});
}
 
return text;
},
showPreview: function(form, venue, params) {
var templatetext = Twinkle.xfd.callbacks.getDiscussionWikitext(venue, params);
if (venue === 'rm') { // RM templates are sensitive to page title
form.previewer.beginRender(templatetext, params.rmtr ? 'Wikipedia:Requested moves/Technical requests' : new mw.Title(Morebits.pageNameNorm).getTalkPage().toText());
} else {
form.previewer.beginRender(templatetext, 'WP:TW'); // Force wikitext
}
},
preview: function(form) {
// venue, reason, xfdcat, tfdtarget, cfdtarget, cfdtarget2, cfdstarget, delsortCats, newname
var params = Morebits.quickForm.getInputData(form);
 
var venue = params.venue;
 
// Remove CfD or TfD namespace prefixes if given
if (params.tfdtarget) {
params.tfdtarget = utils.stripNs(params.tfdtarget);
} else if (params.cfdtarget) {
params.cfdtarget = utils.stripNs(params.cfdtarget);
if (params.cfdtarget2) {
params.cfdtarget2 = utils.stripNs(params.cfdtarget2);
}
} else if (params.cfdstarget) { // Add namespace if not given (CFDS)
params.cfdstarget = utils.addNs(params.cfdstarget, 14);
}
 
if (venue === 'ffd') {
// Fetch the uploader
var page = new Morebits.wiki.page(mw.config.get('wgPageName'));
page.lookupCreation(function() {
params.uploader = page.getCreator();
Twinkle.xfd.callbacks.showPreview(form, venue, params);
});
} else if (venue === 'rfd') { // Find the target
Twinkle.xfd.callbacks.rfd.findTarget(params, function(params) {
Twinkle.xfd.callbacks.showPreview(form, venue, params);
});
} else if (venue === 'cfd') { // Swap in CfD subactions
Twinkle.xfd.callbacks.showPreview(form, params.xfdcat, params);
} else {
Twinkle.xfd.callbacks.showPreview(form, venue, params);
}
},
/**
* Unified handler for sending {{Xfd notice}} notifications
* Also handles userspace logging
* @param {object} params
* @param {string} notifyTarget The user or page being notified
* @param {boolean} [noLog=false] Whether to skip logging to userspace
* XfD log, especially useful in cases in where multiple notifications
* may be sent out (MfD, TfM, RfD)
* @param {string} [actionName] Alternative description of the action
* being undertaken. Required if not notifying a user talk page.
*/
notifyUser: function(params, notifyTarget, noLog, actionName) {
// Ensure items with User talk or no namespace prefix both end
// up at user talkspace as expected, but retain the
// prefix-less username for addToLog
notifyTarget = mw.Title.newFromText(notifyTarget, 3);
var targetNS = notifyTarget.getNamespaceId();
var usernameOrTarget = notifyTarget.getRelativeText(3);
notifyTarget = notifyTarget.toText();
if (targetNS === 3) {
// Disallow warning yourself
if (usernameOrTarget === mw.config.get('wgUserName')) {
Morebits.status.warn('You (' + usernameOrTarget + ') created this page; skipping user notification');
 
// if we thought we would notify someone but didn't,
// then jump to logging.
Twinkle.xfd.callbacks.addToLog(params, null);
return;
}
// Default is notifying the initial contributor, but MfD also
// notifies userspace page owner
actionName = actionName || 'Notifying initial contributor (' + usernameOrTarget + ')';
}
 
var notifytext = '\n{{subst:' + params.venue + ' notice';
// Venue-specific parameters
switch (params.venue) {
case 'afd':
case 'mfd':
notifytext += params.numbering !== '' ? '|order=&#32;' + params.numbering : '';
break;
case 'tfd':
if (params.xfdcat === 'tfm') {
notifytext = '\n{{subst:Tfm notice|2=' + params.tfdtarget;
}
break;
case 'cfd':
notifytext += '|action=' + params.action + (mw.config.get('wgNamespaceNumber') === 10 ? '|stub=yes' : '');
break;
default: // ffd, rfd
break;
}
notifytext += '|1=' + Morebits.pageNameNorm + '}} ~~~~';
 
// Link to the venue; object used here rather than repetitive items in switch
var venueNames = {
afd: 'Articles for deletion',
tfd: 'Templates for discussion',
mfd: 'Miscellany for deletion',
cfd: 'Categories for discussion',
ffd: 'Files for discussion',
rfd: 'Redirects for discussion'
};
var editSummary = 'Notification: [[' + params.discussionpage + '|listing]] of [[:' +
Morebits.pageNameNorm + ']] at [[WP:' + venueNames[params.venue] + ']].';
 
var usertalkpage = new Morebits.wiki.page(notifyTarget, actionName);
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary(editSummary);
usertalkpage.setChangeTags(Twinkle.changeTags);
usertalkpage.setCreateOption('recreate');
// Different pref for RfD target notifications
if (params.venue === 'rfd' && targetNS !== 3) {
usertalkpage.setWatchlist(Twinkle.getPref('xfdWatchRelated'));
} else {
usertalkpage.setWatchlist(Twinkle.getPref('xfdWatchUser'));
}
usertalkpage.setFollowRedirect(true, false);
 
if (noLog) {
usertalkpage.append();
} else {
usertalkpage.append(function onNotifySuccess() {
// Don't treat RfD target or MfD userspace owner as initialContrib in log
if (!params.notifycreator) {
notifyTarget = null;
}
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, usernameOrTarget);
}, function onNotifyError() {
// if user could not be notified, log nomination without mentioning that notification was sent
Twinkle.xfd.callbacks.addToLog(params, null);
});
}
},
addToLog: function(params, initialContrib) {
if (!Twinkle.getPref('logXfdNominations') || Twinkle.getPref('noLogOnXfdNomination').indexOf(params.venue) !== -1) {
return;
}
 
var usl = new Morebits.userspaceLogger(Twinkle.getPref('xfdLogPageName'));// , 'Adding entry to userspace log');
 
usl.initialText =
"This is a log of all [[WP:XFD|deletion discussion]] nominations made by this user using [[WP:TW|Twinkle]]'s XfD module.\n\n" +
'If you no longer wish to keep this log, you can turn it off using the [[Wikipedia:Twinkle/Preferences|preferences panel]], and ' +
'nominate this page for speedy deletion under [[WP:CSD#U1|CSD U1]].' +
(Morebits.userIsSysop ? '\n\nThis log does not track XfD-related deletions made using Twinkle.' : '');
 
var editsummary = 'Logging ' + utils.toTLACase(params.venue) + ' nomination of [[:' + Morebits.pageNameNorm + ']].';
 
// If a logged file is deleted but exists on commons, the wikilink will be blue, so provide a link to the log
var fileLogLink = mw.config.get('wgNamespaceNumber') === 6 ? ' ([{{fullurl:Special:Log|page=' + mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '}} log])' : '';
// CFD/S and RM don't have canonical links
var nominatedLink = params.discussionpage ? '[[' + params.discussionpage + '|nominated]]' : 'nominated';
 
var appendText = '# [[:' + Morebits.pageNameNorm + ']]:' + fileLogLink + ' ' + nominatedLink + ' at [[WP:' + params.venue.toUpperCase() + '|' + utils.toTLACase(params.venue) + ']]';
 
switch (params.venue) {
case 'tfd':
if (params.xfdcat === 'tfm') {
appendText += ' (merge)';
if (params.tfdtarget) {
var contentModel = mw.config.get('wgPageContentModel') === 'Scribunto' ? 'Module:' : 'Template:';
appendText += '; Other ' + contentModel.toLowerCase() + ' [[';
if (!new RegExp('^:?' + Morebits.namespaceRegex([10, 828]) + ':', 'i').test(params.tfdtarget)) {
appendText += contentModel;
}
appendText += params.tfdtarget + ']]';
}
}
break;
case 'mfd':
if (params.notifyuserspace && params.userspaceOwner && params.userspaceOwner !== initialContrib) {
appendText += '; notified {{user|1=' + params.userspaceOwner + '}}';
}
break;
case 'cfd':
appendText += ' (' + utils.toTLACase(params.xfdcat) + ')';
if (params.cfdtarget) {
var categoryOrTemplate = params.xfdcat.charAt(0) === 's' ? 'Template:' : ':Category:';
appendText += '; ' + params.action + ' to [[' + categoryOrTemplate + params.cfdtarget + ']]';
if (params.xfdcat === 'cfs' && params.cfdtarget2) {
appendText += ', [[' + categoryOrTemplate + params.cfdtarget2 + ']]';
}
}
break;
case 'cfds':
appendText += ' (' + utils.toTLACase(params.xfdcat) + ')';
// Ensure there's more than just 'Category:'
if (params.cfdstarget && params.cfdstarget.length > 9) {
appendText += '; New name: [[:' + params.cfdstarget + ']]';
}
break;
case 'rfd':
if (params.rfdtarget) {
appendText += '; Target: [[:' + params.rfdtarget + ']]';
if (params.relatedpage) {
appendText += ' (notified)';
}
}
break;
case 'rm':
if (params.rmtr) {
appendText += ' (technical)';
}
if (params.newname) {
appendText += '; New name: [[:' + params.newname + ']]';
}
break;
 
default: // afd or ffd
break;
}
 
if (initialContrib && params.notifycreator) {
appendText += '; notified {{user|1=' + initialContrib + '}}';
}
appendText += ' ~~~~~';
if (params.reason) {
appendText += "\n#* '''Reason''': " + Morebits.string.formatReasonForLog(params.reason);
}
 
usl.changeTags = Twinkle.changeTags;
usl.log(appendText, editsummary);
},
 
afd: {
main: function(apiobj) {
var xmlDocresponse = apiobj.responseXMLgetResponse();
var titles = $(xmlDoc)response.query.find('allpages p');
 
// There has been no earlier entries with this prefix, just go on.
if ( titles.length <= 0 ) {
apiobj.params.numbering = apiobj.params.number = '';
} else {
var number = 0;
for( (var i = 0; i < titles.length; ++i ) {
var title = titles[i].getAttribute('title');
 
// First, simple test, is there an instance with this exact name?
if( (title === 'Wikipedia:Articles for deletion/' + Morebits.pageNameNorm ) {
number = Math.max( number, 1 );
continue;
}
 
var order_re = new RegExp( '^' +
RegExpMorebits.string.escapeescapeRegExp( 'Wikipedia:Articles for deletion/' + Morebits.pageNameNorm, true ) +
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$');
var match = order_re.exec( title );
 
// No match; A non-good value
if ( !match ) {
continue;
}
 
// A match, set number to the max of current
number = Math.max( number, Number(match[1]) );
}
apiobj.params.number = Twinkle.xfdutils.num2order( parseInt( number, 10 ) + 1);
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
}
apiobj.params.discussionpage = 'Wikipedia:Articles for deletion/' + Morebits.pageNameNorm + apiobj.params.numbering;
 
Morebits.status.info( "'Next discussion page"', "'[["' + apiobj.params.discussionpage + "']]" ');
 
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Morebits.wiki.actionCompleted.notice = "'Nomination completed, now redirecting to the discussion page"';
 
// Tagging article
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "'Adding deletion tag to article"');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the article is moved, we would want to follow the redirect
wikipedia_page.setChangeTags(Twinkle.changeTags); // Here to apply to triage
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.taggingArticle);
 
// Check for existing AfD tag, for the benefit of new page patrollers
var textNoAfd = text.replace(/<!--.*AfD.*\n\{\{\s*(?:Article for deletion\/dated|AfDM).*\s}\}\n<!--.*(\|(?:\{\{[^{}]n<!--.*\}\}|[^{}])?AfD.*)(?\}\}:\s*\n)?/g, ""'');
if (text !== textNoAfd) {
if (confirm("'An AfD tag was found on this article. Maybe someone beat you to it. \nClick OK to replace the current AfD tag (not recommended), or Cancel to abandon your nomination."')) {
text = textNoAfd;
} else {
statelem.error("'Article already tagged with AfD tag, and you chose to abort"');
window.location.reload();
return;
// Now we know we want to go ahead with it, trigger the other AJAX requests
 
// Mark the page as curated/patrolled, if wanted
if (Twinkle.getPref('markXfdPagesAsPatrolled')) {
new Morebits.wiki.page(Morebits.pageNameNorm).triage();
pageobj.patrol();
}
 
// StartingStart discussion page, will also handle pagetriage and delsort listings
var wikipedia_page = new Morebits.wiki.page(params.discussionpage, "'Creating article deletion discussion page"');
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.discussionPage);
 
// Today's list
var date = new DateMorebits.date(pageobj.getLoadTime());
wikipedia_page = new Morebits.wiki.page('Wikipedia:Articles for deletion/Log/' + date.getUTCFullYear() + ' ' +
date.getUTCMonthNameformat()'YYYY +MMMM D', ' + date.getUTCDate(utc'), "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.afd.todaysList);
 
// Notification to first contributor
if (params.usertalknotifycreator) {
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(params);
thispage.setLookupNonRedirectCreator(true); // Look for author of first non-redirect revision
thispage.lookupCreator(Twinkle.xfd.callbacks.afd.userNotification);
thispage.lookupCreation(function(pageobj) {
Twinkle.xfd.callbacks.notifyUser(pageobj.getCallbackParameters(), pageobj.getCreator());
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
 
params.tagText = (params.noinclude ? '<noinclude>{{' : '{{') + (params.number === '' ? 'subst:afd|help=off' : 'subst:afdx|' +
params.number + '|help=off') + (params.noinclude ? '}}</noinclude>\n' : '}}\n');
 
if (pageobj.canEdit()) {
// Remove some tags that should always be removed on AfD.
text = text.replace(/\{\{\s*(dated prod|dated prod blp|Prod blp\/dated|Proposed deletion\/dated|prod2|Proposed deletion endorsed|New unreviewed article|Unreviewed|Userspace draft)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, ""'');
// Then, test if there are speedy deletion-related templates on the article.
var textNoSd = text.replace(/\{\{\s*(db(-\w*)?|delete|(?:hang|hold)[\- ]?on)\s*(\|(?:\{\{[^{}]*\}\}|[^{}])*)?\}\}\s*/ig, ""'');
if (text !== textNoSd && confirm("'A speedy deletion tag was found on this page. Should it be removed?"')) {
text = textNoSd;
}
 
// Insert tag after short description or any hatnotes
pageobj.setPageText((params.noinclude ? "<noinclude>{{" : "{{") + (params.number === '' ? "subst:afd|help=off" : ('subst:afdx|' +
var wikipage = new Morebits.wikitext.page(text);
params.number + "|help=off")) + (params.noinclude ? "}}</noinclude>\n" : "}}\n") + text);
text = wikipage.insertAfterTemplates(params.tagText, Twinkle.hatnoteRegex).getText();
pageobj.setEditSummary("Nominated for deletion; see [[" + params.discussionpage + "]]." + Twinkle.getPref('summaryAd'));
 
switch (Twinkle.getPref('xfdWatchPage')) {
pageobj.setPageText(text);
case 'yes':
pageobj.setEditSummary('Nominated for deletion; see [[:' + params.discussionpage + ']].');
pageobj.setWatchlist(true);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
break;
pageobj.setCreateOption('nocreate');
case 'no':
pageobj.setWatchlistFromPreferencessave(false);
break;} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('nocreate');
pageobj.save();
},
discussionPage: function(pageobj) {
var params = pageobj.getCallbackParameters();
 
pageobj.setPageText("{{subst:afd2|text=" + MorebitsTwinkle.stringxfd.formatReasonTextcallbacks.getDiscussionWikitext('afd', params.reason) +);
pageobj.setEditSummary('Creating deletion discussion page for [[:' + Morebits.pageNameNorm + ']].');
" ~~~~|pg=" + Morebits.pageNameNorm + "|cat=" + params.xfdcat + "}}\n");
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setEditSummary("Creating deletion discussion page for [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion')) {;
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
 
// Actions that should wait on the discussion page actually being created
// and whose errors shouldn't output the user rationale
// List at deletion sorting pages
if (params.delsortCats) {
params.delsortCats.forEach(function (cat) {
var delsortPage = new Morebits.wiki.page('Wikipedia:WikiProject Deletion sorting/' + cat, 'Adding to list of ' + cat + '-related deletion discussions');
delsortPage.setFollowRedirect(true); // In case a category gets renamed
delsortPage.setCallbackParameters({discussionPage: params.discussionpage});
delsortPage.load(Twinkle.xfd.callbacks.afd.delsortListing);
});
}
});
},
todaysList: function(pageobj) {
var old_text = pageobj.getPageText() + "\n"; // MW strips trailing blanks, but we like them, so we add a fake one
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
 
var textadded_data = old_text.replace( /(<\!-- Add new entries to the TOP of the following list -->\n+)/, "$1'{{subst:afd3|pg="' + Morebits.pageNameNorm + params.numbering + "'}}\n")';
if(var text === old_text ) {;
 
var linknode = document.createElement('a');
// add date header if the log is found to be empty (a bot should do this automatically)
linknode.setAttribute("href", mw.util.getUrl("Wikipedia:Twinkle/Fixing AFD") + "?action=purge" );
if (!pageobj.exists()) {
linknode.appendChild(document.createTextNode('How to fix AFD'));
text = '{{subst:AfD log}}\n' + added_data;
statelem.error( [ 'Could not find the target spot for the discussion. To fix this problem, please see ', linknode, '.' ] );
return;} else {
var old_text = pageobj.getPageText() + '\n'; // MW strips trailing blanks, but we like them, so we add a fake one
 
text = old_text.replace(/(<!-- Add new entries to the TOP of the following list -->\n+)/, '$1' + added_data);
if (text === old_text) {
var linknode = document.createElement('a');
linknode.setAttribute('href', mw.util.getUrl('Wikipedia:Twinkle/Fixing AFD') + '?action=purge');
linknode.appendChild(document.createTextNode('How to fix AFD'));
statelem.error([ 'Could not find the target spot for the discussion. To fix this problem, please see ', linknode, '.' ]);
return;
}
}
 
pageobj.setPageText(text);
pageobj.setEditSummary("'Adding [[":' + params.discussionpage + "']]." + Twinkle.getPref('summaryAd'));
switch pageobj.setChangeTags(Twinkle.getPref('xfdWatchList')changeTags) {;
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save();
},
userNotificationdelsortListing: function(pageobj) {
var discussionPage = pageobj.getCallbackParameters().discussionPage;
var text = pageobj.getPageText().replace('directly below this line -->', 'directly below this line -->\n{{' + discussionPage + '}}');
pageobj.setPageText(text);
pageobj.setEditSummary('Listing [[:' + discussionPage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('nocreate');
pageobj.save();
}
},
 
 
tfd: {
main: function(pageobj) {
var params = pageobj.getCallbackParameters();
var initialContrib = pageobj.getCreator();
 
var date = new Morebits.date(pageobj.getLoadTime());
// Disallow warning yourself
params.logpage = 'Wikipedia:Templates for discussion/Log/' + date.format('YYYY MMMM D', 'utc'),
if (initialContrib === mw.config.get('wgUserName')) {
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
// Add log/discussion page params to the already-loaded page object
return;
pageobj.setCallbackParameters(params);
 
// Defined here rather than below to reduce duplication
var watchModule, watch_query;
if (params.scribunto) {
var watchPref = Twinkle.getPref('xfdWatchPage');
// action=watch has no way to rely on user
// preferences (T262912), so we do it manually.
// The watchdefault pref appears to reliably return '1' (string),
// but that's not consistent among prefs so might as well be "correct"
watchModule = watchPref !== 'no' && (watchPref !== 'default' || !!parseInt(mw.user.options.get('watchdefault'), 10));
if (watchModule) {
watch_query = {
action: 'watch',
titles: [ mw.config.get('wgPageName') ],
token: mw.user.tokens.get('watchToken')
};
// Only add the expiry if page is unwatched or already temporarily watched
if (pageobj.getWatched() !== true && watchPref !== 'default' && watchPref !== 'yes') {
watch_query.expiry = watchPref;
}
}
}
 
// Tagging template(s)/module(s)
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
if (params.xfdcat === 'tfm') { // Merge
var notifytext = "\n{{subst:AFDWarning|1=" + Morebits.pageNameNorm + ( params.numbering !== '' ? '|order=&#32;' + params.numbering : '' ) + "}} ~~~~";
var wikipedia_otherpage;
usertalkpage.setAppendText(notifytext);
if (params.scribunto) {
usertalkpage.setEditSummary("Notification: listing at [[WP:AFD|articles for deletion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
wikipedia_otherpage = new Morebits.wiki.page(params.otherTemplateName + '/doc', 'Tagging other module documentation with merge tag');
usertalkpage.setCreateOption('recreate');
 
switch (Twinkle.getPref('xfdWatchUser')) {
// Watch tagged module pages as well
case 'yes':
if (watchModule) {
usertalkpage.setWatchlist(true);
watch_query.titles.push(params.otherTemplateName);
break;
new Morebits.wiki.api('Adding Modules to watchlist', watch_query).post();
case 'no':
}
usertalkpage.setWatchlistFromPreferences(false);
break;} else {
wikipedia_otherpage = new Morebits.wiki.page(params.otherTemplateName, 'Tagging other template with merge tag');
default:
}
usertalkpage.setWatchlistFromPreferences(true);
// Tag this template/module
break;
Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge(pageobj);
 
// Tag other template/module
wikipedia_otherpage.setFollowRedirect(true);
var otherParams = $.extend({}, params);
otherParams.otherTemplateName = Morebits.pageNameNorm;
wikipedia_otherpage.setCallbackParameters(otherParams);
wikipedia_otherpage.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge);
} else { // delete
if (params.scribunto && Twinkle.getPref('xfdWatchPage') !== 'no') {
// Watch tagged module page as well
if (watchModule) {
new Morebits.wiki.api('Adding Module to watchlist', watch_query).post();
}
}
Twinkle.xfd.callbacks.tfd.taggingTemplate(pageobj);
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
},
 
 
// Updating data for the action completed event
tfd: {
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
 
// Adding discussion
var wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's log");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.todaysList);
 
// Notification to first contributors
if (params.notifycreator) {
var involvedpages = [];
var seenusers = [];
involvedpages.push(new Morebits.wiki.page(mw.config.get('wgPageName')));
if (params.xfdcat === 'tfm') {
if (params.scribunto) {
involvedpages.push(new Morebits.wiki.page('Module:' + params.tfdtarget));
} else {
involvedpages.push(new Morebits.wiki.page('Template:' + params.tfdtarget));
}
}
involvedpages.forEach(function(page) {
page.setCallbackParameters(params);
page.lookupCreation(function(innerpage) {
var username = innerpage.getCreator();
if (seenusers.indexOf(username) === -1) {
seenusers.push(username);
// Only log once on merge nominations, for the initial template
Twinkle.xfd.callbacks.notifyUser(innerpage.getCallbackParameters(), username,
params.xfdcat === 'tfm' && innerpage.getPageName() !== Morebits.pageNameNorm);
}
});
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
 
// Notify developer(s) of script(s) that use(s) the nominated template
if (params.devpages) {
var inCategories = mw.config.get('wgCategories');
var categoryNotificationPageMap = {
'Templates used by Twinkle': 'Wikipedia talk:Twinkle',
'Templates used by AutoWikiBrowser': 'Wikipedia talk:AutoWikiBrowser',
'Templates used by RedWarn': 'Wikipedia talk:RedWarn'
};
$.each(categoryNotificationPageMap, function(category, page) {
if (inCategories.indexOf(category) !== -1) {
Twinkle.xfd.callbacks.notifyUser(params, page, true, 'Notifying ' + page + ' of template nomination');
}
});
}
 
},
taggingTemplate: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
 
pageobj.setPageText((params.noincludetagText ?= "<noinclude>" : "") + "'{{subst:template for discussion|help=off' + (params.templatetype !== 'standard' ? '|"type=' + params.templatetype : '') + '}}';
 
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + mw.config.get('wgTitle') + (params.noinclude ? "}}</noinclude>" : "}}") + text);
if (pageobj.getContentModel() === 'sanitized-css') {
pageobj.setEditSummary("Nominated for deletion; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
params.tagText = '/* ' + params.tagText + ' */';
switch (Twinkle.getPref('xfdWatchPage')) {
case} 'yes':else {
if (params.noinclude) {
pageobj.setWatchlist(true);
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
break;
case 'no':}
params.tagText += params.templatetype === 'standard' || params.templatetype === 'sidebar' ? '\n' : ''; // No newline for inline
pageobj.setWatchlistFromPreferences(false);
break;}
 
default:
if (pageobj.canEdit() && ['wikitext', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setWatchlistFromPreferences(true);
pageobj.setPageText(params.tagText + text);
break;
pageobj.setEditSummary('Nominated for deletion; see [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
if (params.scribunto) {
pageobj.setCreateOption('recreate'); // Module /doc might not exist
}
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
pageobj.setCreateOption('nocreate');
pageobj.save();
},
taggingTemplateForMerge: function(pageobj) {
var params = pageobj.getCallbackParameters();
 
pageobj.setPageText((params.noincludetagText ?= "<noinclude>" : "") + "'{{subst:tfm|help=off|"' + (params.templatetype !== 'standard' ? 'type=' + params.templatetype + '|' : '') +
'1=' + params.otherTemplateName.replace(new RegExp('^' + Morebits.namespaceRegex([10, 828]) + ':'), '') + '}}';
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + "1=" + params.otherTemplateName.replace(/^Template:/, "") +
 
(params.noinclude ? "}}</noinclude>" : "}}\n") + text);
if (pageobj.getContentModel() === 'sanitized-css') {
pageobj.setEditSummary("Nominated for merging with [[" + params.otherTemplateName + "]]; see [[" +
params.logpagetagText += "#"'/* + Morebits.pageNameNorm' + "]]params."tagText + Twinkle.getPref('summaryAd */'));
} else {
switch (Twinkle.getPref('xfdWatchPage')) {
if (params.noinclude) {
case 'yes':
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
pageobj.setWatchlist(true);
break;}
params.tagText += params.templatetype === 'standard' || params.templatetype === 'sidebar' ? '\n' : ''; // No newline for inline
case 'no':
}
pageobj.setWatchlistFromPreferences(false);
 
break;
if (pageobj.canEdit() && ['wikitext', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
default:
pageobj.setWatchlistFromPreferencessetPageText(trueparams.tagText + text);
pageobj.setEditSummary('Listed for merging with [[:' + params.otherTemplateName + ']]; see [[:' + params.discussionpage + ']].');
break;
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
if (params.scribunto) {
pageobj.setCreateOption('recreate'); // Module /doc might not exist
}
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
pageobj.setCreateOption('nocreate');
pageobj.save();
},
todaysList: function(pageobj) {
var old_text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
 
var added_data = ""Twinkle.xfd.callbacks.getDiscussionWikitext(params.xfdcat, params);
var text;
switch( params.xfdcat ) {
 
case 'tfd':
// add date header if the log is found to be empty (a bot should do this automatically)
added_data = "{{subst:tfd2|text=" + Morebits.string.formatReasonText(params.reason) +
if (!pageobj.exists()) {
" ~~~~|1=" + mw.config.get('wgTitle') + "}}";
text = '{{subst:TfD log}}\n' + added_data;
break;
case} 'tfm':else {
var old_text = pageobj.getPageText();
added_data = "{{subst:tfm2|text=" + Morebits.string.formatReasonText(params.reason) +
 
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
text = old_text.replace('-->', '-->\n' + added_data);
break;
if (text === old_text) {
default:
statelem.error('failed to find target spot for the discussion');
alert("twinklexfd in todaysList: unknown TFD action");
break return;
}
}
 
var text = old_text.replace( '-->', "-->\n" + added_data );
if( text === old_text ) {
statelem.error( 'failed to find target spot for the discussion' );
return;
}
pageobj.setPageText(text);
pageobj.setEditSummary("'Adding [[Template:"' + mw.config.get(params.xfdcat === 'wgTitletfd' ? 'deletion nomination' : 'merge listing') + "]]' of [[:' + Morebits."pageNameNorm + Twinkle']].getPref('summaryAd'));
pageobj.setChangeTags(Twinkle.changeTags);
switch (Twinkle.getPref('xfdWatchDiscussion')) {
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
 
// Disallow warning yourself
if (initialContrib === mw.config.get('wgUserName')) {
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
return;
}
 
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n";
switch (params.xfdcat) {
case 'tfd':
notifytext += "{{subst:tfdnotice|1=" + mw.config.get('wgTitle') + "}} ~~~~";
break;
case 'tfm':
notifytext += "{{subst:tfmnotice|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}} ~~~~";
break;
default:
alert("twinklexfd in userNotification: unknown TFD action");
break;
}
 
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification: nomination at [[WP:TFD|templates for discussion]] of [[" + pageobj.getPageName() + "]]." + Twinkle.getPref('summaryAd'));
usertalkpage.setCreateOption('recreate');
switch (Twinkle.getPref('xfdWatchUser')) {
case 'yes':
usertalkpage.setWatchlist(true);
break;
case 'no':
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
usertalkpage.setWatchlistFromPreferences(true);
break;
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
},
mfd: {
main: function(apiobj) {
var xmlDocresponse = apiobj.responseXMLgetResponse();
var titles = $(xmlDoc)response.query.find('allpages p');
 
// There has been no earlier entries with this prefix, just go on.
if ( titles.length <= 0 ) {
apiobj.params.numbering = apiobj.params.number = '';
} else {
var number = 0;
for( (var i = 0; i < titles.length; ++i ) {
var title = titles[i].getAttribute('title');
 
// First, simple test, is there an instance with this exact name?
if( (title === 'Wikipedia:Miscellany for deletion/' + Morebits.pageNameNorm ) {
number = Math.max( number, 1 );
continue;
}
 
var order_re = new RegExp( '^' +
RegExpMorebits.string.escapeescapeRegExp( 'Wikipedia:Miscellany for deletion/' + Morebits.pageNameNorm, true ) +
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$' );
var match = order_re.exec( title );
 
// No match; A non-good value
if ( !match ) {
continue;
}
 
// A match, set number to the max of current
number = Math.max( number, Number(match[1]) );
}
apiobj.params.number = Twinkle.xfdutils.num2order( parseInt( number, 10 ) + 1);
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
}
apiobj.params.discussionpage = "'Wikipedia:Miscellany for deletion/"' + Morebits.pageNameNorm + apiobj.params.numbering;
 
apiobj.statelem.info( "'next in order is [["' + apiobj.params.discussionpage + ']]');
 
// Tagging page
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "'Tagging page with deletion tag"');
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(apiobj.params);
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = apiobj.params.discussionpage;
Morebits.wiki.actionCompleted.notice = "'Nomination completed, now redirecting to the discussion page"';
 
// Discussion page
wikipedia_page = new Morebits.wiki.page(apiobj.params.discussionpage, "'Creating deletion discussion page"');
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.discussionPage);
 
// Today's list
wikipedia_page = new Morebits.wiki.page("'Wikipedia:Miscellany for deletion"', "Adding discussion to today's list");
//wikipedia_page.setPageSection(2);
wikipedia_page.setFollowRedirect(true);
// pageSection has been disabled - the API seems to throw up with nonexistent edit conflicts
// it can be turned on again once the problem is fixed, to save bandwidth
//wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(apiobj.params);
wikipedia_page.load(Twinkle.xfd.callbacks.mfd.todaysList);
 
// Notification to first contributor, and/or notification to owner of userspace (if applicable and required)
if (apiobj.params.usertalknotifycreator || apiobj.params.notifyuserspace) {
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(apiobj.params);
thispage.lookupCreatorlookupCreation(Twinkle.xfd.callbacks.mfd.userNotificationsendNotifications);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(apiobj.params, null);
}
},
var params = pageobj.getCallbackParameters();
 
pageobj.setPageText((params.noincludetagText ?= "<noinclude>" : "") + "'{{"' + ((params.number === '') ? "'mfd}}\n"' : ('mfdx|' + params.number) + "'|help=off}}\n")) +';
 
(params.noinclude ? "</noinclude>" : "") + text);
if (['javascript', 'css', 'sanitized-css'].indexOf(mw.config.get('wgPageContentModel')) !== -1) {
pageobj.setEditSummary("Nominated for deletion; see [[" + params.discussionpage + "]]." + Twinkle.getPref('summaryAd'));
params.tagText = '/* ' + params.tagText + ' */\n';
switch (Twinkle.getPref('xfdWatchPage')) {
case} 'yes':else {
params.tagText += '\n';
pageobj.setWatchlist(true);
if (params.noinclude) {
break;
params.tagText = '<noinclude>' + params.tagText + '</noinclude>';
case 'no':
}
pageobj.setWatchlistFromPreferences(false);
break;}
 
default:
if (pageobj.canEdit() && ['wikitext', 'javascript', 'css', 'sanitized-css'].indexOf(pageobj.getContentModel()) !== -1) {
pageobj.setWatchlistFromPreferences(true);
pageobj.setPageText(params.tagText + text);
break;
pageobj.setEditSummary('Nominated for deletion; see [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
pageobj.setCreateOption('nocreate');
pageobj.save();
},
discussionPage: function(pageobj) {
var params = pageobj.getCallbackParameters();
 
pageobj.setPageText("{{subst:mfd2|text=" + MorebitsTwinkle.stringxfd.formatReasonTextcallbacks.getDiscussionWikitext('mfd', params.reason) +);
"pageobj.setEditSummary('Creating ~~~~|pg="deletion discussion page for [[:' + Morebits.pageNameNorm + "}}\n"']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setEditSummary("Creating deletion discussion page for [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion')) {;
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('createonly');
pageobj.save(function() {
var statelem = pageobj.getStatusElement();
 
var date = new DateMorebits.date(pageobj.getLoadTime());
var date_header = "===" + date.getUTCMonthNameformat() + '===MMMM ' + date.getUTCDate() + 'D, ' + date.getUTCFullYear() + "YYYY===\n"', 'utc');
var date_header_regex = new RegExp( "date.format('(===[\\s]*" + date.getUTCMonthName() + 'MMMM[\\s]+' + date.getUTCDate() + 'D,[\\s]+' + date.getUTCFullYear() + "YYYY[\\s]*===)"', 'utc'));
var new_dataadded_data = "'{{subst:mfd3|pg="' + Morebits.pageNameNorm + params.numbering + "'}}"';
 
if ( date_header_regex.test( text ) ) { // we have a section already
statelem.info( 'Found today\'s section, proceeding to add new entry' );
text = text.replace( date_header_regex, "'$1\n"' + new_data added_data);
} else { // we need to create a new section
statelem.info( 'No section for today found, proceeding to create one' );
text = text.replace("'==="', date_header + new_dataadded_data + "'\n\n==="');
}
 
pageobj.setPageText(text);
pageobj.setEditSummary("'Adding [[":' + params.discussionpage + "']]." + Twinkle.getPref('summaryAd'));
switch pageobj.setChangeTags(Twinkle.getPref('xfdWatchList')changeTags) {;
pageobj.setWatchlist(Twinkle.getPref('xfdWatchList'));
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save();
},
userNotificationsendNotifications: function(pageobj) {
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
 
// DisallowNotify warningthe yourselfcreator
if (params.notifycreator) {
if (initialContrib === mw.config.get('wgUserName')) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
} else {
// Really notify the creator
Twinkle.xfd.callbacks.mfd.userNotificationMain(params, initialContrib, "Notifying initial contributor");
}
 
// Also notifyNotify the user who owns the subpage if they are not the creator
params.userspaceOwner = mw.config.get('wgRelevantUserName');
if (params.notifyuserspace) {
if (params.userspaceOwner !== initialContrib) {
var userspaceOwner = ((mw.config.get('wgTitle').indexOf('/') === -1) ? mw.config.get('wgTitle') : mw.config.get('wgTitle').substring(0, mw.config.get('wgTitle').indexOf('/')));
// Don't log if notifying creator above, will log then
if (userspaceOwner !== initialContrib) {
Twinkle.xfd.callbacks.mfd.userNotificationMainnotifyUser(params, params.userspaceOwner, "params.notifycreator, 'Notifying owner of userspace" (' + params.userspaceOwner + ')');
} else if (!params.notifycreator) {
// If we thought we would notify the owner but didn't,
// then we need to log if we didn't notify the creator
// Twinkle.xfd.callbacks.addToLog(params, null);
Twinkle.xfd.callbacks.addToLog(params, initialContrib);
}
}
},
userNotificationMain: function(params, initialContrib, actionName)
{
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, actionName + " (" + initialContrib + ")");
var notifytext = "\n{{subst:MFDWarning|1=" + Morebits.pageNameNorm + ( params.numbering !== '' ? '|order=&#32;' + params.numbering : '' ) + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification: listing at [[WP:MFD|miscellany for deletion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
usertalkpage.setCreateOption('recreate');
switch (Twinkle.getPref('xfdWatchUser')) {
case 'yes':
usertalkpage.setWatchlist(true);
break;
case 'no':
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
usertalkpage.setWatchlistFromPreferences(true);
break;
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
},
 
ffd: {
taggingImage: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
 
var date = new Morebits.date(pageobj.getLoadTime()).format('YYYY MMMM D', 'utc');
params.logpage = 'Wikipedia:Files for discussion/' + date;
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
 
params.tagText = '{{ffd|log=' + date + '|help=off}}\n';
if (pageobj.canEdit()) {
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, '');
 
pageobj.setPageText(params.tagText + text);
pageobj.setEditSummary('Listed for discussion at [[:' + params.discussionpage + ']].');
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('recreate'); // it might be possible for a file to exist without a description page
pageobj.save();
} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
}
 
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = params.logpage;
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
 
// Contributor specific edits
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreation(Twinkle.xfd.callbacks.ffd.main);
},
main: function(pageobj) {
// this is coming in from lookupCreatorlookupCreation...!
var params = pageobj.getCallbackParameters();
var initialContrib = pageobj.getCreator();
 
// Notification to first contributor
if (params.usertalknotifycreator) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
// Disallow warning yourself
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
if (initialContrib === mw.config.get('wgUserName')) {
} else {
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
Twinkle.xfd.callbacks.addToLog(params, null);
} else {
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:fdw|1=" + mw.config.get('wgTitle') + "}}";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification: listing at [[WP:FFD|files for discussion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
usertalkpage.setCreateOption('recreate');
switch (Twinkle.getPref('xfdWatchUser')) {
case 'yes':
usertalkpage.setWatchlist(true);
break;
case 'no':
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
usertalkpage.setWatchlistFromPreferences(true);
break;
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
}
},
taggingImage: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
 
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, "");
 
pageobj.setPageText("{{ffd|log=" + params.date + "}}\n" + text);
pageobj.setEditSummary("Listed for discussion at [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate'); // it might be possible for a file to exist without a description page
pageobj.save();
},
todaysList: function(pageobj) {
var params = pageobj.getCallbackParameters();
 
// add date header if the log is found to be empty (a bot should do this automatically, but it sometimes breaks down)
if (!pageobj.exists()) {
text = "'{{subst:FfdFfD log}}"';
}
 
pageobj.setPageText(text + "'\n{{subst:ffd2|Reason="\n' + MorebitsTwinkle.stringxfd.formatReasonTextcallbacks.getDiscussionWikitext('ffd', params.reason) +);
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
"|Uploader=" + params.uploader + "|1=" + mw.config.get('wgTitle') + "}} ~~~~");
pageobj.setEditSummarysetChangeTags("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd')changeTags);
switch pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion')) {;
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save(function() {
 
 
pufcfd: {
taggingImagemain: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
 
var date = new Morebits.date(pageobj.getLoadTime());
text = text.replace(/\{\{(mtc|(copy |move )?to ?commons|move to wikimedia commons|copy to wikimedia commons)[^}]*\}\}/gi, "");
params.logpage = 'Wikipedia:Categories for discussion/Log/' + date.format('YYYY MMMM D', 'utc');
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Add log/discussion page params to the already-loaded page object
pageobj.setCallbackParameters(params);
 
// Tagging category
pageobj.setPageText("{{puf|help=off|log=" + params.date + "}}\n" + text);
Twinkle.xfd.callbacks.cfd.taggingCategory(pageobj);
pageobj.setEditSummary("Listed at [[WP:PUF|possibly unfree files]]: [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
 
switch (Twinkle.getPref('xfdWatchPage')) {
// Updating data for the action completed event
case 'yes':
Morebits.wiki.actionCompleted.redirect = params.logpage;
pageobj.setWatchlist(true);
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
break;
 
case 'no':
// Adding discussion to list
pageobj.setWatchlistFromPreferences(false);
var wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's list");
break;
wikipedia_page.setFollowRedirect(true);
default:
wikipedia_page.setCallbackParameters(params);
pageobj.setWatchlistFromPreferences(true);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.todaysList);
break;
 
// Notification to first contributor
if (params.notifycreator) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreation(function(pageobj) {
Twinkle.xfd.callbacks.notifyUser(pageobj.getCallbackParameters(), pageobj.getCreator());
});
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
pageobj.setCreateOption('recreate'); // it might be possible for a file to exist without a description page
pageobj.save();
},
todaysListtaggingCategory: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
 
pageobjparams.setPageText(texttagText += "\n'{{subst:puf2|reason="' + Morebits.string.formatReasonText(params.reason) +xfdcat;
"|image="var +editsummary = (mw.config.get('wgTitlewgNamespaceNumber') +=== "}}14 ~~~~"? 'Category' : 'Stub template'); +
' being considered for ' + params.action;
pageobj.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkleparams.getPref('xfdWatchDiscussion')xfdcat) {
case 'yescfd':
case 'sfd-t':
pageobj.setWatchlist(true);
break;
case 'nocfc':
editsummary += ' to an article';
pageobj.setWatchlistFromPreferences(false);
break;// falls through
defaultcase 'cfm':
case 'cfr':
pageobj.setWatchlistFromPreferences(true);
break;case 'sfr-t':
params.tagText += '|' + params.cfdtarget;
}
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
 
// Disallow warning yourself
if (initialContrib === mw.config.get('wgUserName')) {
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
return;
}
 
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:fdw-puf|1=" + mw.config.get('wgTitle') + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification: listing at [[WP:PUF|possibly unfree files]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
usertalkpage.setCreateOption('recreate');
switch (Twinkle.getPref('xfdWatchUser')) {
case 'yes':
usertalkpage.setWatchlist(true);
break;
case 'nocfs':
params.tagText += '|' + params.cfdtarget + '|' + params.cfdtarget2;
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
alert('twinklexfd in taggingCategory(): unknown CFD action');
usertalkpage.setWatchlistFromPreferences(true);
break;
}
params.tagText += '}}\n';
usertalkpage.setFollowRedirect(true);
editsummary += '; see [[:' + params.discussionpage + ']].';
usertalkpage.append();
}
},
 
if (pageobj.canEdit()) {
 
pageobj.setPageText(params.tagText + text);
// NOTE: NFCR doesn't have any callbacks here, everything happens in callback.evaluate
pageobj.setEditSummary(editsummary);
 
pageobj.setChangeTags(Twinkle.changeTags);
 
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
cfd: {
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
taggingCategory: function(pageobj) {
var text = pageobj.getPageTextsave();
} else {
var params = pageobj.getCallbackParameters();
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
 
var added_data = "";
var editsummary = "";
switch( params.xfdcat ) {
case 'cfd':
added_data = "{{subst:cfd}}";
editsummary = "Category being considered for deletion; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]].";
break;
case 'cfm':
added_data = "{{subst:cfm|" + params.target + "}}";
editsummary = "Category being considered for merging; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]].";
break;
case 'cfr':
added_data = "{{subst:cfr|" + params.target + "}}";
editsummary = "Category being considered for renaming; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]].";
break;
case 'cfs':
added_data = "{{subst:cfs|" + params.target + "|" + params.target2 + "}}";
editsummary = "Category being considered for splitting; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]].";
break;
case 'cfc':
added_data = "{{subst:cfc|" + params.target + "}}";
editsummary = "Category being considered for conversion to an article; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]].";
break;
default:
alert("twinklexfd in taggingCategory(): unknown CFD action");
break;
}
 
pageobj.setPageText(added_data + "\n" + text);
pageobj.setEditSummary(editsummary + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save();
},
todaysList: function(pageobj) {
var old_text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
 
var added_data = ""Twinkle.xfd.callbacks.getDiscussionWikitext(params.xfdcat, params);
var editsummary = ""text;
switch( params.xfdcat ) {
case 'cfd':
added_data = "{{subst:cfd2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "}}";
editsummary = "Added delete nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
case 'cfm':
added_data = "{{subst:cfm2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
editsummary = "Added merge nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
case 'cfr':
added_data = "{{subst:cfr2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
editsummary = "Added rename nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
case 'cfs':
added_data = "{{subst:cfs2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "|3=" + params.target2 + "}}";
editsummary = "Added split nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
case 'cfc':
added_data = "{{subst:cfc2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
editsummary = "Added convert nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
default:
alert("twinklexfd in todaysList: unknown CFD action");
break;
}
 
// add date header if the log is found to be empty (a bot should do this automatically)
var text = old_text.replace( 'below this line -->', "below this line -->\n" + added_data );
if ( text === old_text !pageobj.exists()) {
text = '{{subst:CfD log}}\n' + added_data;
statelem.error( 'failed to find target spot for the discussion' );
return;} else {
var old_text = pageobj.getPageText();
 
text = old_text.replace('below this line -->', 'below this line -->\n' + added_data);
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
}
 
pageobj.setPageText(text);
pageobj.setEditSummary(editsummary'Adding ' + Twinkleparams.getPref(action + 'summaryAd nomination of [[:' + Morebits.pageNameNorm + ']].'));
pageobj.setChangeTags(Twinkle.changeTags);
switch (Twinkle.getPref('xfdWatchDiscussion')) {
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
});
},
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
 
// Disallow warning yourself
if (initialContrib === mw.config.get('wgUserName')) {
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
return;
}
 
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:cfd-notify|1=" + Morebits.pageNameNorm + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification: listing at [[WP:CFD|categories for discussion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
usertalkpage.setCreateOption('recreate');
switch (Twinkle.getPref('xfdWatchUser')) {
case 'yes':
usertalkpage.setWatchlist(true);
break;
case 'no':
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
usertalkpage.setWatchlistFromPreferences(true);
break;
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
},
var params = pageobj.getCallbackParameters();
 
pageobjparams.setPageText("tagText = '{{subst:cfr-speedy|1="' + params.targetcfdstarget.replace(/^:?Category:/, '') + "'}}\n" + text)';
if (pageobj.canEdit()) {
pageobj.setEditSummary("Nominated for speedy renaming; see [[WP:CFDS|Categories for discussion/Speedy]]." + Twinkle.getPref('summaryAd'));
pageobj.setPageText(params.tagText + text);
switch (Twinkle.getPref('xfdWatchPage')) {
pageobj.setEditSummary('Listed for speedy renaming; see [[WP:CFDS|Categories for discussion/Speedy]].');
case 'yes':
pageobj.setWatchlistsetChangeTags(trueTwinkle.changeTags);
pageobj.setWatchlist(Twinkle.getPref('xfdWatchPage'));
break;
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
case 'no':
pageobj.setWatchlistFromPreferencessave(function(false); {
// No user notification for CfDS, so just add this nomination to the user's userspace log
break;
Twinkle.xfd.callbacks.addToLog(params, null);
default:
});
pageobj.setWatchlistFromPreferences(true);
break;} else {
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
// No user notification for CfDS, so just add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
}
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save();
},
addToList: function(pageobj) {
var statelem = pageobj.getStatusElement();
 
var text = old_text.replace('BELOW THIS LINE -->', 'BELOW THIS LINE -->\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('cfds', params));
var newcatname = (/^Category:/.test(params.target) ? params.target : ("Category:" + params.target));
if (text === old_text) {
var text = old_text.replace( 'BELOW THIS LINE -->', "BELOW THIS LINE -->\n* [[:" + Morebits.pageNameNorm + "]] to [[:" +
statelem.error('failed to find target spot for the discussion');
newcatname + "]]\u00A0\u2013 " + params.xfdcat + (params.reason ? (": " + Morebits.string.formatReasonText(params.reason)) : ".") +
" ~~~~" );
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
if( text === old_text ) {
statelem.error( 'failed to find target spot for the discussion' );
return;
}
 
pageobj.setPageText(text);
pageobj.setEditSummary("'Adding [[":' + Morebits.pageNameNorm + "']]." + Twinkle.getPref('summaryAd'));
pageobj.setChangeTags(Twinkle.changeTags);
switch (Twinkle.getPref('xfdWatchDiscussion')) {
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save(function() {
 
rfd: {
// This isgets acalled callbackboth fromon ansubmit APIand request,preview whichto getsdetermine the redirect target of the redirect
findTargetCallbackfindTarget: function(apiobjparams, callback) {
// Used by regular redirects to find the target, but for all redirects,
var xmlDoc = apiobj.responseXML;
// avoid relying on the client clock to build the log page
var target = $(xmlDoc).find('redirects r').first().attr('to');
if(var !targetquery )= {
action: 'query',
apiobj.statelem.error( "This page is currently not a redirect, aborting" );
curtimestamp: true,
return;
format: 'json'
};
if (document.getElementById('softredirect')) {
// For soft redirects, define the target early
// to skip target checks in findTargetCallback
params.rfdtarget = document.getElementById('softredirect').textContent.replace(/^:+/, '');
} else {
// Find current target of redirect
query.titles = mw.config.get('wgPageName');
query.redirects = true;
}
var wikipedia_api = new Morebits.wiki.api('Finding target of redirect', query, Twinkle.xfd.callbacks.rfd.findTargetCallback(callback));
apiobj.params.target = target;
wikipedia_api.params = params;
Twinkle.xfd.callbacks.rfd.main(apiobj.params);
wikipedia_api.post();
},
// This is a closure for the callback from the above API request, which gets the target of the redirect
findTargetCallback: function(callback) {
return function(apiobj) {
var response = apiobj.getResponse();
apiobj.params.curtimestamp = response.curtimestamp;
 
if (!apiobj.params.rfdtarget) { // Not a softredirect
var target = response.query.redirects && response.query.redirects[0].to;
if (!target) {
var message = 'No target found. this page does not appear to be a redirect, aborting';
if (mw.config.get('wgAction') === 'history') {
message += '. If this is a soft redirect, try again from the content page, not the page history.';
}
apiobj.statelem.error(message);
return;
}
apiobj.params.rfdtarget = target;
var section = response.query.redirects[0].tofragment;
apiobj.params.section = section;
}
callback(apiobj.params);
};
},
main: function(params) {
var date = new DateMorebits.date(params.curtimestamp);
params.logpage = 'Wikipedia:Redirects for discussion/Log/' + date.getUTCFullYearformat()'YYYY +MMMM D', ' + date.getUTCMonthName() + utc' ' + date.getUTCDate();
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
 
// Tagging redirect
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "'Adding deletion tag to redirect"');
wikipedia_page.setFollowRedirect(false);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.rfd.todaysList);
 
// Notifications
// Notifying initial contributor
if (params.usertalknotifycreator || params.relatedpage) {
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispage.setCallbackParameters(params);
thispage.lookupCreatorlookupCreation(Twinkle.xfd.callbacks.rfd.userNotificationsendNotifications);
// or, if not notifying, add this nomination to the user's userspace log without the initial contributor's name
} else {
Twinkle.xfd.callbacks.addToLog(params, null);
}
},
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
// Imperfect for edit request but so be it
params.tagText = '{{subst:rfd|' + (mw.config.get('wgNamespaceNumber') === 10 ? 'showontransclusion=1|' : '') + 'content=\n';
 
if (pageobj.canEdit()) {
pageobj.setPageText("{{subst:rfd|content=\n" + text + "\n}}");
pageobj.setPageText(params.tagText + text + '\n}}');
pageobj.setEditSummary("Listed for discussion at [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary('Listed for discussion at [[:' + params.discussionpage + ']].');
switch (Twinkle.getPref('xfdWatchPage')) {
pageobj.setChangeTags(Twinkle.changeTags);
case 'yes':
pageobj.setWatchlist(trueTwinkle.getPref('xfdWatchPage'));
pageobj.setCreateOption('nocreate');
break;
case 'no':pageobj.save();
} else {
pageobj.setWatchlistFromPreferences(false);
Twinkle.xfd.callbacks.autoEditRequest(pageobj, params);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('nocreate');
pageobj.save();
},
todaysList: function(pageobj) {
var old_text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
 
var added_data = Twinkle.xfd.callbacks.getDiscussionWikitext('rfd', params);
var text = old_text.replace( /(<\!-- Add new entries directly below this line\.? -->)/, "$1\n{{subst:rfd2|text=" +
var text;
Morebits.string.formatReasonText(params.reason) + "|redirect="+ Morebits.pageNameNorm + "|target=" +
 
params.target + "}} ~~~~\n" );
// add date header if the log is found to be empty (a bot should do this automatically)
if( text === old_text ) {
if (!pageobj.exists()) {
statelem.error( 'failed to find target spot for the discussion' );
text = '{{subst:RfD log}}' + added_data;
return;
} else {
var old_text = pageobj.getPageText();
text = old_text.replace(/(<!-- Add new entries directly below this line\.? -->)/, '$1\n' + added_data);
if (text === old_text) {
statelem.error('failed to find target spot for the discussion');
return;
}
}
 
pageobj.setPageText(text);
pageobj.setEditSummary("'Adding [[":' + Morebits.pageNameNorm + "']]." + Twinkle.getPref('summaryAd'));
pageobj.setChangeTags(Twinkle.changeTags);
switch (Twinkle.getPref('xfdWatchDiscussion')) {
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
pageobj.setCreateOption('recreate');
pageobj.save(function() {
});
},
userNotificationsendNotifications: function(pageobj) {
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
var statelem = pageobj.getStatusElement();
 
// DisallowNotifying warninginitial yourselfcontributor
if (params.notifycreator) {
if (initialContrib === mw.config.get('wgUserName')) {
Twinkle.xfd.callbacks.notifyUser(params, initialContrib);
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
return;
}
 
// Notifying target page's watchers, if not a soft redirect
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
if (params.relatedpage) {
var notifytext = "\n{{subst:RFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
var targetTalk = new mw.Title(params.rfdtarget).getTalkPage();
usertalkpage.setAppendText(notifytext);
 
usertalkpage.setEditSummary("Notification: listing at [[WP:RFD|redirects for discussion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
// On the offchance it's a circular redirect
usertalkpage.setCreateOption('recreate');
if (params.rfdtarget === mw.config.get('wgPageName')) {
switch (Twinkle.getPref('xfdWatchUser')) {
statelem.warn('Circular redirect; skipping target page notification');
case 'yes':
} else if (document.getElementById('softredirect')) {
usertalkpage.setWatchlist(true);
statelem.warn('Soft redirect; skipping target page notification');
break;
// Don't issue if target talk is the initial contributor's talk or your own
case 'no':
} else if (targetTalk.getNamespaceId() === 3 && targetTalk.getNameText() === initialContrib) {
usertalkpage.setWatchlistFromPreferences(false);
statelem.warn('Target is initial contributor; skipping target page notification');
break;
} else if (targetTalk.getNamespaceId() === 3 && targetTalk.getNameText() === mw.config.get('wgUserName')) {
default:
statelem.warn('You (' + mw.config.get('wgUserName') + ') are the target; skipping target page notification');
usertalkpage.setWatchlistFromPreferences(true);
break;} else {
// Don't log if notifying creator above, will log then
Twinkle.xfd.callbacks.notifyUser(params, targetTalk.toText(), params.notifycreator, 'Notifying redirect target of the discussion');
return;
}
// If we thought we would notify the target but didn't,
// we need to log if we didn't notify the creator
if (!params.notifycreator) {
Twinkle.xfd.callbacks.addToLog(params, null);
}
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
},
};
 
rm: {
listAtTalk: function(pageobj) {
var params = pageobj.getCallbackParameters();
 
pageobj.setAppendText('\n\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params));
pageobj.setEditSummary('Proposing move' + (params.newname ? ' to [[:' + params.newname + ']]' : ''));
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.setCreateOption('recreate'); // since the talk page need not exist
pageobj.setWatchlist(Twinkle.getPref('xfdWatchDiscussion'));
pageobj.append(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
},
 
Twinkle.xfd.callback.evaluate = listAtRMTR: function(epageobj) {
var typetext = epageobj.target.category.valuegetPageText();
var params = pageobj.getCallbackParameters();
var usertalk = e.target.notify.checked;
var statelem = pageobj.getStatusElement();
var reason = e.target.xfdreason.value;
 
var xfdcat, xfdtarget, xfdtarget2, ffdvenue, noinclude, tfdtype, notifyuserspace;
var hiddenCommentRE = /---- and enter on a new line.* -->/;
if( type === "afd" || type === "cfd" || type === "cfds" || type === "tfd" ) {
var newtext = text.replace(hiddenCommentRE, '$&\n' + Twinkle.xfd.callbacks.getDiscussionWikitext('rm', params));
xfdcat = e.target.xfdcat.value;
if (text === newtext) {
}
statelem.error('failed to find target spot for the entry');
if( type === "cfd" || type === "cfds" ) {
return;
xfdtarget = e.target.xfdtarget.value;
if (e.target.xfdtarget2) {
xfdtarget2 = e.target.xfdtarget2.value;
}
}
if( type === 'ffd' ) {
var ffdvenues = e.target.ffdvenue;
for( var i = 0; i < ffdvenues.length; i++ )
{
if( !ffdvenues[i].checked ) {
continue;
}
pageobj.setPageText(newtext);
ffdvenue = ffdvenues[i].values;
pageobj.setEditSummary('Adding [[:' + Morebits.pageNameNorm + ']].');
break;
pageobj.setChangeTags(Twinkle.changeTags);
pageobj.save(function() {
Twinkle.xfd.currentRationale = null; // any errors from now on do not need to print the rationale, as it is safely saved on-wiki
// add this nomination to the user's userspace log
Twinkle.xfd.callbacks.addToLog(params, null);
});
}
}
};
if( type === "afd" || type === "mfd" || type === "tfd" ) {
noinclude = e.target.noinclude.checked;
}
if( type === 'tfd' ) {
if (e.target.xfdtarget) {
xfdtarget = e.target.xfdtarget.value;
}
tfdtype = e.target.templatetype.value;
}
if( type === 'mfd' ) {
notifyuserspace = e.target.notifyuserspace && e.target.notifyuserspace.checked;
}
 
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( e.target );
 
Twinkle.xfd.currentRationale = reason;
Morebits.status.onError(Twinkle.xfd.printRationale);
 
Twinkle.xfd.callback.evaluate = function(e) {
if( !type ) {
var form = e.target;
Morebits.status.error( 'Error', 'no action given' );
return;
}
 
var params = Morebits.quickForm.getInputData(form);
var query, wikipedia_page, wikipedia_api, logpage, params;
var date = new Date();
switch( type ) {
 
Morebits.simpleWindow.setButtonsEnabled(false);
case 'afd': // AFD
Morebits.status.init(form);
query = {
'action': 'query',
'list': 'allpages',
'apprefix': 'Articles for deletion/' + Morebits.pageNameNorm,
'apnamespace': 4,
'apfilterredir': 'nonredirects',
'aplimit': Morebits.userIsInGroup( 'sysop' ) ? 5000 : 500
};
wikipedia_api = new Morebits.wiki.api( 'Tagging article with deletion tag', query, Twinkle.xfd.callbacks.afd.main );
wikipedia_api.params = { usertalk:usertalk, reason:reason, noinclude:noinclude, xfdcat:xfdcat };
wikipedia_api.post();
break;
 
Twinkle.xfd.currentRationale = params.reason;
case 'tfd': // TFD
Morebits.wikistatus.addCheckpointonError(Twinkle.xfd.printRationale);
 
var query, wikipedia_page, wikipedia_api;
if (xfdtarget) {
switch (params.venue) {
xfdtarget = Morebits.string.toUpperCaseFirstChar(xfdtarget.replace(/^\:?Template\:/i, ''));
} else {
xfdtarget = '';
}
 
case 'afd': // AFD
logpage = 'Wikipedia:Templates for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
query = {
action: 'query',
list: 'allpages',
apprefix: 'Articles for deletion/' + Morebits.pageNameNorm,
apnamespace: 4,
apfilterredir: 'nonredirects',
aplimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
format: 'json'
};
wikipedia_api = new Morebits.wiki.api('Tagging article with deletion tag', query, Twinkle.xfd.callbacks.afd.main);
wikipedia_api.params = params;
wikipedia_api.post();
break;
 
case 'tfd': // TFD
params = { tfdtype: tfdtype, logpage: logpage, noinclude: noinclude, xfdcat: xfdcat, target: xfdtarget, reason: reason };
if (params.tfdtarget) { // remove namespace name
params.tfdtarget = utils.stripNs(params.tfdtarget);
}
 
// Modules can't be tagged, TfD instructions are to place on /doc subpage
// Tagging template(s)
params.scribunto = mw.config.get('wgPageContentModel') === 'Scribunto';
if (xfdcat === "tfm") {
if (params.xfdcat === 'tfm') { // Merge
// Tag this template
// Tag this template/module
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging this template with merge tag");
if (params.scribunto) {
wikipedia_page.setFollowRedirect(true);
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName') + '/doc', 'Tagging this module documentation with merge tag');
params.otherTemplateName = "Template:" + xfdtarget;
params.otherTemplateName = 'Module:' + params.tfdtarget;
} else {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging this template with merge tag');
params.otherTemplateName = 'Template:' + params.tfdtarget;
}
} else { // delete
if (params.scribunto) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName') + '/doc', 'Tagging module documentation with deletion tag');
} else {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging template with deletion tag');
}
}
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMergemain);
break;
 
case 'mfd': // MFD
// Tag other template
query = {
wikipedia_page = new Morebits.wiki.page("Template:" + xfdtarget, "Tagging other template with merge tag");
action: 'query',
list: 'allpages',
apprefix: 'Miscellany for deletion/' + Morebits.pageNameNorm,
apnamespace: 4,
apfilterredir: 'nonredirects',
aplimit: 'max', // 500 is max for normal users, 5000 for bots and sysops
format: 'json'
};
wikipedia_api = new Morebits.wiki.api('Looking for prior nominations of this page', query, Twinkle.xfd.callbacks.mfd.main);
wikipedia_api.params = params;
wikipedia_api.post();
break;
 
case 'ffd': // FFD
// Tagging file
// A little out of order with this coming before 'main',
// but tagging doesn't need the uploader parameter,
// while everything else does, so tag then get the uploader
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Adding deletion tag to file page');
wikipedia_page.setFollowRedirect(true);
params = $.extend(params);
params.otherTemplateName = Morebits.pageNameNorm;
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfdffd.taggingTemplateForMergetaggingImage);
break;
} else {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging template with deletion tag");
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.taggingTemplate);
}
 
case 'cfd':
// Updating data for the action completed event
if (params.cfdtarget) {
Morebits.wiki.actionCompleted.redirect = logpage;
params.cfdtarget = utils.stripNs(params.cfdtarget);
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
} else {
params.cfdtarget = ''; // delete
}
if (params.cfdtarget2) { // split
params.cfdtarget2 = utils.stripNs(params.cfdtarget2);
}
 
// Used for customized actions in edit summaries and the notification template
// Adding discussion
var summaryActions = {
wikipedia_page = new Morebits.wiki.page(logpage, "Adding discussion to today's log");
'cfd': 'deletion',
wikipedia_page.setFollowRedirect(true);
'sfd-t': 'deletion',
wikipedia_page.setCallbackParameters(params);
'cfm': 'merging',
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.todaysList);
'cfr': 'renaming',
'sfr-t': 'renaming',
'cfs': 'splitting',
'cfc': 'conversion'
};
params.action = summaryActions[params.xfdcat];
 
// Tagging category
// Notification to first contributor
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging category with ' + params.action + ' tag');
if (usertalk) {
wikipedia_page.setFollowRedirect(true); // should never be needed, but if the page is moved, we would want to follow the redirect
var thispage = new Morebits.wiki.page(mw.config.get('wgPageName'));
thispagewikipedia_page.setCallbackParameters(params);
thispagewikipedia_page.lookupCreatorload(Twinkle.xfd.callbacks.tfdcfd.userNotificationmain);
break;
 
case 'cfds':
// Nice try, but what if the two page creators are the same user?
// add namespace name if missing
// Also, other XFD types don't do this... yet!
params.cfdstarget = utils.addNs(params.cfdstarget, 14);
//if (xfdcat === "tfm") {
// thispage = new Morebits.wiki.page("Template:" + xfdtarget);
// thispage.setCallbackParameters(params);
// thispage.lookupCreator(Twinkle.xfd.callbacks.tfd.userNotification);
//}
}
 
var logpage = 'Wikipedia:Categories for discussion/Speedy';
Morebits.wiki.removeCheckpoint();
break;
 
// Updating data for the action completed event
case 'mfd': // MFD
Morebits.wiki.actionCompleted.redirect = logpage;
query = {
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
'action': 'query',
'list': 'allpages',
'apprefix': 'Miscellany for deletion/' + Morebits.pageNameNorm,
'apnamespace': 4,
'apfilterredir': 'nonredirects',
'aplimit': Morebits.userIsInGroup( 'sysop' ) ? 5000 : 500
};
wikipedia_api = new Morebits.wiki.api( "Looking for prior nominations of this page", query, Twinkle.xfd.callbacks.mfd.main );
wikipedia_api.params = { usertalk: usertalk, notifyuserspace: notifyuserspace, reason: reason, noinclude: noinclude, xfdcat: xfdcat };
wikipedia_api.post();
break;
 
// Tagging category
case 'ffd': // FFD/PUF
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), 'Tagging category with rename tag');
var dateString = date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
wikipedia_page.setFollowRedirect(true);
logpage = 'Wikipedia:Files for discussion/' + dateString;
wikipedia_page.setCallbackParameters(params);
params = { usertalk: usertalk, reason: reason, date: dateString, logpage: logpage };
wikipedia_page.load(Twinkle.xfd.callbacks.cfds.taggingCategory);
 
// Adding discussion to list
Morebits.wiki.addCheckpoint();
wikipedia_page = new Morebits.wiki.page(logpage, 'Adding discussion to the list');
switch( ffdvenue ) {
wikipedia_page.setFollowRedirect(true);
case 'puf':
wikipedia_page.setCallbackParameters(params);
params.logpage = logpage = 'Wikipedia:Possibly unfree files/' + dateString;
wikipedia_page.load(Twinkle.xfd.callbacks.cfds.addToList);
 
break;
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's list";
 
case 'rfd':
// Tagging file
// find target and pass main as the callback
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging file with PUF tag");
Twinkle.xfd.callbacks.rfd.findTarget(params, Twinkle.xfd.callbacks.rfd.main);
wikipedia_page.setFollowRedirect(true);
break;
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.puf.taggingImage);
 
case 'rm':
// Adding discussion
var nomPageName = params.rmtr ?
wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's list");
'Wikipedia:Requested moves/Technical requests' :
wikipedia_page.setFollowRedirect(true);
new mw.Title(Morebits.pageNameNorm).getTalkPage().toText();
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.puf.todaysList);
 
Morebits.wiki.actionCompleted.redirect = nomPageName;
// Notification to first contributor
Morebits.wiki.actionCompleted.notice = 'Nomination completed, now redirecting to the discussion page';
if (usertalk) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreator(Twinkle.xfd.callbacks.puf.userNotification);
}
 
wikipedia_page = new Morebits.wiki.page(nomPageName, params.rmtr ? 'Adding entry at WP:RM/TR' : 'Adding entry on talk page');
Morebits.wiki.removeCheckpoint();
wikipedia_page.setFollowRedirect(true);
break;
 
default:
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to the discussion page";
 
// Tagging file
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Adding deletion tag to file page");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.ffd.taggingImage);
 
// Contributor specific edits
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreator(Twinkle.xfd.callbacks.ffd.main);
break;
}
Morebits.wiki.removeCheckpoint();
break;
 
case 'cfd':
Morebits.wiki.addCheckpoint();
 
if( xfdtarget ) {
xfdtarget = xfdtarget.replace( /^\:?Category\:/i, '' );
} else {
xfdtarget = '';
}
 
if( xfdtarget2 ) {
xfdtarget2 = xfdtarget2.replace( /^\:?Category\:/i, '' );
}
 
logpage = 'Wikipedia:Categories for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
 
params = { reason: reason, xfdcat: xfdcat, target: xfdtarget, target2: xfdtarget2, logpage: logpage };
 
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to today's log";
 
// Tagging category
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging category with deletion tag");
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.taggingCategory);
 
// Adding discussion to list
wikipedia_page = new Morebits.wiki.page(logpage, "Adding discussion to today's list");
//wikipedia_page.setPageSection(2);
// pageSection has been disabled - the API seems to throw up with nonexistent edit conflicts
// it can be turned on again once the problem is fixed, to save bandwidth
//wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfd.todaysList);
 
// Notification to first contributor
if (usertalk) {
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'));
wikipedia_page.setCallbackParameters(params);
wikipedia_page.lookupCreator(Twinkle.xfd.callbacks.cfd.userNotification);
}
 
if (params.rmtr) {
Morebits.wiki.removeCheckpoint();
wikipedia_page.setPageSection(2);
break;
wikipedia_page.load(Twinkle.xfd.callbacks.rm.listAtRMTR);
} else {
// listAtTalk uses .append(), so no need to load the page
Twinkle.xfd.callbacks.rm.listAtTalk(wikipedia_page);
}
break;
 
default:
case 'cfds':
alert('twinklexfd: unknown XFD discussion venue');
xfdtarget = xfdtarget.replace( /^\:?Category\:/, '' );
break;
 
logpage = "Wikipedia:Categories for discussion/Speedy";
params = { reason: reason, xfdcat: xfdcat, target: xfdtarget };
 
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = logpage;
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to the discussion page";
 
// Tagging category
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging category with rename tag");
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfds.taggingCategory);
 
// Adding discussion to list
wikipedia_page = new Morebits.wiki.page(logpage, "Adding discussion to the list");
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.cfds.addToList);
 
break;
 
case 'rfd':
params = { usertalk: usertalk, reason: reason };
if (document.getElementById("softredirect")) {
// For soft redirects, skip straight to the callback
params.target = document.getElementById("softredirect").textContent.replace(/^\:+/, "");
Twinkle.xfd.callbacks.rfd.main(params);
} else {
// Find current target of redirect
query = {
'action': 'query',
'titles': mw.config.get('wgPageName'),
'redirects': true
};
wikipedia_api = new Morebits.wiki.api( "Finding target of redirect", query, Twinkle.xfd.callbacks.rfd.findTargetCallback );
wikipedia_api.params = params;
wikipedia_api.post();
}
break;
default:
alert("twinklexfd: unknown XFD discussion venue");
break;
}
};
 
Twinkle.addInitCallback(Twinkle.xfd, 'xfd');
})(jQuery);
 
 
// </nowiki>
10,498

தொகுப்புகள்

"https://ta.wikipedia.org/wiki/சிறப்பு:MobileDiff/3108521" இருந்து மீள்விக்கப்பட்டது