MediaWiki:Gadget-Extra-Editbuttons.js

Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Strg+F5
//============================================================
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL [[:en:User:MarkS/Extra edit buttons]]
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE [[:de:Benutzer:Olliminatore/Extra-Editbuttons]]
//   Converted by [[User:Olliminatore]] 25.09.2006 
//   Angepasst an RL und mw.toolbar von [[User:✓]] April 2011
//============================================================
// de: Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable customEditButtons wählbar.
// <nowiki>
//

(function(){

	// Return early if not on edit page
	var action = mw.config.get( 'wgAction' );
	if( action !== 'edit' && action !== 'submit' ) {
		return;
	}

	// By registering our dependency after document.ready, we make sure
	// that the toolbar is fully loaded before we manipulate it
	mw.loader.using( [ 'mediawiki.toolbar', 'user' ], function() { $( function() {

		// Check that the toolbar is present on the page
		if( !$( '#toolbar' ).length ) {
			return;
		}

		// Define available buttons
		var sig = window.usersignature || '--\~\~\~\~';
		var commonsUrl = "//upload.wikimedia.org/wikipedia/commons/";

		var buttons = {
			'A'  : [
				commonsUrl + 'e/e9/Button_headline2.png',
				'Sekundäre Überschrift',
				'\n=== ',
				' ===',
				'Sekundäre Überschrift'
			],
			'A3' : [
				commonsUrl + '/3/3a/Button_headline3.png',
				'Untergeordnete Überschrift',
				'\n==== ',
				' ====',
				'Untergeordnete Überschrift'
			],
			'B'  : [
				commonsUrl + '1/13/Button_enter.png',
				'Zeilenumbruch',
				'<br />',
				'',
				''
			],
			'B1' : [
				commonsUrl + '6/62/Button_desambig.png',
				'Begriffsklärungseite',
				'{{Begriffsklärung}}',
				'',
				''
			],
			'B2' : [
				commonsUrl + '5/5e/Button_disambig_small.png',
				'Dieser Artikel erläutert…',
				'{{Dieser Artikel|',
				'}}',
				'erläutert den Buchstaben X, zu anderen Bedeutungen siehe [[X (Begriffsklärung)]].'
			],
			'B3' : [
				commonsUrl + '5/5e/Button_disambig_small.png',
				'Begriffsklärungshinweis',
				'{{Begriffsklärungshinweis}}',
				'',
				''
			],
			'C'  : [
				commonsUrl + '5/5f/Button_center.png',
				'Zentriert',
				'<div style="text-align: center;">\n',
				'\n<\/div>',
				'Zentriert'
			],
			'CF' : [
				commonsUrl + '3/37/Btn_toolbar_commentaire.png',
				'Chemische Formel',
				':<math>\u005Cmathrm{',
				'}</math>',
				''
			],
			'CO' : [
				commonsUrl + '6/6c/Button_commons.png',
				'Commons',
				'{{Commons|Category:',
				'}}',
				'Seitenname'
			],
			'D'  : [
				commonsUrl + 'e/ea/Button_align_left.png',
				'Left-Align',
				'<div style="text-align: left; direction: ltr; margin-left: 1em;">\n',
				'\n<\/div>',
				'Left-aligned Text'
	
			],
			'DS' : [
				commonsUrl + '4/4e/Button_romain.png',
				'SORTIERUNG',
				'{{SORTIERUNG:',
				'}}',
				'Sortierbegriff'
			],
			'DO' : [
				commonsUrl + 'e/e9/Button_done.png',
				'Erledigt (kurz)',
				'{{Erl.}}',
				'',
				''
			],
			'ER' : [
				commonsUrl + '9/9d/Button_fait.png',
				'Erledigt (lang)',
				'{{Erledigt|1=' + sig,
				'}}',
				''
			],
			'E'  : [
				commonsUrl + '0/04/Button_array.png',
				'Tabelle',
				'',
				'',
				'',
				'mw-editbutton-tablegenerator'
			],
			'F'  : [
				commonsUrl + '8/8f/Button_poeme.png',
				'Farbiger Text',
				'<span style="color: color">',
				'<\/span>',
				'Farbig'
			],
			'FS' : [
				commonsUrl + '1/1b/Button_miss_signature.png',
				'Fehlende Signatur',
				'\{\{subst\:Unsigned|',
				'}}',
				'BENUTZER'
			],
			'G'  : [
				commonsUrl + '9/9e/Btn_toolbar_gallery.png',
				'Bildergalerie',
				'\n<gallery>\nDatei:M63.jpg|[[M63]]\nDatei:Mona Lisa.jpg|[[Mona Lisa]]\nDatei:Truite arc-en-ciel.jpg|Eine [[Forelle ]]\n<\/gallery>',
				'',
				''
			],
			'H'  : [
				commonsUrl + '7/74/Button_comment.png',
				'Versteckter Kommentar',
				'<!--',
				'-->',
				'Versteckt'
			],
			'I'  : [
				commonsUrl + '4/41/Button_hr_halfwidth.png',
				'Gedankenstrich',
				'–',
				'',
				''
			],
			'I1' : [
				commonsUrl + '6/6a/Button_sup_letter.png',
				'Hochgestellter Text (superscript)',
				'<sup>',
				'<\/sup>',
				'Hochgestellt'
			],
			'I2' : [
				commonsUrl + 'a/aa/Button_sub_letter.png',
				'Tiefgestellter Text (subscript)',
				'<sub>',
				'<\/sub>',
				'Tiefgestellt'
			],
			'J1' : [
				commonsUrl + '5/58/Button_small.png',
				'Kleingeschriebener Text (small)',
				'<small>',
				'<\/small>',
				'Klein'
			],
			'J2' : [
				commonsUrl + '5/56/Button_big.png',
				'Größerer Text (big)',
				'<big>',
				'<\/big>',
				'Groß'
			],
			'K'  : [
				commonsUrl + 'b/b4/Button_category03.png',
				'Kategorie',
				'[[Kategorie:',
				']]',
				'Name der Kategorie'
			],
			'KR' : [
				commonsUrl + 'b/b1/Button_dagger.png',
				'Kreuz',
				'†',
				'',
				''
			],
			'L'  : [
				commonsUrl + '8/8e/Button_shifting.png',
				'Setze Tab(s)',
				':',
				'',
				':'
			],
			'M'  : [
				commonsUrl + 'f/fd/Button_blockquote.png',
				'Markiert ein Zitat mit Absatz',
				'<blockquote style="border: 1px solid blue; padding: 2em;">\n',
				'\n<\/blockquote>',
				'Text'
			],
			'N'  : [
				commonsUrl + '4/4b/Button_nbsp.png',
				'Geschütztes Leerzeichen (nonbreaking space)',
				'&nbsp;',
				'',
				''
			],
			'NT' : [
				commonsUrl + 'b/bf/Button_thinsp.png',
				'Schmales geschütztes Leerzeichen',
				'&thinsp;',
				'',
				''
			],
			'O'  : [
				commonsUrl + '2/23/Button_code.png',
				'Code einfügen',
				'<code>',
				'<\/code>',
				'Code'
			],
			'P'  : [
				commonsUrl + '3/3c/Button_pre.png',
				'Vorformatierter Text',
				'<pre>',
				'<\/pre>',
				'Präformatierter Text'
			],
			'P1' : [
				commonsUrl + '9/93/Button_sub_link.png',
				'Link zu einem Seiten-Abschnitt',
				'[[Seite#',
				']]',
				'Abschnitt'
			],
			'PF' : [
				commonsUrl + 'f/ff/Button_arrow_right.png',
				'Pfeil nach rechts',
				'\u2192',
				'',
				''
			],
			'PD' : [
				commonsUrl + 'e/ee/Button_vote_biblio.png',
				'Personendaten',
				'{{Personendaten\n|NAME=\n|ALTERNATIVNAMEN=',
				'\n|KURZBESCHREIBUNG=\n|GEBURTSDATUM=\n|GEBURTSORT=\n|STERBEDATUM=\n|STERBEORT=\n}}',
				''
			],
			'PO' : [
				commonsUrl + 'c/c7/Button_polytonique.png',
				'Unicode-Sonderzeichen der altgriechischen Schrift',
				'{{Polytonisch|',
				'}}',
				'Text'
			],
			'Q'  : [
				commonsUrl + 'd/d3/Button_definition_list.png',
				'Definitionsliste',
				'\n; ',
				' : ',
				'Text'
			],
			'Q1' : [
				commonsUrl + '0/05/Button_Anf%C3%BChrung.png',
				'Anführungszeichen',
				'„',
				'“',
				'Text'
			],
			'Q2' : [
				commonsUrl + '2/26/Button_latinas.png',
				'Latinas',
				'«',
				'»',
				'Text'
			],
			'Q3' : [
				commonsUrl + 'b/bc/Button_guillemet.png',
				'Guillemets',
				'»',
				'«',
				'Text'
			],
			'R'  : [
				commonsUrl + '7/79/Button_reflink.png',
				'Markiere eine Referenz',
				'<ref>',
				'<\/ref>',
				'Bezugsangabe'
			],
			'R1' : [
				commonsUrl + 'c/c4/Button_ref.png',
				'Referenz mit Name',
				'<ref name="">',
				'<\/ref>',
				'Bezugsangabe'
			],
			'R2' : [
				commonsUrl + 'f/fe/Button_refs.png',
				'Wiederholungs-Referenz',
				'<ref name="',
				'"/>',
				'Referenzname'
			],
			'R3' : [
				commonsUrl + '9/9a/Button_references.png',
				'Referenz-Footer',
				'\n== Einzelnachweise ==\n<references />\n',
				'',
				''
			],
			'RD' : [
				commonsUrl + '7/70/Button_fusion.png',
				'Redundanz',
				'<div id="Alien">
{| align="center" style="margin-top: 8px; padding: 0 0.3em 0.3em; border: 1px solid #B5B5B5; background-color: #FFFFFF; text-align: left; width: 100%;"
| style="width: 20px; vertical-align: top" | [[Image:Merge-arrows.svg|60px]]
| De Artikln [[',
				']]{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}}{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}}{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}}{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}}{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}}{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}}{{#ifeq:a|b|<nowiki> </nowiki>, [[]]}} und [[{{{2}}}]] [[Redundanz (Information)|übaschneidn si]] thematisch. Hüif bitte mit, dass de Artikln bessa vonanaunda åbzgrenzt oda  vareinigt wean. Bevoast den Hinweis wieda außaduast, möidt di bitte auf [[Wikipedia Diskussion:Redundanz]], wo de Redundanzfälle diskutiat wean.

Dankschee!
|}
</div>

[[Kategorie:Wikipedia:Redundanz|{{PAGENAME}}]]',
				'Artikel1|Artikel2|Artikel3…'
			], 
			'S'  : [
				commonsUrl + 'c/c9/Button_strike.png',
				'Durchgestrichener Text',
				'<s>',
				'<\/s>',
				'Durchgestrichen'
			],
			'SA' : [
				commonsUrl + 'b/bb/Seealso.png',
				'Siehe auch',
				'\n== Siehe auch ==\n',
				'',
				''
			],
			'SC' : [
				commonsUrl + '0/02/Button_S_yellow.png',
				'SourceCode hervorheben',
				'<source lang="javascript">',
				'<\/source>',
				'Quelltext'
			], 
			'SM' : [
				commonsUrl + '7/74/Button_oeil.png',
				'Smiley',
				'<tt style="background:#FE3">',
				'</tt>',
				':D'
			],
			'ST' : [
				commonsUrl + '7/72/Button_span_2.png',
				'span-tag mit CSS-Angabe',
				'<span style="">',
				'<\/span>',
				'Markierter Inhalt'
			],
			'T'  : [
				commonsUrl + 'e/eb/Button_plantilla.png',
				'Vorlage',
				'{{',
				'}}',
				'Vorlagenname'
			],
			'TL' : [
				commonsUrl + 'e/eb/Button_templatelink.png',
				'Vorlagenlink',
				'{{[[Vorlage:',
				'|]]}}',
				'Vorlagenname'
			],
			'TT' : [
				commonsUrl + '3/30/Tt_icon.png',
				'Schreibmaschinenstil',
				'<tt>',
				'<\/tt>',
				'Teletyper Text'
			],
			'U'  : [
				commonsUrl + 'f/fd/Button_underline.png',
				'Unterstreichen',
				'<u>',
				'<\/u>',
				'Unterstrichener Text'
			],
			'UR' : [
				commonsUrl + 'e/ec/Button_aviso.png',
				'Urheberrecht ungeklärt',
				'{{Urheberrecht ungeklärt}}',
				'',
				''
			],
			'URV': [
				commonsUrl + '9/9d/Button_halt.png',
				'Urheberrechtsverletzung',
				'{{URV}} [',
				'] ' + sig,
				'Url'
			],
			'V'  : [
				commonsUrl + 'c/c8/Button_redirect.png',
				'Weiterleitung (Redirect)',
				'#WEITERLEITUNG [[',
				']]',
				'Ziel einfügen',
				'mw-editbutton-redirect'
			],
			'VP' : [
				commonsUrl + 'b/ba/Button_conserver.png',
				'Vote *pro*',
				'# {{pro}} ' + sig,
				'',
				''
			],
			'VC' : [
				commonsUrl + 'f/fc/Button_supp.png',
				'Vote *contra*',
				'# {{contra}} ' + sig,
				'',
				''
			],
			'VN' : [
				commonsUrl + '4/4e/Button_neutre.png',
				'Vote *neutral*',
				'# {{neutral}} ' + sig,
				'',
				''
			],
			'WB' : [
				commonsUrl + '6/61/Button_wikibooks.png',
				'Wikibooks',
				'{{Wikibooks',
				'}}',
				'|Seitenname'
			],
			'WS' : [
				commonsUrl + 'e/eb/Button_wikisource.png',
				'Wikisource',
				'{{Wikisource',
				'}}',
				'|Seitenname'
			],
			'WT' : [
				commonsUrl + 'b/bf/WP-icon.png',
				'Wiktionary',
				'{{Wiktionary',
				'}}',
				'|Seitenname'
			],
			'WV' : [
				commonsUrl + 'b/b5/Button_wikiversity.png',
				'Wikiversity',
				'{{Wikiversity',
				'}}',
				'|Seitenname'
			],
			'W'  : [
				commonsUrl + '8/88/Btn_toolbar_enum.png',
				'Nummerierung',
				'\n# Element 1\n# Element 2\n# Element 3',
				'',
				''
			],
			'X'  : [
				commonsUrl + '1/11/Btn_toolbar_liste.png',
				'Liste',
				'\n* Element A\n* Element B\n* Element C',
				'',
				''
			],
			'Y1' : [
				commonsUrl + 'c/ce/Button_no_include.png',
				'No Include',
				'<noinclude>',
				'<\/noinclude>',
				'Text'
			],
			'Y2' : [
				commonsUrl + '7/79/Button_include.png',
				'Include only',
				'<includeonly>',
				'<\/includeonly>',
				'Text'
			],
			'Z'  : [
				commonsUrl + '3/35/Button_substitute.png',
				'Ersetzen',
				'{{ers:',
				'}}',
				'Vorlage'
			],
			'ZI' : [
				commonsUrl + '8/83/Button_biocitas.png',
				'Zitat',
				'{{Zitat|',
				'}}',
				'Text|Autor (optional)|Quelle (optional)'
			],
			'T1' : [
				commonsUrl + 'c/c6/Blending_blue_button_background.png',
				'Spacer (no function)',
				'',
				'',
				''
			],
			'0'  : [
				commonsUrl + 'e/e2/Button_bold.png',
				'Fetter Text',
				'\'\'\'',
				'\'\'\'',
				'Fetter Text',
				'mw-editbutton-bold'
			],
			'1'  : [
				commonsUrl + '1/1d/Button_italic.png',
				'Kursiver Text',
				'\'\'',
				'\'\'',
				'Kursiver Text',
				'mw-editbutton-italic'
			],
			'2'  : [
				commonsUrl + 'c/c0/Button_link.png',
				'Interner Link',
				'[[',
				']]',
				'Link-Text',
				'mw-editbutton-link'
			],
			'3'  : [
				commonsUrl + 'e/ec/Button_extlink.png',
				'Externer Link (http:// beachten)',
				'[',
				']',
				'http://www.example.com Link-Text',
				'mw-editbutton-extlink'
			],
			'4'  : [
				commonsUrl + 'f/fb/Button_headline.png',
				'überschrift',
				'\n== ',
				' ==\n',
				'überschrift',
				'mw-editbutton-headline'
			],
			'5'  : [
				commonsUrl + 'd/de/Button_image.png',
				'Dateilink',
				'[[Datei:',
				']]',
				'Beispiel.jpg',
				'mw-editbutton-image'
			],
			'6'  : [
				commonsUrl + '1/19/Button_media.png',
				'Mediendatei-Link',
				'[[Media:',
				']]',
				'Beispiel.ogg',
				'mw-editbutton-media'
			],
			'7'  : [
				commonsUrl + '2/2e/Button_math.png',
				'Mathematische Formel (LaTeX)',
				'\x3cmath\x3e',
				'\x3c/math\x3e',
				'Formel hier einfügen',
				'mw-editbutton-math'
			],
			'8'  : [
				commonsUrl + '8/82/Nowiki_icon.png',
				'Unformatierter Text',
				'\x3cnowiki\x3e',
				'\x3c/nowiki\x3e',
				'Unformatierten Text hier einfügen',
				'mw-editbutton-nowiki'
			],
			'9'  : [
				commonsUrl + '6/6d/Button_sig.png',
				'Deine Signatur mit Zeitstempel',
				'--\~\~\~\~',
				'',
				'',
				'mw-editbutton-signature'
			],
			'10' : [
				commonsUrl + '0/0d/Button_hr.png',
				'Horizontale Linie (sparsam verwenden)',
				'\n----\n',
				'',
				'',
				'mw-editbutton-hr'
			]
		};

		// Add user defined buttons to the available buttons
		if( window.myButtons ) {
			$.extend( buttons, window.myButtons );
		}

		// Add buttons to the toolbar in the specified order
		var order = window.customEditButtons || 'A,A3,B,E,F,G,H,I1,I2,J1,K,M,Q,R,R1,R2,R3,S,T,U,V,W,X';
		if( order === 'all' ) {
			order = [];
			for( var key in buttons ) {
				if( isNaN( key ) ) {
					order.push( key );
				}
			}
		} else {
			order = order.split( ',' );
		}

		for( var i = 0, l = order.length; i < l; i++ ) {
			var button = buttons[order[i]];
			if( !button ) {
				throw new Error( 'Unknown button: ' + order[i] );
			}
			mw.toolbar.addButton.apply( mw.toolbar, button );
		}

		// Remove some default buttons if requested
		if( window.rmEditButtons ) {
			var remove = window.rmEditButtons;
			if( ( remove[0] + '' ).toLowerCase() === 'all' ) {
				remove = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
			}
			remove.sort().reverse();

			var $toolbarButtons = $( '#toolbar' ).children();
			for( var i = 0, l = remove.length; i < l; i++ ) {
				$toolbarButtons.eq( remove[i] ).remove();
			}
		}

		// Customize signature button
		if( sig !== '--\~\~\~\~' ) {
			$( '#mw-editbutton-signature' ).off( 'click' ).click( function() {
				mw.toolbar.insertTags( sig, '', '' );
				return false;
			} ).attr( 'src', commonsUrl + 'd/d1/Button_mysignature.png' );
		}

		// Add special click handlers
		$( '#mw-editbutton-redirect' ).off( 'click' ).click( function() {
			var target = window.prompt( 'Wohin soll die Weiterleitung?', '' );
			if( target ) {
				var text = '#WEITERLEITUNG [[' + target + ']]';
				$( '#wpTextbox1' ).val( text );
				$( '#wpSummary' ).val( text );
				$( '#wpWatchthis' ).prop( 'checked', false );
			}
		} );			
		$( '#mw-editbutton-tablegenerator' ).click( popupTable );

		// Adjust width of spacer images
		if( mw.toolbar.$toolbar ) {
			mw.toolbar.$toolbar.children( 'img[src="' + buttons['T1'][0] + '"]' ).width( 6 ).off( 'click' );
		}

		//============================================================
		// Table generator 
		//============================================================
		/** en: Generate an array using Mediawiki syntax
		 * @author: originally from fr:user:dake
		 * @version: 0.2 */
		mw.toolbar.generateTable = function( caption, exhead, nbCol, nbRow, exfield, align ) {
			var code = '\n';
			code += '{| class="wikitable" ' + align + '\n' + caption + exhead;
			if( exfield ) {
				code += '!\n';
			}
			for( var i = 1; i < nbCol + 1; i++ ) {
				code += '! FELD ' + i + '\n';
			}
			var items = 0;
			for( var j = 0; j < nbRow; j++ ) {
				if( exfield ) {
					items++;
					code += '|-\n! style="background: #FFDDDD;" | ITEM ' + items + '\n';
				} else {
					code += '|-\n';
				}
				for( var i = 0; i < nbCol; i++ ) {
					code += '| Element\n';
				}
			}
			code += '|}\n';
			mw.toolbar.insertTags( '', '', code );
		};

		/** en: Open a popup with parameters to generate an array. 
		 * The number of rows/columns can be modified.
		 * @author: originally fr:user:dake 
		 * @version: 0.2 */
		function popupTable() {
			var popup = window.open( 'about:blank', 'WPtable', 'height=400,width=400,scrollbars=yes' );
			var javaCode = '<script type="text\/javascript">function insertCode(){'
				+'var caption = (document.paramForm.inputCaption.checked)?"\|\+ TABLE CAPTION \\n":""; '
				+'var exhead = (document.paramForm.inputHead.checked)?\'\|\- style=\"background: #DDFFDD;\"\\n\':""; '
				+'var row = parseInt(document.paramForm.inputRow.value); '
				+'var col = parseInt(document.paramForm.inputCol.value); '
				+'var exfield = document.paramForm.inputItems.checked; '
				+'var align = (document.paramForm.inputAlign.checked)?\'align="center"\':""; '
				+'window.opener.mw.toolbar.generateTable(caption,exhead,col,row,exfield,align); '
				+'window.close()}<\/script>';

			popup.document.write( '<html><head><title>Make table<\/title>'
					+ javaCode +'<\/head><body>'
					+'<p>Enter the table parameters below: <\/p>'
					+'<form name="paramForm">'
					+'Table caption: <input type="checkbox" name="inputCaption"><p\/>'
					+'Table alignment: center<input type="checkbox" name="inputAlign"><p\/>'
					+'Table headline: colored<input type="checkbox" name="inputHead"><p\/>'
					+'Number of rows: <input type="text" name="inputRow" value="3" size="2"><p\/>'
					+'Number of columns: <input type="text" name="inputCol" value="3" size="2"><p\/>'
					+'Item column: <input type="checkbox" name="inputItems" ><p\/>'
					+'<\/form">'
					+'<i>The default table allows for fields and values only.<\/i><p\/>'
					+'Check "Item column" to allow for the table to have fields, items, and values.<\/i><p\/>'
					+'<p><a href="javascript:insertCode()"> Insert table into window<\/a> &nbsp;&nbsp;&nbsp; |'
					+' &nbsp;&nbsp;&nbsp;<a href="javascript:self.close()">Cancel<\/a><\/p>'
					+'<\/body><\/html>'
			);
			popup.document.close();
			return false;
		}
	} ) } );
})();