MediaWiki:Gadget-twinkleprotect.js: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Repo at a491314: tracking branch 'upstream/master'; re-enable check for flaggedrevs/pending changes being enabled; Don't fail if flaggedrevs/pending changes aren't enabled"
Repo at 5c1e7e3: Add missing 'protection' to ECP message; Don't ask to remove tags if you've chosen to remove them; Remove erroneous selected: true for pp-dispute; Fix bug affecting untagging on PC-ineligible namespaces; Add error message for occasional PC-application failure; Add section link at rpp; use API text output to check if page is redirect; Remove PC option entirely on inappropriate namespaces (#738); overhaul action complete status messages; Hide on mediawiki pages (#640)
 
Baris 1:
// <nowiki>
 
 
(function($) {
 
 
Baris 10:
****************************************
* Mode of invocation: Tab ("PP"/"RPP")
* Active on: Non-special, non-MediaWiki pages
* Config directives in: TwinkleConfig
*/
 
Baris 17 ⟶ 16:
 
Twinkle.protect = function twinkleprotect() {
if ( mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgNamespaceNumber') === 8) {
return;
}
 
Twinkle.addPortletLink(Twinkle.protect.callback, Morebits.userIsInGroup('sysop')userIsSysop ? "'PP"' : "'RPP"', "'tw-rpp"',
Morebits.userIsInGroup('sysop')userIsSysop ? "'Lindungi halaman"' : "'Permintaan perlindungan halaman" ');
};
 
Twinkle.protect.callback = function twinkleprotectCallback() {
var Window = new Morebits.simpleWindow( 620, 530 );
Window.setTitle( Morebits.userIsInGroup( 'sysop' )userIsSysop ? "'Terapkan, meminta atau menandai halaman terlindungi"' : "'Minta atau tandai perlindungan halaman" ');
Window.setScriptName( "'Twinkle" ');
Window.addFooterLink( "'Templat perlindungan"', "'Templat:Templat perlindungan" ');
Window.addFooterLink( "'Kebijakan perlindungan"', "'WP:LINDUNG" ');
Window.addFooterLink( "'Bantuan Twinkle"', "'WP:TW/DOC#protect" ');
 
var form = new Morebits.quickForm( Twinkle.protect.callback.evaluate );
var actionfield = form.append( {
type: 'field',
label: 'Jenis tindakan'
} );
if ( Morebits.userIsInGroup( 'sysop' ) userIsSysop) {
actionfield.append( {
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: 'Lindungi halaman',
value: 'protect',
tooltip: 'Terapkan perlindungan ke halaman ini.',
checked: true
}
]
} );
}
actionfield.append( {
type: 'radio',
name: 'actiontype',
Baris 59 ⟶ 44:
list: [
{
label: 'Meminta perlindunganLindungi halaman',
value: 'requestprotect',
tooltip: 'Terapkan perlindungan ke halaman ini.',
tooltip: 'Jika Anda ingin meminta perlindungan halaman melalui WP:RPP' + (Morebits.userIsInGroup('sysop') ? ' alih-alih melindunginya sendiri.' : '.'),
checked: !Morebits.userIsInGroup('sysop')true
},
{
label: 'Tandai halaman dengan templat perlindungan',
value: 'tag',
tooltip: 'Jika pengurus yang melakukan perlindungan lupa memberi templat, atau Anda sudah melindunginya tanpa menandai, Anda dapat menggunakan ini untuk menandai tag yang cocok.',
disabled: mw.config.get('wgArticleId') === 0 || mw.config.get('wgPageContentModel') === 'Scribunto'
}
]
} );
}
actionfield.append({
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: 'Meminta perlindungan halaman',
value: 'request',
tooltip: 'Jika Anda ingin meminta perlindungan halaman melalui WP:RPP' + (Morebits.userIsSysop ? ' alih-alih melindunginya sendiri.' : '.'),
checked: !Morebits.userIsSysop
},
{
label: 'Tandai halaman dengan templat perlindungan',
value: 'tag',
tooltip: 'Jika pengurus yang melakukan perlindungan lupa memberi templat, atau Anda sudah melindunginya tanpa menandai, Anda dapat menggunakan ini untuk menandai tag yang cocok.',
disabled: mw.config.get('wgArticleId') === 0 || mw.config.get('wgPageContentModel') === 'Scribunto'
}
]
});
 
form.append({ type: 'field', label: 'Jenis pengaturan', name: 'field_preset' });
Baris 77 ⟶ 76:
form.append({ type: 'field', label: '2', name: 'field2' });
 
form.append( { type: 'submit' } );
 
var result = form.render();
Window.setContent( result );
Window.display();
 
// We must init the controls
var evt = document.createEvent( "'Event" ');
evt.initEvent( 'change', true, true );
result.actiontype[0].dispatchEvent( evt );
 
Morebits.wiki.actionCompleted.postfix = false; // avoid Action: completed notice
 
// get current protection level asynchronously
Baris 110 ⟶ 107:
letitle: pageName,
letype: protType
}).then(function( data ) {
// don't check log entries that have already been checked (e.g. don't go into an infinite loop!)
var event = data.query ? $.grep(data.query.logevents, function(le) {
return $.inArray(le.logid, logIds);
})[0] : null;
if (!event) {
// fail gracefully
return null;
} else if (event.action === "'move_prot"' || event.action === "'move_stable"') {
return twinkleprotectFetchProtectingAdmin( api, (protType === 'protect' ? event.params.oldtitle_title : event.params.oldtitle), protType, logIds.concat(event.logid) );
} else {
return event.user;
}
return event.user;
});
};
Baris 138 ⟶ 136:
letype: 'protect',
letitle: mw.config.get('wgPageName'),
prop: (mw.loader.getState('ext.flaggedRevs.review') ? 'info|flagged' : 'info'),
inprop: 'protection',
titles: mw.config.get('wgPageName')
Baris 155 ⟶ 153:
}
 
$.when.apply($, earlyDecision).done(function(protectData, stableData) {
// $.when.apply is supposed to take an unknown number of promises
// via an array, which it does, but the type of data returned varies.
Baris 167 ⟶ 165:
var current = {}, adminEditDeferred;
 
$.each(page.protection, function( index, protection ) {
if (protection.type !== "'aft"') {
current[protection.type] = {
level: protection.level,
Baris 215 ⟶ 213:
 
if (Twinkle.protect.hasProtectLog || Twinkle.protect.hasStableLog) {
var $linkMarkup = $("'<span>"');
 
if (Twinkle.protect.hasProtectLog) {
$linkMarkup.append(
$( '<a target="_blank" href="' + mw.util.getUrl('Special:Log', {action: 'view', page: mw.config.get('wgPageName'), type: 'protect'}) + '">log perlindungan</a>' ),
Twinkle.protect.hasStableLog ? $("'<span> &bull; </span>"') : null
);
}
 
if (Twinkle.protect.hasStableLog) {
$linkMarkup.append($( '<a target="_blank" href="' + mw.util.getUrl('Special:Log', {action: 'view', page: mw.config.get('wgPageName'), type: 'stable'}) + '">log perubahan tertunda</a>)' ));
}
 
Baris 241 ⟶ 239:
$.each(Twinkle.protect.currentProtectionLevels, function(type, settings) {
var label = type === 'stabilize' ? 'Perubahan tertunda' : Morebits.string.toUpperCaseFirstChar(type);
protectionNode.push($("'<b>"' + label + "': "' + settings.level + "'</b>"')[0]);
if (settings.expiry === 'infinity') {
protectionNode.push("' (indefinite) "');
} else {
protectionNode.push("' (expires "' + new Date(settings.expiry).toUTCString() + "') "');
}
if (settings.cascade) {
protectionNode.push("'(cascading) "');
}
if (settings.admin) {
var adminLink = '<a target="_blank" href="' + mw.util.getUrl('User talk:' + settings.admin) + '">' + settings.admin + '</a>';
protectionNode.push($("'<span>by "' + adminLink + "'&nbsp;</span>"')[0]);
}
protectionNode.push($("'<span> \u2022 </span>"')[0]);
});
protectionNode = protectionNode.slice(0, -1); // remove the trailing bullet
statusLevel = 'warn';
} else {
protectionNode.push($("'<b>tidak ada perlindungan</b>"')[0]);
}
 
Morebits.status[statusLevel]("'Tingkat perlindungan saat ini"', protectionNode);
};
 
Baris 269 ⟶ 267:
var field1;
var field2;
var isTemplate = mw.config.get("'wgNamespaceNumber"') === 10 || mw.config.get("'wgNamespaceNumber"') === 828;
 
switch (e.target.values) {
Baris 275 ⟶ 273:
field_preset = new Morebits.quickForm.element({ type: 'field', label: 'Pilihan aturan', name: 'field_preset' });
field_preset.append({
type: 'select',
name: 'category',
label: 'Pilih pilihan berikut:',
event: Twinkle.protect.callback.changePreset,
list: (mw.config.get('wgArticleId') ?
Twinkle.protect.protectionTypes.filter(function(v) {
return isTemplate || v.label !== 'Templat perlindungan';
}) :
Twinkle.protect.protectionTypesCreate)
});
 
field2 = new Morebits.quickForm.element({ type: 'field', label: 'Opsi perlindungan', name: 'field2' });
Baris 292 ⟶ 290:
if (mw.config.get('wgArticleId')) {
field2.append({
type: 'checkbox',
name: 'editmodify',
event: Twinkle.protect.formevents.editmodify,
list: [
{
label: 'Ubah perlindungan suntingan',
value: 'editmodify',
tooltip: 'Jika ini dimatikan, tingkat perlindungan suntingan, dan jangka waktu perlindungan, akan ditinggalkan seperti sediakala.',
checked: true
}
]
});
var editlevel = field2.append({
type: 'select',
name: 'editlevel',
label: 'Perlindungan suntingan:',
event: Twinkle.protect.formevents.editlevel
});
editlevel.append({
type: 'option',
label: 'Semua',
value: 'all'
});
editlevel.append({
type: 'option',
label: 'Terkonfirmasi otomatis',
value: 'autoconfirmed'
});
// *
editlevel.append({
// type: 'option',
// label: 'Extended confirmed',
// value: 'extendedconfirmed'
// });
*/
if (isTemplate) {
editlevel.append({
type: 'option',
label: 'Editor templat',
value: 'templateeditor'
});
}
editlevel.append({
type: 'option',
label: 'Pengurus',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'editexpiry',
label: 'Jangka waktu perlindungan:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
list: [
{ label: '1 jam', value: '1 hour' },
{ label: '2 jam', value: '2 hours' },
{ label: '3 jam', value: '3 hours' },
{ label: '6 jam', value: '6 hours' },
{ label: '12 jam', value: '12 hours' },
{ label: '1 hari', value: '1 day' },
{ label: '2 hari', value: '2 days' },
{ label: '3 hari', value: '3 days' },
{ label: '4 hari', value: '4 days' },
{ label: '1 minggu', value: '1 week' },
{ label: '2 minggu', value: '2 weeks' },
{ label: '1 bulan', value: '1 month' },
{ label: '2 bulan', value: '2 months' },
{ label: '3 bulan', value: '3 months' },
{ label: '1 tahun', value: '1 year' },
{ label: 'tak terbatas', value: 'indefinite' },
{ label: 'Lain-lain...', value: 'custom' }
]
});
field2.append({
type: 'checkbox',
name: 'movemodify',
event: Twinkle.protect.formevents.movemodify,
list: [
{
llabel: 'Ubah perlindungan pemindahan',
value: 'movemodify',
tooltip: 'Jika opsi ini dimatikan, tingkat perlindungan pemindahan halaman dan jangka waktu kedaluwarsa akan ditinggalkan sebagaimana adanya.',
checked: true
}
]
});
var movelevel = field2.append({
type: 'select',
name: 'movelevel',
label: 'Perlindungan pemindahan:',
event: Twinkle.protect.formevents.movelevel
});
movelevel.append({
type: 'option',
label: 'Semua',
value: 'all'
});
/*
movelevel.append({
type: 'option',
label: 'Extended confirmed',
value: 'extendedconfirmed'
});
*/
if (isTemplate) {
movelevel.append({
type: 'option',
label: 'PengurusEditor templat',
value: 'sysoptemplateeditor',
selected: true
});
field2.append({
type: 'select',
name: 'editexpiry',
label: 'Jangka waktu perlindungan:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
list: [
{ label: '1 jam', value: '1 hour' },
{ label: '2 jam', value: '2 hours' },
{ label: '3 jam', value: '3 hours' },
{ label: '6 jam', value: '6 hours' },
{ label: '12 jam', value: '12 hours' },
{ label: '1 hari', value: '1 day' },
{ label: '2 hari', value: '2 days' },
{ label: '3 hari', value: '3 days' },
{ label: '4 hari', value: '4 days' },
{ label: '1 minggu', value: '1 week' },
{ label: '2 minggu', value: '2 weeks' },
{ label: '1 bulan', value: '1 month' },
{ label: '2 bulan', value: '2 months' },
{ label: '3 bulan', value: '3 months' },
{ label: '1 tahun', value: '1 year' },
{ label: 'tak terbatas', value:'indefinite' },
{ label: 'Lain-lain...', value: 'custom' }
]
});
}
movelevel.append({
type: 'option',
label: 'Pengurus',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'moveexpiry',
label: 'Jangka waktu perlindungan:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
list: [
{ label: '1 jam', value: '1 hour' },
{ label: '2 jam', value: '2 hours' },
{ label: '3 jam', value: '3 hours' },
{ label: '6 jam', value: '6 hours' },
{ label: '12 jam', value: '12 hours' },
{ label: '1 hari', value: '1 day' },
{ label: '2 hari', selected: true, value: '2 days' },
{ label: '3 hari', value: '3 days' },
{ label: '4 hari', value: '4 days' },
{ label: '1 minggu', value: '1 week' },
{ label: '2 minggu', value: '2 weeks' },
{ label: '1 bulan', value: '1 month' },
{ label: '2 bulan', value: '2 months' },
{ label: '3 bulan', value: '3 months' },
{ label: '1 tahun', value: '1 year' },
{ label: 'tak terbatas', value: 'indefinite' },
{ label: 'Lain-lain...', value: 'custom' }
]
});
// Namespaces hardcoded until [[phab:T218479]]
if (mw.loader.getState('ext.flaggedRevs.review') && (mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 4)) {
field2.append({
type: 'checkbox',
name: 'movemodifypcmodify',
event: Twinkle.protect.formevents.movemodifypcmodify,
list: [
{
label: 'UbahModify perlindunganpending pemindahanchanges protection',
value: 'movemodifypcmodify',
tooltip: 'JikaIf opsithis iniis dimatikanturned off, tingkatthe perlindunganpending pemindahanchanges halamanlevel, danand jangkaexpiry waktutime, kedaluwarsawill akanbe ditinggalkanleft sebagaimanaas adanyais.',
checked: true
}
]
});
var movelevelpclevel = field2.append({
type: 'select',
name: 'movelevelpclevel',
label: 'PerlindunganPerubahan pemindahantertunda:',
event: Twinkle.protect.formevents.movelevelpclevel
});
movelevel pclevel.append({
type: 'option',
label: 'SemuaTidak ada',
value: 'allnone'
});
movelevel pclevel.append({
type: 'option',
label: 'TerkonfirmasiPerubahan otomatistertunda',
value: 'autoconfirmed',
});
if (isTemplate) {
movelevel.append({
type: 'option',
label: 'Editor templat',
value: 'templateeditor'
});
}
movelevel.append({
type: 'option',
label: 'Pengurus',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'moveexpirypcexpiry',
label: 'Jangka waktu perlindungan:',
event: function(e) {
Baris 419 ⟶ 483:
}
},
// default expiry selection is conditionally set in Twinkle.protect.callback.changePreset
list: [
 
{ label: '1 jam', value: '1 hour' },
{ label: '2 jam', value: '2 hours' },
Baris 427 ⟶ 491:
{ label: '12 jam', value: '12 hours' },
{ label: '1 hari', value: '1 day' },
{ label: '2 hari', selected: true, value: '2 days' },
{ label: '3 hari', value: '3 days' },
{ label: '4 hari', value: '4 days' },
{ label: '1 minggu', value: '1 week' },
{ label: '2 minggu', value: '2 weeks' },
{ label: '1 bulan', selected: true, value: '1 month' },
{ label: '2 bulan', value: '2 months' },
{ label: '3 bulan', value: '3 months' },
{ label: '1 tahun', value: '1 year' },
{ label: 'tak terbatas', value: 'indefinite' },
{ label: 'Lain-lain...', value: 'custom' }
]
});
if (mw.loader.getState('ext.flaggedRevs.review')) {
field2.append({
type: 'checkbox',
name: 'pcmodify',
event: Twinkle.protect.formevents.pcmodify,
list: [
{
label: 'Modify pending changes protection',
value: 'pcmodify',
tooltip: 'If this is turned off, the pending changes level, and expiry time, will be left as is.',
checked: true,
disabled: (mw.config.get('wgNamespaceNumber') !== 0 && mw.config.get('wgNamespaceNumber') !== 4) // Hardcoded until [[phab:T218479]]
}
]
});
var pclevel = field2.append({
type: 'select',
name: 'pclevel',
label: 'Perubahan tertunda:',
event: Twinkle.protect.formevents.pclevel
});
pclevel.append({
type: 'option',
label: 'None',
value: 'none'
});
pclevel.append({
type: 'option',
label: 'Perubahan tertunda',
value: 'autoconfirmed',
selected: true
});
field2.append({
type: 'select',
name: 'pcexpiry',
label: 'Kedaluwarsa:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
list: [
{ label: '1 jam', value: '1 hour' },
{ label: '2 jam', value: '2 hours' },
{ label: '3 jam', value: '3 hours' },
{ label: '6 jam', value: '6 hours' },
{ label: '12 jam', value: '12 hours' },
{ label: '1 hari', value: '1 day' },
{ label: '2 hari', value: '2 days' },
{ label: '3 hari', value: '3 days' },
{ label: '4 hari', value: '4 days' },
{ label: '1 minggu', value: '1 week' },
{ label: '2 minggu', value: '2 weeks' },
{ label: '1 bulan', selected: true, value: '1 month' },
{ label: '2 bulan', value: '2 months' },
{ label: '3 bulan', value: '3 months' },
{ label: '1 tahun', value: '1 year' },
{ label: 'tak terbatas', value:'indefinite' },
{ label: 'Lain-lain...', value: 'custom' }
]
});
}
} else { // for non-existing pages
var createlevel = field2.append({
type: 'select',
name: 'createlevel',
label: 'Perlindungan pembuatan:',
event: Twinkle.protect.formevents.createlevel
});
createlevel.append({
type: 'option',
label: 'Semua',
value: 'all'
});
if (mw.config.get('wgNamespaceNumber') !== 0) {
createlevel.append({
type: 'option',
label: 'SemuaTerkonfirmasi otomatis',
value: 'allautoconfirmed'
});
if (mw.config.get("wgNamespaceNumber") !== 0) {
createlevel.append({
type: 'option',
label: 'Terkonfirmasi otomatis',
value: 'autoconfirmed'
});
}
if (isTemplate) {
createlevel.append({
type: 'option',
label: 'Editor templat',
value: 'templateeditor'
});
}
createlevel.append({
type: 'option',
label: 'PengurusEditor templat',
value: 'sysoptemplateeditor', // enwp: extendedconfirmed
selected: true
});
}
/*
createlevel.append({
type: 'option',
label: 'SysopExtended confirmed',
value: 'sysopextendedconfirmed',
});selected: true
});
*/
createlevel.append({
type: 'option',
label: 'Pengurus',
value: 'sysop'
});
field2.append({
type: 'select',
name: 'createexpiry',
label: 'Jangka waktu perlindungan:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
list: [
{ label: '1 jam', value: '1 hour' },
{ label: '2 jam', value: '2 hours' },
{ label: '3 jam', value: '3 hours' },
{ label: '6 jam', value: '6 hours' },
{ label: '12 jam', value: '12 hours' },
{ label: '1 hari', value: '1 day' },
{ label: '2 hari', selected: true, value: '2 days' },
{ label: '3 hari', value: '3 days' },
{ label: '4 hari', value: '4 days' },
{ label: '1 minggu', value: '1 week' },
{ label: '2 minggu', value: '2 weeks' },
{ label: '1 bulan', value: '1 month' },
{ label: '2 bulan', value: '2 months' },
{ label: '3 bulan', value: '3 months' },
{ label: '1 tahun', value: '1 year' },
{ label: 'tak terbatas', value: 'indefinite' },
{ label: 'Lain-lain...', value: 'custom' }
]
});
}
field2.append({
type: 'textarea',
name: 'protectReason',
label: 'Alasan (untuk log perlindungan):'
});
if (!mw.config.get('wgArticleId') || mw.config.get('wgPageContentModel') === 'Scribunto') { // tagging isn't relevant for non-existing or module pages
break;
Baris 582 ⟶ 587:
field1.append({ type: 'div', name: 'currentprot', label: ' ' }); // holds the current protection level, as filled out by the async callback
field1.append({ type: 'div', name: 'hasprotectlog', label: ' ' });
field1.append( {
type: 'select',
name: 'tagtype',
label: 'Pilih templat:',
list: Twinkle.protect.protectionTags,
event: Twinkle.protect.formevents.tagtype
} );
field1.append( {
type: 'checkbox',
list: [
{
name: 'small',
label: 'Ikon (small=yes)',
tooltip: 'Akan menggunakan fitur |small=yes dari templat, dan hanya tampil dengan ikon gembok',
checked: true
},
{
name: 'noinclude',
label: 'Sembunyikan templat ke dalam <noinclude>',
tooltip: 'Akan menyembunyikan templat perlindungan dalam tag &lt;noinclude&gt;, sehingga tidak akan ditransklusi',
checked: (mw.config.get('wgNamespaceNumber') === 10)
}
]
} );
break;
 
Baris 611 ⟶ 616:
field_preset = new Morebits.quickForm.element({ type: 'field', label: 'Jenis perlindungan', name: 'field_preset' });
field_preset.append({
type: 'select',
name: 'category',
label: 'Jenis dan alasan:',
event: Twinkle.protect.callback.changePreset,
list: (mw.config.get('wgArticleId') ? Twinkle.protect.protectionTypes : Twinkle.protect.protectionTypesCreate)
});
 
field1 = new Morebits.quickForm.element({ type: 'field', label: 'Opsi', name: 'field1' });
field1.append({ type: 'div', name: 'currentprot', label: ' ' }); // holds the current protection level, as filled out by the async callback
field1.append({ type: 'div', name: 'hasprotectlog', label: ' ' });
field1.append( {
type: 'select',
name: 'expiry',
label: 'Jangka waktu: ',
list: [
{ label: 'Sementara', value: 'temporary' },
{ label: 'Selamanya', value: 'indefinite' },
{ label: '', selected: true, value: '' }
]
} );
field1.append({
type: 'textareaselect',
name: 'reasonexpiry',
label: 'AlasanJangka waktu: ',
});list: [
{ label: 'Sementara', value: 'temporary' },
{ label: 'Selamanya', value: 'indefinite' },
{ label: '', selected: true, value: '' }
]
});
field1.append({
type: 'textarea',
name: 'reason',
label: 'Alasan: '
});
break;
default:
alert("'Terjadi sesuatu di twinkleprotect"');
break;
}
Baris 665 ⟶ 670:
if (e.target.values === 'protect') {
// fake a change event on the preset dropdown
var evt = document.createEvent( "'Event" ');
evt.initEvent( 'change', true, true );
e.target.form.category.dispatchEvent( evt );
 
// reduce vertical height of dialog
Baris 681 ⟶ 686:
e.target.form.editlevel.disabled = !e.target.checked;
e.target.form.editexpiry.disabled = !e.target.checked || (e.target.form.editlevel.value === 'all');
e.target.form.editlevel.style.color = e.target.form.editexpiry.style.color = (e.target.checked ? ""'' : "'transparent")';
},
editlevel: function twinkleprotectFormEditlevelEvent(e) {
e.target.form.editexpiry.disabled = (e.target.value === 'all');
},
movemodify: function twinkleprotectFormMovemodifyEvent(e) {
Baris 697 ⟶ 702:
e.target.form.movelevel.disabled = !e.target.checked;
e.target.form.moveexpiry.disabled = !e.target.checked || (e.target.form.movelevel.value === 'all');
e.target.form.movelevel.style.color = e.target.form.moveexpiry.style.color = (e.target.checked ? ""'' : "'transparent")';
},
movelevel: function twinkleprotectFormMovelevelEvent(e) {
e.target.form.moveexpiry.disabled = (e.target.value === 'all');
},
pcmodify: function twinkleprotectFormPcmodifyEvent(e) {
e.target.form.pclevel.disabled = !e.target.checked;
e.target.form.pcexpiry.disabled = !e.target.checked || (e.target.form.pclevel.value === 'none');
e.target.form.pclevel.style.color = e.target.form.pcexpiry.style.color = (e.target.checked ? ""'' : "'transparent")';
},
pclevel: function twinkleprotectFormPclevelEvent(e) {
e.target.form.pcexpiry.disabled = (e.target.value === 'none');
},
createlevel: function twinkleprotectFormCreatelevelEvent(e) {
e.target.form.createexpiry.disabled = (e.target.value === 'all');
},
tagtype: function twinkleprotectFormTagtypeEvent(e) {
Baris 749 ⟶ 754:
},
// idwiki doesn't have extendedconfirmed!
// {*
{
// label: 'Extended confirmed protection',
label: 'Extended confirmed protection',
// list: [
list: [
// { label: 'Arbitration enforcement (ECP)', selected: true, value: 'pp-30-500-arb' },
// { label: 'PersistentArbitration vandalismenforcement (ECP)', selected: true, value: 'pp-30-500-vandalismarb' },
// { label: 'DisruptivePersistent editingvandalism (ECP)', value: 'pp-30-500-disruptivevandalism' },
// { label: 'BLP policyDisruptive violationsediting (ECP)', value: 'pp-30-500-blpdisruptive' },
// { label: 'SockpuppetryBLP policy violations (ECP)', value: 'pp-30-500-sockblp' },
{ label: 'Sockpuppetry (ECP)', value: 'pp-30-500-sock' }
// ]
]
// },
},
*/
{
label: 'Perlindungan sebagian',
Baris 845 ⟶ 852:
reason: 'Templat yang sering digunakan'
},
/*
// 'pp-30-500-arb': {
'pp-30-500-arb': {
// edit: 'extendedconfirmed',
// move edit: 'extendedconfirmed',
// move: 'extendedconfirmed',
reason: '[[WP:30/500|Arbitration enforcement]]',
// template: 'pp-30-500'
// },
// 'pp-30-500-vandalism': {
// edit: 'extendedconfirmed',
// move: 'extendedconfirmed',
// reason: 'Persistent [[WP:Vandalism|vandalism]] from (auto)confirmed accounts',
// template: 'pp-30-500'
// },
// 'pp-30-500-disruptive': {
// edit: 'extendedconfirmed',
// move: 'extendedconfirmed',
// reason: 'Persistent [[WP:Disruptive editing|disruptive editing]] from (auto)confirmed accounts',
// template: 'pp-30-500'
// },
// 'pp-30-500-blp': {
// edit: 'extendedconfirmed',
// move: 'extendedconfirmed',
// reason: 'Persistent violations of the [[WP:BLP|biographies of living persons policy]] from (auto)confirmed accounts',
// template: 'pp-30-500'
// },
// 'pp-30-500-sock': {
// edit: 'extendedconfirmed',
// move: 'extendedconfirmed',
// reason: 'Persistent [[WP:Sock puppetry|sock puppetry]]',
// template: 'pp-30-500'
// },
*/
'pp-semi-vandalism': {
edit: 'autoconfirmed',
Baris 997 ⟶ 1.006:
list: [
{ label: '{{pp-vandalism}}: vandalisme', value: 'pp-vandalism' },
{ label: '{{pp-dispute}}: perang suntingan', value: 'pp-dispute', selected: true },
{ label: '{{pp-blp}}: melanggar kebijakan BLP', value: 'pp-blp' },
{ label: '{{pp-sock}}: penyalahgunaan akun boneka', value: 'pp-sock' },
Baris 1.003 ⟶ 1.012:
{ label: '{{pp-usertalk}}: halaman pembicaraan pengguna yang diblokir', value: 'pp-usertalk' },
{ label: '{{pp-protected}}: perlindungan umum', value: 'pp-protected' },
{ label: '{{pp-semi-indef}}: perlindungan sebagian dalam jangka waktu lama umum', value: 'pp-semi-indef' },
// { label: '{{pp-30-500}}: extended confirmed protection', value: 'pp-30-500' }
]
Baris 1.029 ⟶ 1.038:
var actiontypes = form.actiontype;
var actiontype;
for( (var i = 0; i < actiontypes.length; i++ ) {
if (!actiontypes[i].checked) {
{
if( !actiontypes[i].checked ) {
continue;
}
Baris 1.064 ⟶ 1.072:
}
 
if (itemform.stabilizepcmodify) {
if (item.stabilize) {
form.pcmodify.checked = true;
form.pcmodify.checked = true;
Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
form.pclevel.value = item.stabilize;
Twinkle.protect.formevents.pclevel({ target: form.pclevel });
} else if (form.pcmodify) {
form.pcmodify.checked = false;
Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
}
}
} else {
Baris 1.080 ⟶ 1.090:
}
 
var reasonField = (actiontype === "'protect"' ? form.protectReason : form.reason);
if (item.reason) {
reasonField.value = item.reason;
Baris 1.089 ⟶ 1.099:
// sort out tagging options, disabled if nonexistent or lua
if (mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto') {
if ( form.category.value === 'unprotect' ) {
form.tagtype.value = 'none';
} else {
form.tagtype.value = (item.template ? item.template : form.category.value);
}
Twinkle.protect.formevents.tagtype({ target: form.tagtype });
 
if ( /template/.test( form.category.value ) ) {
form.noinclude.checked = true;
form.editexpiry.value = form.moveexpiry.value = form.pcexpiry.value = "'indefinite"';
} else if( (mw.config.get('wgNamespaceNumber') !== 10 ) {
form.noinclude.checked = false;
}
Baris 1.105 ⟶ 1.115:
 
} else { // RPP request
if ( form.category.value === 'unprotect' ) {
form.expiry.value = '';
form.expiry.disabled = true;
Baris 1.120 ⟶ 1.130:
var actiontypes = form.actiontype;
var actiontype;
for( (var i = 0; i < actiontypes.length; i++ ) {
if (!actiontypes[i].checked) {
{
if( !actiontypes[i].checked ) {
continue;
}
Baris 1.130 ⟶ 1.139:
 
var tagparams;
if( (actiontype === 'tag' || (actiontype === 'protect' && mw.config.get('wgArticleId') && mw.config.get('wgPageContentModel') !== 'Scribunto') ) {
tagparams = {
tag: form.tagtype.value,
reason: ((form.tagtype.value === 'pp-protected' || form.tagtype.value === 'pp-semi-protected' || form.tagtype.value === 'pp-move') && form.protectReason) ? form.protectReason.value : null,
small: form.small.checked,
noinclude: form.noinclude.checked
Baris 1.143 ⟶ 1.152:
// protect the page
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.notice = "'Perlindungan selesai"';
 
var statusInited = false;
Baris 1.150 ⟶ 1.159:
var allDone = function twinkleprotectCallbackAllDone() {
if (thispage) {
thispage.getStatusElement().info("'done"');
}
if (tagparams) {
Baris 1.167 ⟶ 1.176:
 
var protectIt = function twinkleprotectCallbackProtectIt(next) {
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "'Sedang melindungi..."');
if (mw.config.get('wgArticleId')) {
if (form.editmodify.checked) {
Baris 1.183 ⟶ 1.192:
thispage.setEditSummary(form.protectReason.value);
} else {
alert("'Berikan alasan perlindungan, yang nantinya akan dimasukkan ke log perlindungan."');
return;
}
 
if (!statusInited) {
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
statusInited = true;
}
Baris 1.198 ⟶ 1.207:
var stabilizeIt = function twinkleprotectCallbackStabilizeIt() {
if (thispage) {
thispage.getStatusElement().info("'done"');
}
 
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "'Menerapkan perlindungan perubahan tertunda"');
thispage.setFlaggedRevs(stabilizeValues.pclevel, stabilizeValues.pcexpiry);
 
Baris 1.207 ⟶ 1.216:
thispage.setEditSummary(stabilizeValues.protectReason);
} else {
alert("'Berikan alasan perlindungan, yang nantinya akan dimasukkan ke log perlindungan."');
return;
}
Baris 1.217 ⟶ 1.226:
}
 
thispage.stabilize(allDone, function(error); {
if (error.errorCode === 'stabilize_denied') { // [[phab:T234743]]
thispage.getStatusElement().error('Failed trying to modify pending changes settings, likely due to a mediawiki bug. Other actions (tagging or regular protection) may have taken place. Please reload the page and try again.');
}
});
};
 
Baris 1.230 ⟶ 1.243:
stabilizeIt();
} else {
alert("'Berikan tugas kepada Twinkle! \nJika Anda hanya ingin menandai halaman, pilih opsi ¨Tandai halaman dengan templat perlindungan¨ di bagian atas."');
}
 
Baris 1.238 ⟶ 1.251:
// apply a protection template
 
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
 
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.followRedirect = false;
Morebits.wiki.actionCompleted.notice = "'Penandaan selesai"';
 
Twinkle.protect.callbacks.taggingPageInitial(tagparams);
Baris 1.251 ⟶ 1.264:
// file request at RFPP
var typename, typereason;
switch ( form.category.value ) {
case 'pp-dispute':
case 'pp-vandalism':
Baris 1.261 ⟶ 1.274:
typename = 'template protection';
break;
// case 'pp-30-500-arb':
// case 'pp-30-500-vandalism':
// case 'pp-30-500-disruptive':
// case 'pp-30-500-blp':
// case 'pp-30-500-sock':
// typename = 'extended confirmed protection';
// break;
case 'pp-semi-vandalism':
case 'pp-semi-disruptive':
Baris 1.297 ⟶ 1.310:
break;
case 'unprotect':
var admins = $.map(Twinkle.protect.currentProtectionLevels, function(pl) {
return pl.admin ? 'User:' + pl.admin : null; });
});
if (admins.length && !confirm('Have you attempted to contact the protecting admins (' + $.unique(admins).join(', ') + ') first?' )) {
if (admins.length && !confirm('Have you attempted to contact the protecting admins (' + $.unique(admins).join(', ') + ') first?')) {
return false;
}
Baris 1.328 ⟶ 1.343:
typereason = 'Templat yang banyak digunakan';
break;
// case 'pp-30-500-arb':
// typereason = '[[WP:30/500|Arbitration enforcement]]';
// break;
case 'pp-usertalk':
case 'pp-semi-usertalk':
Baris 1.368 ⟶ 1.383:
 
var reason = typereason;
if( (form.reason.value !== '') {
if ( typereason !== '' ) {
reason += "'\u00A0\u2013 "'; // U+00A0 NO-BREAK SPACE; U+2013 EN RULE
}
reason += form.reason.value;
}
if( (reason !== '' && reason.charAt( reason.length - 1 ) !== '.' ) {
reason += '.';
}
Baris 1.385 ⟶ 1.400:
};
 
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
 
var rppName = 'Wikipedia:Permintaan perhatian pengurus/Perlindungan';
Baris 1.392 ⟶ 1.407:
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = rppName;
Morebits.wiki.actionCompleted.notice = "'Nominasi selesai, membuka halaman diskusi"';
 
var rppPage = new Morebits.wiki.page( rppName, 'Meminta perlindungan halaman');
rppPage.setFollowRedirect( true );
rppPage.setCallbackParameters( rppparams );
rppPage.load( Twinkle.protect.callbacks.fileRequest );
break;
default:
alert("'twinkleprotect: tindakan tidak diketahui"');
break;
}
Baris 1.406 ⟶ 1.421:
 
Twinkle.protect.callbacks = {
taggingPageInitial: function( tagparams ) {
if (tagparams.tag === 'noop') {
Morebits.status.info("'Terapkan templat perlindungan"', "'tidak tahu apa yang mau dilakukan"');
return;
}
 
var protectedPage = new Morebits.wiki.page( mw.config.get('wgPageName'), 'Tandai halaman');
protectedPage.setCallbackParameters( tagparams );
protectedPage.load( Twinkle.protect.callbacks.taggingPage );
},
taggingPage: function( protectedPage ) {
var params = protectedPage.getCallbackParameters();
var text = protectedPage.getPageText();
Baris 1.424 ⟶ 1.439:
var re_result = oldtag_re.exec(text);
if (re_result) {
if (params.tag === 'none' || confirm("'{{"' + re_result[1] + "'}} ditemukan di halaman ini. \nKlik OK untuk menghapusnya, atau Cancel untuk mengabaikan."')) {
text = text.replace( oldtag_re, '' );
}
}
 
if ( params.tag !=== 'none' ) {
summary = 'Removing protection template' + Twinkle.getPref('summaryAd');
} else {
tag = params.tag;
if ( params.reason ) {
tag += '|reason=' + params.reason;
}
if ( params.small ) {
tag += '|small=yes';
}
}
 
if (/^\s*#redirect/i.test(text)) { // redirect page
if( params.tag === 'none' ) {
// Only tag if no {{rcat shell}} is found
summary = 'Menghapus templat perlindungan' + Twinkle.getPref('summaryAd');
} else {
if( Morebits.wiki.isPageRedirect() ) {
//Only tag if no {{rcat shell}} is found
if (!text.match(/{{(?:redr|this is a redirect|r(?:edirect)?(?:.?cat.*)?[ _]?sh)/i)) {
text = text.replace(/#REDIRECT ?(\[\[.*?\]\])(.*)/i, "'#REDIRECT $1$2\n\n{{"' + tag + "'}}"');
} else {
Morebits.status.info("'Redirect category shell present"', "'nothing to do"');
return;
}
} else if ( params.noinclude ) {
text = "'<noinclude>{{"' + tag + "'}}</noinclude>"' + text;
} else {
text = "'{{"' + tag + "'}}\n"' + text;
}
summary = "'Menambahkan {{"' + params.tag + "'}}"' + Twinkle.getPref('summaryAd');
}
 
protectedPage.setEditSummary( summary );
protectedPage.setPageText( text );
protectedPage.setCreateOption( 'nocreate' );
protectedPage.suppressProtectWarning(); // no need to let admins know they are editing through protection
protectedPage.save();
},
 
fileRequest: function( rppPage ) {
 
var params = rppPage.getCallbackParameters();
Baris 1.471 ⟶ 1.484:
var statusElement = rppPage.getStatusElement();
 
var rppRe = new RegExp( '===\\s*(\\[\\[)?\\s*:?\\s*' + RegExp.escape( Morebits.pageNameNorm, true ) + '\\s*(\\]\\])?\\s*===', 'm' );
var tag = rppRe.exec( text );
 
var rppLink = document.createElement('a');
rppLink.setAttribute('href', mw.util.getUrl(rppPage.getPageName()) );
rppLink.appendChild(document.createTextNode(rppPage.getPageName()));
 
if ( tag ) {
statusElement.error( [ 'Sudah ada permintaan perlindungan halaman ini di ', rppLink, ', sedang membatalkan permintaan.' ] );
return;
}
 
var newtag = '=== [[:' + Morebits.pageNameNorm + ']] ===\n';
if( ( new RegExp( '^' + RegExp.escape( newtag ).replace( /\s+/g, '\\s*' ), 'm' ) ).test( text ) ) {
statusElement.error( [ 'Sudah ada permintaan perlindungan halaman ini di ', rppLink, ', sedang membatalkan permintaan.' ] );
return;
}
Baris 1.491 ⟶ 1.504:
 
var words;
switch ( params.expiry ) {
case 'temporary':
words = "'Sementara "';
break;
case 'indefinite':
words = "'Selamanya "';
break;
default:
words = ""'';
break;
}
 
words += params.typename;
 
newtag += "'''" + Morebits.string.toUpperCaseFirstChar(words) + ( params.reason !== '' ? ( ":''' " +
Morebits.string.formatReasonText(params.reason) ) : ".'''" ) + "' ~~~~"';
 
// If either protection type results in a increased status, then post it under increase
Baris 1.518 ⟶ 1.531:
if (stabilizeLevel) {
if (result) {
if (stabilizeLevel.level === "'autoconfirmed"') {
result += 2;
}
} else {
result = Twinkle.protect.protectionWeight["'flaggedrevs_"' + stabilizeLevel];
}
}
Baris 1.531 ⟶ 1.544:
var editWeight = computeWeight(Twinkle.protect.currentProtectionLevels.edit &&
Twinkle.protect.currentProtectionLevels.edit.level,
Twinkle.protect.currentProtectionLevels.stabilize &&
Twinkle.protect.currentProtectionLevels.stabilize.level);
if (computeWeight(protInfo.edit, protInfo.stabilize) > editWeight ||
Baris 1.542 ⟶ 1.555:
 
var reg;
if ( increase ) {
reg = /(\n==\s*Current requests for reduction in protection level\s*==)/;
} else {
Baris 1.549 ⟶ 1.562:
 
var originalTextLength = text.length;
text = text.replace( reg, "'\n"' + newtag + "'\n$1"');
if (text.length === originalTextLength) {
{
var linknode = document.createElement('a');
linknode.setAttribute("'href"', mw.util.getUrl("'Wikipedia:Twinkle/Fixing PPH"RPP') );
linknode.appendChild(document.createTextNode('Bagaimana memperbaiki PPH'));
statusElement.error( [ 'Tidak menemukan bagian yang sesuai di WP:RPP. Untuk memperbaiki masalah ini, lihat ', linknode, '.' ] );
return;
}
statusElement.status( 'Menambahkan permintaan baru...' );
rppPage.setEditSummary('/* ' + Morebits.pageNameNorm + ' */ "Meminta "' + params.typename + (params.typename === "perubahan'pending tertunda"changes' ? ' di [[:' : ' dari [[:') +
Morebits.pageNameNorm + ']].' + Twinkle.getPref('summaryAd') );
rppPage.setPageText( text );
rppPage.setCreateOption( 'recreate' );
rppPage.save();
}
Baris 1.569 ⟶ 1.581:
 
 
// </nowiki>