User:Lupin/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Lupin/monobook.css. |
// [[User:Lupin/popups.js]] - please include this line
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
function removeAccessKeys(keylist) {
var t=document.getElementsByTagName('A'), u=document.getElementsByTagName('input');
for (var i=0; i<t.length+u.length; ++i) {
var s=((i<t.length) ? t[i] : u[i-t.length]);
for (var j=0; j<keylist.length; ++j) if (s.accessKey==keylist[j]) s.accessKey='';
}
};
function removeDeleteKey() {removeAccessKeys(['d']);}
if (window.addEventListener) window.addEventListener("load",removeDeleteKey,false);
else if (window.attachEvent) window.attachEvent("onload",removeDeleteKey);
function addOnloadFunction (f) {
if (window.addEventListener) window.addEventListener("load",f,false);
else if (window.attachEvent) window.attachEvent("onload",f);
};
////////////////////////////////////////////////////////////////
// Evaluator
// Source: http://krolik.net/js-eval.shtml
var evaluatorHTML='<FORM ID="Tester" NAME="Tester" onsubmit="return TesterExecute();" ><TEXTAREA NAME="MyCommand" COLS=60 ROWS=24 WRAP="off"></TEXTAREA><BR><INPUT TYPE=BUTTON value="Execute" onclick="TesterExecute();"><INPUT TYPE=BUTTON value="Show Object" onclick="ObjectDumpClicked();" ><BR><TEXTAREA NAME="MyResult" COLS=60 ROWS=35 WRAP="off"></TEXTAREA><BR></FORM>';
function ObjectDump(strObject)
{
var strOutput;
var vTemp;
var vAnotherTemp;
var vElement;
vElement = eval(strObject);
strOutput = "typeof = " + typeof(vElement) + "\n\n";
AppendOutput(strOutput);
for (var x in vElement )
{
vTemp = strObject + "." + x.toString() ;
vAnotherTemp = strObject + "[" + x + "]" ;
strOutput = strOutput + vTemp + " = " + eval(vTemp) + "\n";
AppendOutput(vTemp + " = " + eval(vTemp) + "\n");
}
return strOutput ;
}
function AppendOutput(strText)
{
document.Tester.MyResult.value = document.Tester.MyResult.value + strText;
}
function Output(strText)
{
document.Tester.MyResult.value = strText;
}
function ObjectDumpClicked()
{
document.Tester.MyResult.value="";
ObjectDump(document.Tester.MyCommand.value);
return false;
}
function TesterExecute()
{
document.Tester.MyResult.value="";
document.Tester.MyResult.value=eval(document.Tester.MyCommand.value);
return false;
}
function addEvaluator() {
var evalNode=document.createElement('div');
evalNode.id='evalNode';
evalNode.innerHTML=evaluatorHTML;
document.body.appendChild(evalNode);
document.Tester=document.getElementById('Tester');
}
addOnloadFunction(addEvaluator);
//
// end evaluator
////////////////////////////////////////////////////////////////
// ============================================================
// BEGIN Dynamic Navigation Bars
// set up the words in your language
var NavigationBarHide = 'Hide';
var NavigationBarShow = 'Show';
// 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
// I don't think this feature belongs in site-wide javascript,
// and it wasn't trivial to do with my slightly approach. So it no longer does anything!
// it could be re-implemented without a great deal of trouble though
// we don't have nice classnames like the the organized folks in de do.
// So we use a list of ids instead
var toolboxIds=RegExp('^p-(navigation|search|tb)$');
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById(indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// affect all child nodes except these and silly ones without style attributes
var nodenamesToAvoid=RegExp('^(A|H[1-9])$', 'i');
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if (typeof NavChild.nodeName!= 'undefined' &&
typeof NavChild.style != 'undefined' &&
!nodenamesToAvoid.test(NavChild.nodeName))
NavChild.style.display = 'none';
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarShow;
}
}
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
if (typeof NavChild.nodeName != 'undefined' &&
typeof NavChild.style != 'undefined' &&
!nodenamesToAvoid.test(NavChild.nodeName))
NavChild.style.display = 'block';
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarHide;
}
}
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
// iterate over all < div >-elements
var divElements=document.getElementsByTagName('div');
for(
var i=0;
NavFrame = divElements[i];
i++
) {
// if found a navigation bar
if (toolboxIds.test(NavFrame.id)) {
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('href', "javascript:toggleNavigationBar('" + NavFrame.id + "');");
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.setAttribute('id', 'NavToggle' + NavFrame.id);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in < div class="NavFrame" >
NavFrame.insertBefore(
NavToggle,
NavFrame.firstChild
);
}
}
};
function addOnloadFunction_sitewide_monobook (f) {
if (window.addEventListener) window.addEventListener("load",f,false);
else if (window.attachEvent) window.attachEvent("onload",f);
};
addOnloadFunction_sitewide_monobook(createNavigationBarToggleButton);
// END Dynamic Navigation Bars
// ============================================================