Benutzer:Marilyn.hanson/monobook.js

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Strg+F5
// [[:en:User:Lupin/popups.js]]

// Main page in English: [[:en:Wikipedia:Tools/Navigation Popups]]

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');




// MARK AUTOMATICALLY UNSIGNED COMMENTS ON TALK PAGES:
//<pre><nowiki>
// Below (unsigned2.js version 1.3,) by Invitatious. Dual-licensed under the terms of the GFDL v1.2 or the GPL v2.
// New features in this version: you can now choose an edit from the last 16.// New features in this version: you can now choose an edit from the last 16.
// [[User:Olliminatore/unsigned.js]] (suggested), converted/ localized for de:

function addSigWikiCode() {
	// From revision 28011729 of [[:en:Wikipedia:WikiProject_User_scripts/Scripts/Get_tidy_title]]
	function aswcGet_tidy_title(){ // Get's the URL version of the page title.
	 var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
	 // cut everything up to "title=" from the start and everything past "&action=edit" from the end
	 editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
	 return editlk // The result from this function might be needed unescape()ed
	};
  // LOCALIZABLE STRINGS START.
  var lsMonth_names = ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
   lsConflict = "Edit-Konflikt.",
   lsDialog1 = "Bitte wähle einen Edit unten:\n\n",
   lsDialog2 = "Unsigned Edit-Nummer:",
   lsInvalid1 = "Bitte eine gültige Zahl eintragen oder diese Operation annullieren.",
   lsInvalid2 = "Dies ist ein nicht aufgelisteter Minor-Edit. Trotzdem  wählen?",
   lsNoRev = "Keine Veränderung gefunden. Besteht die Seite?",
   lsNoXMLHTTP = "Couldn't get XMLHTTP!";
  // LOCALIZABLE STRINGS END
  
  var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : false; // Try to use native XMLHTTP
  if (!xmlhttp && window.ActiveXObject) { // ActiveX XMLHTTP
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    if (!xmlhttp) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  if (!xmlhttp) return alert(lsNoXMLHTTP); // No XMLHTTP
	xmlhttp.open("GET", "/w/query.php?format=xml&what=revisions&rvlimit=16&rvcomments&titles=" + aswcGet_tidy_title(), true); // Get timestamp, user, summary of last 16 edits
  xmlhttp.onreadystatechange = function (){
		if(xmlhttp.readyState!=4) return;
		if (!xmlhttp) return alert("Error: "+lsNoXMLHTTP + "\n" + xmlhttp.status + ": " + xmlhttp.statusText ); // No XMLHTTP
		var xmldoc = xmlhttp.responseXML;
		// IE workaround suggested by [[User:Olliminatore]]
		if (!xmldoc.documentElement && window.ActiveXObject) { // !FIXME: IE6 can't read XML???
			document.body.style.backgroundColor = "#CCCCFF"; // Debugging aid
			xmldoc = new ActiveXObject("Microsoft.XMLDOM");
			xmldoc.async = false;
			xmldoc.loadXML(xmlhttp.responseText);
		}
		var revisions = xmldoc.documentElement.getElementsByTagName("rv"); // Get the revisions
		if (revisions.length < 1) return alert(lsNoRev); // No revisions
		var t = revisions[0].getAttribute("timestamp").replace(/[^0-9]/g, ""); // Get rid of non-numeric characters in timestamp
		if(t != document.editform.wpEdittime.value) // Detect an edit conflict
			return alert(lsConflict);
		var dialog_text = lsDialog1;
		var edit_data = [];
		var edit_data2 = []; // with minoredits
		
		for (var n = 0; n < revisions.length; n++) { // Extract edit data and build dialog text
			edit_data[n] = { timestamp: revisions[n].getAttribute("timestamp").replace(/[^0-9]/g, ""),
											 user: revisions[n].getAttribute("user"),
											 comment: revisions[n].getAttribute("comment")};
			dialog_text += ("[" + n.toString(16).toUpperCase() + "] " + edit_data[n].timestamp + " " +
			 edit_data[n].user + ": " + edit_data[n].comment).substring(0, 80) + "\n";
			edit_data2[n] = edit_data[n];
			if (revisions[n].getAttribute("minor") != null) edit_data.pop() //continue; // Skip minor edits
		}
		
		while (true) {
			if (edit_data.length == 1) var unsigned_edit = 0; // no choice
			else if (navigator.product == "Gecko") // for Mozilla
				var unsigned_edit = prompt(dialog_text + "\n" + lsDialog2, "0");
			else { // for IE or other
				alert(dialog_text);
				var unsigned_edit = prompt(lsDialog2, "0");
			}
			if (unsigned_edit == null) return; // Cancel button
			else if (isNaN(unsigned_edit = parseInt(unsigned_edit, 16))) return alert(lsInvalid1); // Non-numeric input
			else if (!(unsigned_edit = edit_data[unsigned_edit])) {
				if (confirm(lsInvalid2)) // Non-existent edit
				unsigned_edit = edit_data2[unsigned_edit]
				else return;
			}
			t = unsigned_edit.timestamp; // So the full name doesn't have to be used
			// LOCALIZABLE STRINGS START (current de:)
			insertTags("{{subst:unsigned|" + unsigned_edit.user + "|" + (parseInt(t.substring(8, 10)) + parseInt(fetchTimezone().substring(0,2))) + ":" + t.substring(10, 12) + ", " + (t.substring(6, 8) - 0) + ". " + lsMonth_names[t.substring(4, 6) - 1] + " " + t.substring(0, 4) + " (CEST)| -- \~\~\~\~}}", "", ""); // Format and insert the tag. The data returned by query.php is UTC, FetchTimezone is needed.
			// LOCALIZABLE STRINGS END
			return
		}
	};
	xmlhttp.send(null);
};

$(function(){ // put onload in wikibits.js
// From [[:en:Wikipedia:WikiProject_User_scripts/Scripts/Add_LI_link]]
	function aswcAddlilink(tabs, url, name, id, title, key){
	 var na = document.createElement('a');
	 na.href = url;
	 na.appendChild(document.createTextNode(name));
	 var li = document.createElement('li');
	 if(id) li.id = id;
	 li.appendChild(na);
	 tabs.appendChild(li);
	 if(id){
		 if(key && title) ta[id] = [key, title];
		 else if(key) ta[id] = [key, ''];
		 else if(title) ta[id] = ['', title];
	 }
	 akeytt(); // re-render the title and accesskeys from existing code in wikibits.js
	 return li
	};

	if (/[&?]action=edit/.test(location.search))
		aswcAddlilink(document.getElementById('p-cactions').getElementsByTagName('ul')[0], "javascript:addSigWikiCode();", /* LOCALIZABLE STRINGS START */ "Unsigniert" , "ca-unsigned", "Markiere einen unsignierten Kommentar", "" /* LOCALIZABLE STRINGS END */);
});
// Above by Invitatious. Dual-licensed under the terms of the GFDL v1.2 or the GPL v2.






//============================================================
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL
// de: FÜGE NEUE BUTTONS IN DIE WERKZEUGLEISTE
//============================================================
// Vorschläge für neue Buttons werden gerne entgegengenommen
// Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.

if (typeof XEBOrder == 'undefined') // can be modified
	XEBOrder="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,T,U,V,W,X";

//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar  
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){
 mwCustomEditButtons.push({
  "imageFile": imageFile,
  "speedTip": speedTip,
  "tagOpen": tagOpen,
  "tagClose": tagClose,
  "sampleText": sampleText});
}

var Isrc='http://upload.wikimedia.org/wikipedia/';

var BDict={
'A':['en/c/c9/Button_strike.png','Streichen',"<s>","</s>",'Durchgestrichener Text'],
 'B':['en/e/ea/Button_align_left.png','Left-Align','<div style="text-align: left; direction: ltr; margin-left: 1em;">\n','\n</div>','Left-aligned text'],
'C':['en/5/5f/Button_center.png','Center','<div style="text-align: center;">\n','\n</div>','Centered text'],
'D':['commons/0/04/Button_array.png','Table','\n{| border=1 \n|- \n| 1 || 2\n|- \n| 3 || 4','\n|}\n',''],
'E':['en/1/13/Button_enter.png','Line break','<br />','',''],
'F':['en/8/80/Button_upper_letter.png','Superscript','<sup>','</sup>','Superscript text'],
'G':['en/7/70/Button_lower_letter.png','Subscript','<sub>','</sub>','Subscript text'],
'H':['commons/5/58/Button_small.png','Small','<small>','</small>','Small Text'],
'I':['en/3/34/Button_hide_comment.png','Versteckter Kommentar',"<!--","-->",''],
'J':['commons/9/9e/Btn_toolbar_gallery.png','Bildergalerie',"\n<gallery>\nImage:M63.jpg|[[M63]]\nImage:Mona Lisa.jpg|[[Mona Lisa]]\nImage:Truite arc-en-ciel.jpg|Eine [[Forelle ]]\n</gallery>","",''],
'K':['en/e/e9/Button_headline2.png','Secondary headline','\n===','===','Secondary headline'],
'L':['en/8/8e/Button_shifting.png','Insert tab(s)',':','',':'],
'M':['en/f/fd/Button_blockquote.png','Insert block of quoted text','<blockquote style="border: 1px solid blue; padding: 2em;">\n','\n</blockquote>','Block quote'],
'N':['en/1/1e/Button_font_color.png','Insert colored text','<span style="color: ColorName">','</span>','Span of text'],
'O':['commons/2/23/Button_code.png','Insert code','<code>','</code>','Code'],
 'P':['en/9/93/Button_sub_link.png','Insert link to sub-page','[[Page#',']]','Sub_page'],
'Q':['en/d/d3/Button_definition_list.png','Insert definition list','\n; ',' : ','Insert text'],
'R':['commons/3/3b/Button_template_alt.png','Template','{{','}}','Template name'],
'T':['commons/7/79/Button_reflink.png','<ref>','<ref>','</ref>','Insert reference material'],
'U':['commons/a/a0/Button_references_alt.png','Reference footer','<references/>','',''],
'V':['commons/c/c8/Button_redirect.png','Redirect',"#REDIRECT [[","]]",'Insert Ziel'],
 'W':['commons/8/88/Btn_toolbar_enum.png','Nummerierung',"\n# Element 1\n# Element 2\n# Element 3","",''],
 'X':['commons/1/11/Btn_toolbar_liste.png','Liste',"\n* Element A\n* Element B\n* Element C","",'']
}
XEBOrder=XEBOrder.split(",");
for (var b in XEBOrder) {
	var bc = BDict[XEBOrder[b]];
	addCustomButton(Isrc+bc[0],bc[1],bc[2],bc[3],bc[4])
}






/* Ersetze "..." durch „...“ */
function changeQuotes() {
    var txtArea =  document.editform.wpTextbox1;
    if (txtArea.selectionStart || txtArea.selectionStart == '0') {
        var startPos = txtArea.selectionStart;
	var endPos = txtArea.selectionEnd;
        if (txtArea.value.substring(startPos, startPos + 1) == '"' && 
          txtArea.value.substring(endPos - 1, endPos) == '"') {
            var scrollTop = txtArea.scrollTop;
            txtArea.value = txtArea.value.substring(0, startPos) +
              "„" + txtArea.value.substring(startPos + 1, endPos - 1) + "“" + 
              txtArea.value.substring(endPos);
            txtArea.focus();
            txtArea.selectionStart = startPos;
            txtArea.selectionEnd = endPos;
            txtArea.scrollTop = scrollTop;
        }
        else insertTags('„','“','');
    }
}

/* Biegt den Link zum Einfügen der Sonderzeichen „...“ auf die Funktion
   changeQuotes() um und setzt den accesskey " */
function modifyQuoteLink(elem) {
    var newAttr;
    newAttr = document.createAttribute("href");
    newAttr.nodeValue = "javascript:changeQuotes()";
    elem.setAttributeNode(newAttr);
    newAttr = document.createAttribute("accesskey");
    newAttr.nodeValue = '"';
    elem.setAttributeNode(newAttr);
}





/* Dieses Script von mir sortiert automatisch die Interwikis und korrigiert automatisch
einige Rechtschreibfehler. Die Änderungen sollten immer noch einmal kontrolliert werden,
da das Script der Einfachhaltshalber nicht immer 100% korrekt funktioniert. Zudem ist darauf
zu achten, dass die Rechtschreibung innerhalb von Zitaten nicht angepasst werden darf (Es
seidenn natürlich bei Übersetzungen...)  */
document.writeln('<div style="position:absolute; top:10px; right:10px;" onclick="korr()">Auto<br />korrigieren</div>');
function korr()
{
	// Text bekommen
	var text = document.editform.wpTextbox1.value;
	var textalt = text;


	// Interwikis sortieren
	// alle Sprachen mit mehr als 100 Artikeln werden unterstützt. (insofern ich mich nicht vertippt habe) Quelle: http://meta.wikimedia.org/w/index.php?title=List_of_Wikipedias&oldid=326392
	var regex = /\[\[(en|de|fr|pl|ja|nl|sv|it|pt|es|ru|zh|no|fi|eo|da|he|ro|sk|sr|hu|cs|ca|sl|bg|uk|ko|id|tr|et|lt|hr|nn|gl|io|ms|ar|fa|th|is|el|lb|bs|simple|wa|sq|vi|eu|ka|br|mk|af|la|ast|scn|nap|co|cy|tt|sh|lv|an|mr|ia|ga|az|ku|te|be|ta|nds|fy|tl|cv|oc|li|fo|als|jv|zh-min-nan|os|kn|sco|gd|yi|hi|war|ceb|kw|pam|ilo|su|ht|csb|bn|se|hy|ur|ang|sa|fur|ps|ml|pdc|mi|mt|mo|sw|ks|fiu-vro|mn|am|ie|tpi|nrm|lmo|lad|jbo|na|map-bms|gu|udm|zh-yue|uz|dv|ln|sc|nah|mg|vec|rm|ba):(.+?)\]\]\s*/g;

	var ar = text.match(regex);
	if(ar)
	{
		if(ar.join("#") != ar.sort().join("#"))
		{
			pos = text.search(regex);
			text = text.replace(regex, "");
			text = text.substr(0,pos) + ar.join("") + text.substr(pos);
		}
	}


	// Autokorrektur von einigen Schreibfehlern
	text = text.replace(/Daß/g,"Dass");
	text = text.replace(/daß/g,"dass");

	text = text.replace(/desweiteren/g,"des Weiteren");
	text = text.replace(/Desweiteren/g,"Des Weiteren");

	text = text.replace(/d\. ?h\./g,"d.&nbsp;h.");
	text = text.replace(/z\. ?B\./g,"z.&nbsp;B.");
	text = text.replace(/u\. ?a\./g,"u.&nbsp;a.");
	text = text.replace(/z\. ?Z\./g,"z.&nbsp;Z.");

	// stub-Vorlage entfernen, da diese in der de-WP nicht mehr verwendet wird
	text = text.replace(/\{\{stub\}\}/,"");


	// Text schreiben
	if(text==textalt)
		alert("nichts geändert");
	else
	{
		document.editform.wpTextbox1.value = text;
		document.editform.wpSummary.value = document.editform.wpSummary.value ? document.editform.wpSummary.value + ", Autokorrektur" : "[[Wikipedia:Skin#M.A.|Autokorrektur]]";
		document.editform.wpDiff.click();
	}
}




// [[Benutzer:Dschwen/wikiminiatlas2.js]] - diese Zeile bitte mitkopieren
document.write('<script type="text/javascript" src="' 
     + 'http://de.wikipedia.org/w/index.php?title=User:Dschwen/wikiminiatlas2.js' 
     + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');


//</nowiki></pre>