User:Voice of All/extraeditbuttons.js

/* */ //============================================================ // Extra toolbar options //============================================================ //********WRITTEN BY User:MarkS******** //This is a modified copy of a script by User:MarkS for extra features added by User:Voice of All.

// This is based on the original code on Wikipedia:Tools/Editing tools

function InsertButtonsToToolBar { //Strike-Out Button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png", "speedTip": "Strike", "tagOpen": " ", "tagClose": " ", "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": " \n", "tagClose": "\n ", "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": " \n", "tagClose": "\n ", "sampleText": "Centered text"} //Line break button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": " ", "tagClose": "", "sampleText": ""} //Superscript mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png", "speedTip": "Superscript", "tagOpen": " ", "tagClose": " ", "sampleText": "Superscript text"} //Subscript mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png", "speedTip": "Subscript", "tagOpen": " ", "tagClose": " ", "sampleText": "Subscript text"} //Small Text mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png", "speedTip": "Small", "tagOpen": " ", "tagClose": " ", "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": "", "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", "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": "\n", "tagClose": "\n ", "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": " ", "tagClose": " ", "sampleText": "Span of text"} //Code mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/2/23/Button_code.png", "speedTip": "Insert code", "tagOpen": " ", "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", "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": "", "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": " ", "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": " ", "tagClose": "", "sampleText": ""} } addOnloadHook( InsertButtonsToToolBar );

//============================================================ // Table generator //============================================================

/** * * English: Generate an array using Mediawiki syntax * * @author: fr:user:dake (language conversion and new options added by en:user:Voice of All) * @version: 0.1 */ function generateTableau(nbCol, nbRow, border, cborder, styleHeader, styleLine, exfield, align) {	var code = "\n"; if (styleHeader==1) { code += '{| border="' + border + '" align="' + align + '" style="text-align: center;"\n'; code += "|TABLE NAME\n"; code += '\n'; } else { code += '{| border="' + cborder + '" align="' + align + '" style="text-align: center;"\n'; code += '|+\n'; }       if (exfield==true) code += '!\n'; for (var i=1;i<nbCol+1;i++) code += '! style="background: #BBEEFF;"|FIELD ' + i + '\n';

var items = 0; for (var j=0;j<nbRow;j++) { if ((j+1)%2==0 && styleLine==1 && exfield==true) { items+=1; code += '|-bgcolor="#EFEFEF"\n' code += '! style="background: #FFBBBB;"|ITEM ' + items + '\n'; }                  else if ((j+1)%2==0 && styleLine==1 && exfield==false) { code += '|-bgcolor="#EFEFEF"\n' } else if (exfield==true) { items+=1; code += '|-\n' code += '! style="background: #FFBBBB;"|ITEM ' + items + '\n'; }                 else if (exfield==false) { code += '|-\n' }		for (var i=0;i<nbCol;i++) code += '| element\n'; }	if (styleHeader==1) code += '|}\n'; else code += '|+\n'; code += '|}\n'; insertTags(,, code); }

/** * * English: Open a popup with parameters to generate an array. * The number of rows/columns can be modified. Some additional * parameters are related to templates available on :fr * * @author: fr:user:dake * @version: 0.1 */ function popupTable { var popup = window.open('','name','height=400,width=500,scrollbars=yes'); javaCode = 'function insertCode{'; javaCode += 'var row = parseInt(document.paramForm.inputRow.value); ' javaCode += 'var col = parseInt(document.paramForm.inputCol.value); ' javaCode += 'var bord = parseInt(document.paramForm.inputBorder.value); ' javaCode += 'var cbord = parseInt(document.paramForm.inputCBorder.value); ' javaCode += 'var styleHeader = document.paramForm.inputHeader.checked; ' javaCode += 'var styleLine = document.paramForm.inputLine.checked; ' javaCode += 'var exfield = document.paramForm.inputItems.checked; ' javaCode += 'var align = document.paramForm.inputAlign.value; ' javaCode += 'window.opener.generateTableau(col,row,bord,cbord,styleHeader,styleLine,exfield,align); ' javaCode += "alert('Table created! Note that the text \"Standard table\" must remain.'); " javaCode += 'window.close; ' javaCode += '}<\/script>'; popup.document.write('  Make table '); popup.document.write('<\/script>'); popup.document.write('/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>'); popup.document.write(javaCode); popup.document.write(' '); popup.document.write(' Enter the table parameters: '); popup.document.write(''); popup.document.write('Table alignment:  '); popup.document.write('Number of rows:  '); popup.document.write('Number of columns:  '); popup.document.write('Table border style (number):  '); popup.document.write('Cell border style (number):  '); popup.document.write(' Table header ' + ' '); popup.document.write(' ' + '  Alternating grey lines '); popup.document.write('Item column:  '); popup.document.write(' '); popup.document.write('Note: The default table consist of matrix suitable for fields and values only. Check "Item column" to allow for the table to have fields, items, and values. '); popup.document.write('Note: You cannot set the "Table border style" if "Table header" is not checked. '); popup.document.write('  Insert table into window '); popup.document.write('  Close (cancel)</a> '); popup.document.write(' '); popup.document.close; }

//Ressemble à la fonction de /skins-1.5/commons/wikibits.js pour insérer un autre lien que insertTags function marque_tab { var toolbar = document.getElementById('toolbar'); if (!toolbar) return false; var textbox = document.getElementById('wpTextbox1'); if (!textbox) return false; if (!document.selection && textbox.selectionStart == null) return false; var image = document.createElement("img"); image.width = 23; image.height = 22; image.src = 'http://upload.wikimedia.org/wikipedia/fr/0/04/Button_array.png'; image.border = 0; image.alt = 'Table'; image.title = 'Make table'; image.style.cursor = "pointer"; image.onclick = function { popupTable; return false; } toolbar.appendChild(image); }

addOnloadHook(marque_tab); /* */