(Translated by https://www.hiragana.jp/)
MediaWiki:Gadget-noteTA.js - 维基百科,自由的百科全书 とべ转到内容ないよう

MediaWiki:Gadget-noteTA.js

维基百科ひゃっか自由じゆうてき百科ひゃっかぜん

这是ほん页的いち历史版本はんぽんゆかりLiangentとめげん | 贡献ざい2014ねん6がつ18にち (さん) 11:55编辑。这可能かのうとうぜん版本はんぽん存在そんざい巨大きょだいてき异。

注意ちゅうい保存ほぞんきさき,你必须清じょ浏览缓存才能さいのういた做出てき更改こうかいGoogle ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具こうぐ栏的“刷新さっしん”按钮。まいりHelp:绕过浏览缓存以获取さら帮助。

( function( $, mw ) { $( function() {
	var api = null;
	var init = function( hash ) {
		var $dialog = $( '<div class="noteTA-dialog" />' );
		$dialog.html( '<div class="mw-ajax-loader" style="margin-top: 48px;" />' );
		$dialog.dialog( {
			title: wgULS( '词转换', '轉換てんかん' )
		} );
		api = new mw.Api();
		run( $dialog, hash );
		return $dialog;
	}, run = function( $dialog, hash ) {
		var wikitext = '';
		var $dom = $( '#noteTA-' + hash );
		var collapse = true;

		var $noteTAtitle = $dom.find( '.noteTA-title' );
		if ( $noteTAtitle.length ) {
			var titleConv = decodeURIComponent( $noteTAtitle.attr( 'data-noteta-code' ).replace(/\+/g, '%20') );
			var titleDesc = $noteTAtitle.attr( 'data-noteta-desc' );
			if ( titleDesc ) {
				titleDesc = '(' + decodeURIComponent( titleDesc.replace(/\+/g, '%20') ) + ')';
			} else {
				titleDesc = '';
			}
			wikitext += '<span style="float: right;">{{edit|' + mw.config.get( 'wgPageName' ) + '|section=0}}</span>\n';
			wikitext += '; 本文ほんぶん使用しよう[[Help:ちゅうぶん维基百科ひゃっかてきしげる简、地区ちく词处#條目じょうもく標題ひょうだい|标题手工しゅこう转换]]\n';
			wikitext += '* 转换标题为:-{D|' + titleConv + '}-' + titleDesc + '\n';
			wikitext += '* 实际标题为:-{' + mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ) + '}-;とうぜん显示为:-{' + titleConv + '}-\n';
		}

		var $noteTAgroups = $dom.find( '.noteTA-group > *[data-noteta-group]' );
		if ( $noteTAgroups.length > 1 ) {
			collapse = true;
		}
		$noteTAgroups.each( function() {
			var $this = $( this );
			if ( $this.attr( 'data-noteta-group' ) == 'missing' ) {
				wikitext += '; 本文ほんぶん使用しようてき公共こうきょう转换组“' + $this.attr( 'data-noteta-group' ) + '”なお创建\n';
				wikitext += '* {{edit|Template:CGroup/' + $this.attr( 'data-noteta-group' ) + '|创建公共こうきょう转换组“' + $this.attr( 'data-noteta-group' ) + '”}}\n';
			} else {
				wikitext += '{{CGroup/' + $this.attr( 'data-noteta-group' ) + '}}\n';
			}
		} );

		var $noteTAlocal = $dom.find( '.noteTA-local' );
		if ( $noteTAlocal.length ) {
			collapse = true;
			wikitext += '<span style="float: right;">{{edit|' + mw.config.get( 'wgPageName' ) + '|section=0}}</span>\n';
			wikitext += '; 本文ほんぶん使用しよう[[Help:ちゅうぶん维基百科ひゃっかてきしげる简、地区ちく词处#ひかえせい动转换的だい碼|全文ぜんぶん手工しゅこう转换]]\n';
			var $noteTAlocals = $noteTAlocal.children( '*[data-noteta-code]' );
			$noteTAlocals.each( function() {
				var $this = $( this );
				var localConv = decodeURIComponent( $this.attr( 'data-noteta-code' ).replace(/\+/g, '%20') );
				var localDesc = $this.attr( 'data-noteta-desc' );
				if ( localDesc ) {
					localDesc = '(' + decodeURIComponent( localDesc.replace(/\+/g, '%20') ) + ')';
				} else {
					localDesc = '';
				}
				wikitext += '* -{D|' + localConv + '}-' + localDesc + 'とうぜん显示为:-{' + localConv + '}-\n';
			} );
		}

		// Maybe move to a template
		wikitext += '{{noteTA/footer}}';

		var parse = function() {
			api.post( {
				action: 'parse',
				title: 'Template:CGroup/-',
				text: wikitext,
				prop: 'text',
				variant: mw.config.get( 'wgUserVariant' )
			}, {
				ok: function( results ) {
					$dialog.html( results.parse.text['*'] );
					if ( collapse ) {
						$dialog.find( '.mw-collapsible' ).makeCollapsible();
						$dialog.find( '.mw-collapsible-toggle' ).on( 'click.mw-collapse', function( e ) {
							var $collapsibleContent = $( this ).parent( '.mw-collapsible' ).find( '.mw-collapsible-content' );
							setTimeout( function() {
								$collapsibleContent.promise().done( function() {
									$dialog.dialog( 'option', 'position', 'center' );
								} );
							}, 0 );
						} );
					}
					$dialog.dialog( 'option', 'width', Math.round( $( window ).width() * 0.8 ) );
					$dialog.css( 'max-height', Math.round( $( window ).height() * 0.8 ) + 'px' );
					$dialog.dialog( 'option', 'position', 'center' );
				},
				err: parse
			} );
		};
		parse();
	};

	$( '.noteTA-topicon' )
		.css( 'cursor', 'pointer' )
		.each( function() {
			var $dialog = null;
			var $this = $( this );
			var hash = $this.attr( 'id' ).replace( /^noteTA-topicon-/, '' );
			$this.click( function() {
				if ( $dialog === null ) {
					$dialog = init( hash );
				} else {
					$dialog.dialog( 'open' );
				}
			} );
		} );

} ); } )( jQuery, mediaWiki );