User:MarkS/extraeditbuttons.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:MarkS/extraeditbuttons. |
// This is based on the original code on Wikipedia:Tools/Editing tools
//
// The original code was on the project page and needed to be cut and paste to the user's
// monobook.js page. However, this caused problems with the quote marks. So I have moved
// it to its own page.
//
// I do not know a lot about Javascript so please do not ask for a complicated change
function InsertButtonsToToolBar()
{
tooly = document.getElementById('toolbar');
if (tooly != null)
{
StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','Insert text here');\"><img src=\"/media/wikipedia/en/c/c9/Button_strike.png\" alt=\"Strike\" title=\"Strike-through text\"></a>";
LeftTexttButton = "<a href=\"javascript:insertTags('<div style="text-align: left; direction: ltr; margin-left: 1em;">\\n','\\n</div>','Left-aligned text');\"><img src=\"/media/wikipedia/en/e/ea/Button_align_left.png\" alt=\"Left-align\" title=\"Left-aligned text\"></a>";
CenterTextButton = "<a href=\"javascript:insertTags('<div style="text-align: center;">','</div>','Centered text');\"><img src=\"/media/wikipedia/en/5/5f/Button_center.png\" alt=\"Centered\" title=\"Centered text\"></a>";
TableButton = "<a href=\"javascript:insertTags('\\n{| border=\"1\" \\n|- \\n| 1 || 2\\n|- \\n| 3 || 4','\\n|}\\n','');\"><img src=\"/media/wikipedia/en/6/60/Button_insert_table.png\" alt=\"Table\" title=\"Insert table\"></a>";
EenterButton = "<a href=\"javascript:insertTags('<br />','','');\"><img src=\"/media/wikipedia/en/1/13/Button_enter.png\" alt=\"Break\" title=\"Line break\"></a>";
UpperTextButton = "<a href=\"javascript:insertTags('<sup>','</sup>','Superscript');\"><img src=\"/media/wikipedia/en/8/80/Button_upper_letter.png\" alt=\"Superscript\" title=\"Superscript text\"></a>";
LowerTextlButton = "<a href=\"javascript:insertTags('<sub>','</sub>','Subscript');\"><img src=\"/media/wikipedia/en/7/70/Button_lower_letter.png\" alt=\"Subscript\" title=\"Subscript text\"></a>";
SmallTextButton = "<a href=\"javascript:insertTags('<small>','</small>','Small text');\"><img src=\"/media/wikipedia/en/5/58/Button_small.png\" alt=\"Small\" title=\"Small text\"></a>";
CommentButton = "<a href=\"javascript:insertTags('<!--','-->','Comment here');\"><img src=\"/media/wikipedia/en/3/34/Button_hide_comment.png\" alt=\"Comment\" title=\"Insert hidden comment\"></a>";
GalleryButton = "<a href=\"javascript:insertTags('\\n<gallery>\\n','\\n</gallery>','Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2');\"><img src=\"/media/wikipedia/en/1/12/Button_gallery.png\" alt=\"Gallery\" title=\"Insert a picture gallery\"></a>";
SecondaryHeadlineButton = "<a href=\"javascript:insertTags('\\n===','===','Secondary headline');\"><img src=\"/media/wikipedia/en/e/e9/Button_headline2.png\" alt=\"2nd header\" title=\"Insert secondary headline\"></a>";
ShiftingButton = "<a href=\"javascript:insertTags(':','',':');\"><img src=\"/media/wikipedia/en/8/8e/Button_shifting.png\" alt=\"Tab\" title=\"Insert tab(s)\"></a>";
BlockQuoteButton = "<a href=\"javascript:insertTags('<blockquote style="border: 1px solid blue; padding: 2em;">\\n','\\n</blockquote>','Block quote');\"><img src=\"/media/wikipedia/en/f/fd/Button_blockquote.png\" alt=\"Block quote\" title=\"Insert block of quoted text\"></a>";
FontColorButton = "<a href=\"javascript:insertTags('<span style="color: ColorName">','</span>','Span of text');\"><img src=\"/media/wikipedia/en/1/1e/Button_font_color.png\" alt=\"Color\" title=\"Insert colored text\"></a>";
CodeButton = "<a href=\"javascript:insertTags('<code>','</code>','Code');\"><img src=\"/media/wikipedia/en/2/23/Button_code.png\" alt=\"Code\" title=\"Insert code\"></a>";
SubLinkButton = "<a href=\"javascript:insertTags('[[Page#',']]','Sub_page');\"><img src=\"/media/wikipedia/en/9/93/Button_sub_link.png\" alt=\"sub-page link\" title=\"Insert link to sub-page\"></a>";
DefinitionListCodeButton = "<a href=\"javascript:insertTags('\\n; ',' : ','Insert text');\"><img src=\"/media/wikipedia/en/d/d3/Button_definition_list.png\" alt=\"Definition\" title=\"Insert definition list\"></a>";
tooly.innerHTML = tooly.innerHTML + StrikeTextButton + LeftTexttButton + CenterTextButton + TableButton + EenterButton + UpperTextButton + LowerTextlButton + SmallTextButton + CommentButton + GalleryButton + SecondaryHeadlineButton + ShiftingButton + BlockQuoteButton + FontColorButton + CodeButton + SubLinkButton + DefinitionListCodeButton;
}
}
window.onload = InsertButtonsToToolBar;