User:Sakretsu/unpatrolled edits.js

From Wikidata
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$( function ( mw, $ ) {
	'use strict';

	var i18n = {
		en: 'Warning: the last edit to the page has not yet been patrolled.',
		it: 'Attenzione: l\'ultima versione della pagina non è stata verificata.'
	};

	function addNotice() {
		var url = mw.util.getUrl( mw.config.get( 'wgPageName' ), { diff: '' } );
		$( '<div></div>' ).load( url + ' .patrollink', function () {
			if ( $( this ).text().length ) {
				var lang = mw.user.options.get( 'language' );
				var msg = lang in i18n ? i18n[ lang ] : i18n.en;
				var $div = $( '<div>' )
					.css( {
						'background': '#ffdbdb',
						'border': '1px solid #bb7070',
						'display': 'inline-block',
						'font-weight': 'bold',
						'margin-bottom': '1em',
						'padding': '.5em 1em'
					} )
					.append( '<p>' + msg + '</p>' );
				$div.insertBefore( '#mw-content-text' );
			}
		} );
	}

	$( function () {
		if ( mw.config.get( 'wgNamespaceNumber' ) === 0 &&
			 mw.config.get( 'wgArticleId' ) !== 0 &&
			 mw.config.get( 'wgAction' ) == 'view' &&
			 !$( '.mw-revision' ).length ) {
			mw.loader.using( 'mediawiki.util' ).done( addNotice() );
		}
	} );
} ( mediaWiki, jQuery ) );