User:MarkS/extraeditbuttons.js

This is an old revision of this page, as edited by Karl Dickman (talk | contribs) at 02:52, 1 December 2006 (add standard buttons, promise to check its effectiveness quickly). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<pre>
//============================================================
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE
//============================================================
// Vorschläge für neue Buttons werden gerne entgegengenommen
// Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.

if (typeof XEBOrder == 'undefined') // can be modified
	XEBOrder="A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V";

if (XEBOrder.toLowerCase() == 'all') 
        XEBOrder="A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V,FS,J2,N,P,P1,R1,R2,R3,R4,T1,TL,Y1,Y2,Z,AI";

//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar  
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){
 mwCustomEditButtons.push({
  "imageFile": imageFile,
  "speedTip": speedTip,
  "tagOpen": tagOpen,
  "tagClose": tagClose,
  "sampleText": sampleText});
}

var Isrc[0]='http://upload.wikimedia.org/wikipedia/commons/';
var Isrc[1]='http://en.wikipedia.org/skins-1.5/common/images/button_';

var BDict={
'0A':[Isrc[1]+'bold.png','Bold text','\'\'\,'\'\'\,'Bold text'],
'0B':[Isrc[1]+'italic.png','Italic text','\'\,'\'\,'Italic text'],
'0C':[Isrc[1]+'link.png','Internal link','[[',']]','Link title'],
'0D':[Isrc[1]+'extlink.png','External link (remember http:// prefix)','[',']','http://www.example.com link title'],
'0E':[Isrc[1]+'headline.png','Level 2 headline','\n== ',' ==\n','Headline text'],
'0F':[Isrc[1]+'image.png','Embedded image','[[Image:',']]','Example.jpg'],
'0G':[Isrc[1]+'media.png','Media file link','[[Media:',']]','Example.ogg'],
'0H':[Isrc[1]+'math.png','Mathematical formula (LaTeX)','<math>','<\/math>','Insert formula here'],
'0I':[Isrc[1]+'nowiki.png','Ignore wiki formatting','<nowiki>','<\/nowiki>','Insert non-formatted text here'],
'0J':[Isrc[1]+'sig.png','Your signature with timestamp','--~~~~'],
'0K':[Isrc[1]+'hr.png','Horizontal line (use sparingly)','\n----\n'],
'A':[Isrc[0]+'e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'],
'B':[Isrc[0]+'1/13/Button_enter.png','Line break','<br />','',''],
'C':[Isrc[0]+'5/5f/Button_center.png','Center','<div style="text-align: center;">\n','\n<\/div>','Centred text'],
'D':[Isrc[0]+'e/ea/Button_align_left.png','Left-Align','<div style="text-align: left; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Left-aligned text'],
'D1':[Isrc[0]+'a/a5/Button_align_right.png','Right-Align','<div style="text-align: right; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Right-aligned text'],
'E':[Isrc[0]+'0/04/Button_array.png','Table','\n{| class="wikitable" \n|- \n| 1 || 2\n|- \n| 3 || 4','\n|}\n',''],
'F':[Isrc[0]+'1/1e/Button_font_color.png','Insert coloured text','<span style="color: ','">Coloured text<\/span>','ColourName'],
'FS':[Isrc[0]+'1/1b/Button_miss_signature.png','Unsigned post','{{subst:unsigned|','|date}}','user name or IP'],
'G':[Isrc[0]+'9/9e/Btn_toolbar_gallery.png','Picture gallery',"\n<gallery>\nImage:","|[[M63]]\nImage:Mona Lisa.jpg|[[Mona Lisa]]\nImage:Truite arc-en-ciel.jpg|Eine [[Forelle ]]\n<\/gallery>",'M63.jpg'],
'H':[Isrc[0]+'7/74/Button_comment.png','Comment',"<!--","-->",'Comment'],
'I1':[Isrc[0]+'6/6a/Button_sup_letter.png','Superscript','<sup>','<\/sup>','Superscript text'],
'I2':[Isrc[0]+'a/aa/Button_sub_letter.png','Subscript','<sub>','<\/sub>','Subscript text'],
'J1':[Isrc[0]+'5/58/Button_small.png','Small','<small>','<\/small>','Small Text'],
'J2':[Isrc[0]+'5/56/Button_big.png','Big text','<big>','<\/big>','Big text'],
'K':[Isrc[0]+'b/b4/Button_category03.png','Category',"[[Category:","]]",'Category name'],
'L':[Isrc[0]+'8/8e/Button_shifting.png','Insert tab(s)',':','',':'],
'M':[Isrc[0]+'f/fd/Button_blockquote.png','Insert block of quoted text','<blockquote style="border: 1px solid blue; padding: 2em;">\n','\n<\/blockquote>','Block quote'],
'N':[Isrc[0]+'4/4b/Button_nbsp.png','nonbreaking space','&nbsp;','',''],
'O':[Isrc[0]+'2/23/Button_code.png','Insert code','<code>','<\/code>','Code'],
'P':[Isrc[0]+'3/3c/Button_pre.png','Pre formatted Text','<pre>','<\/pre>','Pre formatted text'],
'P1':[Isrc[0]+'9/93/Button_sub_link.png','Insert link to sub-page','[[','/Sub_Page]]','Page'],
'Q':[Isrc[0]+'d/d3/Button_definition_list.png','Insert definition list','\n; ','\n: Item 1\n: Item 2','Definition'],
'R':[Isrc[0]+'7/79/Button_reflink.png','Insert a reference','<ref>','<\/ref>','Insert reference material'],
'R1':[Isrc[0]+'7/79/Button_reflink.png','Start a reference','<ref name="','','Reference name'],
'R2':[Isrc[0]+'9/99/Button_reflink_advanced_2.png','Insert reference material','">','</ref>','Reference material'],
'R3':[Isrc[0]+'1/1a/Button_reflink_advanced_3.png','No reference material','','"/>',''],
'R4':[Isrc[0]+'9/9a/Button_references.png','Reference footer',"\n==Notes==\n<!--See http://en.wikipedia.org/wiki/Wikipedia:Footnotes for an explanation of how to generate footnotes using the <ref(erences/)> tags-->\n<div class=\'references-small\'>\n<references/>\n</div>",'',''],
'S':[Isrc[0]+'c/c9/Button_strike.png','Strikeout','<s>','<\/s>','Struck out text'],
'T':[Isrc[0]+'e/eb/Button_plantilla.png','Template','{{','}}','Template name'],
'T1':[Isrc[0]+'3/30/Tt_icon.png','Teletype text','<tt>','<\/tt>','Teletype Text'],
'TL':[Isrc[0]+'3/37/Button_tl_template.png','Template link',"{{subst:"+"tl|",'}}','Template name'],
'U':[Isrc[0]+'f/fd/Button_underline.png','Underlined',"<u>","<\/u>",'Underlined text'],
'V':[Isrc[0]+'c/c8/Button_redirect.png','Redirect',"#REDIRECT [[","]]",'Article Name'],
'W':[Isrc[0]+'8/88/Btn_toolbar_enum.png','Numbering',"\n# ","\n# Element 2\n# Element 3",'Element 1'],
'X':[Isrc[0]+'1/11/Btn_toolbar_liste.png','List',"\n* ","\n* Element B\n* Element C",'Element A'],
'Y1':[Isrc[0]+'c/ce/Button_no_include.png','No Include',"<noinclude>","<\/noinclude>",'Text'],
'Y2':[Isrc[0]+'7/79/Button_include.png','Include only',"<includeonly>","<\/includeonly>",'Text'],
'Z':[Isrc[0]+'3/35/Button_substitute.png','Substitute',"{{subst:","}}",'Template'],
'AI':[Isrc[0]+'1/1c/Button_advanced_image.png','Advanaced Image',"[[Image:","|thumb|right|px|Caption]]",'FileName.jpg']
}

XEBOrder=XEBOrder.split(",");
for (var b in XEBOrder) {
	var bc = BDict[XEBOrder[b]];
	addCustomButton(bc[0],bc[1],bc[2],bc[3],bc[4])
}
//</pre>