Benutzer:Loki/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Loki (Diskussion | Beiträge) (Test) |
Loki (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 23: | Zeile 23: | ||
function createNavButtons() { | function createNavButtons() { | ||
var Tables = document.getElementsByTagName( " | var Tables = document.getElementsByTagName( "table" ); | ||
for ( var i = 0; i < Tables.length; i++ ) { | for ( var i = 0; i < Tables.length; i++ ) { | ||
if ( hasClass( Tables[i], "jahresartikel" ) ) { | if ( hasClass( Tables[i], "jahresartikel" ) ) { | ||
/* only add button and increment count if there is a header row to work with | /* only add button and increment count if there is a header row to work with */ | ||
var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; | var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; | ||
if (!HeaderRow) continue; | if (!HeaderRow) continue; | ||
var Header = HeaderRow.getElementsByTagName( "th" )[0]; | var Header = HeaderRow.getElementsByTagName( "th" )[0]; | ||
if (!Header) continue; | if (!Header) continue; | ||
var Button1 = document.createElement( "span" ); | var Button1 = document.createElement( "span" ); |
Version vom 20. Juli 2008, 00:05 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 Tables = document.getElementsByTagName( "table" ); for ( var i = 0; i < Tables.length; i++ ) { if ( hasClass( Tables[i], "jahresartikel" ) ) { /* only add button and increment count if there is a header row to work with */ var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; if (!HeaderRow) continue; var Header = HeaderRow.getElementsByTagName( "th" )[0]; if (!Header) continue; var Button1 = document.createElement( "span" ); var Button1Link = document.createElement( "a" ); var Button1Text = document.createTextNode( "Alles" ); Button1.style.styleFloat = "right"; Button1.style.cssFloat = "right"; Button1.style.fontWeight = "normal"; Button1.style.textAlign = "right"; Button1.style.width = "6em"; Button1Link.style.color = Header.style.color; Button1Link.setAttribute( "id", "AllesButton" ); Button1Link.setAttribute( "href", "javascript:obj_toggle()" ); Button1Link.appendChild( Button1Text ); Button1.appendChild( document.createTextNode( "[" ) ); Button1.appendChild( Button1Link ); Button1.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button1, Header.childNodes[0] ); var Button2 = document.createElement( "span" ); var Button2Link = document.createElement( "a" ); var Button2Text = document.createTextNode( "Magie" ); Button2.style.styleFloat = "left"; Button2.style.cssFloat = "left"; Button2.style.fontWeight = "normal"; Button2.style.textAlign = "left"; Button2.style.width = "6em"; Button2Link.style.color = Header.style.color; Button2Link.setAttribute( "id", "MagieButton" ); Button2Link.setAttribute( "href", "javascript:obj_toggle_magie()" ); Button2Link.appendChild( Button2Text ); Button2.appendChild( document.createTextNode( "[" ) ); Button2.appendChild( Button2Link ); Button2.appendChild( document.createTextNode( "]" ) ); Header.insertBefore( Button2, Header.childNodes[0] ); } } } addOnloadHook( createNavButtons ); /* Ausblendfunktionen */ function obj_toggle() { var objects = document.getElementsByTagName('tr'); for (var i=1; i < objects.length; i++) { objects[i].style.display = '' } } function obj_toggle_nav() { var objects = document.getElementById('jahresartikel'); .style.display = ''; } function obj_toggle_magie() { obj_toggle(); var objects = document.getElementsByTagName('tr'); for (var i=1; i < objects.length; i++) { var keys = String(objects[i].getAttribute('keys')); if (keys.search(/magie/) != -1) {} else {objects[i].style.display = 'none'} } obj_toggle_nav(); } /* 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); }; })();