MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Loki (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Loki (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
(59 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
Zeile 116: | Zeile 116: | ||
} else { | } else { | ||
objects[i].style.display = 'none'; | objects[i].style.display = 'none'; | ||
} | |||
} | |||
} | |||
function switchOnVisibilityOnClass( targetClass ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
objects[i].style.display = ''; | |||
} | |||
} | |||
function switchOffVisibilityOnClass( targetClass ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
objects[i].style.display = 'none'; | |||
} | |||
} | |||
function showOnlyParentNodeWithIdGreaterZero( targetClass, defaultIdValue ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (!(objects[i].parentNode.id)) { | |||
objects[i].parentNode.id = defaultIdValue; | |||
} | |||
if (objects[i].parentNode.id > 0) { | |||
objects[i].parentNode.style.display = ''; | |||
} else { | |||
objects[i].parentNode.style.display = 'none'; | |||
} | |||
} | |||
} | |||
function parentNodeNumericalIdChange( targetClass, increment ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (objects[i].parentNode.id) { | |||
objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + increment; | |||
} else { | |||
if (increment > 0) { | |||
objects[i].parentNode.id = 1; | |||
} else { | |||
objects[i].parentNode.id = 0; | |||
} | |||
} | |||
} | |||
} | |||
function parentNodeInvisible( targetClass ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (objects[i].parentNode.id) { | |||
objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + 1; | |||
} else { | |||
objects[i].parentNode.id = 1; | |||
} | |||
if (objects[i].parentNode.id > 0) { | |||
objects[i].parentNode.style.display = 'none'; | |||
} | |||
} | |||
} | |||
function parentNodeVisible( targetClass ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
objects[i].parentNode.id = parseInt(objects[i].parentNode.id) - 1; | |||
if (!(objects[i].parentNode.id > 0)) { | |||
objects[i].parentNode.style.display = ''; | |||
} | |||
} | |||
} | |||
function parentNodeFade( targetClass, opacityValue ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (objects[i].parentNode.id) { | |||
objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + 1; | |||
} else { | |||
objects[i].parentNode.id = 1; | |||
} | |||
if (objects[i].parentNode.id > 0) { | |||
objects[i].parentNode.style.opacity = opacityValue; | |||
} | |||
} | |||
} | |||
function parentNodeUnFade( targetClass ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (objects[i].parentNode.id) { | |||
objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + 1; | |||
} else { | |||
objects[i].parentNode.id = 1; | |||
} | |||
if (objects[i].parentNode.id > 0) { | |||
objects[i].parentNode.style.opacity = '1'; | |||
} | |||
} | |||
} | |||
function toggleParentNodeVisibilityMatch( targetClass, targetID ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (objects[i].id.search(targetID) == -1) { | |||
objects[i].parentNode.style.display = 'none'; | |||
} else { | |||
objects[i].parentNode.style.display = ''; | |||
} | } | ||
} | } | ||
Zeile 130: | Zeile 268: | ||
} else { | } else { | ||
objects[i].style.display = 'none'; | objects[i].style.display = 'none'; | ||
} | |||
} | |||
} | |||
function resetParentNodeVisibility( targetClass, allVisible ) { | |||
var objects = document.getElementsByClassName( targetClass ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
if (allVisible != 0) { | |||
objects[i].parentNode.style.display = ''; | |||
} else { | |||
objects[i].parentNode.style.display = 'none'; | |||
} | } | ||
} | } | ||
Zeile 146: | Zeile 298: | ||
} | } | ||
} | } | ||
} | |||
/* Aufruf mehrerer Funktionen */ | |||
function multiCall11( func1,var11,func2,var21 ) { | |||
window[func1](var11); | |||
window[func2](var21); | |||
} | |||
function multiCall12( func1,var11,func2,var21,var22 ) { | |||
window[func1](var11); | |||
window[func2](var21,var22); | |||
} | |||
function multiCall22( func1,var11,var12,func2,var21,var22 ) { | |||
window[func1](var11,var12); | |||
window[func2](var21,var22); | |||
} | |||
function multiCall112( func1,var11,func2,var21,func3,var31,var32 ) { | |||
window[func1](var11); | |||
window[func2](var21); | |||
window[func3](var31,var32); | |||
} | |||
function multiCall122( func1,var11,func2,var21,var22,func3,var31,var32 ) { | |||
window[func1](var11); | |||
window[func2](var21,var22); | |||
window[func3](var31,var32); | |||
} | } | ||
Zeile 156: | Zeile 347: | ||
} | } | ||
function | function multiCall2222( func1,var11,var12,func2,var21,var22,func3,var31,var32,func4,var41,var42 ) { | ||
window[func1](var11,var12); | window[func1](var11,var12); | ||
window[func2](var21,var22); | window[func2](var21,var22); | ||
window[func3](var31,var32); | |||
window[func4](var41,var42); | |||
} | |||
function singleCall2( func1,var11,var12 ) { | |||
window[func1](var11,var12); | |||
} | |||
/* Funktion um die Darstellung von Shadowtalk-Boxen im Artikel an- und abzuschalten */ | |||
function toggleShadowtalkTab() { | |||
mw.util.addPortletLink('p-cactions', 'javascript:switchVisibilityOnClass( "shadowtalkbox" )', 'Shadowtalk An/Aus', 'ca-last', 'Shadowtalk ein- oder ausblenden'); | |||
} | |||
$( toggleShadowtalkTab ); | |||
/* Funktion zur Formatierung der Links auf Artikel in den besonderen Kategorien (Quellen, Abenteuer, Erzählungen) */ | |||
function formatLinksKategorie() { | |||
if ( document.location.href.search('/Kategorie:Quellen') != -1 || document.location.href.search('=Kategorie:Quellen') != -1 ) { | |||
var objects = document.getElementsByTagName( "a" ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
objects[i].innerHTML = objects[i].innerHTML.replace(/Quelle, (cs|de|en|es|fr|he|hu|it|ja|pl|pt):/,"<tt class=\"language-$1\"><small>Quelle, </small>$1:</tt>").replace(/, <\/small>(de|en):/,", </small><span style=\"font-style:italic; color:green;\">$1</span>:").replace(/, <\/small>(cs|es|fr|he|hu|it|ja|pl|pt):/,", </small><span style=\"font-style:italic; color:purple;\">$1</span>:").replace(/\/Abbildungsverzeichnis/,"<tt><small>\/Abbildungsverzeichnis<\/small><\/tt>"); | |||
} | |||
} | |||
if ( document.location.href.search('/Kategorie:Abenteuer') != -1 || document.location.href.search('=Kategorie:Abenteuer') != -1 ) { | |||
var objects = document.getElementsByTagName( "a" ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
objects[i].innerHTML = objects[i].innerHTML.replace(/Abenteuer:/,"<small>Abenteuer:</small>"); | |||
} | |||
} | |||
if ( document.location.href.search('/Kategorie:Erz%C3%A4hlungen') != -1 || document.location.href.search('=Kategorie:Erz%C3%A4hlungen') != -1 ) { | |||
var objects = document.getElementsByTagName( "a" ); | |||
for ( var i = 0; i < objects.length; i++ ) { | |||
objects[i].innerHTML = objects[i].innerHTML.replace(/Erzählung:/,"<small>Erzählung:</small>"); | |||
} | |||
} | |||
} | } | ||
function | $( formatLinksKategorie ); | ||
/* Funktion um die Darstellung von Shadowtalk-Boxen als Defaulteinstellung in reduzierter Form darzustellen */ | |||
function defaultShadowtalkCollapsed() { | |||
var objects = document.getElementsByClassName( 'open-shadowtalk' ); | |||
for ( var i = objects.length - 1; i >= 0; i-- ) { | |||
objects[i].style.display = 'none'; | |||
objects[i].className = "open-shadowtalk-" + i; | |||
} | |||
var objects = document.getElementsByClassName( 'collapsed-shadowtalk' ); | |||
for ( var i = objects.length - 1; i >= 0; i-- ) { | |||
objects[i].style.display = ''; | |||
objects[i].className = "collapsed-shadowtalk-" + i; | |||
} | |||
var objects = document.getElementsByClassName( 'st-jsFunctionButton' ); | |||
for ( var i = objects.length - 1; i >= 0; i-- ) { | |||
objects[i].id = "multiCall11_switchVisibilityOnClass_open-shadowtalk-" + i + "_switchVisibilityOnClass_collapsed-shadowtalk-" + i; | |||
objects[i].className = "jsFunctionButton"; | |||
} | |||
} | } | ||
$( defaultShadowtalkCollapsed ); | |||
$( createFunctionButtons ); |
Aktuelle Version vom 6. Juni 2017, 15:50 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */ function createFunctionButtons() { var Selection = document.getElementsByClassName( "jsFunctionButton" ); for ( var i = Selection.length - 1; i >= 0 ; i-- ) { var input = Selection[i].id.split("_"); var jsFunction = input.shift(); var Button = document.createElement( "a" ); var inputString = ""; for ( var j = 0; j < input.length; j++ ) { inputString = inputString + "'"+input[j]; if (j != input.length - 1) { inputString = inputString + "',"; } else { inputString = inputString + "'"; } } Button.setAttribute( "href", "javascript:"+jsFunction+"("+inputString+")" ); Button.appendChild( Selection[i].childNodes[0] ); $(Selection[i]).replaceWith( Button ); } } function toggleVisibility( targetClass, targetID ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].id != targetID) { objects[i].style.display = 'none'; } else { objects[i].style.display = ''; } } } function toggleVisibilityMatch( targetClass, targetID ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].id.search(targetID) == -1) { objects[i].style.display = 'none'; } else { objects[i].style.display = ''; } } } function toggleWeight( targetClass, targetID ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].id != targetID) { objects[i].style.fontWeight = 'normal'; } else { objects[i].style.fontWeight = 'bold'; } } } function switchWeight( targetClass, targetID ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].id == targetID) { if (objects[i].style.fontWeight == '700') { objects[i].style.fontWeight = 'normal'; } else { objects[i].style.fontWeight = 'bold'; } } } } function switchVisibility( targetClass, targetID ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].id == targetID) { if (objects[i].style.display == 'none') { objects[i].style.display = ''; } else { objects[i].style.display = 'none'; } } } } function switchVisibilityOnClass( targetClass ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].style.display == 'none') { objects[i].style.display = ''; } else { objects[i].style.display = 'none'; } } } function switchOnVisibilityOnClass( targetClass ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { objects[i].style.display = ''; } } function switchOffVisibilityOnClass( targetClass ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { objects[i].style.display = 'none'; } } function showOnlyParentNodeWithIdGreaterZero( targetClass, defaultIdValue ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (!(objects[i].parentNode.id)) { objects[i].parentNode.id = defaultIdValue; } if (objects[i].parentNode.id > 0) { objects[i].parentNode.style.display = ''; } else { objects[i].parentNode.style.display = 'none'; } } } function parentNodeNumericalIdChange( targetClass, increment ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].parentNode.id) { objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + increment; } else { if (increment > 0) { objects[i].parentNode.id = 1; } else { objects[i].parentNode.id = 0; } } } } function parentNodeInvisible( targetClass ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].parentNode.id) { objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + 1; } else { objects[i].parentNode.id = 1; } if (objects[i].parentNode.id > 0) { objects[i].parentNode.style.display = 'none'; } } } function parentNodeVisible( targetClass ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { objects[i].parentNode.id = parseInt(objects[i].parentNode.id) - 1; if (!(objects[i].parentNode.id > 0)) { objects[i].parentNode.style.display = ''; } } } function parentNodeFade( targetClass, opacityValue ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].parentNode.id) { objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + 1; } else { objects[i].parentNode.id = 1; } if (objects[i].parentNode.id > 0) { objects[i].parentNode.style.opacity = opacityValue; } } } function parentNodeUnFade( targetClass ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].parentNode.id) { objects[i].parentNode.id = parseInt(objects[i].parentNode.id) + 1; } else { objects[i].parentNode.id = 1; } if (objects[i].parentNode.id > 0) { objects[i].parentNode.style.opacity = '1'; } } } function toggleParentNodeVisibilityMatch( targetClass, targetID ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (objects[i].id.search(targetID) == -1) { objects[i].parentNode.style.display = 'none'; } else { objects[i].parentNode.style.display = ''; } } } function resetVisibility( targetClass, allVisible ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (allVisible != 0) { objects[i].style.display = ''; } else { objects[i].style.display = 'none'; } } } function resetParentNodeVisibility( targetClass, allVisible ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (allVisible != 0) { objects[i].parentNode.style.display = ''; } else { objects[i].parentNode.style.display = 'none'; } } } function resetWeight( targetClass, allNormal ) { var objects = document.getElementsByClassName( targetClass ); for ( var i = 0; i < objects.length; i++ ) { if (allNormal != 0) { objects[i].style.fontWeight = 'normal'; } else { objects[i].style.fontWeight = 'bold'; } } } /* Aufruf mehrerer Funktionen */ function multiCall11( func1,var11,func2,var21 ) { window[func1](var11); window[func2](var21); } function multiCall12( func1,var11,func2,var21,var22 ) { window[func1](var11); window[func2](var21,var22); } function multiCall22( func1,var11,var12,func2,var21,var22 ) { window[func1](var11,var12); window[func2](var21,var22); } function multiCall112( func1,var11,func2,var21,func3,var31,var32 ) { window[func1](var11); window[func2](var21); window[func3](var31,var32); } function multiCall122( func1,var11,func2,var21,var22,func3,var31,var32 ) { window[func1](var11); window[func2](var21,var22); window[func3](var31,var32); } function multiCall222( func1,var11,var12,func2,var21,var22,func3,var31,var32 ) { window[func1](var11,var12); window[func2](var21,var22); window[func3](var31,var32); } function multiCall2222( func1,var11,var12,func2,var21,var22,func3,var31,var32,func4,var41,var42 ) { window[func1](var11,var12); window[func2](var21,var22); window[func3](var31,var32); window[func4](var41,var42); } function singleCall2( func1,var11,var12 ) { window[func1](var11,var12); } /* Funktion um die Darstellung von Shadowtalk-Boxen im Artikel an- und abzuschalten */ function toggleShadowtalkTab() { mw.util.addPortletLink('p-cactions', 'javascript:switchVisibilityOnClass( "shadowtalkbox" )', 'Shadowtalk An/Aus', 'ca-last', 'Shadowtalk ein- oder ausblenden'); } $( toggleShadowtalkTab ); /* Funktion zur Formatierung der Links auf Artikel in den besonderen Kategorien (Quellen, Abenteuer, Erzählungen) */ function formatLinksKategorie() { if ( document.location.href.search('/Kategorie:Quellen') != -1 || document.location.href.search('=Kategorie:Quellen') != -1 ) { var objects = document.getElementsByTagName( "a" ); for ( var i = 0; i < objects.length; i++ ) { objects[i].innerHTML = objects[i].innerHTML.replace(/Quelle, (cs|de|en|es|fr|he|hu|it|ja|pl|pt):/,"<tt class=\"language-$1\"><small>Quelle, </small>$1:</tt>").replace(/, <\/small>(de|en):/,", </small><span style=\"font-style:italic; color:green;\">$1</span>:").replace(/, <\/small>(cs|es|fr|he|hu|it|ja|pl|pt):/,", </small><span style=\"font-style:italic; color:purple;\">$1</span>:").replace(/\/Abbildungsverzeichnis/,"<tt><small>\/Abbildungsverzeichnis<\/small><\/tt>"); } } if ( document.location.href.search('/Kategorie:Abenteuer') != -1 || document.location.href.search('=Kategorie:Abenteuer') != -1 ) { var objects = document.getElementsByTagName( "a" ); for ( var i = 0; i < objects.length; i++ ) { objects[i].innerHTML = objects[i].innerHTML.replace(/Abenteuer:/,"<small>Abenteuer:</small>"); } } if ( document.location.href.search('/Kategorie:Erz%C3%A4hlungen') != -1 || document.location.href.search('=Kategorie:Erz%C3%A4hlungen') != -1 ) { var objects = document.getElementsByTagName( "a" ); for ( var i = 0; i < objects.length; i++ ) { objects[i].innerHTML = objects[i].innerHTML.replace(/Erzählung:/,"<small>Erzählung:</small>"); } } } $( formatLinksKategorie ); /* Funktion um die Darstellung von Shadowtalk-Boxen als Defaulteinstellung in reduzierter Form darzustellen */ function defaultShadowtalkCollapsed() { var objects = document.getElementsByClassName( 'open-shadowtalk' ); for ( var i = objects.length - 1; i >= 0; i-- ) { objects[i].style.display = 'none'; objects[i].className = "open-shadowtalk-" + i; } var objects = document.getElementsByClassName( 'collapsed-shadowtalk' ); for ( var i = objects.length - 1; i >= 0; i-- ) { objects[i].style.display = ''; objects[i].className = "collapsed-shadowtalk-" + i; } var objects = document.getElementsByClassName( 'st-jsFunctionButton' ); for ( var i = objects.length - 1; i >= 0; i-- ) { objects[i].id = "multiCall11_switchVisibilityOnClass_open-shadowtalk-" + i + "_switchVisibilityOnClass_collapsed-shadowtalk-" + i; objects[i].className = "jsFunctionButton"; } } $( defaultShadowtalkCollapsed ); $( createFunctionButtons );