MediaWiki:Gadget-twinkleprod.js: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Repo at a491314: tracking branch 'upstream/master'; Don't insert a stray comma when endorsing prod (#585); Don't insert a stray comma when endorsing prod |
Repo at 5c1e7e3: Update from Github |
||
Baris 1:
// <nowiki>
(function($) {
Baris 12:
* Active on: Existing articles, files, books which are not redirects,
* and user pages in [[:Category:Wikipedia books (user books)]]
*/
Twinkle.prod = function twinkleprod() {
if
|| !mw.config.get('wgCurRevisionId') || Morebits.wiki.isPageRedirect()
return;
}
Twinkle.addPortletLink(
};
Baris 41 ⟶ 40:
namespace = 'book';
break;
// no default
}
var Window = new Morebits.simpleWindow(
Window.setTitle(
Window.setScriptName(
var form = new Morebits.quickForm(
if (namespace === 'article') {
Window.addFooterLink(
Window.addFooterLink(
} else if (
Window.addFooterLink(
} else {
Window.addFooterLink(
}
var field = form.append(
type: 'field',
label: 'type UP',
id: 'prodtype_fieldset'
}
field.append(
// Placeholder fieldset to be replaced in Twinkle.prod.callback.prodtypechanged
form.append(
type: 'field',
name: 'parameters'
}
Window.addFooterLink('Bantuan
form.append(
var result = form.render();
Window.setContent(
Window.display();
// Hide fieldset for File and Book PROD types since only normal PROD is allowed
if (namespace !== 'article') {
$(result).find('#prodtype_fieldset').hide();
}
// Fake a change event on the first prod type radio, to initialize the type-dependent controls
var evt = document.createEvent(
evt.initEvent(
result.prodtype[0].dispatchEvent(
};
Baris 111:
Twinkle.prod.callback.prodtypechanged = function(event) {
// prepare frame for prod type dependant controls
var field = new Morebits.quickForm.element(
// create prod type dependant controls
switch (
case 'prod':
field.append(
field.append(
break;
Baris 146:
}
field.append(
// temp warning, can be removed down the line once BLPPROD is more established. Amalthea, May 2010.
var boldtext = document.createElement('b');
boldtext.appendChild(document.createTextNode('Ingatlah bahwa hanya biografi tokoh yang masih hidup tanpa referensi yang cocok untuk tag ini.'));
Baris 172:
}
event.target.form.replaceChild(
};
Baris 181:
var params = apiobj.params;
// Check talk page for templates indicating prior XfD or PROD
var numTemplates = $(xmlDoc).find('templates tl').length;
if (
var template = $(xmlDoc).find('templates tl')[0].getAttribute('title');
if (numTemplates === 1 && template === 'Template:Old prod') {
if (params.blp) {
if (!confirm('Previous PROD nomination found on talk page. Do you still want to continue applying BLPPROD? ')) {
statelem.warn('Previous PROD found on talk page, aborted by user');
return;
}
statelem.info('Previous PROD found on talk page, continuing');
}
statelem.warn('Previous PROD found on talk page, aborting procedure');
return;
}
// if there are multiple templates, at least one of them would be a prior xfd template
} else {
statelem.warn(
return;
}
}
var ts = new Morebits.wiki.page(mw.config.get('wgPageName'));
ts.setFollowRedirect(true); // for NPP, and also because redirects are ineligible for PROD
ts.setCallbackParameters(params);
ts.setLookupNonRedirectCreator(true); // Look for author of first non-redirect revision
ts.lookupCreation(Twinkle.prod.callbacks.creationInfo);
},
creationInfo: function(pageobj) {
var params = pageobj.getCallbackParameters();
params.initialContrib = pageobj.getCreator();
params.creation = pageobj.getCreationTimestamp();
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.notice =
var wikipedia_page = new Morebits.wiki.page(mw.config.get('wgPageName'),
wikipedia_page.setFollowRedirect(true); // for NPP, and also because redirects are ineligible for PROD
wikipedia_page.setCallbackParameters(params);
Baris 231 ⟶ 228:
var statelem = pageobj.getStatusElement();
if (
statelem.error(
return;
}
Baris 241 ⟶ 238:
// Check for already existing deletion tags
var tag_re = /{{(?:db-?|delete|article for deletion\/dated|ffd\b)|#invoke:RfD/i;
if (
statelem.warn(
return;
}
// Alert if article is at least three days old, not in Category:Living people, and BLPPROD is selected
if (
var isMoreThan3DaysOld = new Morebits.date(params.creation).add(3, 'days').isAfter(new Date(pageobj.getLoadTime()));
var blpcheck_re = /\[\[Category:Living people\]\]/i;
if (
if (
return;
}
Baris 257 ⟶ 255:
// Remove tags that become superfluous with this action
text = text.replace(/{{\s*(userspace draft|mtc|(copy|move) to wikimedia commons|(copy |move )?to ?commons)\s*(\|(?:{{[^{}]*}}|[^{}])*)?}}\s*/gi,
var prod_re = /{{\s*(?:Prod blp|Proposed deletion|book-prod)\/dated(?: files)?\s*\|(?:{{[^{}]*}}|[^{}])*}}/i;
var summaryText;
if (
// Notification to first contributor
if (
// Disallow warning yourself
if (params.initialContrib === mw.config.get('wgUserName')) {
statelem.warn('You (' + params.initialContrib + ') created this page; skipping user notification');
if (Twinkle.getPref('logProdPages')) {
Twinkle.prod.callbacks.addToLog(params);
}
} else {
// [[Template:Proposed deletion notify]] supports File namespace
var notifyTemplate;
if (params.blp) {
notifyTemplate = 'prodwarningBLP';
} else if (params.book) {
notifyTemplate = 'bprodwarning';
} else {
notifyTemplate = 'proposed deletion notify';
}
var notifytext = '\n{{subst:' + notifyTemplate + '|1=' + Morebits.pageNameNorm + '|concern=' + params.reason + '}} ~~~~';
var usertalkpage = new Morebits.wiki.page('User talk:' + params.initialContrib, 'Notifying initial contributor (' + params.initialContrib + ')');
usertalkpage.setAppendText(notifytext);
usertalkpage.setEditSummary('Notification: proposed deletion of [[:' + Morebits.pageNameNorm + ']].' + Twinkle.getPref('summaryAd'));
usertalkpage.setCreateOption('recreate');
usertalkpage.setFollowRedirect(true);
usertalkpage.setCallbackParameters(params);
usertalkpage.append(function onNotifySuccess() {
// add nomination to the userspace log, if the user has enabled it
if (Twinkle.getPref('logProdPages')) {
params.logInitialContrib = params.initialContrib;
Twinkle.prod.callbacks.addToLog(params);
}
}, function onNotifyError() {
// if user could not be notified, log nomination without mentioning that notification was sent
if (Twinkle.getPref('logProdPages')) {
Twinkle.prod.callbacks.addToLog(params);
}
});
}
} else if (Twinkle.getPref('logProdPages')) { // If not notifying, log this PROD
Twinkle.prod.callbacks.addToLog(params);
}
if (params.blp) {
summaryText =
text =
} else if (params.book) {
summaryText = 'Usulkan penghapusan buku per [[WP:BOOKPROD]].';
text = '{{subst:book-prod|1=' + Morebits.string.formatReasonText(params.reason) + (params.usertalk ? '|help=off' : '') + '}}\n' + text;
} else {
summaryText = 'Usulan penghapusan ' + namespace + ' per [[WP:PROD]].';
text = '{{subst:prod|1=' + Morebits.string.formatReasonText(params.reason) + (params.usertalk ? '|help=off' : '') + '}}\n' + text;
}
Baris 289 ⟶ 317:
var talkpage = new Morebits.wiki.page(talktitle, 'Menambahkan {{Old prod}} di halaman pembicaraan');
talkpage.setPrependText(oldprodfull);
talkpage.setEditSummary('Menambahkan {{Old prod}}
talkpage.setFollowRedirect(true); // match behavior for page tagging
talkpage.setCreateOption('recreate');
talkpage.prepend();
} else { // already tagged for PROD, so try endorsing it
var prod2_re = /{{(?:Proposed deletion endorsed|prod-?2).*?}}/i;
if (prod2_re.test(text)) {
statelem.warn('Halaman sudah ditandai dengan {{proposed deletion}} dan {{proposed deletion endorsed}}, proses dihentikan');
return;
}
var confirmtext =
if (params.blp) {
confirmtext =
// FIXME: this msg is shown even if it was a BLPPROD tag.
}
if (
statelem.warn(
return;
}
summaryText =
text = text.replace(
Morebits.string.formatReasonText(params.reason)) +
if (
params.logEndorsing = true;
Twinkle.prod.callbacks.addToLog(params);
}
}
// curate/patrol the page
if (Twinkle.getPref('markProdPagesAsPatrolled')) {
pageobj.triage();
}
Baris 326 ⟶ 358:
pageobj.setCreateOption('nocreate');
pageobj.save();
},
addToLog: function(params) {
var
usl.initialText =
'Ini merupakan log semua tag [[WP:UP|usulan penghapusan]] yang diberikan atau didukung oleh pengguna ini dengan menggunakan modul UP [[WP:TW|Twinkle]].\n\n' +
'Apabila Anda tidak ingin menyimpan log ini, matikan di [[Wikipedia:Twinkle/Preferences|preferences panel]], dan ' +
'usulkan penghapusan cepat halaman ini dengan kriteria [[WP:KPC#U1|KPC U1]].\n';
var logText = '# [[:' + Morebits.pageNameNorm + ']]';
var summaryText;
// If a logged file is deleted but exists on commons, the wikilink will be blue, so provide a link to the log
logText += namespace === 'file' ? ' ([{{fullurl:Special:Log|page=' + mw.util.wikiUrlencode(mw.config.get('wgPageName')) + '}} log]): ' : ': ';
if (params.logEndorsing) {
if (params.reason) {
}
} else {
if (params.logInitialContrib) {
}
if (!params.blp) {
}
}
usl.log(logText, summaryText + Twinkle.getPref('summaryAd'));
}
};
Baris 425 ⟶ 399:
var prodtype;
if (
var prodtypes = form.prodtype;
for
if (
prodtype = prodtypes[i].values;
break;
Baris 442 ⟶ 416:
};
Morebits.simpleWindow.setButtonsEnabled(
Morebits.status.init(
var talk_title = new mw.Title(mw.config.get('wgPageName')).getTalkPage().getPrefixedText();
// Talk page templates for PROD-able discussions
var blocking_templates = 'Template:Old XfD multi|Template:Old MfD|Template:Oldffdfull|' + // Common prior XfD talk page templates
'Template:Oldpuffull|' + // Legacy prior XfD template
'Template:Olddelrev|' + // Prior DRV template
'Template:Old prod';
var query = {
'action': 'query',
'titles': talk_title,
'prop': 'templates',
'tltemplates': blocking_templates
};
Baris 460 ⟶ 439:
// </nowiki>
|