Benutzer:TheBookman/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Quellcode-Test...) |
(Quellcoe-Update...) |
||
Zeile 24: | Zeile 24: | ||
var Navigation = document.getElementsByTagName( "div" ); | var Navigation = document.getElementsByTagName( "div" ); | ||
for ( var i = 0; i < Navigation.length; i++ ) { | for ( var i = 0; i < Navigation.length; i++ ) { | ||
if ( hasClass( Navigation[i], "jahresartikel" ) ) { | if ( hasClass( Navigation[i], "jahresartikel" ) ) { | ||
var | var ButtonID = new Array(11); | ||
ButtonID[0] = "Unterwelt"; | |||
var | ButtonID[1] = "Technologie"; | ||
ButtonID[2] = "Sport"; | |||
ButtonID[3] = "Politik"; | |||
ButtonID[4] = "Metamenschen"; | |||
ButtonID[5] = "Magie"; | |||
ButtonID[6] = "Kriege"; | |||
ButtonID[7] = "Konzerne"; | |||
ButtonID[8] = "Katastrophen"; | |||
ButtonID[9] = "Drachen"; | |||
ButtonID[10] = "Alles"; | |||
for ( var j = 0; j < ButtonID.length; j++ ) { | |||
var Button = document.createElement( "span" ); | |||
Button.style.styleFloat = "left"; | |||
Button.style.cssFloat = "left"; | |||
Button.style.fontWeight = "normal"; | |||
Button.style.textAlign = "center"; | |||
Button.style.width = "12em"; | |||
if (j == (ButtonID.length - 1)) { | |||
Button.style.styleFloat = "right"; | |||
Button.style.cssFloat = "right"; | |||
} | |||
var ButtonLink = document.createElement( "a" ); | |||
ButtonLink.style.color = Navigation[i].style.color; | |||
ButtonLink.setAttribute( "id", ButtonID[j] ); | |||
var ButtonText = document.createTextNode( ButtonID[j] ); | |||
if (j == (ButtonID.length - 1) ) { | |||
ButtonLink.setAttribute( "href", "javascript:obj_toggle()" ); | |||
} else { | |||
ButtonLink.setAttribute( "href", "javascript:obj_toggle_theme('" | |||
+ButtonID[j].toLowerCase()+"')" ); | |||
} | |||
ButtonLink.appendChild( ButtonText ); | |||
Button.appendChild( document.createTextNode( "[" ) ); | |||
Button.appendChild( ButtonLink ); | |||
Button.appendChild( document.createTextNode( "]" ) ); | |||
Navigation[i].insertBefore( Button, Navigation[i].childNodes[0] ); | |||
} | |||
} | } | ||
} | } | ||
} | } | ||
addOnloadHook( createNavButtons ); | addOnloadHook( createNavButtons ); | ||
Zeile 80: | Zeile 86: | ||
function obj_toggle() { | function obj_toggle() { | ||
var objects = document.getElementsByTagName('td'); | |||
for (var i=0; i < objects.length; i++) { | |||
objects[i].style.display = '' | |||
} | |||
} | } | ||
function obj_toggle_theme( theme ) { | function obj_toggle_theme( theme ) { | ||
obj_toggle(); | |||
var objects = document.getElementsByTagName('td'); | |||
for (var i=0; i < objects.length; i++) { | |||
var keys = String(objects[i].getAttribute('id')); | |||
if (keys.search(theme) != -1) {} | |||
else {objects[i].style.display = 'none'} | |||
} | |||
} | } | ||
Version vom 22. Juli 2008, 18:34 Uhr
/* Ergänzung der Editierzeile mit zusätzlichen Buttons */ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://shadowhelix.de/images/b/b9/Button_E.png", "speedTip": "Artikelende", "tagOpen": "<!-- Ende des Artikelinhalts - Metainformationen -->", "tagClose": "", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://shadowhelix.de/images/b/b0/Button_trash.png", "speedTip": "Löschantrag", "tagOpen": "{{Löschantrag|}}", "tagClose": "", "sampleText": ""}; } /* Buttons für Jahresartikel-Navigation */ function createNavButtons() { var Navigation = document.getElementsByTagName( "div" ); for ( var i = 0; i < Navigation.length; i++ ) { if ( hasClass( Navigation[i], "jahresartikel" ) ) { var ButtonID = new Array(11); ButtonID[0] = "Unterwelt"; ButtonID[1] = "Technologie"; ButtonID[2] = "Sport"; ButtonID[3] = "Politik"; ButtonID[4] = "Metamenschen"; ButtonID[5] = "Magie"; ButtonID[6] = "Kriege"; ButtonID[7] = "Konzerne"; ButtonID[8] = "Katastrophen"; ButtonID[9] = "Drachen"; ButtonID[10] = "Alles"; for ( var j = 0; j < ButtonID.length; j++ ) { var Button = document.createElement( "span" ); Button.style.styleFloat = "left"; Button.style.cssFloat = "left"; Button.style.fontWeight = "normal"; Button.style.textAlign = "center"; Button.style.width = "12em"; if (j == (ButtonID.length - 1)) { Button.style.styleFloat = "right"; Button.style.cssFloat = "right"; } var ButtonLink = document.createElement( "a" ); ButtonLink.style.color = Navigation[i].style.color; ButtonLink.setAttribute( "id", ButtonID[j] ); var ButtonText = document.createTextNode( ButtonID[j] ); if (j == (ButtonID.length - 1) ) { ButtonLink.setAttribute( "href", "javascript:obj_toggle()" ); } else { ButtonLink.setAttribute( "href", "javascript:obj_toggle_theme('" +ButtonID[j].toLowerCase()+"')" ); } ButtonLink.appendChild( ButtonText ); Button.appendChild( document.createTextNode( "[" ) ); Button.appendChild( ButtonLink ); Button.appendChild( document.createTextNode( "]" ) ); Navigation[i].insertBefore( Button, Navigation[i].childNodes[0] ); } } } } addOnloadHook( createNavButtons ); /* Ausblendfunktionen */ function obj_toggle() { var objects = document.getElementsByTagName('td'); for (var i=0; i < objects.length; i++) { objects[i].style.display = '' } } function obj_toggle_theme( theme ) { obj_toggle(); var objects = document.getElementsByTagName('td'); for (var i=0; i < objects.length; i++) { var keys = String(objects[i].getAttribute('id')); if (keys.search(theme) != -1) {} else {objects[i].style.display = 'none'} } } /* Test if an element has a certain class * * Copied from Wikipedia */ var hasClass = (function () { var reCache = {}; return function (element, className) { return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); }; })();