Qualitätswoche: Artikel verbessern und Crunchyroll-Premium-Abo gewinnen!
Verbessere im Rahmen der Qualitätswoche einen Artikel deiner Wahl und gewinne mit etwas |
Benutzer:Rikku/monobook.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
Rikku (Diskussion | Beiträge) KKeine Bearbeitungszusammenfassung |
Rikku (Diskussion | Beiträge) K (test spoilerbutton;) |
||
Zeile 77: | Zeile 77: | ||
} |
} |
||
} |
} |
||
+ | } |
||
+ | var link = document.getElementsByName("spoilerbutton")[0]; |
||
+ | if(null != link){ |
||
+ | link.firstChild.data = "zeige alle Spoiler"; |
||
+ | link.href = "javascript:spoilOpenAll()"; |
||
+ | link.getAttribute("value").nodeValue = "closed"; |
||
} |
} |
||
} |
} |
||
Zeile 98: | Zeile 104: | ||
} |
} |
||
} |
} |
||
− | + | } |
|
+ | var link = document.getElementsByName("spoilerbutton")[0]; |
||
+ | if(null != link){ |
||
+ | link.firstChild.data = "verstecke alle Spoiler"; |
||
+ | link.href = "javascript:spoilReset()"; |
||
+ | link.getAttribute("value").nodeValue = "open"; |
||
+ | } |
||
} |
} |
||
Zeile 135: | Zeile 147: | ||
spoiler[j].parentNode.insertBefore(par, spoiler[j]); |
spoiler[j].parentNode.insertBefore(par, spoiler[j]); |
||
} |
} |
||
+ | if(0 < spoiler.length){ |
||
⚫ | |||
+ | //baue link... |
||
+ | var par = document.createElement("p"); |
||
+ | var link = document.createElement("link"); |
||
+ | link.href = "javascript:spoilAll()"; |
||
+ | var text = document.createTextNode("spoilerbutton"); |
||
+ | var value = document.createAttribute("name"); |
||
+ | value.nodeValue = "spoilerbutton"; |
||
+ | link.setAttributeNode(value); |
||
+ | var value = document.createAttribute("value"); |
||
+ | value.nodeValue = "open"; |
||
+ | link.setAttributeNode(value); |
||
+ | var style = document.createAttribute("style"); |
||
+ | style.nodeValue = "float:right"; |
||
+ | link.setAttributeNode(style); |
||
+ | link.appendChild(text); |
||
+ | //insert link... |
||
+ | par.appendChild(link); |
||
+ | var h1 = document.getElementsByTagName("h1")[0]; |
||
+ | h1.parentNode.insertBefore(par, h1); |
||
⚫ | |||
+ | |||
+ | } |
||
} |
} |
||
Version vom 11. November 2010, 22:58 Uhr
function spoilAll() { var els = document.getElementsByTagName('*'); var spoiler = new Array(); var pattern = new RegExp("(^|\\s)spoiler(\\s|$)"); for (i = 0; i < els.length; i++) { if(pattern.test(els[i].className)){ spoiler.push(els[i]); } } for (j = 0; j < spoiler.length; j++){ if(pattern.test(spoiler[j].className)){ if("closed" == spoiler[j].getAttribute("value")){ spoiler[j].style.display = 'block'; spoiler[j].setAttribute("value","open"); var link = findLink(j); if(null != link){ link.firstChild.data = "verstecke Spoiler"; } } else{ spoiler[j].style.display = 'none'; spoiler[j].setAttribute("value","closed"); var link = findLink(j); if(null != link){ link.firstChild.data = "zeige Spoiler"; } } } } } function spoil(j) { var els = document.getElementsByTagName('*'); var spoiler = new Array(); var pattern = new RegExp("(^|\\s)spoiler(\\s|$)"); for (i = 0; i < els.length; i++) { if(pattern.test(els[i].className)){ spoiler.push(els[i]); } } if(j < spoiler.length){ if("closed" == spoiler[j].getAttribute("value")){ spoiler[j].style.display = 'block'; spoiler[j].setAttribute("value","open"); var link = findLink(j); if(null != link){ link.firstChild.data = "verstecke Spoiler"; } } else{ spoiler[j].style.display = 'none'; spoiler[j].setAttribute("value","closed"); var link = findLink(j); if(null != link){ link.firstChild.data = "zeige Spoiler"; } } } } function spoilReset() { var els = document.getElementsByTagName('*'); var spoiler = new Array(); var pattern = new RegExp("(^|\\s)spoiler(\\s|$)"); for (i = 0; i < els.length; i++) { if(pattern.test(els[i].className)){ spoiler.push(els[i]); } } for (j = 0; j < spoiler.length; j++){ if(pattern.test(spoiler[j].className)){ spoiler[j].style.display = 'none'; spoiler[j].setAttribute("value","closed"); var link = findLink(j); if(null != link){ link.firstChild.data = "zeige Spoiler"; } } } var link = document.getElementsByName("spoilerbutton")[0]; if(null != link){ link.firstChild.data = "zeige alle Spoiler"; link.href = "javascript:spoilOpenAll()"; link.getAttribute("value").nodeValue = "closed"; } } function spoilOpenAll() { var els = document.getElementsByTagName('*'); var spoiler = new Array(); var pattern = new RegExp("(^|\\s)spoiler(\\s|$)"); for (i = 0; i < els.length; i++) { if(pattern.test(els[i].className)){ spoiler.push(els[i]); } } for (j = 0; j < spoiler.length; j++){ if(pattern.test(spoiler[j].className)){ spoiler[j].style.display = 'block'; spoiler[j].setAttribute("value","open"); var link = findLink(j); if(null != link){ link.firstChild.data = "verstecke Spoiler"; } } } var link = document.getElementsByName("spoilerbutton")[0]; if(null != link){ link.firstChild.data = "verstecke alle Spoiler"; link.href = "javascript:spoilReset()"; link.getAttribute("value").nodeValue = "open"; } } function findLink(j) { var linksAll = document.getElementsByName("spoilerlink-"+j); if(0<linksAll.length){ return linksAll[0]; } return null; } function buildSpoitertags(){ var els = document.getElementsByTagName('*'); var spoiler = new Array(); var pattern = new RegExp("(^|\\s)spoiler(\\s|$)"); for (i = 0; i < els.length; i++) { if(pattern.test(els[i].className)){ spoiler.push(els[i]); } } for(j=0;j < spoiler.length;j++){ var value = document.createAttribute("value"); value.nodeValue = "open"; spoiler[j].setAttributeNode(value); //baue link... var par = document.createElement("p"); var link = document.createElement("link"); link.href = "javascript:spoil("+j+")"; var text = document.createTextNode("verstecke spoiler"); var value = document.createAttribute("name"); value.nodeValue = "spoilerlink-"+j; link.setAttributeNode(value); link.appendChild(text); //insert link... par.appendChild(link); spoiler[j].parentNode.insertBefore(par, spoiler[j]); } if(0 < spoiler.length){ //baue link... var par = document.createElement("p"); var link = document.createElement("link"); link.href = "javascript:spoilAll()"; var text = document.createTextNode("spoilerbutton"); var value = document.createAttribute("name"); value.nodeValue = "spoilerbutton"; link.setAttributeNode(value); var value = document.createAttribute("value"); value.nodeValue = "open"; link.setAttributeNode(value); var style = document.createAttribute("style"); style.nodeValue = "float:right"; link.setAttributeNode(style); link.appendChild(text); //insert link... par.appendChild(link); var h1 = document.getElementsByTagName("h1")[0]; h1.parentNode.insertBefore(par, h1); spoilReset(); } } addOnloadHook(buildSpoitertags);