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

Aus ConanWiki
Zur Navigation springen Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
(test iconbar;)
K (test iconbar;)
Zeile 3: Zeile 3:
 
var glSpoilerbutton;
 
var glSpoilerbutton;
 
var glIconbar = new Array();
 
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 = '_toggler_hide-de _toggler_show-jp';
  +
toggler(0);
  +
}
  +
else{
  +
spoilerbutton.firstChild.data = "verstecke alle Spoiler";
  +
//todo:toggle...
  +
spoilerbutton.className = '_toggler_hide-jp _toggler_show-de';
  +
toggler(0);
  +
}
  +
}
   
 
function createSpoilerbutton(){
 
function createSpoilerbutton(){
Zeile 30: Zeile 64:
 
function addIcon(){
 
function addIcon(){
 
var img = document.createElement('img');
 
var img = document.createElement('img');
img.src = './images/20px-Qsicon_gesprochen.png';
+
img.src = /images/thumb/b/bd/Close.png/25px-Close.png'; //'./images/20px-Qsicon_gesprochen.png';
 
img.alt = "gesprochen Version";
 
img.alt = "gesprochen Version";
 
var value = document.createAttribute("class");
 
var value = document.createAttribute("class");
Zeile 40: Zeile 74:
   
 
function findIcons(){
 
function findIcons(){
var audio = document.getElementById("Gesprochene Version");
+
var audio = document.getElementById("Gesprochene_Version");
 
if (null!=audio){
 
if (null!=audio){
 
addIcon();
 
addIcon();

Version vom 2. Januar 2011, 02:34 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 = '_toggler_hide-de _toggler_show-jp';
    toggler(0);
  }
  else{
    spoilerbutton.firstChild.data = "verstecke alle Spoiler";
    //todo:toggle...
    spoilerbutton.className = '_toggler_hide-jp _toggler_show-de';
    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);