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

Aus ConanWiki
Zur Navigation springen Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
K (mal ein bisschen js testen...)
 
KKeine Bearbeitungszusammenfassung
 
(5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
  +
//global variables for spoilerbutton and iconbar;
function spoil() {
 
  +
//will be used in the initIconbar()-function;
var spoiler = document.getElementsByTagName("spoiler")
 
  +
var glSpoilerbutton;
for (i = 0; i < els.length; i++) {
 
  +
var glIconbar = new Array();
document.getElementsByTagName("spoiler")[i].firstChild.data = "hier stand ein spoiler";
 
  +
  +
/**changes value-attribute of an object, reffering to the given value-attribute-status of the object;
  +
*@param linkObject:
  +
*/
  +
function _toggleLinkValue(linkObject) {
  +
if (linkObject) {
  +
if (linkObject.getAttribute("value") == 'closed') {
  +
linkObject.setAttribute("value", "open");
  +
} else {
  +
linkObject.setAttribute("value", "closed");
  +
}
  +
}
  +
}
  +
  +
/**function for hiding or showing all spoilerparts;
  +
*(modified for dcw....)
  +
*/
  +
function spoilAll() {
  +
var spoilerbutton = document.getElementById("spoilerbutton");
  +
_toggleLinkValue(spoilerbutton);
  +
  +
if("closed" == spoilerbutton.getAttribute("value")){
  +
spoilerbutton.firstChild.data = "zeige alle Spoiler";
  +
//todo:toggle...
  +
//spoilerbutton.className = '_toggle de';
  +
toggler(0);
  +
}
  +
else{
  +
spoilerbutton.firstChild.data = "verstecke alle Spoiler";
  +
//todo:toggle...
  +
//spoilerbutton.className = '_toggle jp';
  +
toggler(0);
  +
}
  +
}
  +
  +
function createSpoilerbutton(){
  +
//baue link...
  +
  +
var link = document.createElement("a");
  +
link.href = "javascript:spoilAll()";
  +
var text = document.createTextNode("zeige alle Spoiler");
  +
link.appendChild(text);
  +
  +
var value = document.createAttribute("name");
  +
value.nodeValue = "spoilerbutton";
  +
link.setAttributeNode(value);
  +
  +
var value = document.createAttribute("id");
  +
value.nodeValue = "spoilerbutton";
  +
link.setAttributeNode(value);
  +
  +
var value = document.createAttribute("value");
  +
value.nodeValue = "closed";
  +
link.setAttributeNode(value);
  +
  +
return link;
  +
}
  +
  +
//testfunction...
  +
function addIcon(){
  +
var img = document.createElement('img');
  +
img.src = /images/thumb/b/bd/Close.png/25px-Close.png'; //'./images/20px-Qsicon_gesprochen.png';
  +
img.alt = "gesprochen Version";
  +
var value = document.createAttribute("class");
  +
value.nodeValue = "icon";
  +
img.close;
  +
img.setAttributeNode(value);
  +
glIconbar.push(img);
  +
}
  +
  +
function findIcons(){
  +
var audio = document.getElementById("Gesprochene_Version");
  +
if (null!=audio){
  +
addIcon();
  +
}
  +
//var lesenswert = document.getElementById("lesenswert");
  +
//var exzellent = document.getElementById("exzellent");
  +
}
  +
  +
function initIconbar(){
  +
var iconbar = new Array();
  +
var ul = document.createElement("ul");
  +
var value = document.createAttribute("id");
  +
value.nodeValue = "iconbar";
  +
ul.setAttributeNode(value);
  +
  +
//find icons;
  +
findIcons();
  +
  +
//add icons;
  +
for(i=0; i< glIconbar.length; i++){
  +
var li = document.createElement("li");
  +
li.appendChild(glIconbar[i]);
  +
ul.appendChild(li);
  +
}
  +
var h1 = document.getElementsByTagName("h1")[0];
  +
h1.parentNode.insertBefore(ul, h1);
  +
}
  +
  +
function initSpoiler(){
  +
var els = document.getElementsByTagName('*');
  +
var spoiler = new Array();
  +
//var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
  +
var pattern = new RegExp("(^|\\s)jp(\\s|$)");
  +
  +
for (i = 0; i < els.length; i++) {
  +
if(pattern.test(els[i].className)){
  +
spoiler.push(els[i]);
  +
els[i].style.display = "none";
  +
}
  +
}
  +
  +
/*for(j=0;j < spoiler.length;j++){
  +
//document.writeln(spoiler[j].nodeName);
  +
var value = document.createAttribute("value");
  +
value.nodeValue = "closed";
  +
spoiler[j].setAttributeNode(value);
  +
//baue link...
  +
var link = createSpoilerlink(j, spoiler[j].nodeName);
  +
//insert link...
  +
if(!modifySpoilerhinweis(j, spoiler[j], link)){
  +
spoiler[j].parentNode.insertBefore(link, spoiler[j]);
  +
}
  +
}*/
  +
  +
if(0 < spoiler.length){
  +
//baue link...
  +
glSpoilerbutton = createSpoilerbutton();
  +
glIconbar.push(glSpoilerbutton);
 
}
 
}
  +
  +
initIconbar();
 
}
 
}
   
addOnloadHook(spoil);
+
addOnloadHook(initSpoiler);

Aktuelle Version vom 2. Januar 2011, 02:45 Uhr

//global variables for spoilerbutton and iconbar; 
//will be used in the initIconbar()-function;
var glSpoilerbutton;
var glIconbar = new Array();

/**changes value-attribute of an object, reffering to the given value-attribute-status of the object;
*@param linkObject:
*/
function _toggleLinkValue(linkObject) {
  if (linkObject) {
    if (linkObject.getAttribute("value") == 'closed') {
      linkObject.setAttribute("value", "open");
    } else {
      linkObject.setAttribute("value", "closed");
    }
  }
}

/**function for hiding or showing all spoilerparts;
*(modified for dcw....)
*/
function spoilAll() {
  var spoilerbutton = document.getElementById("spoilerbutton");
  _toggleLinkValue(spoilerbutton);

  if("closed" == spoilerbutton.getAttribute("value")){
    spoilerbutton.firstChild.data = "zeige alle Spoiler";
    //todo:toggle...
    //spoilerbutton.className = '_toggle de';
    toggler(0);
  }
  else{
    spoilerbutton.firstChild.data = "verstecke alle Spoiler";
    //todo:toggle...
    //spoilerbutton.className = '_toggle jp';
    toggler(0);
  }
}

function createSpoilerbutton(){
	//baue link...

	var link = document.createElement("a");
	link.href = "javascript:spoilAll()";
	var text = document.createTextNode("zeige alle Spoiler");
	link.appendChild(text);

	var value = document.createAttribute("name");
	value.nodeValue = "spoilerbutton";
	link.setAttributeNode(value);

	var value = document.createAttribute("id");
	value.nodeValue = "spoilerbutton";
	link.setAttributeNode(value);

	var value = document.createAttribute("value");
	value.nodeValue = "closed";
	link.setAttributeNode(value);

	return link;
}

//testfunction...
function addIcon(){
  var img = document.createElement('img'); 
  img.src = /images/thumb/b/bd/Close.png/25px-Close.png';  //'./images/20px-Qsicon_gesprochen.png';
  img.alt = "gesprochen Version";
  var value = document.createAttribute("class");
  value.nodeValue = "icon";
  img.close;
  img.setAttributeNode(value);
  glIconbar.push(img);
}

function findIcons(){
  var audio = document.getElementById("Gesprochene_Version");
  if (null!=audio){
    addIcon();
  }
  //var lesenswert = document.getElementById("lesenswert");
  //var exzellent = document.getElementById("exzellent");
}

function initIconbar(){
  var iconbar = new Array();
  var ul = document.createElement("ul");
  var value = document.createAttribute("id");
  value.nodeValue = "iconbar";
  ul.setAttributeNode(value);

  //find icons;
  findIcons();

  //add icons;
  for(i=0; i< glIconbar.length; i++){
    var li = document.createElement("li");
    li.appendChild(glIconbar[i]);
    ul.appendChild(li);
  }
 var h1 = document.getElementsByTagName("h1")[0];
 h1.parentNode.insertBefore(ul, h1);
}

function initSpoiler(){
  var els = document.getElementsByTagName('*');
  var spoiler = new Array();
  //var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
  var pattern = new RegExp("(^|\\s)jp(\\s|$)");

  for (i = 0; i < els.length; i++) {  
	if(pattern.test(els[i].className)){
		spoiler.push(els[i]);
		els[i].style.display = "none";
	}
  }

  /*for(j=0;j < spoiler.length;j++){
	//document.writeln(spoiler[j].nodeName);
	var value = document.createAttribute("value");
	value.nodeValue = "closed";
	spoiler[j].setAttributeNode(value);
	//baue link...
	var link = createSpoilerlink(j, spoiler[j].nodeName);
	//insert link...
 	if(!modifySpoilerhinweis(j, spoiler[j], link)){
	  spoiler[j].parentNode.insertBefore(link, spoiler[j]);
	}
  }*/

  if(0 < spoiler.length){
	//baue link...
	glSpoilerbutton = createSpoilerbutton();
	glIconbar.push(glSpoilerbutton);
  }
 
  initIconbar();
}

addOnloadHook(initSpoiler);