میدیاویکی:Gadget-Page descriptions.js

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
تێبینی: دوای پاشەکەوتکردن، پێویستە کاشی وێبگەڕەکەت پاک بکەیتەوە تا گۆڕانکارییەکان ببینیت. بۆ گووگڵ کڕۆم، فایەرفۆکس، مایکرۆسۆفت ئێج و سافاری: پەنجە لەسەر دوگمەی ⇧ Shift ڕاگرە و کرتە لەسەر Reload بکە. بۆ وردەکاری و ڕێنمایییەکان لەسەر وێبگەڕەکانی تر، بڕوانە ئێرە.
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 && mw.config.get( 'wgAction' ) === 'view' ) {
	mw.loader.using( 'mediawiki.api' ).then( function () {
		// Adds a page description just below the "page title"
		// Behaves a lot like the mobile version
		var wgQid = mw.config.get( 'wgWikibaseItemId' ),
			api = new mw.Api(),
			callPromise = api.get( {
				action: 'query',
				titles: mw.config.get( 'wgTitle' ),
				prop: 'description',
				formatversion: 2
			} ),
			isEditor = mw.config.get( 'wgUserGroups' ).indexOf( 'autoconfirmed' ) !== -1;

		$.when( callPromise, $.ready ).then( function ( results ) {
			var pageDescription, $description,
				response = results[ 0 ];
			if (
				response.query &&
				response.query.pages &&
				response.query.pages[ 0 ].description
			) {
				pageDescription = response.query.pages[ 0 ].description;
				$description = $( '<span>' )
					.addClass( 'mw-page-description' )
					.text( pageDescription );
				if ( response.query.pages[ 0 ].descriptionsource !== 'local' && isEditor ) {
					$description.append(
						' (',
						$( '<a>' )
							.attr( 'href', 'https://www.wikidata.org/wiki/Special:SetLabelDescriptionAliases/' + wgQid + '/' + mw.config.get( 'wgContentLanguage' ) )
							.css( 'color', 'darkorange' )
							.text( 'ویکیدراوە' ),
						')'
					);
				}
				$description.append( '. ' );
			} else if ( isEditor ) {
				$description = $( '<span>' )
					.css( 'color', 'red' )
					.append(
						'ونبوونی ',
						$( '<a>' )
							.attr( 'href', '/wiki/داڕێژە:وەسف' )
							.text( 'وەسفی پەڕە' ),
						'. '
					);
			}
			if ( $description ) {
				$( '#siteSub' ).prepend( $description );
			}
		} );
	} );
}