Content deleted Content added
rv - meant to test new code in dev version not the live version |
New Release - Copy of the development code |
||
Line 7:
// Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.
//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={
'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();
}
addOnloadHook(initButtons);
/** 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>
|