User:MarkS/extraeditbuttons.js: Difference between revisions

Content deleted Content added
MarkS (talk | contribs)
4 New buttons
MarkS (talk | contribs)
New version of XEB
Line 1:
//<pre>
// This is based on the original code on Wikipedia:Tools/Editing tools
//============================================================
//
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL
// The original code was on the project page and needed to be cut and paste to the user's
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE
// monobook.js page. However, this caused problems with the quote marks. So I have moved
//============================================================
// it to its own page.
// Vorschläge für neue Buttons werden gerne entgegengenommen
//
// Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.
// I do not know a lot about Javascript so please do not ask for a complicated change
//
// See the [[User:MarkS/Extra edit buttons]] for changes log
 
if (typeof XEBOrder == 'undefined') // can be modified
XEBOrder="A,B,D,C,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V";
 
//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar
function InsertButtonsToToolBar()
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){
{
mwCustomEditButtons.push({
//Strike-Out Button
"imageFile": imageFile,
mwCustomEditButtons[mwCustomEditButtons.length] = {
"speedTip": speedTip,
"imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png",
"speedTiptagOpen": "Strike"tagOpen,
"tagOpentagClose": "<s>"tagClose,
"sampleText": sampleText});
"tagClose": "</s>",
"sampleText": "Strike-through text"}
//Left-Text Button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png",
"speedTip": "Left-Align",
"tagOpen": "<div style='text-align: left; direction: ltr; margin-left: 1em;'>\n",
"tagClose": "\n</div>",
"sampleText": "Left-aligned text"}
//Center-Text Button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/5/5f/Button_center.png",
"speedTip": "Center",
"tagOpen": "<div style='text-align: center;'>\n",
"tagClose": "\n</div>",
"sampleText": "Centered text"}
//Table button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
"speedTip": "Table",
"tagOpen": "\n{| border='1' \n|- \n| 1 || 2\n|- \n| 3 || 4",
"tagClose": "\n|}\n",
"sampleText": ""}
//Line break button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
"speedTip": "Line break",
"tagOpen": "<br />",
"tagClose": "",
"sampleText": ""}
//Superscript
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png",
"speedTip": "Superscript",
"tagOpen": "<sup>",
"tagClose": "</sup>",
"sampleText": "Superscript text"}
//Subscript
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png",
"speedTip": "Subscript",
"tagOpen": "<sub>",
"tagClose": "</sub>",
"sampleText": "Subscript text"}
//Small Text
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png",
"speedTip": "Small",
"tagOpen": "<small>",
"tagClose": "</small>",
"sampleText": "Small Text"}
//Comment
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png",
"speedTip": "Insert hidden Comment",
"tagOpen": "<!-- ",
"tagClose": " -->",
"sampleText": "Comment"}
//Gallery
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png",
"speedTip": "Insert a picture gallery",
"tagOpen": "\n<gallery>\n",
"tagClose": "\n</gallery>",
"sampleText": "Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2"}
//Secondary Headline
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png",
"speedTip": "Secondary headline",
"tagOpen": "\n===",
"tagClose": "===",
"sampleText": "Secondary headline"}
//Tabs
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png",
"speedTip": "Insert tab(s)",
"tagOpen": ":",
"tagClose": "",
"sampleText": ":"}
//Block Quote
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png",
"speedTip": "Insert block of quoted text",
"tagOpen": "<blockquote style='border: 1px solid blue; padding: 2em;'>\n",
"tagClose": "\n</blockquote>",
"sampleText": "Block quote"}
//Colour
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/1/1e/Button_font_color.png",
"speedTip": "Insert colored text",
"tagOpen": "<span style='color: ColorName'>",
"tagClose": "</span>",
"sampleText": "Span of text"}
//Code
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/2/23/Button_code.png",
"speedTip": "Insert code",
"tagOpen": "<code>",
"tagClose": "</code>",
"sampleText": "Code"}
//Sub-Link
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/9/93/Button_sub_link.png",
"speedTip": "Insert link to sub-page",
"tagOpen": "[[Page#",
"tagClose": "]]",
"sampleText": "Sub_page"}
//Definition List
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/d/d3/Button_definition_list.png",
"speedTip": "Insert definition list",
"tagOpen": "\n; ",
"tagClose": " : ",
"sampleText": "Insert text"}
//Template button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/3/3b/Button_template_alt.png",
"speedTip": "Template",
"tagOpen": "{{",
"tagClose": "}}",
"sampleText": "Template name"}
//Category button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5a/Button_category_alt.png",
"speedTip": "Category",
"tagOpen": "[[Category:",
"tagClose": "]]",
"sampleText": "Category title"}
//Reference link button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
"speedTip": "<ref>",
"tagOpen": "<ref>",
"tagClose": "</ref>",
"sampleText": "Insert reference material"}
//Reference button
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png",
"speedTip": "Reference footer",
"tagOpen": "<references/>",
"tagClose": "",
"sampleText": ""}
}
 
addOnloadHook( InsertButtonsToToolBar );
var Isrc='http://upload.wikimedia.org/wikipedia/';
 
var BDict={
'A':['commons/e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'],
'B':['commons/1/13/Button_enter.png','Line break','<br />','',''],
'C':['commons/5/5f/Button_center.png','Center','<div style="text-align: center;">\n','\n<\/div>','Centred text'],
'D':['commons/e/ea/Button_align_left.png','Left-Align','<div style="text-align: left; direction: ltr; margin-left: 1em;">\n','\n<\/div>','Left-aligned text'],
'E':['commons/0/04/Button_array.png','Table','\n{| class="wikitable" \n|- \n| 1 || 2\n|- \n| 3 || 4','\n|}\n',''],
'F':['commons/1/1e/Button_font_color.png','Insert coloured text','<span style="color: ','">Coloured text<\/span>','ColourName'],
'G':['commons/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':['commons/7/74/Button_comment.png','Comment',"<!--","-->",'Comment'],
'I1':['commons/6/6a/Button_sup_letter.png','Superscript','<sup>','<\/sup>','Superscript text'],
'I2':['commons/a/aa/Button_sub_letter.png','Subscript','<sub>','<\/sub>','Subscript text'],
'J1':['commons/5/58/Button_small.png','Small','<small>','<\/small>','Small Text'],
'J2':['commons/5/56/Button_big.png','Big text','<big>','<\/big>','Big text'],
'K':['commons/b/b4/Button_category03.png','Category',"[[Category:","]]",'Category name'],
'L':['commons/8/8e/Button_shifting.png','Insert tab(s)',':','',':'],
'M':['commons/f/fd/Button_blockquote.png','Insert block of quoted text','<blockquote style="border: 1px solid blue; padding: 2em;">\n','\n<\/blockquote>','Block quote'],
'N':['commons/4/4b/Button_nbsp.png','nonbreaking space','&nbsp;','',''],
'O':['commons/2/23/Button_code.png','Insert code','<code>','<\/code>','Code'],
'P':['commons/3/3c/Button_pre.png','Pre formatted Text','<pre>','<\/pre>','Pre formatted text'],
'P1':['commons/9/93/Button_sub_link.png','Insert link to sub-page','[[','/Sub_Page]]','Page'],
'Q':['commons/d/d3/Button_definition_list.png','Insert definition list','\n; ','\n: Item 1\n: Item 2','Definition'],
'R':['commons/7/79/Button_reflink.png','Insert a reference','<ref>','<\/ref>','Insert reference material'],
'R1':['commons/7/79/Button_reflink.png','Start a reference','<ref name="','','Reference name'],
'R2':['commons/1/1c/Button_reflink_advanced_2.gif','Insert reference material','">','</ref>','Reference material'],
'R3':['commons/2/28/Button_reflink_advanced_3.gif','No reference material','','"/>',''],
'R4':['commons/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':['commons/c/c9/Button_strike.png','Strikeout','<s>','<\/s>','Struck out text'],
'T':['commons/e/eb/Button_plantilla.png','Template','{{','}}','Template name'],
'T1':['commons/3/30/Tt_icon.png','Teletype text','<tt>','<\/tt>','Teletype Text'],
'U':['commons/f/fd/Button_underline.png','Underlined',"<u>","<\/u>",'Underlined text'],
'V':['commons/c/c8/Button_redirect.png','Redirect',"#REDIRECT [[","]]",'Article Name'],
'W':['commons/8/88/Btn_toolbar_enum.png','Numbering',"\n# ","\n# Element 2\n# Element 3",'Element 1'],
'X':['commons/1/11/Btn_toolbar_liste.png','List',"\n* ","\n* Element B\n* Element C",'Element A'],
'Y1':['commons/c/ce/Button_no_include.png','No Include',"<noinclude>","<\/noinclude>",'Text'],
'Y2':['commons/7/79/Button_include.png','Include only',"<includeonly>","<\/includeonly>",'Text'],
'Z':['commons/3/35/Button_substitute.png','Substitute',"{{subst:","}}",'Template'],
'AI':['commons/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(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4])
}
//</pre>