MediaWiki:Skin/Kamelionary.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K (index.php -> wiki)
 
(40 dazwischenliegende Versionen von 5 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
if(wgCanonicalNamespace == "Kamelionary" && wgAction == "edit")
+
if(mw.config.get( 'wgCanonicalNamespace' ) == "Kamelionary" && (Aktion == "edit" || Aktion == "submit") )
 
{
 
{
addJS("MediaWiki:Skin/KamelionaryEdit.js")
+
importJS("MediaWiki:Skin/KamelionaryEdit.js");
 
}
 
}
  
addOnloadHook( function ()
+
function startKamelionary()
 
{
 
{
 
changeLogoPath();
 
changeLogoPath();
Zeile 14: Zeile 14:
 
}
 
}
 
};
 
};
 +
 +
jQuery(document).ready(startKamelionary);
  
 
function changeLogoPath()
 
function changeLogoPath()
 
{
 
{
document.getElementById("p-logo").getElementsByTagName("a")[0].href = "/index.php/Kamelionary:Hauptseite";
+
document.getElementById("p-logo").getElementsByTagName("a")[0].href = "/wiki/Kamelionary:Hauptseite";
 +
document.getElementById("n-Hauptseite").getElementsByTagName("a")[0].href = "/wiki/Kamelionary:Hauptseite";
 +
document.getElementById("n-Kamelionary").getElementsByTagName("a")[0].href = "/wiki/Kamelopedia:Hauptseite";
 +
document.getElementById("n-Kamelionary").getElementsByTagName("a")[0].innerHTML = "Kamelopedia";
 +
document.getElementById("n-Letzte-.C3.84nderungen").getElementsByTagName("a")[0].href = "/index.php?namespace=106&associated=1&tagfilter=&title=Spezial%3ALetzte+%C3%84nderungen";
 
}
 
}
  
Zeile 34: Zeile 40:
 
function changeTab() /* funktioniert nicht auf Diskussionsseiten, da geprüft wird, ob Vorlage:Kamelionary da ist */
 
function changeTab() /* funktioniert nicht auf Diskussionsseiten, da geprüft wird, ob Vorlage:Kamelionary da ist */
 
{
 
{
document.getElementById("ca-nstab-kamelionary").getElementsByTagName("a")[0].innerHTML = "Eintrag";
+
if (mw.config.get("skin") == "monobook")
 +
document.getElementById("ca-nstab-kamelionary").getElementsByTagName("a")[0].innerHTML = "Eintrag";
 +
else if (mw.config.get("skin") == "vector")
 +
document.getElementById("ca-nstab-kamelionary").getElementsByTagName("a")[0].childNodes[0].innerHTML = "Eintrag";
 
}
 
}
  
Zeile 41: Zeile 50:
 
var feedbackdiv          = document.createElement("div");
 
var feedbackdiv          = document.createElement("div");
 
var divclass              = document.createAttribute("class");
 
var divclass              = document.createAttribute("class");
  divclass.nodeValue      = "portlet";
+
  divclass.nodeValue      = "portal collapsed";
 
var divid                = document.createAttribute("id");
 
var divid                = document.createAttribute("id");
 
  divid.nodeValue        = "p-feedback";
 
  divid.nodeValue        = "p-feedback";
var feedbackheader        = document.createElement("h5");
+
var feedbackheader        = document.createElement("h3");
var feedbackheadera      = document.createElement("a");
+
//var feedbackheadera      = document.createElement("a");
var headertext            = document.createTextNode("Rückmeldung");
+
var headertext            = document.createTextNode("Dieser Eintrag ist");
 
var feedbackbody          = document.createElement("div");
 
var feedbackbody          = document.createElement("div");
 
var bodyclass            = document.createAttribute("class");
 
var bodyclass            = document.createAttribute("class");
  bodyclass.nodeValue    = "pBody";
+
  bodyclass.nodeValue    = "body";
 
var feedbackp            = document.createElement("p");
 
var feedbackp            = document.createElement("p");
var pid                  = document.createAttribute("id");
+
//var pid                  = document.createAttribute("id");
  pid.nodeValue          = "fb_text";
+
//  pid.nodeValue          = "fb_text";
var ptext                = document.createTextNode("Dieser Eintrag ist");
+
//var ptext                = document.createTextNode("Dieser Eintrag ist");
 
var feedbackul            = document.createElement("ul");
 
var feedbackul            = document.createElement("ul");
 
var ulid                  = document.createAttribute("id");
 
var ulid                  = document.createAttribute("id");
Zeile 67: Zeile 76:
 
feedbackdiv.setAttributeNode(divid);
 
feedbackdiv.setAttributeNode(divid);
 
feedbackdiv.appendChild(feedbackheader);
 
feedbackdiv.appendChild(feedbackheader);
  feedbackheader.appendChild(feedbackheadera);
+
  //feedbackheader.appendChild(feedbackheadera);
    feedbackheadera.appendChild(headertext);
+
    feedbackheader.appendChild(headertext);
 
feedbackdiv.appendChild(feedbackbody);
 
feedbackdiv.appendChild(feedbackbody);
 
  feedbackbody.setAttributeNode(bodyclass);
 
  feedbackbody.setAttributeNode(bodyclass);
    feedbackbody.appendChild(feedbackp);
+
    //feedbackbody.appendChild(feedbackp);
               feedbackp.setAttributeNode(pid);
+
               //feedbackp.setAttributeNode(pid);
      feedbackp.appendChild(ptext);
+
      //feedbackp.appendChild(ptext);
 
    feedbackbody.appendChild(feedbackul);
 
    feedbackbody.appendChild(feedbackul);
 
               feedbackul.setAttributeNode(ulid);
 
               feedbackul.setAttributeNode(ulid);
Zeile 79: Zeile 88:
 
           discussionp.appendChild(discussiona);
 
           discussionp.appendChild(discussiona);
 
             discussiona.appendChild(discussionatext);
 
             discussiona.appendChild(discussionatext);
document.getElementById("column-one").insertBefore(feedbackdiv, document.getElementById("p-tb"));
+
jQuery('#p-tb').before(feedbackdiv);
 
for (var i = 0; i < feedbacklist.length; i++)
 
for (var i = 0; i < feedbacklist.length; i++)
 
{
 
{
Zeile 102: Zeile 111:
 
document.getElementById("p-feedback").getElementsByTagName("div")[0].innerHTML = '<p id="fb_thanks"><a href="/index.php/Kamelopedia:Danke">Vielen Dank!</a></p><p id="fb_comment">' + document.getElementById("fb_comment").innerHTML + '</p>';
 
document.getElementById("p-feedback").getElementsByTagName("div")[0].innerHTML = '<p id="fb_thanks"><a href="/index.php/Kamelopedia:Danke">Vielen Dank!</a></p><p id="fb_comment">' + document.getElementById("fb_comment").innerHTML + '</p>';
 
}
 
}
} );
+
}

Aktuelle Version vom 4. August 2014, 01:23 Uhr

if(mw.config.get( 'wgCanonicalNamespace' ) == "Kamelionary" && (Aktion == "edit" || Aktion == "submit") )
	{
		importJS("MediaWiki:Skin/KamelionaryEdit.js");			
	}

function startKamelionary()
	{
	changeLogoPath();
	changeFirstHeading();
	if(document.getElementById("Kamelionary_Eintrag"))
		{
		changeTab();
		insertFeedback();
		}
	};

jQuery(document).ready(startKamelionary);

function changeLogoPath()
	{
	document.getElementById("p-logo").getElementsByTagName("a")[0].href = "/wiki/Kamelionary:Hauptseite";
	document.getElementById("n-Hauptseite").getElementsByTagName("a")[0].href = "/wiki/Kamelionary:Hauptseite";
	document.getElementById("n-Kamelionary").getElementsByTagName("a")[0].href = "/wiki/Kamelopedia:Hauptseite";
	document.getElementById("n-Kamelionary").getElementsByTagName("a")[0].innerHTML = "Kamelopedia";
	document.getElementById("n-Letzte-.C3.84nderungen").getElementsByTagName("a")[0].href = "/index.php?namespace=106&associated=1&tagfilter=&title=Spezial%3ALetzte+%C3%84nderungen";
	}

function changeFirstHeading()
	{
	var i = document.getElementsByTagName("h1");
	for (j = 0; j < i.length; j++)
		{
		if (i[j].className == "firstHeading")
			{
			i[j].innerHTML = i[j].innerHTML.replace(/Kamelionary:/, "");
			}
		}
	}

function changeTab() /* funktioniert nicht auf Diskussionsseiten, da geprüft wird, ob Vorlage:Kamelionary da ist */
	{
		if (mw.config.get("skin") == "monobook")
			document.getElementById("ca-nstab-kamelionary").getElementsByTagName("a")[0].innerHTML = "Eintrag";
		else if (mw.config.get("skin") == "vector")
			document.getElementById("ca-nstab-kamelionary").getElementsByTagName("a")[0].childNodes[0].innerHTML = "Eintrag";
	}

function insertFeedback() /* ach du Sch*** ist das kompliziert ... aber .innerHTML macht doofes Zeug :-( */
	{
	var feedbackdiv           = document.createElement("div");
	var divclass              = document.createAttribute("class");
	  divclass.nodeValue      = "portal collapsed";
	var divid                 = document.createAttribute("id");
	  divid.nodeValue         = "p-feedback";
	var feedbackheader        = document.createElement("h3");
	//var feedbackheadera       = document.createElement("a");
	var headertext            = document.createTextNode("Dieser Eintrag ist");
	var feedbackbody          = document.createElement("div");
	var bodyclass             = document.createAttribute("class");
	  bodyclass.nodeValue     = "body";
	var feedbackp             = document.createElement("p");
	//var pid                   = document.createAttribute("id");
	//  pid.nodeValue           = "fb_text";
	//var ptext                 = document.createTextNode("Dieser Eintrag ist");
	var feedbackul            = document.createElement("ul");
	var ulid                  = document.createAttribute("id");
	  ulid.nodeValue          = "fb_list";
	var feedbacklist          = new Array("obertittenaffengeil", "total GaGA", "das beste, was ich je gelesen habe", "nobelpreisverdächtig", "lololol");
	var discussionp           = document.createElement("p");
	var discussionpid         = document.createAttribute("id");
	  discussionpid.nodeValue = "fb_comment";
	var discussiona           = document.createElement("a");
	var discussionatext       = document.createTextNode("Eintrag kommentieren?");
	var discussionhref        = document.getElementById("ca-talk").getElementsByTagName("a")[0].href;
	feedbackdiv.setAttributeNode(divclass);
	feedbackdiv.setAttributeNode(divid);
	feedbackdiv.appendChild(feedbackheader);
	  //feedbackheader.appendChild(feedbackheadera);
	    feedbackheader.appendChild(headertext);
	feedbackdiv.appendChild(feedbackbody);
	  feedbackbody.setAttributeNode(bodyclass);
	    //feedbackbody.appendChild(feedbackp);
              //feedbackp.setAttributeNode(pid);
	      //feedbackp.appendChild(ptext);
	    feedbackbody.appendChild(feedbackul);
              feedbackul.setAttributeNode(ulid);
        discussionp.setAttributeNode(discussionpid);
          discussionp.appendChild(discussiona);
            discussiona.appendChild(discussionatext);
	jQuery('#p-tb').before(feedbackdiv);
	for (var i = 0; i < feedbacklist.length; i++)
		{
		var feedbackli  = document.createElement("li");
		var feedbacklia = document.createElement("a");
		document.getElementById("fb_list").appendChild(feedbackli);
		document.getElementById("fb_list").getElementsByTagName("li")[i].appendChild(feedbacklia);
		document.getElementById("fb_list").getElementsByTagName("a")[i].appendChild(document.createTextNode(feedbacklist[i]));
		document.getElementById("fb_list").getElementsByTagName("a")[i].href = "javascript:feedback('" + feedbacklist[i] + "')";
		}
	document.getElementById("p-feedback").getElementsByTagName("a")[0].href = "/index.php/Dung";
	document.getElementById("p-feedback").getElementsByTagName("div")[0].appendChild(discussionp);
	document.getElementById("fb_comment").getElementsByTagName("a")[0].href = discussionhref;
	}

function feedback(feedbacktext)
	{
	Check = confirm("Diesen Eintrag als " + feedbacktext + " melden?");
	if (Check == true)
		{
		document.getElementById("fb_list").style.display = "none";
		document.getElementById("p-feedback").getElementsByTagName("div")[0].innerHTML = '<p id="fb_thanks"><a href="/index.php/Kamelopedia:Danke">Vielen Dank!</a></p><p id="fb_comment">' + document.getElementById("fb_comment").innerHTML + '</p>';
		}
	}