MediaWiki:Gadget-Einleitung-bearbeiten.js

Aus Kitakien

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(AZ: Die Seite wurde neu angelegt.)
K (10 Versionen: Systemmeldungen)
 
(Der Versionsvergleich bezieht 9 dazwischenliegende Versionen mit ein.)
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
+
-
var addEditTopLinkNumHeaders = 2;
+
/* Autoren:
-
function addEditTopLink() {
+
* ursprünglich: [[:en:User:Pile0nades]]
-
//
+
* Erweitert von: Maciej Jaros [[:pl:User:Nux]] (siehe http://pl.wikipedia.org/wiki/MediaWiki:Monobook.js)
-
// somehow it gets run twice on some pages - stop that
+
* Korrigiert von: [[Benutzer:TMg]] */
-
if (window.addEditTopLinkDone)
+
-
return
+
-
;
+
-
window.addEditTopLinkDone = true;
+
-
//
+
/*global addOnloadHook, wgIsArticle */
-
// if this is preview page or there is no edit tab, stop
+
-
if (!wgIsArticle)
+
-
return
+
-
;
+
-
//
+
if (wgIsArticle) {
-
// if there are no edit-section links then stop
+
addOnloadHook(function () {
-
var spans = document.getElementById("bodyContent").getElementsByTagName("span");
+
// Neither run on fully-protected pages (which lack ca-edit) nor modify the same page twice
-
var i;
+
if ((document.getElementById("ca-edit") == null) ||
-
for (i = 0; i < spans.length; i++) {
+
                    (document.getElementById('firstsectionedit') !== null)) {
-
if (spans[i].className == 'editsection')
+
return;
-
break
+
}
-
;
+
-
}
+
-
if (i>=spans.length)
+
-
return
+
-
;
+
-
//
+
// if there are no edit-section links then stop
-
// additional checkup to stop
+
var spans = document.getElementsByTagName("span");
-
var test = document.getElementById("bodyContent").getElementsByTagName("h2").length +
+
for (var i = 0 ; i < spans.length ; i++) {
-
document.getElementById("bodyContent").getElementsByTagName("h3").length +
+
if (spans[i].className === 'editsection') {
-
document.getElementById("bodyContent").getElementsByTagName("h4").length;
+
break;
-
// note that there is always siteSub (h3)
+
}
-
if (test<=addEditTopLinkNumHeaders)
+
}
-
return
+
if (i >= spans.length) {
-
;
+
return;
-
+
}
-
//
+
-
// get first header element
+
-
var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0];
+
-
//
+
// get first header element
-
// Creating elements
+
var fst_h1 = document.getElementsByTagName("h1")[0];
-
//
+
-
// create div
+
-
var div = document.createElement("DIV");
+
-
div.className = 'editsection';
+
-
// create link
+
-
var link = document.createElement("A");
+
-
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
+
-
link.setAttribute('title', 'Einleitung des Artikels bearbeiten');
+
-
link.appendChild(document.createTextNode('Bearbeiten'));
+
-
// append link and stuff to div
+
-
div.appendChild(document.createTextNode('['));
+
-
div.appendChild(link);
+
-
div.appendChild(document.createTextNode(']'));
+
-
//
+
// Creating elements
-
// Styling
+
// create span
-
//
+
var span = document.createElement("SPAN");
-
fst_h1.style.cssText = 'position:relative';
+
span.className = 'editsection';
-
div.style.cssText = 'position:absolute; right:0px; font-size:x-small; bottom:-1.7em';
+
span.id = 'firstsectionedit';
-
// IE fix — relative>absolute just dont work there (is positioned relative to body)
+
-
if (clientPC.indexOf('msie')!=-1 && clientPC.indexOf('opera') == -1)
+
-
div.style.cssText='position:absolute; right:1.5em; font-size:x-small; top:3.8em'
+
-
;
+
-
//
+
// create link
-
// Insert div container into the DOM before the h1
+
var link = document.createElement("A");
-
//
+
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '&section=0';
-
fst_h1.appendChild(div);
+
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);
 +
});
}
}
-
addOnloadHook(addEditTopLink);
 

Aktuelle Version vom 18:01, 9. Dez. 2009

// 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 () {
		// Neither run on fully-protected pages (which lack ca-edit) nor modify the same page twice
		if ((document.getElementById("ca-edit") == null) || 
                    (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;
		}
 
		// 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