MediaWiki:Common.js
sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
/* Any JavaScript here will be loaded for all users on every page load. */
var customizeToolbar = function () {
/* Your code goes here */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'snippets': {
'type': 'booklet',
'label': 'Useful Codes',
'pages': {
'section-xml': {
'label': 'SPL Tags',
'layout': 'characters',
'characters': [
'<references/>',
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<ref>',
'peri': '',
'post': '</ref>'
}
},
'label': '<ref></ref>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<poem>',
'peri': '',
'post': '</poem>'
}
},
'label': '<poem></poem>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<center>',
'peri': '',
'post': '</center>'
}
},
'label': '<center></center>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="red">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Red>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="green">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Green>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="blue">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Blue>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="orange">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Orange>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="maroon">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Maroon>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<font size="" color="purple">',
'peri': '',
'post': '</font>'
}
},
'label': '<Font Purple>'
}
]
},
'section-links': {
'label': 'Wikilinks',
'layout': 'characters',
'characters': [
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '[[Category:',
'peri': '',
'post': ']]'
}
},
'label': '[[Category:]]'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '[[File:',
'peri': '',
'post': ']]'
}
},
'label': '[[File:]]'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{{#ev:youtube|',
'peri': 'Video ID',
'post': '|315|center|caption}}'
}
},
'label': '<Youtube Video>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '{{#iDisplay:',
'peri': 'EMBED_URL',
'post': '|Width without PX|Height without PX}}'
}
},
'label': '<Embed Scribed Doc or PPT>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<gallery>',
'peri': '',
'post': '</gallery>'
}
},
'label': '<Gallery>'
},
{
'action': {
'type': 'encapsulate',
'options': {
'pre': '<hovergallery maxhoverwidth=400 maxhoverheight=300>',
'peri': '',
'post': '</hovergallery>'
}
},
'label': '<Hovergallery>'
}
]
}
}
}
}
} );
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
}
} );
}
/*HERE STARTS THE WORKING-CODE OF "METABOXES"
*/
/* Funcionament de la Plantilla:Metacaixa
Implementat per: Usuari:Peleguer.
Actualitzat per Joanjoc seguint les indicacions d'en Martorell
*/
function MetaCaixaInit(){
//S'executa al carregar-se la pàgina, si hi ha metacaixes,
// s'assignen els esdeveniments als botons
//alert("MetaCaixaInit");
var i=0 //Inicialitzem comptador de caixes
for (i=0;i<=9;i++){
var vMc = document.getElementById("mc"+i);
if (!vMc) break;
//alert("MetaCaixaInit, trobada Metacaixa mc"+i);
var j=1 //Inicialitzem comptador de botons dins de la caixa
var vPsIni = 0 //Pestanya visible inicial
for (j=1;j<=9;j++){
var vBt = document.getElementById("mc"+i+"bt"+j);
if (!vBt) break;
//alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j);
vBt.onclick = MetaCaixaMostraPestanya; //A cada botó assignem l'esdeveniment onclick
//alert (vBt.className);
if (vBt.className=="mcBotoSel") vPsIni=j; //Si tenim un botó seleccionat, en guardem l'index
}
//alert ("mc="+i+", ps="+j+", psini="+vPsIni );
if (vPsIni == 0) { //Si no tenim cap botó seleccionat, n'agafem un aleatòriament
vPsIni = 1+Math.floor((j-1)*Math.random()) ;
//alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_");
document.getElementById("mc"+i+"ps"+vPsIni).style.display = "block";
document.getElementById("mc"+i+"ps"+vPsIni).style.visibility = "visible";
document.getElementById("mc"+i+"bt"+vPsIni).className="mcBotoSel";
}
}
}
function MetaCaixaMostraPestanya(){
//S'executa al clicar una pestanya,
//aquella es fa visible i les altres s'oculten
var vMcNom = this.id.substr(0,3); //A partir del nom del botó, deduïm el nom de la caixa
var vIndex = this.id.substr(5,1); //I l'index
var i=1
for (i=1;i<=9;i++){ //busquem totes les pestanyes d'aquella caixa
//alert(vMcNom+"ps"+i);
var vPsElem = document.getElementById(vMcNom+"ps"+i);
if (!vPsElem) break;
if (vIndex==i){ //Si és la pestanya bona la mostrem i canviem la classe de botó
vPsElem.style.display = "block";
vPsElem.style.visibility = "visible";
document.getElementById(vMcNom+"bt"+i).className="mcBotoSel";
} else { //Sinó, l'ocultem i canviem la classe de botó
vPsElem.style.display = "none";
vPsElem.style.visibility = "hidden";
document.getElementById(vMcNom+"bt"+i).className="mcBoto";
}
}
return false; //evitem la recàrrega de la pàgina
}
jQuery( document ).ready( function( $ ) {
MetaCaixaInit();
} );
/*HERE FINISHES THE WORKING-CODE OF "METABOXES"</pre> */