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

Aus ConanWiki
Zur Navigation springen Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
K (test spoilerbutton;)
KKeine Bearbeitungszusammenfassung
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
  +
//global variables for spoilerbutton and iconbar;
function spoilAll() {
 
  +
//will be used in the initIconbar()-function;
var els = document.getElementsByTagName('*');
 
  +
var glSpoilerbutton;
var spoiler = new Array();
 
var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
+
var glIconbar = new Array();
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";
 
}
 
}
 
}
 
}
 
}
 
   
  +
/**changes value-attribute of an object, reffering to the given value-attribute-status of the object;
function spoil(j) {
 
  +
*@param linkObject:
var els = document.getElementsByTagName('*');
 
  +
*/
var spoiler = new Array();
 
  +
function _toggleLinkValue(linkObject) {
var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
 
  +
if (linkObject) {
for (i = 0; i < els.length; i++) {
 
  +
if (linkObject.getAttribute("value") == 'closed') {
if(pattern.test(els[i].className)){
 
  +
linkObject.setAttribute("value", "open");
spoiler.push(els[i]);
 
  +
} else {
}
 
  +
linkObject.setAttribute("value", "closed");
}
 
  +
}
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 for hiding or showing all spoilerparts;
function spoilReset() {
 
  +
*(modified for dcw....)
var els = document.getElementsByTagName('*');
 
  +
*/
var spoiler = new Array();
 
  +
function spoilAll() {
var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
 
  +
var spoilerbutton = document.getElementById("spoilerbutton");
for (i = 0; i < els.length; i++) {
 
  +
_toggleLinkValue(spoilerbutton);
if(pattern.test(els[i].className)){
 
  +
spoiler.push(els[i]);
 
  +
if("closed" == spoilerbutton.getAttribute("value")){
}
 
  +
spoilerbutton.firstChild.data = "zeige alle Spoiler";
  +
//todo:toggle...
  +
//spoilerbutton.className = '_toggle de';
  +
toggler(0);
 
}
 
}
  +
else{
for (j = 0; j < spoiler.length; j++){
 
  +
spoilerbutton.firstChild.data = "verstecke alle Spoiler";
if(pattern.test(spoiler[j].className)){
 
  +
//todo:toggle...
spoiler[j].style.display = 'none';
 
  +
//spoilerbutton.className = '_toggle jp';
spoiler[j].setAttribute("value","closed");
 
var link = findLink(j);
+
toggler(0);
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() {
+
function createSpoilerbutton(){
  +
//baue link...
var els = document.getElementsByTagName('*');
 
  +
var spoiler = new Array();
 
  +
var link = document.createElement("a");
var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
 
  +
link.href = "javascript:spoilAll()";
for (i = 0; i < els.length; i++) {
 
  +
var text = document.createTextNode("zeige alle Spoiler");
if(pattern.test(els[i].className)){
 
  +
link.appendChild(text);
spoiler.push(els[i]);
 
  +
}
 
  +
var value = document.createAttribute("name");
}
 
  +
value.nodeValue = "spoilerbutton";
for (j = 0; j < spoiler.length; j++){
 
  +
link.setAttributeNode(value);
if(pattern.test(spoiler[j].className)){
 
  +
spoiler[j].style.display = 'block';
 
  +
var value = document.createAttribute("id");
spoiler[j].setAttribute("value","open");
 
  +
value.nodeValue = "spoilerbutton";
var link = findLink(j);
 
  +
link.setAttributeNode(value);
if(null != link){
 
  +
link.firstChild.data = "verstecke Spoiler";
 
  +
var value = document.createAttribute("value");
}
 
  +
value.nodeValue = "closed";
}
 
  +
link.setAttributeNode(value);
}
 
  +
var link = document.getElementsByName("spoilerbutton")[0];
 
if(null != link){
+
return link;
  +
}
link.firstChild.data = "verstecke alle Spoiler";
 
  +
link.href = "javascript:spoilReset()";
 
  +
//testfunction...
link.getAttribute("value").nodeValue = "open";
 
  +
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 findLink(j) {
+
function initIconbar(){
  +
var iconbar = new Array();
var linksAll = document.getElementsByName("spoilerlink-"+j);
 
  +
var ul = document.createElement("ul");
if(0<linksAll.length){
 
  +
var value = document.createAttribute("id");
return linksAll[0];
 
  +
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];
return null;
 
  +
h1.parentNode.insertBefore(ul, h1);
 
}
 
}
   
function buildSpoitertags(){
+
function initSpoiler(){
 
var els = document.getElementsByTagName('*');
 
var els = document.getElementsByTagName('*');
 
var spoiler = new Array();
 
var spoiler = new Array();
var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
+
//var pattern = new RegExp("(^|\\s)spoiler(\\s|$)");
  +
var pattern = new RegExp("(^|\\s)jp(\\s|$)");
  +
 
for (i = 0; i < els.length; i++) {
 
for (i = 0; i < els.length; i++) {
 
if(pattern.test(els[i].className)){
 
if(pattern.test(els[i].className)){
 
spoiler.push(els[i]);
 
spoiler.push(els[i]);
  +
els[i].style.display = "none";
 
}
 
}
 
}
 
}
  +
for(j=0;j < spoiler.length;j++){
 
  +
/*for(j=0;j < spoiler.length;j++){
  +
//document.writeln(spoiler[j].nodeName);
 
var value = document.createAttribute("value");
 
var value = document.createAttribute("value");
value.nodeValue = "open";
+
value.nodeValue = "closed";
 
spoiler[j].setAttributeNode(value);
 
spoiler[j].setAttributeNode(value);
 
//baue link...
 
//baue link...
  +
var link = createSpoilerlink(j, spoiler[j].nodeName);
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...
 
//insert link...
  +
if(!modifySpoilerhinweis(j, spoiler[j], link)){
par.appendChild(link);
 
spoiler[j].parentNode.insertBefore(par, spoiler[j]);
+
spoiler[j].parentNode.insertBefore(link, spoiler[j]);
  +
}
}
 
  +
}*/
  +
 
if(0 < spoiler.length){
 
if(0 < spoiler.length){
 
//baue link...
 
//baue link...
  +
glSpoilerbutton = createSpoilerbutton();
var par = document.createElement("p");
 
  +
glIconbar.push(glSpoilerbutton);
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();
 
 
 
}
 
}
  +
  +
initIconbar();
 
}
 
}
   
addOnloadHook(buildSpoitertags);
+
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);