MediaWiki:Common.js
De YPPedia
Nota: tras guardar, quizás necesites actualizar la caché de tu navegador para ver los cambios.
- Firefox/Safari: Mantén presionada la tecla Mayús mientras pulsas el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
- Google Chrome: presiona Ctrl+Shift+R (⌘+Mayús+R en Mac)
- Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar, o presiona Ctrl+F5
- Opera: dirígete a Menú → Configuración (Opera → Preferencias en Mac) y luego a Privacidad y seguridad → Borrar datos de navegación → Imágenes y archivos en caché.
/* <pre> */ /* Any JavaScript here will be loaded for all users on every page load. */ // ============================================================ // BEGIN Dynamic content boxes, adapted from older navigation bar stuff // configurable, language dependent variables var DynboxHide = '[ Hide ]'; var DynboxShow = '[ Show ]'; var DynboxLoad = '[ Load ]'; // toggle the state of a dynamic box function toggleDynbox(index) { var toggleButton = document.getElementById("DynboxToggle" + index); var frame = document.getElementById("DynboxFrame" + index); if (!toggleButton || !frame) return false; // if shown now if (toggleButton.firstChild.data == DynboxHide) { for (var child=frame.firstChild; child!=null; child=child.nextSibling) { if (child.className == 'DynboxContent') child.style.display = 'none'; else if (child.className == 'DynboxPreview') child.style.display = 'block'; } toggleButton.firstChild.data = DynboxShow; // if hidden now } else if (toggleButton.firstChild.data == DynboxShow || toggleButton.firstChild.data == DynboxLoad) { for (var child=frame.firstChild; child!=null; child=child.nextSibling) { if (child.className == 'DynboxContent') child.style.display = 'block'; else if (child.className == 'DynboxPreview') child.style.display = 'none'; else if (child.className == 'DynboxLoad') // load page with name passed in the id field and pluck that in for the content // after that handle it like a regular DynboxContent { var req = false; if (window.XMLHttpRequest) req = new XMLHttpRequest(); else req = new ActiveXObject("Msxml2.XMLHTTP"); req.open("GET", wgServer + wgScript + "?title=" + encodeURI(child.id) + "&action=render", false); req.send(null); child.innerHTML = req.responseText; child.style.display = 'block'; child.setAttribute('class', 'DynboxContent'); child.setAttribute('className', 'DynboxContent'); // for the benefit of IE6/7 } } toggleButton.firstChild.data = DynboxHide; } } // register dynamic content boxes and add show/hide button function registerDynboxes() { var index = 0; // iterate over all <div>-elements var frames = document.getElementsByTagName("div"); for (var i=0; frame=frames[i]; i++) { if (frame.className == "DynboxFrame") // found a dynamic box { index++; var toggleButton = document.createElement("a"); toggleButton.className = 'DynboxToggle'; toggleButton.setAttribute('id', 'DynboxToggle' + index); toggleButton.setAttribute('href', 'javascript:toggleDynbox(' + index + ');'); toggleButton.appendChild(document.createTextNode(DynboxShow)); // append toggleButton to child with class "DynboxHead" for(var j=0; j<frame.childNodes.length; j++) { if (frame.childNodes[j].className == "DynboxHead") frame.childNodes[j].appendChild(toggleButton); else if (frame.childNodes[j].className == "DynboxLoad") toggleButton.firstChild.data = DynboxLoad; } frame.setAttribute('id', 'DynboxFrame' + index); } } } hookEvent("load", registerDynboxes); // END Dynamic content boxes // ============================================================ /* </pre> */