MediaWiki:Gadget-Einleitung-bearbeiten.js

Aus Kitakien

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K (und noch ein typo)
K (Bisschen sortiert)
Zeile 1: Zeile 1:
-
// ursprünglich: [[:en:User:Pile0nades]]
+
// Anwenderbeschreibung siehe [[MediaWiki:Gadget-Einleitung-bearbeiten]]
-
// Erweitert von: Maciej Jaros [[:pl:User:Nux]]
+
-
// siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js
+
-
// Korrigiert von: [[Benutzer:TMg]]
+
-
if (wgIsArticle) addOnloadHook(function() {
+
/* Autoren:
-
// somehow it gets run twice on some pages - stop that
+
* ursprünglich: [[:en:User:Pile0nades]]
-
if (window.addEditTopLinkDone)
+
* Erweitert von: Maciej Jaros [[:pl:User:Nux]] (siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js)
-
return;
+
* Korrigiert von: [[Benutzer:TMg]] */
-
window.addEditTopLinkDone = true;
+
-
// if there are no edit-section links then stop
+
/*global addOnloadHook, wgIsArticle */
-
var spans = document.getElementsByTagName("span");
+
-
var i;
+
-
for (i = 0; i < spans.length; i++) {
+
-
if (spans[i].className == 'editsection')
+
-
break;
+
-
}
+
-
if (i >= spans.length)
+
-
return;
+
-
// additional checkup to stop
+
if (wgIsArticle) {
-
var test = document.getElementsByTagName("h2").length +
+
addOnloadHook(function () {
-
document.getElementsByTagName("h3").length +
+
// somehow it gets run twice on some pages - stop that
-
document.getElementsByTagName("h4").length - ((typeof document.getElementById('siteSub') == 'undefined' || document.getElementById('siteSub').tagName != 'H3') ? 0 : 1) ;
+
if (document.getElementById('firstsectionedit') !== null) {
-
// note that there is always siteSub (h3)
+
return;
-
var addEditTopLinkNumHeaders = window.addEditTopLinkNumHeaders || 2;
+
}
-
if (test <= addEditTopLinkNumHeaders)
+
-
return;
+
-
// get first header element
+
// if there are no edit-section links then stop
-
var fst_h1 = document.getElementsByTagName("h1")[0];
+
var spans = document.getElementsByTagName("span");
 +
for (var i = 0 ; i < spans.length ; i++) {
 +
if (spans[i].className === 'editsection') {
 +
break;
 +
}
 +
}
 +
if (i >= spans.length) {
 +
return;
 +
}
-
// Creating elements
+
// additional checkup to stop
-
// create span
+
var test = document.getElementsByTagName("h2").length +
-
var span = document.createElement("SPAN");
+
document.getElementsByTagName("h3").length +
-
span.className = 'editsection';
+
document.getElementsByTagName("h4").length - ((typeof document.getElementById('siteSub') === 'undefined' || document.getElementById('siteSub').tagName !== 'H3') ? 0 : 1);
-
// create link
+
// note that there is always siteSub (h3)
-
var link = document.createElement("A");
+
var addEditTopLinkNumHeaders = window.addEditTopLinkNumHeaders || 2;
-
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
+
-
link.title = "Abschnitt bearbeiten: Einleitung";
+
-
link.appendChild(document.createTextNode('Bearbeiten'));
+
-
// append link and stuff to span
+
-
span.appendChild(document.createTextNode('['));
+
-
span.appendChild(link);
+
-
span.appendChild(document.createTextNode(']'));
+
-
// Insert span container into the DOM before the h1
+
if (test <= addEditTopLinkNumHeaders) {
-
fst_h1.insertBefore(document.createTextNode(" "), fst_h1.firstChild);
+
return;
-
fst_h1.insertBefore(span, fst_h1.firstChild);
+
}
-
});
+
 
 +
// get first header element
 +
var fst_h1 = document.getElementsByTagName("h1")[0];
 +
 
 +
// Creating elements
 +
// create span
 +
var span = document.createElement("SPAN");
 +
span.className = 'editsection';
 +
span.id = 'firstsectionedit';
 +
 
 +
// create link
 +
var link = document.createElement("A");
 +
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
 +
link.title = "Abschnitt bearbeiten: Einleitung";
 +
link.appendChild(document.createTextNode('Bearbeiten'));
 +
// append link and stuff to span
 +
span.appendChild(document.createTextNode('['));
 +
span.appendChild(link);
 +
span.appendChild(document.createTextNode(']'));
 +
 
 +
// Insert span container into the DOM before the h1
 +
fst_h1.insertBefore(document.createTextNode(" "), fst_h1.firstChild);
 +
fst_h1.insertBefore(span, fst_h1.firstChild);
 +
});
 +
}

Version vom 14:13, 9. Okt. 2008

// Anwenderbeschreibung siehe [[MediaWiki:Gadget-Einleitung-bearbeiten]]
 
/* Autoren:
* ursprünglich: [[:en:User:Pile0nades]]
* Erweitert von: Maciej Jaros [[:pl:User:Nux]] (siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js)
* Korrigiert von: [[Benutzer:TMg]] */
 
/*global addOnloadHook, wgIsArticle */
 
if (wgIsArticle) {
	addOnloadHook(function () {
		// somehow it gets run twice on some pages - stop that
		if (document.getElementById('firstsectionedit') !== null) {
			return;
		}
 
		// if there are no edit-section links then stop
		var spans = document.getElementsByTagName("span");
		for (var i = 0 ; i < spans.length ; i++) {
			if (spans[i].className === 'editsection') {
				break;
			}
		}
		if (i >= spans.length) {
			return;
		}
 
		// additional checkup to stop
		var test = document.getElementsByTagName("h2").length +
			document.getElementsByTagName("h3").length +
			document.getElementsByTagName("h4").length - ((typeof document.getElementById('siteSub') === 'undefined' || document.getElementById('siteSub').tagName !== 'H3') ? 0 : 1);
		// note that there is always siteSub (h3)
		var addEditTopLinkNumHeaders = window.addEditTopLinkNumHeaders || 2;
 
		if (test <= addEditTopLinkNumHeaders) {
			return;
		}
 
		// get first header element
		var fst_h1 = document.getElementsByTagName("h1")[0];
 
		// Creating elements
		// create span
		var span = document.createElement("SPAN");
		span.className = 'editsection';
		span.id = 'firstsectionedit';
 
		// create link
		var link = document.createElement("A");
		link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
		link.title = "Abschnitt bearbeiten: Einleitung";
		link.appendChild(document.createTextNode('Bearbeiten'));
		// append link and stuff to span
		span.appendChild(document.createTextNode('['));
		span.appendChild(link);
		span.appendChild(document.createTextNode(']'));
 
		// Insert span container into the DOM before the h1
		fst_h1.insertBefore(document.createTextNode(" "), fst_h1.firstChild);
		fst_h1.insertBefore(span, fst_h1.firstChild);
	});
}
Persönliche Werkzeuge