打开/关闭菜单
59
83
13
872
诺布百科 · Noblecraft Wiki
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
Baneq留言 | 贡献
创建页面,内容为“这里的任何JavaScript将为所有用户在每次页面加载时加载。:​ // 给源码编辑器工具栏加"颜色/高亮"按钮 $( function () { if ( typeof mw === 'undefined' || !mw.loader ) { return; } mw.loader.using( 'user.options' ).then( function () { if ( $( '#wpTextbox1' ).length && $.fn.wikiEditor ) { var buttons = { '红': '红', '绿': '绿', '蓝': '蓝', '橙': '橙', '高亮': '高亮' }; var tools = {};…”
 
Baneq留言 | 贡献
无编辑摘要
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
// 给源码编辑器工具栏加"颜色/高亮"按钮
$( function () {
$( function () {
if ( typeof mw === 'undefined' || !mw.loader ) { return; }
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
mw.loader.using( 'user.options' ).then( function () {
var colors = [ '红', '绿', '蓝', '橙', '高亮' ];
if ( $( '#wpTextbox1' ).length && $.fn.wikiEditor ) {
var tools = {};
var buttons = {
colors.forEach( function ( name ) {
'红': '红',
tools[ name ] = {
'绿': '绿',
label: name,
'蓝': '',
type: 'button',
'': '',
action: {
'高亮': '高亮'
type: 'encapsulate',
options: { pre: '{{' + name + '|', peri: '文字', post: '}}' }
}
};
};
var tools = {};
} );
Object.keys( buttons ).forEach( function ( label ) {
$textarea.wikiEditor( 'addToToolbar', {
tools[ label ] = {
section: 'main',
label: label,
group: 'format',
type: 'button',
tools: tools
action: {
} );
type: 'encapsulate',
options: {
pre: '{{' + buttons[ label ] + '|',
peri: '文字',
post: '}}'
}
}
};
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'main',
group: 'format',
tools: tools
} );
}
} );
} );
} );
} );

2026年5月31日 (日) 06:34的版本

$( function () {
	mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
		var colors = [ '红', '绿', '蓝', '橙', '高亮' ];
		var tools = {};
		colors.forEach( function ( name ) {
			tools[ name ] = {
				label: name,
				type: 'button',
				action: {
					type: 'encapsulate',
					options: { pre: '{{' + name + '|', peri: '文字', post: '}}' }
				}
			};
		} );
		$textarea.wikiEditor( 'addToToolbar', {
			section: 'main',
			group: 'format',
			tools: tools
		} );
	} );
} );