MediaWiki:Gadget-twinklexfd.js: Difference between revisions

m
1 revision imported
(clean up)
m (1 revision imported)
(One intermediate revision by the same user not shown)
Line 40: Line 40:
Twinkle.xfd.printRationale = function twinklexfdPrintRationale() {
Twinkle.xfd.printRationale = function twinklexfdPrintRationale() {
if (Twinkle.xfd.currentRationale) {
if (Twinkle.xfd.currentRationale) {
var p = document.createElement("p");
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:");
p.textContent = "Your deletion rationale is provided below, which you can copy and paste into a new XFD dialog if you wish to try again:";
var pre = document.createElement("pre");
pre.className = "toccolours";
pre.style.marginTop = "0";
pre.textContent = Twinkle.xfd.currentRationale;
p.appendChild(pre);
Morebits.status.root.appendChild(p);
// only need to print the rationale once
// only need to print the rationale once
Twinkle.xfd.currentRationale = null;
Twinkle.xfd.currentRationale = null;
Line 92: Line 85:
value: 'cfd'
value: 'cfd'
} );
} );
  categories.append( {
categories.append( {
type: 'option',
type: 'option',
label: 'CfD/S (Categories for speedy renaming)',
label: 'CfD/S (Categories for speedy renaming)',
Line 149: Line 142:
var oldreasontextbox = form.getElementsByTagName('textarea')[0];
var oldreasontextbox = form.getElementsByTagName('textarea')[0];
var oldreason = (oldreasontextbox ? oldreasontextbox.value : '');
var oldreason = (oldreasontextbox ? oldreasontextbox.value : '');
 
var appendReasonBox = function twinklexfdAppendReasonBox() {
var appendReasonBox = function twinklexfdAppendReasonBox() {
work_area.append( {
work_area.append( {
Line 235: Line 228:
tfd_category.append( { type: 'option', label: 'Deletion', value: 'tfd', selected: true } );
tfd_category.append( { type: 'option', label: 'Deletion', value: 'tfd', selected: true } );
tfd_category.append( { type: 'option', label: 'Merge', value: 'tfm' } );
tfd_category.append( { type: 'option', label: 'Merge', value: 'tfm' } );
var tfd_template_type = 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.'
} );
tfd_template_type.append( { type: 'option', value: 'standard', label: 'Standard', selected: true } );
tfd_template_type.append( { type: 'option', value: 'sidebar', label: 'Sidebar/infobox' } );
tfd_template_type.append( { type: 'option', value: 'inline', label: 'Inline template' } );
tfd_template_type.append( { type: 'option', value: 'tiny', label: 'Tiny inline' } );
work_area.append( {
work_area.append( {
type: 'checkbox',
type: 'checkbox',
list: [
list: [
{
label: 'Inline deletion tag',
value: 'tfdinline',
name: 'tfdinline',
tooltip: 'Use {{tfd|type=inline}} to tag the page instead of {{tfd}}. Good for inline templates (those that appear amongst the words of text).',
checked: false
},
{
{
label: 'Wrap deletion tag with <noinclude> (for substituted templates only)',
label: 'Wrap deletion tag with <noinclude> (for substituted templates only)',
Line 252: Line 250:
}
}
]
]
} );
} );
 
appendReasonBox();
appendReasonBox();
work_area = work_area.render();
work_area = work_area.render();
Line 307: Line 306:
value: 'ffd',
value: 'ffd',
tooltip: 'General deletion discussion',
tooltip: 'General deletion discussion',
checked: true
checked: mw.config.get('wgNamespaceNumber') === 6
},
},
{
{
Line 317: Line 316:
label: 'Non-free content review',
label: 'Non-free content review',
value: 'nfcr',
value: 'nfcr',
tooltip: 'File\'s compliance with non-free content criteria ([[WP:NFCC]]) is disputed. User notification does not occur for NFCR, as it is not deemed relevant.'
tooltip: 'File\'s compliance with non-free content criteria ([[WP:NFCC]]) is disputed. User notification does not occur for NFCR, as it is not deemed relevant.',
checked: mw.config.get('wgNamespaceNumber') !== 6
}
}
]
]
Line 474: Line 474:


// First, simple test, is there an instance with this exact name?
// First, simple test, is there an instance with this exact name?
if( title === 'Sarkarverse:Articles for deletion/' + Morebits.pageNameNorm ) {
if( title === 'Wikipedia:Articles for deletion/' + Morebits.pageNameNorm ) {
number = Math.max( number, 1 );
number = Math.max( number, 1 );
continue;
continue;
Line 480: Line 480:


var order_re = new RegExp( '^' +
var order_re = new RegExp( '^' +
RegExp.escape( 'Sarkarverse:Articles for deletion/' + Morebits.pageNameNorm, true ) +
RegExp.escape( 'Wikipedia:Articles for deletion/' + Morebits.pageNameNorm, true ) +
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$');
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$');
var match = order_re.exec( title );
var match = order_re.exec( title );
Line 495: Line 495:
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
}
}
apiobj.params.discussionpage = 'Sarkarverse:Articles for deletion/' + Morebits.pageNameNorm + apiobj.params.numbering;
apiobj.params.discussionpage = 'Wikipedia:Articles for deletion/' + Morebits.pageNameNorm + apiobj.params.numbering;


Morebits.status.info( "Next discussion page", "[[" + apiobj.params.discussionpage + "]]" );
Morebits.status.info( "Next discussion page", "[[" + apiobj.params.discussionpage + "]]" );
Line 541: Line 541:
// Today's list
// Today's list
var date = new Date();
var date = new Date();
wikipedia_page = new Morebits.wiki.page('Sarkarverse:Articles for deletion/Log/' + date.getUTCFullYear() + ' ' +
wikipedia_page = new Morebits.wiki.page('Wikipedia:Articles for deletion/Log/' + date.getUTCFullYear() + ' ' +
date.getUTCMonthName() + ' ' + date.getUTCDate(), "Adding discussion to today's list");
date.getUTCMonthName() + ' ' + date.getUTCDate(), "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setFollowRedirect(true);
Line 580: Line 580:
},
},
discussionPage: function(pageobj) {
discussionPage: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();


Line 610: Line 609:
if( text === old_text ) {
if( text === old_text ) {
var linknode = document.createElement('a');
var linknode = document.createElement('a');
linknode.setAttribute("href", mw.util.wikiGetlink("Sarkarverse:Twinkle/Fixing AFD") + "?action=purge" );
linknode.setAttribute("href", mw.util.getUrl("Wikipedia:Twinkle/Fixing AFD") + "?action=purge" );
linknode.appendChild(document.createTextNode('How to fix AFD'));
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, '.' ] );
statelem.error( [ 'Could not find the target spot for the discussion. To fix this problem, please see ', linknode, '.' ] );
Line 634: Line 633:
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();
var initialContrib = pageobj.getCreator();
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 usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:AFDWarning|1=" + Morebits.pageNameNorm + ( params.numbering !== '' ? '|order=&#32;' + params.numbering : '' ) + "}} ~~~~";
var notifytext = "\n{{subst:AFDWarning|1=" + Morebits.pageNameNorm + ( params.numbering !== '' ? '|order=&#32;' + params.numbering : '' ) + "}} ~~~~";
Line 662: Line 668:


pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:template for discussion|help=off|" +
pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:template for discussion|help=off|" +
(params.tfdinline ? "type=inline|" : "") + mw.config.get('wgTitle') + (params.noinclude ? "}}</noinclude>" : "}}\n") + text);
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + mw.config.get('wgTitle') + (params.noinclude ? "}}</noinclude>" : "}}") + text);
pageobj.setEditSummary("Nominated for deletion; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary("Nominated for deletion; see [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
switch (Twinkle.getPref('xfdWatchPage')) {
Line 683: Line 689:


pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:tfm|help=off|" +
pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:tfm|help=off|" +
(params.tfdinline ? "type=inline|1=" : "1=") + params.otherTemplateName.replace(/^Template:/, "") +  
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + "1=" + params.otherTemplateName.replace(/^Template:/, "") +
(params.noinclude ? "}}</noinclude>" : "}}\n") + text);
(params.noinclude ? "}}</noinclude>" : "}}\n") + text);
pageobj.setEditSummary("Nominated for merging with [[" + params.otherTemplateName + "]]; see [[" +  
pageobj.setEditSummary("Nominated for merging with [[" + params.otherTemplateName + "]]; see [[" +
params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
switch (Twinkle.getPref('xfdWatchPage')) {
Line 709: Line 715:
switch( params.xfdcat ) {
switch( params.xfdcat ) {
case 'tfd':
case 'tfd':
added_data = "{{subst:tfd2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:tfd2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "}}";
break;
break;
case 'tfm':
case 'tfm':
added_data = "{{subst:tfm2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:tfm2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
break;
break;
Line 747: Line 753:
var initialContrib = pageobj.getCreator();
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
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 usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n";
var notifytext = "\n";
switch (params.xfdcat) {
switch (params.xfdcat) {
Line 790: Line 802:
if( titles.length <= 0 ) {
if( titles.length <= 0 ) {
apiobj.params.numbering = apiobj.params.number = '';
apiobj.params.numbering = apiobj.params.number = '';
numbering = number = '';
} else {
} else {
var number = 0;
var number = 0;
Line 797: Line 808:


// First, simple test, is there an instance with this exact name?
// First, simple test, is there an instance with this exact name?
if( title === 'Sarkarverse:Miscellany for deletion/' + Morebits.pageNameNorm ) {
if( title === 'Wikipedia:Miscellany for deletion/' + Morebits.pageNameNorm ) {
number = Math.max( number, 1 );
number = Math.max( number, 1 );
continue;
continue;
Line 803: Line 814:


var order_re = new RegExp( '^' +
var order_re = new RegExp( '^' +
RegExp.escape( 'Sarkarverse:Miscellany for deletion/' + Morebits.pageNameNorm, true ) +
RegExp.escape( 'Wikipedia:Miscellany for deletion/' + Morebits.pageNameNorm, true ) +
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$' );
'\\s*\\(\\s*(\\d+)(?:(?:th|nd|rd|st) nom(?:ination)?)?\\s*\\)\\s*$' );
var match = order_re.exec( title );
var match = order_re.exec( title );
Line 818: Line 829:
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
apiobj.params.numbering = number > 0 ? ' (' + apiobj.params.number + ' nomination)' : '';
}
}
apiobj.params.discussionpage = "Sarkarverse:Miscellany for deletion/" + Morebits.pageNameNorm + apiobj.params.numbering;
apiobj.params.discussionpage = "Wikipedia:Miscellany for deletion/" + Morebits.pageNameNorm + apiobj.params.numbering;


apiobj.statelem.info( "next in order is [[" + apiobj.params.discussionpage + ']]');
apiobj.statelem.info( "next in order is [[" + apiobj.params.discussionpage + ']]');
Line 838: Line 849:


// Today's list
// Today's list
wikipedia_page = new Morebits.wiki.page("Sarkarverse:Miscellany for deletion", "Adding discussion to 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.setPageSection(2);
// pageSection has been disabled - the API seems to throw up with nonexistent edit conflicts
// pageSection has been disabled - the API seems to throw up with nonexistent edit conflicts
Line 875: Line 886:
},
},
discussionPage: function(pageobj) {
discussionPage: function(pageobj) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();


pageobj.setPageText("{{subst:mfd2|text=" + Morebits.string.formatReasonText(params.reason) +  
pageobj.setPageText("{{subst:mfd2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|pg=" + Morebits.pageNameNorm + "}}\n");
" ~~~~|pg=" + Morebits.pageNameNorm + "}}\n");
pageobj.setEditSummary("Creating deletion discussion page for [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary("Creating deletion discussion page for [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
Line 935: Line 945:
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();


// Really notify the creator
// Disallow warning yourself
Twinkle.xfd.callbacks.mfd.userNotificationMain(params, initialContrib, "Notifying initial contributor");
if (initialContrib === mw.config.get('wgUserName')) {
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 notify the user who owns the subpage if they are not the creator
// Also notify the user who owns the subpage if they are not the creator
Line 978: Line 993:


// Adding discussion
// Adding discussion
wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's list");
var wikipedia_page = new Morebits.wiki.page(params.logpage, "Adding discussion to today's list");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setCallbackParameters(params);
Line 984: Line 999:


// Notification to first contributor
// Notification to first contributor
if(params.usertalk) {
if (params.usertalk) {
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
// Disallow warning yourself
var notifytext = "\n{{subst:idw|1=" + mw.config.get('wgTitle') + "}}";
if (initialContrib === mw.config.get('wgUserName')) {
usertalkpage.setAppendText(notifytext);
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
usertalkpage.setEditSummary("Notification: listing at [[WP:FFD|files for deletion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
} else {
usertalkpage.setCreateOption('recreate');
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
switch (Twinkle.getPref('xfdWatchUser')) {
var notifytext = "\n{{subst:idw|1=" + mw.config.get('wgTitle') + "}}";
case 'yes':
usertalkpage.setAppendText(notifytext);
usertalkpage.setWatchlist(true);
usertalkpage.setEditSummary("Notification: listing at [[WP:FFD|files for deletion]] of [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
break;
usertalkpage.setCreateOption('recreate');
case 'no':
switch (Twinkle.getPref('xfdWatchUser')) {
usertalkpage.setWatchlistFromPreferences(false);
case 'yes':
break;
usertalkpage.setWatchlist(true);
default:
break;
usertalkpage.setWatchlistFromPreferences(true);
case 'no':
break;
usertalkpage.setWatchlistFromPreferences(false);
break;
default:
usertalkpage.setWatchlistFromPreferences(true);
break;
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
}
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
}
}
},
},
Line 1,036: Line 1,056:
}
}


pageobj.setPageText(text + "\n{{subst:ffd2|Reason=" + Morebits.string.formatReasonText(params.reason) +  
pageobj.setPageText(text + "\n{{subst:ffd2|Reason=" + Morebits.string.formatReasonText(params.reason) +
"|Uploader=" + params.uploader + "|1=" + mw.config.get('wgTitle') + "}} ~~~~");
"|Uploader=" + params.uploader + "|1=" + mw.config.get('wgTitle') + "}} ~~~~");
pageobj.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
Line 1,085: Line 1,105:
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();


pageobj.setPageText(text + "\n{{subst:puf2|reason=" + Morebits.string.formatReasonText(params.reason) +  
pageobj.setPageText(text + "\n{{subst:puf2|reason=" + Morebits.string.formatReasonText(params.reason) +
"|image=" + mw.config.get('wgTitle') + "}} ~~~~");
"|image=" + mw.config.get('wgTitle') + "}} ~~~~");
pageobj.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
Line 1,106: Line 1,126:
userNotification: function(pageobj) {
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
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 usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:idw-puf|1=" + mw.config.get('wgTitle') + "}} ~~~~";
var notifytext = "\n{{subst:idw-puf|1=" + mw.config.get('wgTitle') + "}} ~~~~";
Line 1,189: Line 1,216:
switch( params.xfdcat ) {
switch( params.xfdcat ) {
case 'cfd':
case 'cfd':
added_data = "{{subst:cfd2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:cfd2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "}}";
editsummary = "Added delete nomination of [[:" + Morebits.pageNameNorm + "]].";
editsummary = "Added delete nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
break;
case 'cfm':
case 'cfm':
added_data = "{{subst:cfm2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:cfm2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
editsummary = "Added merge nomination of [[:" + Morebits.pageNameNorm + "]].";
editsummary = "Added merge nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
break;
case 'cfr':
case 'cfr':
added_data = "{{subst:cfr2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:cfr2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
editsummary = "Added rename nomination of [[:" + Morebits.pageNameNorm + "]].";
editsummary = "Added rename nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
break;
case 'cfs':
case 'cfs':
added_data = "{{subst:cfs2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:cfs2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "|3=" + params.target2 + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "|3=" + params.target2 + "}}";
editsummary = "Added split nomination of [[:" + Morebits.pageNameNorm + "]].";
editsummary = "Added split nomination of [[:" + Morebits.pageNameNorm + "]].";
break;
break;
case 'cfc':
case 'cfc':
added_data = "{{subst:cfc2|text=" + Morebits.string.formatReasonText(params.reason) +  
added_data = "{{subst:cfc2|text=" + Morebits.string.formatReasonText(params.reason) +
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
" ~~~~|1=" + mw.config.get('wgTitle') + "|2=" + params.target + "}}";
editsummary = "Added convert nomination of [[:" + Morebits.pageNameNorm + "]].";
editsummary = "Added convert nomination of [[:" + Morebits.pageNameNorm + "]].";
Line 1,218: Line 1,245:
}
}


text = old_text.replace( 'below this line -->', "below this line -->\n" + added_data );
var text = old_text.replace( 'below this line -->', "below this line -->\n" + added_data );
if( text === old_text ) {
if( text === old_text ) {
statelem.error( 'failed to find target spot for the discussion' );
statelem.error( 'failed to find target spot for the discussion' );
Line 1,244: Line 1,271:
userNotification: function(pageobj) {
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
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 usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:CFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
var notifytext = "\n{{subst:CFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
Line 1,294: Line 1,327:


var newcatname = (/^Category:/.test(params.target) ? params.target : ("Category:" + params.target));
var newcatname = (/^Category:/.test(params.target) ? params.target : ("Category:" + params.target));
text = old_text.replace( 'BELOW THIS LINE -->', "BELOW THIS LINE -->\n* [[:" + Morebits.pageNameNorm + "]] to [[:" +
var text = old_text.replace( 'BELOW THIS LINE -->', "BELOW THIS LINE -->\n* [[:" + Morebits.pageNameNorm + "]] to [[:" +
newcatname + "]]\u00A0\u2013 " + params.xfdcat + (params.reason ? (": " + Morebits.string.formatReasonText(params.reason)) : ".") +  
newcatname + "]]\u00A0\u2013 " + params.xfdcat + (params.reason ? (": " + Morebits.string.formatReasonText(params.reason)) : ".") +
" ~~~~" );
" ~~~~" );
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
// U+00A0 NO-BREAK SPACE; U+2013 EN RULE
Line 1,338: Line 1,371:
main: function(params) {
main: function(params) {
var date = new Date();
var date = new Date();
params.logpage = 'Sarkarverse:Redirects for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
params.logpage = 'Wikipedia:Redirects for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();


// Tagging redirect
// Tagging redirect
Line 1,367: Line 1,400:
var params = pageobj.getCallbackParameters();
var params = pageobj.getCallbackParameters();


pageobj.setPageText("{{subst:rfd}}\n" + text);
pageobj.setPageText("{{subst:rfd|content=\n" + text + "\n}}");
pageobj.setEditSummary("Listed for discussion at [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setEditSummary("Listed for discussion at [[" + params.logpage + "#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
switch (Twinkle.getPref('xfdWatchPage')) {
switch (Twinkle.getPref('xfdWatchPage')) {
Line 1,416: Line 1,449:
userNotification: function(pageobj) {
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
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 usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:RFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
var notifytext = "\n{{subst:RFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
Line 1,444: Line 1,484:
var usertalk = e.target.notify.checked;
var usertalk = e.target.notify.checked;
var reason = e.target.xfdreason.value;
var reason = e.target.xfdreason.value;
var xfdcat, xfdtarget, xfdtarget2, ffdvenue, noinclude, tfdinline, notifyuserspace;
var xfdcat, xfdtarget, xfdtarget2, ffdvenue, noinclude, tfdtype, notifyuserspace;
if( type === "afd" || type === "cfd" || type === "cfds" || type === "tfd" ) {
if( type === "afd" || type === "cfd" || type === "cfds" || type === "tfd" ) {
xfdcat = e.target.xfdcat.value;
xfdcat = e.target.xfdcat.value;
Line 1,469: Line 1,509:
}
}
if( type === 'tfd' ) {
if( type === 'tfd' ) {
tfdinline = e.target.tfdinline.checked;
if (e.target.xfdtarget) {
if (e.target.xfdtarget) {
xfdtarget = e.target.xfdtarget.value;
xfdtarget = e.target.xfdtarget.value;
}
}
tfdtype = e.target.templatetype.value;
}
}
if( type === 'mfd' ) {
if( type === 'mfd' ) {
Line 1,516: Line 1,556:
}
}


logpage = 'Sarkarverse:Templates for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
logpage = 'Wikipedia:Templates for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
params = { tfdinline: tfdinline, logpage: logpage, noinclude: noinclude, xfdcat: xfdcat, target: xfdtarget, reason: reason };
 
params = { tfdtype: tfdtype, logpage: logpage, noinclude: noinclude, xfdcat: xfdcat, target: xfdtarget, reason: reason };


// Tagging template(s)
// Tagging template(s)
Line 1,527: Line 1,568:
wikipedia_page.setCallbackParameters(params);
wikipedia_page.setCallbackParameters(params);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge);
wikipedia_page.load(Twinkle.xfd.callbacks.tfd.taggingTemplateForMerge);
 
// Tag other template
// Tag other template
wikipedia_page = new Morebits.wiki.page("Template:" + xfdtarget, "Tagging other template with merge tag");
wikipedia_page = new Morebits.wiki.page("Template:" + xfdtarget, "Tagging other template with merge tag");
Line 1,557: Line 1,598:
thispage.setCallbackParameters(params);
thispage.setCallbackParameters(params);
thispage.lookupCreator(Twinkle.xfd.callbacks.tfd.userNotification);
thispage.lookupCreator(Twinkle.xfd.callbacks.tfd.userNotification);
 
// Nice try, but what if the two page creators are the same user?
// Nice try, but what if the two page creators are the same user?
// Also, other XFD types don't do this... yet!
// Also, other XFD types don't do this... yet!
Line 1,586: Line 1,627:
case 'ffd': // FFD/PUF/NFCR
case 'ffd': // FFD/PUF/NFCR
var dateString = date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
var dateString = date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
logpage = 'Sarkarverse:Files for deletion/' + dateString;
logpage = 'Wikipedia:Files for deletion/' + dateString;
params = { usertalk: usertalk, reason: reason, date: dateString, logpage: logpage };
params = { usertalk: usertalk, reason: reason, date: dateString, logpage: logpage };


Line 1,592: Line 1,633:
switch( ffdvenue ) {
switch( ffdvenue ) {
case 'puf':
case 'puf':
params.logpage = logpage = 'Sarkarverse:Possibly unfree files/' + dateString;
params.logpage = logpage = 'Wikipedia:Possibly unfree files/' + dateString;


// Updating data for the action completed event
// Updating data for the action completed event
Line 1,622: Line 1,663:
case 'nfcr':
case 'nfcr':
// Updating data for the action completed event
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = "Sarkarverse:Non-free content review";
Morebits.wiki.actionCompleted.redirect = "Wikipedia:Non-free content review";
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to the discussion page";
Morebits.wiki.actionCompleted.notice = "Nomination completed, now redirecting to the discussion page";


// Tagging file
// Tagging file
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging file with review tag");
if (mw.config.get('wgNamespaceNumber') === 6) {
wikipedia_page.setFollowRedirect(true);
wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'), "Tagging file with review tag");
wikipedia_page.setPrependText("{{non-free review}}\n");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setEditSummary("This image has been listed for review at [[Sarkarverse:Non-free content review#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
wikipedia_page.setPrependText("{{non-free review}}\n");
switch (Twinkle.getPref('xfdWatchPage')) {
wikipedia_page.setEditSummary("This file" +
case 'yes':
" has been listed for review at [[Wikipedia:Non-free content review#" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
wikipedia_page.setWatchlist(true);
switch (Twinkle.getPref('xfdWatchPage')) {
break;
case 'yes':
case 'no':
wikipedia_page.setWatchlist(true);
wikipedia_page.setWatchlistFromPreferences(false);
break;
break;
case 'no':
default:
wikipedia_page.setWatchlistFromPreferences(false);
wikipedia_page.setWatchlistFromPreferences(true);
break;
break;
default:
wikipedia_page.setWatchlistFromPreferences(true);
break;
}
wikipedia_page.setCreateOption('recreate');  // it might be possible for a file to exist without a description page
wikipedia_page.prepend();
}
}
wikipedia_page.setCreateOption('recreate');  // it might be possible for a file to exist without a description page
wikipedia_page.prepend();


// Adding discussion
// Adding discussion
wikipedia_page = new Morebits.wiki.page("Sarkarverse:Non-free content review", "Adding discussion to the NFCR page");
wikipedia_page = new Morebits.wiki.page("Wikipedia:Non-free content review", "Adding discussion to the NFCR page");
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setFollowRedirect(true);
wikipedia_page.setAppendText("\n\n== [[:" + Morebits.pageNameNorm + "]] ==\n\n" +  
wikipedia_page.setAppendText("\n\n== [[:" + Morebits.pageNameNorm + "]] ==\n\n" +
Morebits.string.formatReasonText(params.reason) + " ~~~~");
Morebits.string.formatReasonText(params.reason) + " ~~~~");
wikipedia_page.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
wikipedia_page.setEditSummary("Adding [[" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
Line 1,670: Line 1,714:
Morebits.wiki.removeCheckpoint();
Morebits.wiki.removeCheckpoint();
break;
break;
 
default:
default:
// Updating data for the action completed event
// Updating data for the action completed event
Line 1,704: Line 1,748:
}
}


logpage = 'Sarkarverse:Categories for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
logpage = 'Wikipedia:Categories for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();


params = { reason: reason, xfdcat: xfdcat, target: xfdtarget, target2: xfdtarget2, logpage: logpage };
params = { reason: reason, xfdcat: xfdcat, target: xfdtarget, target2: xfdtarget2, logpage: logpage };
Line 1,739: Line 1,783:
xfdtarget = xfdtarget.replace( /^\:?Category\:/, '' );
xfdtarget = xfdtarget.replace( /^\:?Category\:/, '' );


logpage = "Sarkarverse:Categories for discussion/Speedy";
logpage = "Wikipedia:Categories for discussion/Speedy";
params = { reason: reason, xfdcat: xfdcat, target: xfdtarget };
params = { reason: reason, xfdcat: xfdcat, target: xfdtarget };