跳转到内容

MediaWiki:Common.js/Toolbox.js

来自维客图书,开放世界中的开放图书
注意:保存后,更改可能不会立即生效。点击此处,了解如何绕过浏览器的缓存。
  • Mozilla / Firefox / Safari:按住Shift键同时点击Reload,或按下Ctrl-Shift-R(Mac上为Cmd-Shift-R);
  • Internet Explorer:按住Ctrl键同时点击刷新,或按下Ctrl-F5;
  • Konqueror:只需点击Reload,或按下F5;
  • Opera用户可能需要在Tools→Preferences中彻底清除其缓存。
(function($, mw) {
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) === -1 ) {
	return;
}
mw.loader.using( 'user.options', function () {
	if ( mw.user.options.get('usebetatoolbar') ) {
		mw.loader.using('ext.wikiEditor', function () {
			$(document).ready( function() {
				var $textbox = $('#wpTextbox1');
				toolbox( $textbox, $);
			});
		});
	}
});

function toolbox($textbox, $) {
	$textbox.wikiEditor( 'addToToolbar', {
		'section': 'main',
		'group': 'format',
		'tools': {
			'underline': {
				label: 'underline',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/8/8b/Button_underline_he.png',
				action: {
					type: 'encapsulate',
					options: { pre: "<u>", peri: "text", post: "</u>" }
				}
			},
			'strikethrough': {
				label: 'strikeout',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/6/6d/Vector_strikeout.png',
				action: {
					type: 'encapsulate',
					options: { pre: "<s>", peri: "text", post: "</s>" }
				}
			}
		}
	});
	text_type($textbox, $);
}

function text_type($textbox, $) {

var sourcetext_type = [
['text', 'Text'],
['abap', 'ABAP'],
['actionscript', 'ActionScript'],
['ada', 'Ada'],
['apache', 'Apache'],
['applescript', 'AppleScript'],
['asm', 'ASM'],
['asp', 'Active Server Pages'],
['autoit', 'AutoIt'],
['bash', 'Bash'],
['basic4gl', 'Basic4GL'],
['bf', 'Brainfuck'],
['blitzbasic', 'Blitz BASIC'],
['bnf', 'Backus-Naur Form'],
['c', 'C'],
['c_mac', 'C (Mac)'],
['caddcl', 'AutoCAD DCL'],
['cadlisp', 'AutoLISP'],
['cfdg', 'CFDG'],
['cfm', 'ColdFusion'],
['cil', 'Common Intermediate Language'],
['cobol', 'COBOL'],
['cpp-qt', 'C++ (Qt toolkit)'],
['cpp', 'C++'],
['csharp', 'C#'],
['css', 'Cascading Style Sheets'],
['d', 'D'],
['delphi', 'Delphi'],
['diff', 'Diff'],
['div', 'DIV'],
['dos', 'DOS batch file'],
['dot', 'DOT'],
['eiffel', 'Eiffel'],
['fortran', 'Fortran'],
['freebasic', 'FreeBASIC'],
['genero', 'Genero'],
['gettext', 'i18n'],
['glsl', 'OpenGL Shading Language'],
['gml', 'Game Maker Language'],
['gnuplot', 'gnuplot'],
['groovy', 'Groovy'],
['haskell', 'Haskell'],
['hq9plus', 'HQ9+'],
['html4strict', 'HTML'],
['idl', 'Uno IDL'],
['ini', 'INI'],
['inno', 'Inno'],
['intercal', 'INTERCAL'],
['io', 'Io'],
['java5', 'Java 5.0'],
['java', 'Java'],
['javascript', 'JavaScript'],
['kixtart', 'KiXtart'],
['klonec', 'Klone C'],
['klonecpp', 'Klone C++'],
['latex', 'LaTeX'],
['lisp', 'Lisp'],
['lolcode', 'LOLCODE'],
['lotusscript', 'LotusScript'],
['lua', 'Lua'],
['m68k', 'Motorola 68000 Assembler'],
['make', 'make'],
['matlab', 'MATLAB M'],
['mirc', 'mIRC scripting language'],
['mxml', 'MXML'],
['mpasm', 'Microchip Assembler'],
['mysql', 'MySQL'],
['nsis', 'Nullsoft Scriptable Install System'],
['objc', 'Objective-C'],
['ocaml-brief', 'OCaml Brief'],
['ocaml', 'OCaml'],
['oobas', 'OpenOffice Basic'],
['oracle8', 'Oracle 8 SQL'],
['oracle11', 'Oracle 11 SQL'],
['pascal', 'Pascal'],
['per', 'per'],
['perl', 'Perl'],
['php-brief', 'PHP Brief'],
['php', 'PHP'],
['pixelbender', 'Pixel Bender'],
['plsql', 'PL/SQL'],
['povray', 'Persistence of Vision Raytracer'],
['powershell', 'Windows PowerShell'],
['progress', 'OpenEdge ABL'],
['prolog', 'Prolog'],
['providex', 'ProvideX'],
['python', 'Python'],
['qbasic', 'QBasic/QuickBASIC'],
['rails', 'Rails'],
['reg', 'Windows Registry'],
['robots', 'robots.txt'],
['ruby', 'Ruby'],
['rsplus', 'R/S+'],
['sas', 'SAS'],
['scala', 'Scala'],
['scheme', 'Scheme'],
['scilab', 'Scilab'],
['sdlbasic', 'SdlBasic'],
['smalltalk', 'Smalltalk'],
['smarty', 'Smarty'],
['sql', 'SQL'],
['tcl', 'Tcl'],
['teraterm', 'Tera Term'],
['thinbasic', 'thinBasic'],
['tsql', 'Transact-SQL'],
['typoscript', 'TypoScript'],
['vbnet', 'Visual Basic .NET'],
['vb', 'Visual Basic'],
['verilog', 'Verilog'],
['vhdl', 'VHDL'],
['vim', 'Vimscript'],
['visualfoxpro', 'Visual FoxPro'],
['visualprolog', 'Visual Prolog'],
['whitespace', 'Whitespace'],
['winbatch', 'Winbatch'],
['xml', 'XML'],
['xorg_conf', 'Xorg.conf'],
['xpp', 'X++'],
['z80', 'ZiLOG Z80 Assembler']
],

source_list = {
	label: 'Text Type',
	type: 'select',
	list: {
		teletype: {
			label: 'teletype',
			'action': { 'type': 'encapsulate', 'options': { 'pre': '<tt>', 'peri': 'text', 'post': '</tt>' } }
		},
		code: {
			'label': 'inline code',
			'action': { 'type': 'encapsulate', 'options': { 'pre': '<code>', 'peri': 'text', 'post': '</code>' } }
		}
	}
};

$.eachAsync(sourcetext_type, {
	'delay': 1,
	'bulk': 0,
	'loop': function(index, value) {
		var name = value[1], lang = value[0];
		source_list.list[name] = {
			'label': name,
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': '<syntaxhighlight lang="'+ lang + '">\n',
					'post': '\n</syntaxhighlight>',
					ownline: true
				}
			}
		};
	},
	'end': function() {
		$textbox.wikiEditor( 'addToToolbar', {
			'section': 'advanced',
			'group': 'heading',
			'tools': {
				'text-type': source_list
			}
		});		
	}
});

}
})(jQuery, mediaWiki);
华夏公益教科书