میدیاویکی:Gadget-ProtectionIndicator.js
تێبینی: دوای پاشەکەوتکردن، پێویستە کاشی وێبگەڕەکەت پاک بکەیتەوە تا گۆڕانکارییەکان ببینیت. بۆ گووگڵ کڕۆم، فایەرفۆکس، مایکرۆسۆفت ئێج و سافاری: پەنجە لەسەر دوگمەی ⇧ Shift ڕاگرە و کرتە لەسەر Reload بکە. بۆ وردەکاری و ڕێنمایییەکان لەسەر وێبگەڕەکانی تر، بڕوانە ئێرە.
( function ( mw, $ ) {
function setMessages() {
mw.messages.set( {
'gadget-protection-autoconfirmed': 'Ця сторінка частково захищена.',
'gadget-protection-editprotected': 'Ця сторінка повністю захищена.'
} );
}
function init() {
// є думка, що на Головній воно неестетично...
if (mw.config.get( 'wgIsMainPage' ))
return;
var restrictions = mw.config.get( 'wgRestrictionEdit' ),
action = mw.config.get( 'wgAction' );
if ( action === 'view' && restrictions !== null && restrictions.length > 0 ) {
var $indicators = $( '.mw-indicators' ).first();
protectLevel = null;
if ( $indicators.find( '#mw-indicator-protected' ).length > 0 ) {
return;
}
setMessages();
if ( restrictions.indexOf( 'sysop' ) !== -1 ) {
protectLevel = 'editprotected';
} else if ( restrictions.indexOf( 'autoconfirmed' ) !== -1 ) {
protectLevel = 'autoconfirmed';
}
var protectText = mw.msg( 'gadget-protection-' + protectLevel );
$( '<div>' )
.addClass( 'mw-indicator mw-indicator-protect' )
.attr( {
id: 'mw-indicator-protect-' + protectLevel,
title: protectText,
alt: protectText
} )
.appendTo( $indicators );
}
}
$( init );
}( mediaWiki, jQuery ) );