Медиавики:Gadget-ProtectionIndicator.js

Мавод аз Википедиа — донишномаи озод

Эзоҳ: Баъди захира намудан, Шумо метавонед тағйиротҳои худро аз хотираи браузер гузариш карда, бубинед. Дар браузерҳои Mozilla / Firefox / Safari: тугмаи Shift-ро пахш намуда бо мушак Reload-ро пахш кунед, ё Ctrl-Shift-R-ро пахш намоед (Cmd-Shift-R барои компютерҳои Apple Mac); дар браузери IE: тугмаи Ctrl-ро пахш намуда бо мушак Refresh-ро пахш намоед, ё Ctrl-F5-ро пахш намоед; дар браузери Konqueror:: бо мушак Reload-ро пахш кунед, ё тугмаи F5-ро пахш намоед; дар браузери Opera ба Шумо пурра тоза кардани хотираи браузер ба воситаи Tools→Preferences лозим аст.

( 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 ) );