User:MarkS/extraeditbuttons.js: Difference between revisions

Content deleted Content added
MarkS (talk | contribs)
rv - meant to test new code in dev version not the live version
MarkS (talk | contribs)
New Release - Copy of the development code
Line 7:
// 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
Line 24 ⟶ 19:
 
var Isrc='http://upload.wikimedia.org/wikipedia/commons/';
 
// English Wikipedia creates 11 extra buttons which are stored in mwCustomEditButtons
// rather than mwEditButtons. However, there is no guarantee it will always be 11
// so we count them here.
var enExtraButtons=mwCustomEditButtons.length;
 
 
var BDict={
'A0':['6/6f/Bold_icon.png','Bold text','\'\'\'','\'\'\'','Bold text'],
'B0':['d/d7/Italic_icon.png','Italic text','\'\'','\'\'','Italic text'],
'C0':['f/f3/Internal_link_icon.png','Internal link','[[',']]','Link title'],
'D0':['7/73/External_link_icon.png','External link (remember http:// prefix)','[',']','http://www.example.com link title'],
'E0':['b/ba/Headline_icon.png','Level 2 headline','\n== ',' ==\n','Headline text'],
'F0':['f/f0/Image_icon.png','Embedded image','[[Image:',']]','Example.jpg'],
'G0':['9/9d/Media_icon.png','Media file link','[[Media:',']]','Example.ogg'],
'H0':['5/5b/Math_icon.png','Mathematical formula (LaTeX)','<math>','<\/math>','Insert formula here'],
'I0':['8/82/Nowiki_icon.png','Ignore wiki formatting','<nowiki>','<\/nowiki>','Insert non-formatted text here'],
'J0':['c/c7/Signature_icon.png','Your signature with timestamp','--~~~~'],
'K0':['a/a4/H-line_icon.png','Horizontal line (use sparingly)','\n----\n'],
'A':['e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'],
'B':['1/13/Button_enter.png','Line break','<br />','',''],
Line 66 ⟶ 56:
'S':['c/c9/Button_strike.png','Strikeout','<s>','<\/s>','Struck out text'],
'T':['e/eb/Button_plantilla.png','Template','{{','}}','Template name'],
'TS':['a/a4/TableStart.png','Start a table','{|','',''],
'TC':['7/71/TableCell.png','Table cell','|','',''],
'TE':['0/06/TableEnd.png','End a table','','|}',''],
'TR':['4/4c/TableRow.png','Start a table row','|-','',''],
'T1':['3/30/Tt_icon.png','Teletype text','<tt>','<\/tt>','Teletype Text'],
'TL':['3/37/Button_tl_template.png','Template link',"{{subst:"+"tl|",'}}','Template name'],
Line 76 ⟶ 70:
'Z':['3/35/Button_substitute.png','Substitute',"{{subst:","}}",'Template'],
'AI':['1/1c/Button_advanced_image.png','Advanaced Image',"[[Image:","|thumb|right|px|Caption]]",'FileName.jpg']
};
 
var XEBOrder2=[];
if (typeof XEBOrder!='string') // can be modified
XEBOrder2="A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V".split(",");
else if (XEBOrder.toLowerCase()=='all')
for (b in BDict) XEBOrder2.push(b);
else XEBOrder2=XEBOrder.toUpperCase().split(",");
 
 
function initButtons(){
 
var bc,d;
 
for (b in BDict) BDict[b][0] = Isrc+BDict[b][0]; // // Add the start of the URL (Isrc) to the XEB buttons
// If the user has defined any buttons then add them into the available button lists
 
if (typeof myButtons=='object')
for (b in myButtons) BDict[b] = myButtons[b]; // custom user buttons
// Add the media wiki standard buttons into the available buttons
 
for (b in mwEditButtons) { // add standard buttons for full XEB order changing
BDict[b]=[];
for (d in mwEditButtons[b]) BDict[b].push(mwEditButtons[b][d]);
}
 
// Build the new buttons
 
 
for (i=0;i<XEBOrder2.length;i++) {
 
bc = BDict[XEBOrder2[i]];
//Check if bc is an object (its not if just viewing the page, in which case IE might display an error)
if(typeof bc!='object')return;
addCustomButton(bc[0],bc[1],bc[2],bc[3],bc[4]);
}
 
// Remove the default buttons (if requested by the user)
eraseButtons();
}
 
 
XEBOrder=XEBOrder.split(",");
addOnloadHook(initButtons);
for (var b in XEBOrder) {
 
var bc = BDict[XEBOrder[b]];
 
addCustomButton(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4])
 
/** en: Removes arbitrary standard buttons from the toolbar
* @author: [[:de:User:Olliminatore]]
* @version: 0.1 (01.10.2006) **/
 
function eraseButtons(){
 
//Remove the buttons the user doesn't want
 
if(typeof rmEditButtons!='object') return;
 
if (typeof rmEditButtons[0] == 'string' && rmEditButtons[0].toLowerCase() == 'all')
{
mwEditButtons=[];
for(i=0;i<enExtraButtons;i++){mwCustomEditButtons.shift();}
}
//Sort the user's requests so we remove the button with the highest index first
//- This ensures we remove the buttons the user expects whatever order he requested the buttons in
rmEditButtons.sort(sortit);
 
//Remove individual buttons the user doesn't want
 
for(i=0;i<rmEditButtons.length;i++){
var n=rmEditButtons[i];
//Standard Wikimedia buttons
if(n>=0 && n<mwEditButtons.length){
if(n<mwEditButtons.length){
var x = -1;
while((++x)<mwEditButtons.length)
if(x>=n)
mwEditButtons[x] = mwEditButtons[x+1];
}
mwEditButtons.pop();
}
//Extra buttons in English Wikipedia
n=n-mwEditButtons.length;
if(n>0 && n<mwCustomEditButtons.length){
if(n<mwCustomEditButtons.length){
var x = -1;
while((++x)<mwCustomEditButtons.length)
if(x>=n)
mwCustomEditButtons[x] = mwCustomEditButtons[x+1];
}
mwCustomEditButtons.pop();
}
}
};
 
//Function:
// sortit
//Purpose:
// Used to sort the rmEditButtons array into descending order
function sortit(a,b){
return(b-a)
}
 
//</pre>