미디어위키:Gadget-twinkleprotect.js
참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.
- 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
- 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
- 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
//<nowiki>
(function($){
/*
****************************************
*** twinkleprotect.js: Protect/RPP module
****************************************
* Mode of invocation: Tab ("PP"/"RPP")
* Active on: Non-special pages
* Config directives in: TwinkleConfig
*/
// Note: a lot of code in this module is re-used/called by batchprotect.
Twinkle.protect = function twinkleprotect() {
if ( mw.config.get('wgNamespaceNumber') < 0 ) {
return;
}
Twinkle.addPortletLink(Twinkle.protect.callback, Morebits.userIsInGroup('sysop') ? "문서 보호" : "문서 보호 요청", "tw-rpp",
Morebits.userIsInGroup('sysop') ? "문서를 보호합니다" : "문서 보호를 요청합니다" );
};
Twinkle.protect.callback = function twinkleprotectCallback() {
var Window = new Morebits.simpleWindow( 620, 530 );
Window.setTitle( Morebits.userIsInGroup( 'sysop' ) ? "문서 보호의 적용, 요청, 태그 처리" : "문서 보호 요청, 태그 처리" );
Window.setScriptName( "트윙클" );
Window.addFooterLink( "보호 틀", "틀:보호 틀" );
Window.addFooterLink( "보호 정책", "위키백과:보호 정책" );
Window.addFooterLink( "트윙클 도움말", ":en:WP:TW/DOC#protect" );
var form = new Morebits.quickForm( Twinkle.protect.callback.evaluate );
var actionfield = form.append( {
type: 'field',
label: '동작 종류'
} );
if( Morebits.userIsInGroup( 'sysop' ) ) {
actionfield.append( {
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: '문서 보호',
value: 'protect',
tooltip: 'Apply actual protection to the page.',
checked: true
}
]
} );
}
actionfield.append( {
type: 'radio',
name: 'actiontype',
event: Twinkle.protect.callback.changeAction,
list: [
{
label: '문서 보호 요청',
value: 'request',
tooltip: '백:문서_관리_요청을 통해 보호 요청을 원하는 경우 사용하십시오.' + (Morebits.userIsInGroup('sysop') ? ' (관리자로서 직접 보호하고 싶지 않은 경우)' : ''),
checked: !Morebits.userIsInGroup('sysop')
},
{
label: '보호 틀로 페이지 태그',
value: 'tag',
tooltip: '보호 관리자가 보호 틀 적용을 잊은 경우나 태그 없이 방금 문서를 보호 처리한 경우, 이 옵션을 사용하여 적절한 보호 태그를 적용할 수 있습니다.',
disabled: mw.config.get('wgArticleId') === 0
}
]
} );
form.append({ type: 'field', label: '프리셋', name: 'field_preset' });
form.append({ type: 'field', label: '1', name: 'field1' });
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
Twinkle.protect.fetchProtectionLevel();
};
// Contains the current protection level in an object
// Once filled, it will look something like:
// { edit: { level: "sysop", expiry: <some date>, cascade: true }, ... }
Twinkle.protect.currentProtectionLevels = {};
Twinkle.protect.fetchProtectionLevel = function twinkleprotectFetchProtectionLevel() {
var api = new mw.Api();
var protectDeferred = api.get({
format: 'json',
indexpageids: true,
action: 'query',
list: 'logevents',
letype: 'protect',
letitle: mw.config.get('wgPageName'),
prop: 'info|flagged',
inprop: 'protection',
titles: mw.config.get('wgPageName')
});
var stableDeferred = api.get({
format: 'json',
action: 'query',
list: 'logevents',
letype: 'stable',
letitle: mw.config.get('wgPageName')
});
$.when.apply($, [protectDeferred, stableDeferred]).done(function(protectData, stableData){
var pageid = protectData[0].query.pageids[0];
var page = protectData[0].query.pages[pageid];
var current = {};
$.each(page.protection, function( index, protection ) {
if (protection.type !== "aft") {
current[protection.type] = {
level: protection.level,
expiry: protection.expiry,
cascade: protection.cascade === ''
};
}
});
if (page.flagged) {
current.stabilize = {
level: page.flagged.protection_level,
expiry: page.flagged.protection_expiry
};
}
// show the protection level and log info
Twinkle.protect.hasProtectLog = !!protectData[0].query.logevents.length;
Twinkle.protect.hasStableLog = !!stableData[0].query.logevents.length;
Twinkle.protect.currentProtectionLevels = current;
Twinkle.protect.callback.showLogAndCurrentProtectInfo();
});
};
Twinkle.protect.callback.showLogAndCurrentProtectInfo = function twinkleprotectCallbackShowLogAndCurrentProtectInfo() {
var currentlyProtected = !$.isEmptyObject(Twinkle.protect.currentProtectionLevels);
if (Twinkle.protect.hasProtectLog || Twinkle.protect.hasStableLog) {
var $linkMarkup = $("<span>");
if (Twinkle.protect.hasProtectLog)
$linkMarkup.append(
$( '<a target="_blank" href="' + mw.util.getUrl('특수:기록', {action: 'view', page: mw.config.get('wgPageName'), type: 'protect'}) + '">protection log</a>' ),
Twinkle.protect.hasStableLog ? $("<span> • </span>") : null
);
if (Twinkle.protect.hasStableLog)
$linkMarkup.append($( '<a target="_blank" href="' + mw.util.getUrl('특수:기록', {action: 'view', page: mw.config.get('wgPageName'), type: 'stable'}) + '">pending changes log</a>)' ));
Morebits.status.init($('div[name="hasprotectlog"] span')[0]);
Morebits.status.warn(
currentlyProtected ? 'Previous protections' : 'This page has been protected in the past',
$linkMarkup[0]
);
}
Morebits.status.init($('div[name="currentprot"] span')[0]);
var protectionNode = [], statusLevel = 'info';
if (currentlyProtected) {
$.each(Twinkle.protect.currentProtectionLevels, function(type, settings) {
var label = type === 'stabilize' ? 'Pending Changes' : Morebits.string.toUpperCaseFirstChar(type);
protectionNode.push($("<b>" + label + ": " + settings.level + "</b>")[0]);
if (settings.expiry === 'infinity') {
protectionNode.push(" (무기한) ");
} else {
protectionNode.push(" (expires " + new Date(settings.expiry).toUTCString() + ") ");
}
if (settings.cascade) {
protectionNode.push("(cascading) ");
}
});
statusLevel = 'warn';
} else {
protectionNode.push($("<b>보호 없음</b>")[0]);
}
Morebits.status[statusLevel]("현재 보호 수준", protectionNode);
};
Twinkle.protect.callback.changeAction = function twinkleprotectCallbackChangeAction(e) {
var field_preset;
var field1;
var field2;
var isTemplate = mw.config.get("wgNamespaceNumber") === 10 || mw.config.get("wgNamespaceNumber") === 828;
switch (e.target.values) {
case 'protect':
field_preset = new Morebits.quickForm.element({ type: 'field', label: '프리셋', name: 'field_preset' });
field_preset.append({
type: 'select',
name: 'category',
label: '프리셋 선택:',
event: Twinkle.protect.callback.changePreset,
list: (mw.config.get('wgArticleId') ?
Twinkle.protect.protectionTypes.filter(function(v) {
return isTemplate || v.label !== '틀 보호';
}) :
Twinkle.protect.protectionTypesCreate)
});
field2 = new Morebits.quickForm.element({ type: 'field', label: '보호 옵션', name: 'field2' });
field2.append({ type: 'div', name: 'currentprot', label: ' ' }); // holds the current protection level, as filled out by the async callback
field2.append({ type: 'div', name: 'hasprotectlog', label: ' ' });
// for existing pages
if (mw.config.get('wgArticleId')) {
field2.append({
type: 'checkbox',
name: 'editmodify',
event: Twinkle.protect.formevents.editmodify,
list: [
{
label: '편집 보호 수정',
value: 'editmodify',
tooltip: 'If this is turned off, the edit protection level, and expiry time, will be left as is.',
checked: true
}
]
});
var editlevel = field2.append({
type: 'select',
name: 'editlevel',
label: '편집 보호:',
event: Twinkle.protect.formevents.editlevel
});
editlevel.append({
type: 'option',
label: '모든 사용자',
value: 'all'
});
editlevel.append({
type: 'option',
label: '자동 인증된 사용자',
value: 'autoconfirmed'
});
editlevel.append({
type: 'option',
label: 'Extended confirmed',
value: 'extendedconfirmed'
});
if (isTemplate) {
editlevel.append({
type: 'option',
label: '틀 편집기',
value: 'templateeditor'
});
}
editlevel.append({
type: 'option',
label: '관리자',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'editexpiry',
label: '기한:',
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 hour', value: '1 hour' },
{ label: '2 hours', value: '2 hours' },
{ label: '3 hours', value: '3 hours' },
{ label: '6 hours', value: '6 hours' },
{ label: '12 hours', value: '12 hours' },
{ label: '1 day', value: '1 day' },
{ label: '2 days', value: '2 days' },
{ label: '3 days', value: '3 days' },
{ label: '4 days', value: '4 days' },
{ label: '1 week', value: '1 week' },
{ label: '2 weeks', value: '2 weeks' },
{ label: '1 month', value: '1 month' },
{ label: '2 months', value: '2 months' },
{ label: '3 months', value: '3 months' },
{ label: '1 year', value: '1 year' },
{ label: '무기한', value:'indefinite' },
{ label: '사용자 지정...', value: 'custom' }
]
});
field2.append({
type: 'checkbox',
name: 'movemodify',
event: Twinkle.protect.formevents.movemodify,
list: [
{
label: '이동 보호 수정',
value: 'movemodify',
tooltip: 'If this is turned off, the move protection level, and expiry time, will be left as is.',
checked: true
}
]
});
var movelevel = field2.append({
type: 'select',
name: 'movelevel',
label: '이동 보호:',
event: Twinkle.protect.formevents.movelevel
});
movelevel.append({
type: 'option',
label: '모든 사용자',
value: 'all'
});
movelevel.append({
type: 'option',
label: '자동 인증된 사용자',
value: 'autoconfirmed'
});
movelevel.append({
type: 'option',
label: 'Extended confirmed',
value: 'extendedconfirmed'
});
if (isTemplate) {
movelevel.append({
type: 'option',
label: '틀 편집기',
value: 'templateeditor'
});
}
movelevel.append({
type: 'option',
label: 'Sysop',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'moveexpiry',
label: '기한:',
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 hour', value: '1 hour' },
{ label: '2 hours', value: '2 hours' },
{ label: '3 hours', value: '3 hours' },
{ label: '6 hours', value: '6 hours' },
{ label: '12 hours', value: '12 hours' },
{ label: '1 day', value: '1 day' },
{ label: '2 days', value: '2 days' },
{ label: '3 days', value: '3 days' },
{ label: '4 days', value: '4 days' },
{ label: '1 week', value: '1 week' },
{ label: '2 weeks', value: '2 weeks' },
{ label: '1 month', value: '1 month' },
{ label: '2 months', value: '2 months' },
{ label: '3 months', value: '3 months' },
{ label: '1 year', value: '1 year' },
{ label: '무기한', value: 'indefinite' },
{ label: '사용자 지정...', value: 'custom' }
]
});
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
}
]
});
var pclevel = field2.append({
type: 'select',
name: 'pclevel',
label: 'Pending changes:',
event: Twinkle.protect.formevents.pclevel
});
pclevel.append({
type: 'option',
label: 'None',
value: 'none'
});
pclevel.append({
type: 'option',
label: 'Level 1',
value: 'autoconfirmed',
selected: true
});
pclevel.append({
type: 'option',
label: 'Level 2 (do not use)',
value: 'review'
});
field2.append({
type: 'select',
name: 'pcexpiry',
label: '기한:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
list: [
{ label: '1 hour', value: '1 hour' },
{ label: '2 hours', value: '2 hours' },
{ label: '3 hours', value: '3 hours' },
{ label: '6 hours', value: '6 hours' },
{ label: '12 hours', value: '12 hours' },
{ label: '1 day', value: '1 day' },
{ label: '2 days', value: '2 days' },
{ label: '3 days', value: '3 days' },
{ label: '4 days', value: '4 days' },
{ label: '1 week', value: '1 week' },
{ label: '2 weeks', value: '2 weeks' },
{ label: '1 month', selected: true, value: '1 month' },
{ label: '2 months', value: '2 months' },
{ label: '3 months', value: '3 months' },
{ label: '1 year', value: '1 year' },
{ label: '무기한', value:'indefinite' },
{ label: '사용자 지정...', value: 'custom' }
]
});
} else { // for non-existing pages
var createlevel = field2.append({
type: 'select',
name: 'createlevel',
label: 'Create protection:',
event: Twinkle.protect.formevents.createlevel
});
createlevel.append({
type: 'option',
label: '모든 사용자',
value: 'all'
});
createlevel.append({
type: 'option',
label: '자동 인증된 사용자',
value: 'autoconfirmed'
});
if (isTemplate) {
createlevel.append({
type: 'option',
label: '틀 편집기',
value: 'templateeditor'
});
}
createlevel.append({
type: 'option',
label: '관리자',
value: 'sysop',
selected: true
});
field2.append({
type: 'select',
name: 'createexpiry',
label: '기한:',
event: function(e) {
if (e.target.value === 'custom') {
Twinkle.protect.doCustomExpiry(e.target);
}
},
list: [
{ label: '1 hour', value: '1 hour' },
{ label: '2 hours', value: '2 hours' },
{ label: '3 hours', value: '3 hours' },
{ label: '6 hours', value: '6 hours' },
{ label: '12 hours', value: '12 hours' },
{ label: '1 day', value: '1 day' },
{ label: '2 days', value: '2 days' },
{ label: '3 days', value: '3 days' },
{ label: '4 days', value: '4 days' },
{ label: '1 week', value: '1 week' },
{ label: '2 weeks', value: '2 weeks' },
{ label: '1 month', value: '1 month' },
{ label: '2 months', value: '2 months' },
{ label: '3 months', value: '3 months' },
{ label: '1 year', value: '1 year' },
{ label: 'indefinite', selected: true, value: 'indefinite' },
{ label: 'Custom...', value: 'custom' }
]
});
}
field2.append({
type: 'textarea',
name: 'protectReason',
label: '이유 (보호 기록):'
});
if (!mw.config.get('wgArticleId')) { // tagging isn't relevant for non-existing pages
break;
}
/* falls through */
case 'tag':
field1 = new Morebits.quickForm.element({ type: 'field', label: '태그 옵션', 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: 'tagtype',
label: '보호 틀 선택:',
list: Twinkle.protect.protectionTags,
event: Twinkle.protect.formevents.tagtype
} );
field1.append( {
type: 'checkbox',
list: [
{
name: 'small',
label: '아이콘 표시 (작게=예)',
tooltip: 'Will use the |small=yes feature of the template, and only render it as a keylock',
checked: true
},
{
name: 'noinclude',
label: '보호 틀을 <noinclude>로 감싸기',
tooltip: 'Will wrap the protection template in <noinclude> tags, so that it won\'t transclude',
checked: (mw.config.get('wgNamespaceNumber') === 10)
}
]
} );
break;
case 'request':
field_preset = new Morebits.quickForm.element({ type: 'field', label: 'Type of protection', name: 'field_preset' });
field_preset.append({
type: 'select',
name: 'category',
label: 'Type and reason:',
event: Twinkle.protect.callback.changePreset,
list: (mw.config.get('wgArticleId') ? Twinkle.protect.protectionTypes : Twinkle.protect.protectionTypesCreate)
});
field1 = new Morebits.quickForm.element({ type: 'field', label: 'Options', 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: '기간: ',
list: [
{ label: '일시적', value: 'temporary' },
{ label: '무기한', value: 'indefinite' },
{ label: '', selected: true, value: '' }
]
} );
field1.append({
type: 'textarea',
name: 'reason',
label: '이유: '
});
break;
default:
alert("Something's afoot in twinkleprotect");
break;
}
var oldfield;
if (field_preset) {
oldfield = $(e.target.form).find('fieldset[name="field_preset"]')[0];
oldfield.parentNode.replaceChild(field_preset.render(), oldfield);
} else {
$(e.target.form).find('fieldset[name="field_preset"]').css('display', 'none');
}
if (field1) {
oldfield = $(e.target.form).find('fieldset[name="field1"]')[0];
oldfield.parentNode.replaceChild(field1.render(), oldfield);
} else {
$(e.target.form).find('fieldset[name="field1"]').css('display', 'none');
}
if (field2) {
oldfield = $(e.target.form).find('fieldset[name="field2"]')[0];
oldfield.parentNode.replaceChild(field2.render(), oldfield);
} else {
$(e.target.form).find('fieldset[name="field2"]').css('display', 'none');
}
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
$(e.target.form).find('fieldset[name="field2"] select').parent().css({ display: 'inline-block', marginRight: '0.5em' });
}
// re-add protection level and log info, if it's available
Twinkle.protect.callback.showLogAndCurrentProtectInfo();
};
Twinkle.protect.formevents = {
editmodify: function twinkleprotectFormEditmodifyEvent(e) {
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) {
// sync move settings with edit settings if applicable
if (e.target.form.movelevel.disabled && !e.target.form.editlevel.disabled) {
e.target.form.movelevel.value = e.target.form.editlevel.value;
e.target.form.moveexpiry.value = e.target.form.editexpiry.value;
} else if (e.target.form.editlevel.disabled) {
e.target.form.movelevel.value = 'sysop';
e.target.form.moveexpiry.value = 'indefinite';
}
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) {
e.target.form.small.disabled = e.target.form.noinclude.disabled = (e.target.value === 'none') || (e.target.value === 'noop');
}
};
Twinkle.protect.doCustomExpiry = function twinkleprotectDoCustomExpiry(target) {
var custom = prompt('Enter a custom expiry time. \nYou can use relative times, like "1 minute" or "19 days", or absolute timestamps, "yyyymmddhhmm" (e.g. "200602011405" is Feb 1, 2006, at 14:05 UTC).', '');
if (custom) {
var option = document.createElement('option');
option.setAttribute('value', custom);
option.textContent = custom;
target.appendChild(option);
target.value = custom;
} else {
target.selectedIndex = 0;
}
};
Twinkle.protect.protectionTypes = [
{ label: '보호 해제', value: 'unprotect' },
{
label: '일반 보호',
list: [
{ label: '일반 (완전)', value: '보호' },
{ label: '내용 상의 논쟁 /편집 경고 (완전)', value: '보호-논쟁' },
{ label: '지속적인 문서 훼손 (완전)', value: '보호-훼손' },
{ label: '차단된 사용자의 사용자 토론 (완전)', value: '보호-사용자토론' }
]
},
{
label: '틀 보호',
list: [
{ label: '매우 민감한 틀', value: '보호-틀' }
]
},
{
label: '준보호',
list: [
{ label: 'Generic (semi)', value: '준보호' },
{ label: 'Persistent vandalism (semi)', selected: true, value: '준보호-훼손' },
{ label: 'Disruptive editing (semi)', value: '준보호-논쟁' },
{ label: 'Adding unsourced content (semi)', value: 'pp-semi-unsourced' },
{ label: 'BLP policy violations (semi)', value: '준보호-인물' },
{ label: 'User talk of blocked user (semi)', value: '준보호-사용자토론' }
]
},
{
label: 'Pending changes',
list: [
{ label: 'Generic (PC)', value: 'pp-pc-protected' },
{ label: 'Persistent vandalism (PC)', value: 'pp-pc-vandalism' },
{ label: 'Disruptive editing (PC)', value: 'pp-pc-disruptive' },
{ label: 'Adding unsourced content (PC)', value: 'pp-pc-unsourced' },
{ label: 'BLP policy violations (PC)', value: 'pp-pc-blp' }
]
},
{
label: '이동 보호',
list: [
{ label: 'Generic (move)', value: '이동보호' },
{ label: 'Dispute/move warring (move)', value: '이동보호-논쟁' },
{ label: 'Page-move vandalism (move)', value: '이동보호-훼손' },
{ label: 'Highly visible page (move)', value: '이동보호-무기한' }
]
}
];
Twinkle.protect.protectionTypesCreate = [
{ label: '보호 해제', value: 'unprotect' },
{
label: '생성 보호',
list: [
{ label: 'Generic ({{생성보호}})', value: '생성보호' },
{ label: 'Offensive name', value: '생성보호-offensive' },
{ label: 'Repeatedly recreated', selected: true, value: '생성보호-salt' },
{ label: 'Recently deleted BLP', value: '생성보호-인물' }
]
}
];
// A page with both regular and PC protection will be assigned its regular
// protection weight plus 2 (for PC1) or 7 (for PC2)
Twinkle.protect.protectionWeight = {
sysop: 40,
templateeditor: 30,
extendedconfirmed: 20,
flaggedrevs_review: 15, // Pending Changes level 2 protection alone
autoconfirmed: 10,
flaggedrevs_autoconfirmed: 5, // Pending Changes level 1 protection alone
all: 0,
flaggedrevs_none: 0 // just in case
};
// NOTICE: keep this synched with [[MediaWiki:Protect-dropdown]]
// Also note: stabilize = Pending Changes level
Twinkle.protect.protectionPresetsInfo = {
'보호': {
edit: 'sysop',
move: 'sysop',
reason: null
},
'보호-논쟁': {
edit: 'sysop',
move: 'sysop',
reason: '편집 경고 / 내용 상의 분쟁'
},
'보호-훼손': {
edit: 'sysop',
move: 'sysop',
reason: '지속적인 문서 훼손'
},
'보호-사용자토론': {
edit: 'sysop',
move: 'sysop',
reason: '차단 중 부적절한 사용자 토론의 이용'
},
'보호-틀': {
edit: 'templateeditor',
move: 'templateeditor',
reason: '매우 민감한 틀'
},
'준보호-훼손': {
edit: 'autoconfirmed',
reason: '지속적인 문서 훼손',
template: '보호-훼손'
},
'준보호-논쟁': {
edit: 'autoconfirmed',
reason: '논쟁 중인 편집',
template: '보호'
},
'pp-semi-unsourced': {
edit: 'autoconfirmed',
reason: 'Persistent addition of [[WP:INTREF|unsourced or poorly sourced content]]',
template: '보호'
},
'준보호-인물': {
edit: 'autoconfirmed',
reason: 'Violations of the [[WP:BLP|biographies of living persons policy]]',
template: '보호-인물'
},
'준보호-사용자토론': {
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: '차단 중 부적절한 사용자 토론의 이용',
template: '보호-사용자토론'
},
'pp-semi-template': { // removed for now
edit: 'autoconfirmed',
move: 'autoconfirmed',
reason: '[[WP:High-risk templates|Highly visible template]]',
template: '보호-틀'
},
'준보호': {
edit: 'autoconfirmed',
reason: null,
template: '보호'
},
'pp-pc-vandalism': {
stabilize: 'autoconfirmed', // stabilize = Pending Changes
reason: 'Persistent [[WP:Vandalism|vandalism]]',
template: 'pp-pc1'
},
'pp-pc-disruptive': {
stabilize: 'autoconfirmed',
reason: 'Persistent [[WP:Disruptive editing|disruptive editing]]',
template: 'pp-pc1'
},
'pp-pc-unsourced': {
stabilize: 'autoconfirmed',
reason: 'Persistent addition of [[WP:INTREF|unsourced or poorly sourced content]]',
template: 'pp-pc1'
},
'pp-pc-blp': {
stabilize: 'autoconfirmed',
reason: 'Violations of the [[WP:BLP|biographies of living persons policy]]',
template: 'pp-pc1'
},
'pp-pc-protected': {
stabilize: 'autoconfirmed',
reason: null,
template: 'pp-pc1'
},
'이동보호': {
move: 'sysop',
reason: null
},
'이동보호-논쟁': {
move: 'sysop',
reason: '이동 경고'
},
'이동보호-훼손': {
move: 'sysop',
reason: '문서 이동 훼손'
},
'이동보호-무기한': {
move: 'sysop',
reason: '매우 민감한 문서'
},
'unprotect': {
edit: 'all',
move: 'all',
stabilize: 'none',
create: 'all',
reason: null,
template: 'none'
},
'생성보호-offensive': {
create: 'sysop',
reason: '부적절한 문서 제목'
},
'생성보호-salt': {
create: 'sysop',
reason: '반복적인 재생성'
},
'생성보호-인물': {
create: 'sysop',
reason: '최근에 삭제된 인물 문서'
},
'생성보호': {
create: 'sysop',
reason: '{{생성보호}}'
}
};
Twinkle.protect.protectionTags = [
{
label: '없음 (기존의 보호 틀 제거)',
value: 'none'
},
{
label: '없음 (기존의 보호 틀 제거하지 않음)',
value: 'noop'
},
{
label: '편집 보호 틀',
list: [
{ label: '{{보호-훼손}}: vandalism', value: '보호-훼손' },
{ label: '{{보호-논쟁}}: dispute/edit war', value: '보호-논쟁', selected: true },
{ label: '{{보호-인물}}: BLP violations', value: '보호-인물' },
{ label: '{{보호-틀}}: high-risk template', value: '보호-틀' },
{ label: '{{보호-사용자토론}}: blocked user talk', value: '보호-사용자토론' },
{ label: '{{보호}}: general protection', value: '보호' },
{ label: '{{준보호-무기한}}: general long-term semi-protection', value: '준보호-무기한' },
]
},
{
label: 'Pending changes templates',
list: [
{ label: '{{pp-pc1}}: pending changes level 1', value: 'pp-pc1' }
]
},
{
label: '이동 보호 틀',
list: [
{ label: '{{이동보호-논쟁}}: dispute/move war', value: '이동보호-논쟁' },
{ label: '{{이동보호-훼손}}: page-move vandalism', value: '이동보호-훼손' },
{ label: '{{이동보호-무기한}}: general long-term', value: '이동보호-무기한' },
{ label: '{{이동보호}}: other', value: '이동보호' }
]
}
];
Twinkle.protect.callback.changePreset = function twinkleprotectCallbackChangePreset(e) {
var form = e.target.form;
var actiontypes = form.actiontype;
var actiontype;
for( var i = 0; i < actiontypes.length; i++ )
{
if( !actiontypes[i].checked ) {
continue;
}
actiontype = actiontypes[i].values;
break;
}
if (actiontype === 'protect') { // actually protecting the page
var item = Twinkle.protect.protectionPresetsInfo[form.category.value],
isArbEnforcement = item.edit === 'extendedconfirmed';
if (mw.config.get('wgArticleId')) {
if (item.edit) {
form.editmodify.checked = true;
Twinkle.protect.formevents.editmodify({ target: form.editmodify });
form.editlevel.value = item.edit;
Twinkle.protect.formevents.editlevel({ target: form.editlevel });
// NOTE: Currently extendedconfirmed protection is only for Arbitration enforcement,
// and inherently of indefinite duration.
if (isArbEnforcement) {
form.editexpiry.value = 'indefinite';
} else {
form.editexpiry.value = '2 days';
}
} else {
form.editmodify.checked = false;
Twinkle.protect.formevents.editmodify({ target: form.editmodify });
}
if (item.move) {
form.movemodify.checked = true;
Twinkle.protect.formevents.movemodify({ target: form.movemodify });
form.movelevel.value = item.move;
Twinkle.protect.formevents.movelevel({ target: form.movelevel });
if (isArbEnforcement) {
form.moveexpiry.value = 'indefinite';
} else {
form.moveexpiry.value = '2 days';
}
} else {
form.movemodify.checked = false;
Twinkle.protect.formevents.movemodify({ target: form.movemodify });
}
if (item.stabilize) {
form.pcmodify.checked = true;
Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
form.pclevel.value = item.stabilize;
Twinkle.protect.formevents.pclevel({ target: form.pclevel });
} else {
form.pcmodify.checked = false;
Twinkle.protect.formevents.pcmodify({ target: form.pcmodify });
}
} else {
if (item.create) {
form.createlevel.value = item.create;
Twinkle.protect.formevents.createlevel({ target: form.createlevel });
}
}
var reasonField = (actiontype === "protect" ? form.protectReason : form.reason);
if (item.reason) {
reasonField.value = item.reason;
} else {
reasonField.value = '';
}
// sort out tagging options
if (mw.config.get('wgArticleId')) {
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;
}
}
} else { // RPP request
if( form.category.value === 'unprotect' ) {
form.expiry.value = '';
form.expiry.disabled = true;
} else {
form.expiry.value = '';
form.expiry.disabled = false;
}
}
};
Twinkle.protect.callback.evaluate = function twinkleprotectCallbackEvaluate(e) {
var form = e.target;
var actiontypes = form.actiontype;
var actiontype;
for( var i = 0; i < actiontypes.length; i++ )
{
if( !actiontypes[i].checked ) {
continue;
}
actiontype = actiontypes[i].values;
break;
}
var tagparams;
if( actiontype === 'tag' || (actiontype === 'protect' && mw.config.get('wgArticleId')) ) {
tagparams = {
tag: form.tagtype.value,
reason: ((form.tagtype.value === '보호' || form.tagtype.value === '준보호' || form.tagtype.value === '이동보호') && form.protectReason) ? form.protectReason.value : null,
expiry: (actiontype === 'protect') ?
(form.editmodify.checked ? form.editexpiry.value :
(form.movemodify.checked ? form.moveexpiry.value :
(form.pcmodify.checked ? form.pcexpiry.value : null)
)
) : null,
small: form.small.checked,
noinclude: form.noinclude.checked
};
}
switch (actiontype) {
case 'protect':
// protect the page
if (form.editlevel.value === 'extendedconfirmed' && !confirm('Extended confirmed protection is only for Arbitration enforcement. ' +
'Please confirm that the subject of this page is a qualifying topic (see WP:30/500).')) {
return;
}
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.notice = "보호 완료";
var statusInited = false;
var thispage;
var allDone = function twinkleprotectCallbackAllDone() {
if (thispage) {
thispage.getStatusElement().info("done");
}
if (tagparams) {
Twinkle.protect.callbacks.taggingPageInitial(tagparams);
}
};
var stabilizeValues = {};
if (form.pclevel) {
stabilizeValues = {
pclevel: form.pclevel.value,
pcexpiry: form.pcexpiry.value,
protectReason: form.protectReason.value
};
}
var protectIt = function twinkleprotectCallbackProtectIt(next) {
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "문서 보호 중");
if (mw.config.get('wgArticleId')) {
if (form.editmodify.checked) {
thispage.setEditProtection(form.editlevel.value, form.editexpiry.value);
}
if (form.movemodify.checked) {
thispage.setMoveProtection(form.movelevel.value, form.moveexpiry.value);
}
} else {
thispage.setCreateProtection(form.createlevel.value, form.createexpiry.value);
thispage.setWatchlist(false);
}
if (form.protectReason.value) {
thispage.setEditSummary(form.protectReason.value);
} else {
alert("You must enter a protect reason, which will be inscribed into the protection log.");
return;
}
if (!statusInited) {
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
statusInited = true;
}
thispage.protect(next);
};
var stabilizeIt = function twinkleprotectCallbackStabilizeIt() {
if (thispage) {
thispage.getStatusElement().info("done");
}
thispage = new Morebits.wiki.page(mw.config.get('wgPageName'), "Applying pending changes protection");
thispage.setFlaggedRevs(stabilizeValues.pclevel, stabilizeValues.pcexpiry);
if (stabilizeValues.protectReason) {
thispage.setEditSummary(stabilizeValues.protectReason);
} else {
alert("You must enter a protect reason, which will be inscribed into the protection log.");
return;
}
if (!statusInited) {
Morebits.simpleWindow.setButtonsEnabled(false);
Morebits.status.init(form);
statusInited = true;
}
thispage.stabilize(allDone);
};
if ((form.editmodify && form.editmodify.checked) || (form.movemodify && form.movemodify.checked) ||
!mw.config.get('wgArticleId')) {
if (form.pcmodify && form.pcmodify.checked) {
protectIt(stabilizeIt);
} else {
protectIt(allDone);
}
} else if (form.pcmodify && form.pcmodify.checked) {
stabilizeIt();
} else {
alert("Please give Twinkle something to do! \nIf you just want to tag the page, you can choose the 'Tag page with protection template' option at the top.");
}
break;
case 'tag':
// 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 = "Tagging complete";
Twinkle.protect.callbacks.taggingPageInitial(tagparams);
break;
case 'request':
// file request at RPP
var typename, typereason;
switch( form.category.value ) {
case '보호-논쟁':
case '보호-훼손':
case '보호-사용자토론':
case '보호':
typename = '완전한 보호';
break;
case '보호-틀':
typename = '틀 보호';
break;
case '준보호-훼손':
case '준보호-논쟁':
case 'pp-semi-unsourced':
case '준보호-사용자토론':
case '준보호-인물':
case '준보호':
typename = '준보호';
break;
case 'pp-pc-vandalism':
case 'pp-pc-blp':
case 'pp-pc-protected':
case 'pp-pc-unsourced':
case 'pp-pc-disruptive':
typename = 'pending changes';
break;
case '이동보호':
case '이동보호-논쟁':
case '이동보호-무기한':
case '이동보호-훼손':
typename = '이동 보호';
break;
case '생성보호':
case '생성보호-offensive':
case '생성보호-인물':
case '생성보호-salt':
typename = '생성 보호';
break;
case 'unprotect':
/* falls through */
default:
typename = '보호 해제';
break;
}
switch (form.category.value) {
case '보호-논쟁':
typereason = 'Content dispute/edit warring';
break;
case '보호-훼손':
case '준보호-훼손':
case 'pp-pc-vandalism':
typereason = 'Persistent vandalism';
break;
case '준보호-논쟁':
case 'pp-pc-disruptive':
typereason = 'Persistent [[Wikipedia:Disruptive editing|disruptive editing]]';
break;
case 'pp-semi-unsourced':
case 'pp-pc-unsourced':
typereason = 'Persistent addition of [[WP:INTREF|unsourced or poorly sourced content]]';
break;
case '보호-틀':
typereason = '매우 민감한 틀';
break;
case '보호-사용자토론':
case '준보호-사용자토론':
typereason = '차단 중 부적절한 사용자 토론의 사용';
break;
case '준보호-인물':
case 'pp-pc-blp':
typereason = '[[WP:BLP|BLP]] policy violations';
break;
case '이동보호-논쟁':
typereason = '문서 제목 논쟁/이동 경고';
break;
case '이동보호-훼손':
typereason = '문서 이동 훼손';
break;
case '이동보호-무기한':
typereason = '매우 민감한 문서';
break;
case '생성보호-offensive':
typereason = '부적절한 문서 제목';
break;
case '생성보호-인물':
typereason = '최근에 삭제됨';
break;
case '생성보호-salt':
typereason = '지속적인 재생성';
break;
default:
typereason = '';
break;
}
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 += '.';
}
var rppparams = {
reason: reason,
typename: typename,
category: form.category.value,
expiry: form.expiry.value
};
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( form );
// 한국어 위키백과에서는 문서 관리 요청이 문서 보호 요청 과정을 함께 하도록 되어 있음
var rppName = '위키백과:문서 관리 요청';
// Updating data for the action completed event
Morebits.wiki.actionCompleted.redirect = rppName;
Morebits.wiki.actionCompleted.notice = "Nomination completed, redirecting now to the discussion page";
var rppPage = new Morebits.wiki.page( rppName, '문서 보호 요청 중');
rppPage.setFollowRedirect( true );
rppPage.setCallbackParameters( rppparams );
rppPage.load( Twinkle.protect.callbacks.fileRequest );
break;
default:
alert("twinkleprotect: unknown kind of action");
break;
}
};
Twinkle.protect.callbacks = {
taggingPageInitial: function( tagparams ) {
if (tagparams.tag === 'noop') {
Morebits.status.info("Applying protection template", "nothing to do");
return;
}
var protectedPage = new Morebits.wiki.page( mw.config.get('wgPageName'), 'Tagging page');
protectedPage.setCallbackParameters( tagparams );
protectedPage.load( Twinkle.protect.callbacks.taggingPage );
},
taggingPage: function( protectedPage ) {
var params = protectedPage.getCallbackParameters();
var text = protectedPage.getPageText();
var tag, summary;
var oldtag_re = /\s*(?:<noinclude>)?\s*\{\{\s*(보호-메타|보호-논쟁|이동보호-논쟁|이동보호-훼손|보호-훼손|보호-틀|보호-사용자토론|준보호-사용자토론|보호-인물|보호-무기한|준보호-무기한|이동보호-무기한|보호|이동보호|보호-재단|무기한 보호 알림|임시 보호 알림|생성보호)\s*?\}\}\s*(?:<\/noinclude>)?\s*/gi;
var re_result = oldtag_re.exec(text);
if (re_result) {
if (confirm("{{" + re_result[1] + "}} 틀을 문서에서 찾았습니다. \n제거하려면 확인을 누르시고, 유지하려면 취소를 누르십시오.")) {
text = text.replace( oldtag_re, '' );
}
}
if ( params.tag !== 'none' ) {
tag = params.tag;
if( params.reason ) {
tag += '|reason=' + params.reason;
}
if( ['indefinite', 'infinite', 'never', null].indexOf(params.expiry) === -1 ) {
tag += '|expiry={{subst:#time:H:i, j F Y|' + (/^\s*\d+\s*$/.exec(params.expiry) ? params.expiry : '+' + params.expiry) + '}}';
}
if( params.small ) {
tag += '|small=yes';
}
}
if( params.tag === 'none' ) {
summary = 'Removing protection template' + Twinkle.getPref('summaryAd');
} else {
if( params.noinclude ) {
text = "<noinclude>{{" + tag + "}}</noinclude>" + text;
} else if( Morebits.wiki.isPageRedirect() ) {
text = text + "\n{{" + tag + "}}";
} else {
text = "{{" + tag + "}}\n" + text;
}
summary = "Adding {{" + 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();
var text = rppPage.getPageText();
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( [ 'There is already a protection request for this page at ', rppLink, ', aborting.' ] );
return;
}
var newtag = '=== [[:' + Morebits.pageNameNorm + ']] ===\n';
if( ( new RegExp( '^' + RegExp.escape( newtag ).replace( /\s+/g, '\\s*' ), 'm' ) ).test( text ) ) {
statusElement.error( [ 'There is already a protection request for this page at ', rppLink, ', aborting.' ] );
return;
}
newtag += '* {{pagelinks|' + Morebits.pageNameNorm + '}}\n\n';
var words;
switch( params.expiry ) {
case 'temporary':
words = "Temporary ";
break;
case 'indefinite':
words = "Indefinite ";
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
// else we post it under decrease
var increase = false;
var protInfo = Twinkle.protect.protectionPresetsInfo[params.category];
// function to compute protection weights (see comment at Twinkle.protect.protectionWeight)
var computeWeight = function(mainLevel, stabilizeLevel) {
var result = Twinkle.protect.protectionWeight[mainLevel || 'all'];
if (stabilizeLevel) {
if (result) {
if (stabilizeLevel.level === "autoconfirmed") {
result += 2;
} else if (stabilizeLevel.level === "review") {
result += 7;
}
} else {
result = Twinkle.protect.protectionWeight["flaggedrevs_" + stabilizeLevel];
}
}
return result;
};
// compare the page's current protection weights with the protection we are requesting
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 ||
computeWeight(protInfo.move) > computeWeight(Twinkle.protect.currentProtectionLevels.move &&
Twinkle.protect.currentProtectionLevels.move.level) ||
computeWeight(protInfo.create) > computeWeight(Twinkle.protect.currentProtectionLevels.create &&
Twinkle.protect.currentProtectionLevels.create.level)) {
increase = true;
}
var reg;
if ( increase ) {
reg = /(\n==\s*Current requests for reduction in protection level\s*==)/;
} else {
reg = /(\n==\s*Current requests for edits to a protected page\s*==)/;
}
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(":en:Wikipedia:Twinkle/Fixing RPP") );
linknode.appendChild(document.createTextNode('RPP 수정 방법'));
statusElement.error( [ 'Could not find relevant heading on WP:RPP. To fix this problem, please see ', linknode, '.' ] );
return;
}
statusElement.status( '새로운 요청을 추가 중...' );
rppPage.setEditSummary( "Requesting " + params.typename + (params.typename === "pending changes" ? ' on [[' : ' of [[') +
Morebits.pageNameNorm + ']].' + Twinkle.getPref('summaryAd') );
rppPage.setPageText( text );
rppPage.setCreateOption( 'recreate' );
rppPage.save();
}
};
})(jQuery);
//</nowiki>