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) K (mal ein bisschen js testen...) |
Rikku (Diskussion | Beiträge) KKeine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
− | function |
+ | function spoilAll() { |
− | + | var els = document.getElementsByTagName('*'); |
|
+ | var spoiler = new Array(); |
||
− | for (i = 0; i < els.length; i++) { |
||
+ | var pattern = new RegExp("(^|\\s)spoiler(\\s|$)"); |
||
− | document.getElementsByTagName("spoiler")[i].firstChild.data = "hier stand ein spoiler"; |
||
+ | 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"; |
||
+ | } |
||
+ | } |
||
+ | } |
||
+ | } |
||
+ | |||
+ | 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"; |
||
+ | } |
||
+ | } |
||
+ | } |
||
+ | } |
||
+ | |||
+ | 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]); |
||
+ | } |
||
+ | spoilReset(); |
||
} |
} |
||
− | addOnloadHook( |
+ | addOnloadHook(buildSpoitertags); |
Version vom 11. November 2010, 22:21 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"; } } } } 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"; } } } } 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]); } spoilReset(); } addOnloadHook(buildSpoitertags);