MediaWiki:Common.js:修订间差异
外观
无编辑摘要 |
|||
| 第1行: | 第1行: | ||
// | function MetaCaixaInit() { | ||
// S'executa al carregar-se la pàgina, si hi ha metacaixes, | |||
var i = 0; | // s'assignen els esdeveniments als botons | ||
//alert("MetaCaixaInit"); | |||
var i = 0; // Inicialitzem comptador de caixes | |||
for (i = 0; i <= 9; i++) { | for (i = 0; i <= 9; i++) { | ||
var vMc = document.getElementById("mc" + i); | var vMc = document.getElementById("mc" + i); | ||
if (!vMc) break; | if (!vMc) break; | ||
//alert("MetaCaixaInit, trobada Metacaixa mc"+i); | //alert("MetaCaixaInit, trobada Metacaixa mc"+i); | ||
var j = 1; | var j = 1; // Inicialitzem comptador de botons dins de la caixa | ||
var vPsIni = 0; | var vPsIni = 0; // Pestanya visible inicial | ||
for (j = 1; j <= 9; j++) { | for (j = 1; j <= 9; j++) { | ||
var vBt = document.getElementById("mc" + i + "bt" + j); | var vBt = document.getElementById("mc" + i + "bt" + j); | ||
if (!vBt) break; | if (!vBt) break; | ||
vBt.onclick = MetaCaixaMostraPestanya; | //alert("MetaCaixaInit, trobat botó mc"+i+"bt"+j); | ||
if (vBt.className == "mcBotoSel") vPsIni = 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 ); | //alert ("mc="+i+", ps="+j+", psini="+vPsIni ); | ||
if (vPsIni === 0) { | if (vPsIni === 0) { // Si no tenim cap botó seleccionat, n'agafem un aleatòriament | ||
vPsIni = 1 + Math.floor((j - 1) * Math.random()); | vPsIni = 1 + Math.floor((j - 1) * Math.random()); | ||
//alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_"); | //alert ("Activant Pestanya a l'atzar; _mc"+i+"bt"+vPsIni +"_"); | ||
| 第26行: | 第30行: | ||
function MetaCaixaMostraPestanya() { | function MetaCaixaMostraPestanya() { | ||
var vMcNom = this.id.substr(0, 3); | // S'executa al clicar una pestanya, | ||
var vIndex = this.id.substr(5, 1); | // 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; | var i = 1; | ||
for (i = 1; i <= 9; i++) { | for (i = 1; i <= 9; i++) { // busquem totes les pestanyes d'aquella caixa | ||
//alert(vMcNom+"ps"+i); | |||
var vPsElem = document.getElementById(vMcNom + "ps" + i); | var vPsElem = document.getElementById(vMcNom + "ps" + i); | ||
if (!vPsElem) break; | if (!vPsElem) break; | ||
if (vIndex == i) { | if (vIndex == i) { // Si és la pestanya bona la mostrem i canviem la classe de botó | ||
vPsElem.style.display = "block"; | vPsElem.style.display = "block"; | ||
vPsElem.style.visibility = "visible"; | vPsElem.style.visibility = "visible"; | ||
document.getElementById(vMcNom + "bt" + i).className = "mcBotoSel"; | document.getElementById(vMcNom + "bt" + i).className = "mcBotoSel"; | ||
} else { / | } else { // Sinó, l'ocultem i canviem la classe de botó | ||
vPsElem.style.display = "none"; | vPsElem.style.display = "none"; | ||
vPsElem.style.visibility = "hidden"; | vPsElem.style.visibility = "hidden"; | ||
| 第42行: | 第49行: | ||
} | } | ||
} | } | ||
return false; | return false; // evitem la recàrrega de la pàgina | ||
} | } | ||
$(MetaCaixaInit); | $(MetaCaixaInit); | ||
2016年5月1日 (日) 13:43的版本
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
}
$(MetaCaixaInit);