« MediaWiki:Modeles.js » : différence entre les versions
Jump to navigation
Jump to search
(Page créée avec « // ============================================================ // BEGIN Boîtes déroulantes // set up the words in your language var NavigationBarHide = '▲ Masquer'; var… ») |
Aucun résumé des modifications |
||
| Ligne 13 : | Ligne 13 : | ||
| ⚫ | |||
// shows and hides content and picture (if available) of navigation bars |
|||
// Parameters: |
|||
// indexNavigationBar: the index of navigation bar to be toggled |
|||
| ⚫ | |||
{ |
|||
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); |
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); |
||
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); |
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); |
||
| ⚫ | |||
| ⚫ | |||
return false; |
|||
} |
|||
// if shown now |
|||
if (NavToggle.firstChild.data == NavigationBarHide) { |
if (NavToggle.firstChild.data == NavigationBarHide) { |
||
for (var NavChild = NavFrame.firstChild;NavChild != null;NavChild = NavChild.nextSibling) { |
|||
for ( |
|||
if (NavChild.className == 'NavPic') NavChild.style.display = 'none'; |
|||
NavChild |
if (NavChild.className == 'NavContent') NavChild.style.display = 'none'; |
||
NavChild = |
if (NavChild.className == 'NavToggle') NavChild.firstChild.data = NavigationBarShow; |
||
) { |
|||
if (NavChild.className == 'NavPic') { |
|||
NavChild.style.display = 'none'; |
|||
} |
|||
if (NavChild.className == 'NavContent') { |
|||
NavChild.style.display = 'none'; |
|||
} |
|||
if (NavChild.className == 'NavToggle') { |
|||
NavChild.firstChild.data = NavigationBarShow; |
|||
} |
|||
} |
} |
||
// if hidden now |
|||
} else if (NavToggle.firstChild.data == NavigationBarShow) { |
} else if (NavToggle.firstChild.data == NavigationBarShow) { |
||
for (var NavChild = NavFrame.firstChild;NavChild != null;NavChild = NavChild.nextSibling) { |
|||
for ( |
|||
if (NavChild.className == 'NavPic') NavChild.style.display = 'block'; |
|||
NavChild |
if (NavChild.className == 'NavContent') NavChild.style.display = 'block'; |
||
NavChild = |
if (NavChild.className == 'NavToggle') NavChild.firstChild.data = NavigationBarHide; |
||
) { |
|||
if (NavChild.className == 'NavPic') { |
|||
NavChild.style.display = 'block'; |
|||
} |
|||
if (NavChild.className == 'NavContent') { |
|||
NavChild.style.display = 'block'; |
|||
} |
|||
if (NavChild.className == 'NavToggle') { |
|||
NavChild.firstChild.data = NavigationBarHide; |
|||
} |
|||
} |
} |
||
} |
} |
||
} |
} |
||
| ⚫ | |||
// adds show/hide-button to navigation bars |
|||
| ⚫ | |||
{ |
|||
var indexNavigationBar = 0; |
var indexNavigationBar = 0; |
||
| ⚫ | |||
// iterate over all <div>-elements |
|||
for( |
|||
var i=0; |
|||
| ⚫ | |||
i++ |
|||
) { |
|||
// if found a navigation bar |
|||
if (NavFrame.className == "NavFrame") { |
if (NavFrame.className == "NavFrame") { |
||
indexNavigationBar++; |
indexNavigationBar++; |
||
var NavToggle = document.createElement("a"); |
var NavToggle = document.createElement("a"); |
||
| Ligne 81 : | Ligne 41 : | ||
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); |
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); |
||
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); |
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); |
||
var NavToggleText = document.createTextNode(NavigationBarHide); |
var NavToggleText = document.createTextNode(NavigationBarHide); |
||
NavToggle.appendChild(NavToggleText); |
NavToggle.appendChild(NavToggleText); |
||
| ⚫ | |||
// add NavToggle-Button as first div-element |
|||
// in <div class="NavFrame"> |
|||
| ⚫ | |||
NavToggle, |
|||
NavFrame.firstChild |
|||
); |
|||
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
||
} |
} |
||
} |
} |
||
// if more Navigation Bars found than Default: hide all |
|||
if (NavigationBarShowDefault < indexNavigationBar) { |
if (NavigationBarShowDefault < indexNavigationBar) { |
||
for( |
for(var i=1; i<=indexNavigationBar;i++) { |
||
var i=1; |
|||
i<=indexNavigationBar; |
|||
i++ |
|||
) { |
|||
toggleNavigationBar(i); |
toggleNavigationBar(i); |
||
} |
} |
||
} |
} |
||
} |
} |
||
aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton; |
aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton; |
||
| Ligne 115 : | Ligne 61 : | ||
/* Permet d'afficher un compte à rebours sur une page avec le modèle [[Modèle:Compte à rebours]] */ |
/* Permet d'afficher un compte à rebours sur une page avec le modèle [[Modèle:Compte à rebours]] */ |
||
/* Plyd - 3 février 2009 */ |
/* Plyd - 3 février 2009 */ |
||
/* |
|||
function Rebours() { |
function Rebours() { |
||
if(wgNamespaceNumber==0) return; |
if(wgNamespaceNumber==0) return; |
||
try { |
try { |
||
var Comptes = getElementsByClassName(document, "span", "rebours"); |
|||
var |
|||
if(!Comptes[0]) return; |
|||
if (document.getElementById("rebours")) { |
|||
for(var a=0,l=Comptes.length;a<l;a++) { |
|||
destime = |
destime = Comptes[a].title.HTMLize().split(";;"); |
||
Maintenant = (new Date).getTime(); |
Maintenant = (new Date).getTime(); |
||
Future = new Date(Date.UTC(destime[0], (destime[1]-1), destime[2], destime[3], destime[4], destime[5])).getTime(); |
Future = new Date(Date.UTC(destime[0], (destime[1]-1), destime[2], destime[3], destime[4], destime[5])).getTime(); |
||
| Ligne 137 : | Ligne 84 : | ||
} |
} |
||
TempsRestant = TempsRestant + TempsRestantH + " h " + TempsRestantM + " min " + TempsRestantS + " s"; |
TempsRestant = TempsRestant + TempsRestantH + " h " + TempsRestantM + " min " + TempsRestantS + " s"; |
||
Comptes[a].innerHTML = TempsRestant; |
|||
| ⚫ | |||
} |
} |
||
| ⚫ | |||
} catch (e) {} |
} catch (e) {} |
||
} |
} |
||
addOnloadHook(Rebours); |
addOnloadHook(Rebours); |
||
// ============================================================ |
|||
*/ |
|||
Version du 17 juillet 2011 à 13:11
// ============================================================
// BEGIN Boîtes déroulantes
// set up the words in your language
var NavigationBarHide = '▲ Masquer';
var NavigationBarShow = '▼ Afficher';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;
function toggleNavigationBar(indexNavigationBar){
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) return false;
if (NavToggle.firstChild.data == NavigationBarHide) {
for (var NavChild = NavFrame.firstChild;NavChild != null;NavChild = NavChild.nextSibling) {
if (NavChild.className == 'NavPic') NavChild.style.display = 'none';
if (NavChild.className == 'NavContent') NavChild.style.display = 'none';
if (NavChild.className == 'NavToggle') NavChild.firstChild.data = NavigationBarShow;
}
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (var NavChild = NavFrame.firstChild;NavChild != null;NavChild = NavChild.nextSibling) {
if (NavChild.className == 'NavPic') NavChild.style.display = 'block';
if (NavChild.className == 'NavContent') NavChild.style.display = 'block';
if (NavChild.className == 'NavToggle') NavChild.firstChild.data = NavigationBarHide;
}
}
}
function createNavigationBarToggleButton(){
var indexNavigationBar = 0;
for(var i=0; NavFrame = document.getElementsByTagName("div")[i];i++) {
if (NavFrame.className == "NavFrame") {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
NavFrame.insertBefore( NavToggle, NavFrame.firstChild);
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
if (NavigationBarShowDefault < indexNavigationBar) {
for(var i=1; i<=indexNavigationBar;i++) {
toggleNavigationBar(i);
}
}
}
aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton;
// END Boîtes déroulantes
// ============================================================
// ============================================================
/* Permet d'afficher un compte à rebours sur une page avec le modèle [[Modèle:Compte à rebours]] */
/* Plyd - 3 février 2009 */
function Rebours() {
if(wgNamespaceNumber==0) return;
try {
var Comptes = getElementsByClassName(document, "span", "rebours");
if(!Comptes[0]) return;
for(var a=0,l=Comptes.length;a<l;a++) {
destime = Comptes[a].title.HTMLize().split(";;");
Maintenant = (new Date).getTime();
Future = new Date(Date.UTC(destime[0], (destime[1]-1), destime[2], destime[3], destime[4], destime[5])).getTime();
Diff = (Future-Maintenant);
if (Diff < 0) {Diff = 0}
TempsRestantJ = Math.floor(Diff/(24*3600*1000));
TempsRestantH = Math.floor(Diff/(3600*1000)) % 24;
TempsRestantM = Math.floor(Diff/(60*1000)) % 60;
TempsRestantS = Math.floor(Diff/1000) % 60;
TempsRestant = "" + destime[6] + " ";
if (TempsRestantJ == 1) {
TempsRestant = TempsRestant + TempsRestantJ + " jour ";
} else if (TempsRestantJ > 1) {
TempsRestant = TempsRestant + TempsRestantJ + " jours ";
}
TempsRestant = TempsRestant + TempsRestantH + " h " + TempsRestantM + " min " + TempsRestantS + " s";
Comptes[a].innerHTML = TempsRestant;
}
setTimeout("Rebours()", 1000)
} catch (e) {}
}
addOnloadHook(Rebours);
// ============================================================
Ce que tu peux faire
Outils

Outils personnels