MediaWiki:Gadget-twinklexfd.js: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Repo at d9666d4: Update Twinkle from upstream |
Repo at a491314: put repeated code into a function; Use indexOf instead of startsWith, the latter isn't supported in IE 11 (#619); add delsort to afd (#580); add delsort to afd; Adjust edit summaries for parallelism and to be more helpful (#583); Use indexOf instead of startsWith, the latter isn't supported in IE 11; Adjust edit summaries for parallelism and to be more helpful; Fix broken AfD category sorting |
||
Baris 22:
return;
}
Twinkle.addPortletLink( Twinkle.xfd.callback, "XFD", "tw-xfd", "
};
Baris 47:
Twinkle.xfd.callback = function twinklexfdCallback() {
var Window = new Morebits.simpleWindow( 600, 350 );
Window.setTitle( "
Window.setScriptName( "Twinkle" );
Window.addFooterLink( "About deletion discussions", "WP:XFD" );
Baris 94:
type: 'option',
label: 'MfD (Miscellany for deletion)',
selected: [ 0, 6, 10, 14, 828 ].indexOf(namespace) === -1 || Morebits.pageNameNorm.
//Other namespaces, and userboxes in template namespace
value: 'mfd'
Baris 203:
afd_category.append( { type:'option', label:'Indiscernible or unclassifiable topic', value:'I' } );
afd_category.append( { type:'option', label:'Debate not yet sorted', value:'U' } );
// delsort categories list copied off [[User:Enterprisey/delsort.js]], originally taken from [[WP:DS/C]]
var delsortCategories = {
"People": ["People", "Academics and educators", "Actors and filmmakers", "Artists", "Authors", "Bands and musicians", "Businesspeople", "Politicians", "Sportspeople", "Women", "Lists of people"],
"Arts": ["Arts", "Fictional elements", "Science fiction"],
"Arts/Culinary": ["Food and drink", "Wine"],
"Arts/Language": ["Language", "Academic journals", "Bibliographies", "Journalism", "Literature", "Logic", "News media", "Philosophy", "Poetry"],
"Arts/Performing": ["Albums and songs", "Dance", "Film", "Magic", "Music", "Radio", "Television", "Theatre", "Video games"],
"Arts/Visual arts": ["Visual arts", "Architecture", "Fashion", "Photography"],
"Arts/Comics and animation": ["Comics and animation", "Anime and manga", "Webcomics"],
"Places of interest": ["Museums and libraries", "Shopping malls"],
"Topical": ["Animal", "Bilateral relations", "Business", "Conservatism", "Conspiracy theories", "Crime", "Disability", "Discrimination", "Ethnic groups", "Events", "Games", "Health and fitness", "History", "Law", "Military", "Organizations", "Paranormal", "Piracy", "Politics", "Terrorism"],
"Topical/Business": ["Business", "Advertising", "Companies", "Management", "Finance"],
"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", "Economics", "Environment", "Geography", "Mathematics", "Medicine", "Organisms", "Social science", "Transportation"],
"Topical/Sports": ["Sports", "American football", "Baseball", "Basketball", "Bodybuilding", "Boxing", "Cricket", "Cycling", "Football", "Golf", "Horse racing", "Ice hockey", "Rugby union", "Softball", "Martial arts", "Wrestling"],
"Topical/Technology": ["Technology", "Aviation", "Computing", "Firearms", "Internet", "Software", "Websites"],
"Wikipedia page type": ["Disambiguations", "Lists"],
"Geographic/Africa": ["Africa", "Egypt", "Ethiopia", "Ghana", "Kenya", "Laos", "Mauritius", "Morocco", "Nigeria", "Somalia", "South Africa", "Zimbabwe"],
"Geographic/Asia": ["Asia", "Afghanistan", "Bangladesh", "Bahrain", "Brunei", "Cambodia", "China", "Hong Kong", "India", "Indonesia", "Japan", "Korea", "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", "Iran", "Iraq", "Israel", "Jordan", "Kuwait", "Lebanon", "Libya", "Palestine", "Saudi Arabia", "Syria", "United Arab Emirates", "Yemen", "Qatar"],
"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", "Macedonia", "Malta", "Moldova", "Montenegro", "Netherlands", "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", "British Columbia", "Manitoba", "Nova Scotia", "Ontario", "Quebec", "Alberta"],
"Geographic/Americas/Latin America": ["Latin America", "Caribbean", "South America", "Argentina", "Barbados", "Belize", "Bolivia", "Brazil", "Chile", "Colombia", "Cuba", "Ecuador", "El Salvador", "Guatemala", "Haiti", "Mexico", "Nicaragua", "Panama", "Paraguay", "Peru", "Puerto Rico", "Trinidad and Tobago", "Uruguay", "Venezuela", "Grenada"],
"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( {
type: 'select',
multiple: true,
name: 'delsort',
label: 'Choose deletion sorting categories: ',
tooltip: 'Select a few categories that are relevant to the subject of the article'
} );
$.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 );
// TODO: Add to the gadget definition if used elsewhere
mw.loader.using('jquery.chosen').then(function chosenInit() {
$(work_area).find('[name=delsort]')
.attr('data-placeholder', 'Select delsort pages')
.chosen({width: "100%"});
});
break;
case 'tfd':
Baris 456 ⟶ 511:
}
};
Twinkle.xfd.setWatchPref = function twinklexfdsetWatchPref(pageobj, pref) {
switch (pref) {
case 'yes':
pageobj.setWatchlist(true);
break;
case 'no':
pageobj.setWatchlistFromPreferences(false);
break;
default:
pageobj.setWatchlistFromPreferences(true);
break;
}
}
Twinkle.xfd.callbacks = {
Baris 476 ⟶ 545:
if (venue === "afd" || venue === "mfd") {
text += "|pg=" + Morebits.pageNameNorm;
if (venue === "afd") {
text += "|cat=" + params.xfdcat;
}
} else if (venue === "rfd") {
text += "|redirect=" + Morebits.pageNameNorm;
Baris 500 ⟶ 572:
text += "}}";
if (params.delsort_cats) { // Only for AFDs
params.delsort_cats.forEach(function (cat) {
text += "\n{{subst:delsort|" + cat + "|~~~~}}";
});
}
return text;
},
Baris 521 ⟶ 600:
params.target2 = form.xfdtarget2.value;
}
params.delsort_cats = $(form.delsort).val();
if (venue === "ffd") {
Baris 636 ⟶ 716:
thispage.setCallbackParameters(params);
thispage.lookupCreator(Twinkle.xfd.callbacks.afd.userNotification);
}
// List at deletion sorting pages
if (params.delsort_cats) {
params.delsort_cats.forEach(function (cat) {
var delsortPage = new Morebits.wiki.page("Wikipedia:WikiProject Deletion sorting/" + cat, 'Adding to list of ' + cat + '-related deletion discussions');
delsortPage.setCallbackParameters({discussionPage: params.discussionpage});
delsortPage.load(Twinkle.xfd.callbacks.afd.delsortListing);
});
}
Baris 649 ⟶ 738:
params.number + "|help=off")) + (params.noinclude ? "}}</noinclude>\n" : "}}\n") + text);
pageobj.setEditSummary("Nominated for deletion; see [[:" + params.discussionpage + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('nocreate');
pageobj.save();
Baris 668 ⟶ 747:
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext("afd", params));
pageobj.setEditSummary("Creating deletion discussion page for [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Baris 699 ⟶ 768:
pageobj.setPageText(text);
pageobj.setEditSummary("Adding [[:" + params.discussionpage + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save();
Baris 726 ⟶ 785:
var notifytext = "\n{{subst:AFDWarning|1=" + Morebits.pageNameNorm + ( params.numbering !== '' ? '|order= ' + params.numbering : '' ) + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification:
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
},
delsortListing: 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 +']].' + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('nocreate');
pageobj.save();
}
},
Baris 753 ⟶ 810:
pageobj.setPageText((params.noinclude ? "<noinclude>" : "") + "{{subst:template for discussion|help=off" +
(params.tfdtype !== "standard" ? "|type=" + params.tfdtype : "") + (params.noinclude ? "}}</noinclude>" : "}}") + tableNewline + text);
pageobj.setEditSummary("Nominated for deletion; see [[:" + params.
pageobj.setCreateOption('recreate'); // Module /doc might not exist
pageobj.save();
Baris 776 ⟶ 823:
(params.tfdtype !== "standard" ? "type=" + params.tfdtype + "|" : "") + "1=" + params.otherTemplateName.replace(/^(?:Template|Module):/, "") +
(params.noinclude ? "}}</noinclude>" : "}}") + tableNewline + text);
pageobj.setEditSummary("
pageobj.setCreateOption('recreate'); // Module /doc might not exist
pageobj.save();
Baris 805 ⟶ 841:
}
pageobj.setPageText(text);
pageobj.setEditSummary("Adding " + (params.xfdcat === 'tfd' ? 'deletion nomination' : 'merge listing') + " of [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Baris 848 ⟶ 874:
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification:
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
Baris 945 ⟶ 961:
(params.noinclude ? "</noinclude>" : "") + text);
pageobj.setEditSummary("Nominated for deletion; see [[:" + params.discussionpage + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('nocreate');
pageobj.save();
Baris 964 ⟶ 970:
pageobj.setPageText(Twinkle.xfd.callbacks.getDiscussionWikitext("mfd", params));
pageobj.setEditSummary("Creating deletion discussion page for [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('createonly');
pageobj.save(function() {
Baris 1.000 ⟶ 996:
pageobj.setPageText(text);
pageobj.setEditSummary("Adding [[:" + params.discussionpage + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save();
Baris 1.039 ⟶ 1.025:
var notifytext = "\n{{subst:MFDWarning|1=" + Morebits.pageNameNorm + ( params.numbering !== '' ? '|order= ' + params.numbering : '' ) + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification:
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
Baris 1.080 ⟶ 1.056:
var notifytext = "\n{{subst:fdw|1=" + mw.config.get('wgTitle') + "}}";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification:
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
Baris 1.105 ⟶ 1.071:
pageobj.setPageText("{{ffd|log=" + params.date + "|help=off}}\n" + text);
pageobj.setEditSummary("Listed for discussion at [[:" + params.
pageobj.setCreateOption('recreate'); // it might be possible for a file to exist without a description page
pageobj.save();
Baris 1.131 ⟶ 1.087:
pageobj.setPageText(text + "\n\n" + Twinkle.xfd.callbacks.getDiscussionWikitext("ffd", params));
pageobj.setEditSummary("Adding [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Baris 1.160 ⟶ 1.106:
case 'cfd':
added_data = "{{subst:cfd}}";
editsummary = "Category being considered for deletion; see [[:" + params.
break;
case 'cfm':
added_data = "{{subst:cfm|" + params.target + "}}";
editsummary = "Category being considered for merging; see [[:" + params.
break;
case 'cfr':
added_data = "{{subst:cfr|" + params.target + "}}";
editsummary = "Category being considered for renaming; see [[:" + params.
break;
case 'cfs':
added_data = "{{subst:cfs|" + params.target + "|" + params.target2 + "}}";
editsummary = "Category being considered for splitting; see [[:" + params.
break;
case 'cfc':
added_data = "{{subst:cfc|" + params.target + "}}";
editsummary = "Category being considered for conversion to an article; see [[:" + params.
break;
default:
Baris 1.185 ⟶ 1.131:
pageobj.setPageText(added_data + "\n" + text);
pageobj.setEditSummary(editsummary + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save();
Baris 1.212 ⟶ 1.148:
cfc: 'convert'
};
var editsummary = '
var text = old_text.replace( 'below this line -->', "below this line -->\n" + added_data );
Baris 1.222 ⟶ 1.158:
pageobj.setPageText(text);
pageobj.setEditSummary(editsummary + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Baris 1.240 ⟶ 1.166:
userNotification: function(pageobj) {
var initialContrib = pageobj.getCreator();
var params = pageobj.getCallbackParameters();
// Disallow warning yourself
Baris 1.250 ⟶ 1.177:
var notifytext = "\n{{subst:cfd-notify|1=" + Morebits.pageNameNorm + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification:
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
Baris 1.275 ⟶ 1.192:
pageobj.setPageText("{{subst:cfr-speedy|1=" + params.target + "}}\n" + text);
pageobj.setEditSummary("
pageobj.setCreateOption('recreate'); // since categories can be populated without an actual page at that title
pageobj.save();
Baris 1.304 ⟶ 1.211:
pageobj.setPageText(text);
pageobj.setEditSummary("Adding [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Baris 1.360 ⟶ 1.257:
var date = new Date();
params.logpage = 'Wikipedia:Redirects for discussion/Log/' + date.getUTCFullYear() + ' ' + date.getUTCMonthName() + ' ' + date.getUTCDate();
params.discussionpage = params.logpage + "#" + Morebits.pageNameNorm;
// Tagging redirect
Baris 1.389 ⟶ 1.287:
pageobj.setPageText("{{subst:rfd|content=\n" + text + "\n}}");
pageobj.setEditSummary("Listed for discussion at [[:" + params.
pageobj.setCreateOption('nocreate');
pageobj.save();
Baris 1.419 ⟶ 1.307:
pageobj.setPageText(text);
pageobj.setEditSummary("Adding [[:" + Morebits.pageNameNorm + "]]." + Twinkle.getPref('summaryAd'));
pageobj.setCreateOption('recreate');
pageobj.save(function() {
Baris 1.445 ⟶ 1.323:
pageobj.getStatusElement().warn("You (" + initialContrib + ") created this page; skipping user notification");
} else {
Twinkle.xfd.callbacks.rfd.userNotification(params, initialContrib);
}
}
Baris 1.465 ⟶ 1.343:
}
} else {
Twinkle.xfd.callbacks.rfd.targetNotification(params, targetTalk);
}
}
},
userNotification: function(params, initialContrib) {
var usertalkpage = new Morebits.wiki.page('User talk:' + initialContrib, "Notifying initial contributor (" + initialContrib + ")");
var notifytext = "\n{{subst:RFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary("Notification:
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.append();
},
targetNotification: function(params, targetTalk) {
var targettalkpage = new Morebits.wiki.page(targetTalk, "Notifying redirect target of the discussion");
var notifytext = "\n{{subst:RFDNote|1=" + Morebits.pageNameNorm + "}} ~~~~";
targettalkpage.setAppendText(notifytext);
targettalkpage.setEditSummary("Notification:
targettalkpage.setCreateOption('recreate');
targettalkpage.setFollowRedirect(true);
targettalkpage.append();
Baris 1.518 ⟶ 1.376:
var usertalk = e.target.notify.checked;
var reason = e.target.xfdreason.value;
var delsort_cats = $(e.target.delsort).val();
var xfdcat, xfdtarget, xfdtarget2, noinclude, tfdtype, notifyuserspace, relatedpage;
if( type === "afd" || type === "cfd" || type === "cfds" || type === "tfd" ) {
Baris 1.569 ⟶ 1.428:
};
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, delsort_cats:delsort_cats };
wikipedia_api.post();
break;
Baris 1.584 ⟶ 1.444:
params = { tfdtype: tfdtype, logpage: logpage, noinclude: noinclude, xfdcat: xfdcat, target: xfdtarget, reason: reason };
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Modules can't be tagged, TfD instructions are to place on /doc subpage
Baris 1.678 ⟶ 1.539:
logpage = 'Wikipedia:Files for discussion/' + dateString;
params = { usertalk: usertalk, reason: reason, date: dateString, logpage: logpage };
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
Morebits.wiki.addCheckpoint();
Baris 1.715 ⟶ 1.577:
params = { reason: reason, xfdcat: xfdcat, target: xfdtarget, target2: xfdtarget2, logpage: logpage };
params.discussionpage = params.logpage + '#' + Morebits.pageNameNorm;
// Updating data for the action completed event
|