Benutzer:Rikku/monobook.js: Unterschied zwischen den Versionen

K
keine Bearbeitungszusammenfassung
K (mal ein bisschen js testen...)
 
KKeine Bearbeitungszusammenfassung
Zeile 1:
function spoilspoilAll() {
var spoilerels = document.getElementsByTagName("spoiler"'*');
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(spoilbuildSpoitertags);
5.367

Bearbeitungen