Järjestelmäviesti:Gadget-ProtectionIndicator.js

Wikipediasta
Siirry navigaatioon Siirry hakuun

Huomautus: Selaimen välimuisti pitää tyhjentää asetusten tallentamisen jälkeen, jotta muutokset tulisivat voimaan.

  • Firefox ja Safari: Napsauta Shift-näppäin pohjassa Päivitä, tai paina Ctrl-F5 tai Ctrl-R (⌘-R Macilla)
  • Google Chrome: Paina Ctrl-Shift-R (⌘-Shift-R Macilla)
  • Internet Explorer ja Edge: Napsauta Ctrl-näppäin pohjassa Päivitä tai paina Ctrl-F5
  • Opera: Paina Ctrl-F5.
( function ( mw, $ ) {

function setMessages() { 
	mw.messages.set( {
		'gadget-protection-autoconfirmed': 'Tämä sivu on osittain suojattu muutoksilta.',
		'gadget-protection-editprotected': 'Tämä sivu on suojattu muutoksilta.'
			} );
	}
	
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;

		setMessages();

		if ( restrictions.indexOf( 'sysop' ) !== -1 ) {
			protectLevel = 'editprotected';
		} else if ( restrictions.indexOf( 'autoconfirmed' ) !== -1 ) {
			protectLevel = 'autoconfirmed';
		}
		
		if ( $indicators.find( '#mw-indicator-protected-' + protectLevel ).length > 0 ) {
			return;
		}

		var protectText = mw.msg( 'gadget-protection-' + protectLevel );

		$( '<div>' )
			.addClass( 'mw-indicator Gadget-ProtectionIndicator' )
			.attr( {
				id: 'mw-indicator-protected-' + protectLevel,
				title: protectText
			} )
			.appendTo( $indicators );
	}
}

$( init );

}( mediaWiki, jQuery ) );