MediaWiki:Gadget-disambiguationLinks.js: различия между версиями

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
Содержимое удалено Содержимое добавлено
Проще и легче через нативный title
Проверка на наличие runAsEarlyAsPossible
 
Строка 1: Строка 1:
runAsEarlyAsPossible( function () {
( function () {
function extendLinkTitle() {
if( mw.loader.getState( 'ext.popups' ) !== 'ready' ) {
if( mw.loader.getState( 'ext.popups' ) !== 'ready' ) {
var $nodes = $( 'a.mw-disambig' );
var $nodes = $( 'a.mw-disambig' );
$nodes.each( function () {
var $node = $( this );
var title = $node.attr( 'title' );
$nodes.each( function () {
if( title.indexOf( '(значения)' ) < 0 ) {
var $node = $( this );
$node.attr( 'title', [ title, 'страница значений' ].join( ' — ' ) );
var title = $node.attr( 'title' );
}
} );
if( title.indexOf( '(значения)' ) < 0 ) {
$node.attr( 'title', [ title, 'страница значений' ].join( ' — ' ) );
}
} );
}
}
}
} );
// In case other projects copypaste the code and forget to implement
// runAsEarlyAsPossible() in MediaWiki:Common.js, which is too easy a mistake to
// make to not account for.
if ( typeof runAsEarlyAsPossible === 'undefined' ) {
$( extendLinkTitle );
} else {
runAsEarlyAsPossible( extendLinkTitle );
}
} )();

Текущая версия от 22:35, 27 апреля 2021

( function () {
	function extendLinkTitle() {
		if( mw.loader.getState( 'ext.popups' ) !== 'ready' ) {
			var $nodes = $( 'a.mw-disambig' );
			
			$nodes.each( function () {
				var $node = $( this );
				var title = $node.attr( 'title' );
				
				if( title.indexOf( '(значения)' ) < 0 ) {
					$node.attr( 'title', [ title, 'страница значений' ].join( ' — ' ) );
				}
			} );
		}
	}
	
	// In case other projects copypaste the code and forget to implement
	// runAsEarlyAsPossible() in MediaWiki:Common.js, which is too easy a mistake to
	// make to not account for.
	
	if ( typeof runAsEarlyAsPossible === 'undefined' ) {
		$( extendLinkTitle );
	} else {
		runAsEarlyAsPossible( extendLinkTitle );
	}
} )();