monobook.js

Aus RMG-Wiki
Wechseln zu: Navigation, Suche

Hinweis: Leere nach dem Speichern 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: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Extras → Internetspuren löschen … → Individuelle Auswahl → Den kompletten Cache löschen
// Rechtschreibprüfung
document.write('<SCRIPT SRC="http://de.wikipedia.org/w/index.php?title=MediaWiki:Gadget-Rechtschreibpruefung.js&action=raw&type=text/javascript"><\/SCRIPT>');
 
//------------------------------------
//Letzte Änderungen
//------------------------------------
 
var rcp_http;
var rcp_enabled=true;
var rcp_num_pages=20;
var rcp_refresh=10;
 
addOnloadHook( rcp_init );
 
/* initalise */
function rcp_init() {
 
  // allow user settings through
  if(rcp_enabled == null) {
    rcp_enabled = false;
  }
  if(rcp_num_pages == null) {
    rcp_num_pages = 10;
  }
  if(rcp_refresh == null) {
    rcp_refresh = 5;
  }
 
  // A few limits to be nice to the servers
  if (rcp_num_pages > 50) {
    rcp_num_pages = 50;
  }
  if (rcp_num_pages < 1) {
    rcp_num_pages = 1;
  }
  if (rcp_refresh < 2) {
    rcp_refresh = 2;
  }
 
  // get our cookie
  if (document.cookie.length > 0) {
    var c_start = document.cookie.indexOf("rcp_show_box=");
    if (c_start != -1) { 
      c_start = c_start + 13; 
      var c_end = document.cookie.indexOf(";", c_start);
      if (c_end == -1) {
        c_end = document.cookie.length;
      }
 
      if (document.cookie.substring(c_start, c_end) == "yes") {
        rcp_enabled = true;
      } else {
        rcp_enabled = false;
      }
    } 
  }
 
  // Either make a request or show nothing
  if (rcp_enabled == true) {
    rcp_ajax_request();
  } else {
    rcp_draw_disabled_box();
  }
}
 
/* init ajax */
function rcp_create_request() {
  try {
    rcp_http = new XMLHttpRequest();
 
  } catch (e) {
    try {
      rcp_http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        rcp_http = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
 
  rcp_http.onreadystatechange = function() {
    if(rcp_http.readyState == 4) rcp_ajax_response();
  }
 
  return true;
}
 
/* make a request */
function rcp_ajax_request() {
  // check we are enabled
  if (rcp_enabled == false) return;
 
  // firstly, inform the user
  var cur_box = document.getElementById('p-recentchanges');
  if (cur_box != null) {
    cur_box.firstChild.firstChild.data = 'Letzte Änderungen (laden...)';
  }
 
  if (rcp_create_request () == false) {
    if (cur_box != null) {
      cur_box.firstChild.firstChild.data = 'Letzte Änderungen (Konnte nicht geladen werden!)';
    } else {
      alert ("There seems to be a problem using the RecentChangePatrol script. I can't make AJAX objects, so I'm just going to complain. God Bless!");
    }
  }
 
  // Then make the request
  rcp_http.open("GET", "http://wikis.zum.de/rmg/api.php?action=query&list=recentchanges&rcnamespace=0&format=xml&rcshow=!bot&rclimit=" + rcp_num_pages, true);
  rcp_http.send(null);
}
 
/* we have received a response */
function rcp_ajax_response() {
 
  var items = rcp_http.responseXML.getElementsByTagName('rc');
 
  // create the div that holds all the recentchanges links
  var link_div = document.createElement('div');
  link_div.className = 'pBody';
  var list = document.createElement('ul');
  link_div.appendChild(list);
 
  // populate the list with 10 links.
  for (var i = 0; i < items.length; i++) {
    var item_name = items[i].getAttribute('title');
    var item_url = 'http://wikis.zum.de/rmg/index.php?&title=' + escape(item_name);
 
    a = document.createElement('a');
    a.setAttribute('href', item_url);
    a.appendChild(document.createTextNode(item_name));
 
    var li = document.createElement('li');
    li.appendChild(a);
    list.appendChild(li);
  }
 
  // Container div
  var div = document.createElement('div');
  div.setAttribute('id', 'p-recentchanges');
  div.className = 'portlet';
  var heading = document.createElement('h5');
  heading.appendChild(document.createTextNode('Letzte Änderungen'));
  div.appendChild(heading);
  div.appendChild(link_div);
 
  // disable link
  var p = document.createElement('p');
  p.style.fontSize = 'x-small';
  p.style.margin = '0px';
  p.style.textAlign = 'right';
  a = document.createElement('a');
  a.appendChild(document.createTextNode('Ausblenden'));
  a.onclick = rcp_disable_box;
  p.appendChild(a);
  link_div.appendChild(p);
 
  // now replace the div
  var old_div = document.getElementById('p-recentchanges');
  var side_col = document.getElementById('column-one');
  if (old_div != null) {
    side_col.replaceChild(div, old_div);
  } else {
    var node = document.getElementById('p-search');
    side_col.insertBefore(div, node);
  }
 
  // and do it again in 5 secs
  setTimeout("rcp_ajax_request()", rcp_refresh * 1000);
}
 
function rcp_disable_box() {
  rcp_enabled = false;
  rcp_draw_disabled_box();
  document.cookie = "rcp_show_box=no; path=/";
}
 
function rcp_enable_box() {
  rcp_enabled = true;
  document.cookie = "rcp_show_box=yes; path=/";
  rcp_ajax_request();
}
 
function rcp_draw_disabled_box() {
  // Container div
  var link_div = document.createElement('div');
  link_div.className = 'pBody';
  var div = document.createElement('div');
  div.setAttribute('id', 'p-recentchanges');
  div.className = 'portlet';
  var heading = document.createElement('h5');
  heading.appendChild(document.createTextNode('Letzte Änderungen'));
  div.appendChild(heading);
  div.appendChild(link_div);
 
  // enable link
  var p = document.createElement('p');
  p.style.fontSize = 'x-small';
  p.style.margin = '0px';
  var a = document.createElement('a');
  a.appendChild(document.createTextNode('Einblenden'));
  a.onclick = rcp_enable_box;
  p.appendChild(a);
  link_div.appendChild(p);
 
  // now replace the div
  var old_div = document.getElementById('p-recentchanges');
  var side_col = document.getElementById('column-one');
  if (old_div != null) {
    side_col.replaceChild(div, old_div);
  } else {
    var node = document.getElementById('p-search');
    side_col.insertBefore(div, node);
  }
}
 
document.addEventListener("DOMContentLoaded", function() {
   var vl_logout = document.getElementById("pt-logout");
   if (vl_logout) 
   {
     var ins_li = document.createElement("LI");
     ins_li.innerHTML=/* */'<a href="http://rechtschreibpruefung24.de" target="_blank">Rechtschreibprüfung</a>';/* */
     vl_logout.parentNode.insertBefore(ins_li, vl_logout);
   }
 }, false);
 
document.addEventListener("DOMContentLoaded", function() {
   var vl_logout = document.getElementById("pt-logout");
   if (vl_logout) 
   {
     var ins_li = document.createElement("LI");
     ins_li.innerHTML=/* */'<a href="http://wikis.zum.de/rmg/index.php/Spezial:Texbox" target="_blank">Texbox</a>';/* */
     vl_logout.parentNode.insertBefore(ins_li, vl_logout);
   }
 }, false);
 
document.addEventListener("DOMContentLoaded", function() {
   var vl_logout = document.getElementById("pt-logout");
   if (vl_logout) 
   {
     var ins_li = document.createElement("LI");
     ins_li.innerHTML=/* */'<a href="http://wikis.zum.de/rmg/index.php/Fortbildung" target="_blank">Hilfe</a>';/* */
     vl_logout.parentNode.insertBefore(ins_li, vl_logout);
   }
 }, false);
 
document.addEventListener("DOMContentLoaded", function() {
   var vl_logout = document.getElementById("pt-logout");
   if (vl_logout) 
   {
     var ins_li = document.createElement("LI");
     ins_li.innerHTML=/* */'<a href="http://wikis.zum.de/rmg/index.php/Benutzer:Zehe_Albin/monobook.js">Monobook</a>';/* */
     vl_logout.parentNode.insertBefore(ins_li, vl_logout);
   }
 }, false);
 
document.addEventListener("DOMContentLoaded", function() {
   var vl_userpage = document.getElementById("pt-userpage");
   if (vl_userpage) 
   {
     var ins_li = document.createElement("LI");
     ins_li.innerHTML=/* */'<a href="http://wikis.zum.de/rmg/index.php/10c_2009_10">Klassenseite</a>';/* */
     vl_userpage.parentNode.insertBefore(ins_li, vl_userpage);
   }
 }, false);
 
//============================================================
// en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL [[:en:User:MarkS/Extra edit buttons]]
// de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE [[:de:Benutzer:Olliminatore/Extra-Editbuttons]]
//   Converted by [[User:Olliminatore]] 25.09.2006 
//============================================================
 
// de: Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable customEditButtons wählbar.
//
 
var XEBOrder=[];
var attributes = ["imageFile","speedTip","tagOpen","tagClose","sampleText"];
var rmEditButtons = "all";
// isMSIE55
 
//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the toolbar  
function addCustomButton(){
 var a = {};
 for (d in attributes) a[attributes[d]] = arguments[d];
 mwCustomEditButtons.push(a);
};
 
if (typeof usersignature == 'undefined') var usersignature = '-- \~\~\~\~';
 
var Isrc='';
var BDict={
 
'_KB':['http://wikis.zum.de/rmg/images/3/34/Button_Kasten.jpg','Fügt einen (hellblauen) Kasten um den markierten Text ein !!!Neue Zeile vor "| valign="top" einfügen!!!',
'{|width=100%| style="background-color:lightblue; border: 1px solid #dfdfdf; padding:0.5em" | valign="top" |','|}','Eingerahmter Text'],
'_KB2':['http://wikis.zum.de/rmg/images/3/34/Button_Kasten.jpg', 'Fügt ein Box ein', '{| width="99%" | style="vertical-align:top" | <div style="margin: 0; margin-right:10px; border: 1px solid #dfdfdf; padding: 0em 1em 1em 1em; background-color:#FFB90F; align:left;">', '|}', ''],
'_KI':['http://wikis.zum.de/rmg/images/4/44/Button_Kein_Inhaltsverzeichnis.PNG', 'Verhindert die Ertellung eines Inhaltsverzeichnisses', '','','__NOTOC__'],
'_H':['http://upload.wikimedia.org/wikipedia/commons/f/ff/Button_arrow_right.png', 'Ermöglicht, eine Lösung zu verstecken', '<div style="padding:1px;background:#ddeeff;border:1px groove;"> :{{Lösung versteckt|1= :', '}} </div>', 'Lösung'],
};
 
 
customEditButtons = "all";
 
 
if (typeof customEditButtons!='string') // can be modified
	XEBOrder="A,A3,B,E,F,G,H,I1,I2,J1,K,M,Q,R,R1,R2,R3,S,T,U,V,W,X".split(",");
else if (customEditButtons.toLowerCase()=='all') 
	for (b in BDict) XEBOrder.push(b);
else XEBOrder=customEditButtons.split(",");
 
 
function initButtons(){
  var bc,d;
	for (b in BDict) BDict[b][0] = Isrc+BDict[b][0]; // // Add the start of the URL (Isrc) to the XEB buttons
	// If the user has defined any buttons then add them into the available button lists 
	if (typeof myButtons=='object')
	  for (b in myButtons) BDict[b] = myButtons[b];	// custom user buttons
  // Add the media wiki standard buttons into the available buttons 
	for (b in mwEditButtons) { // add standard buttons for full XEB order changing
		BDict[b]=[];
	//	for (d in mwEditButtons[b]) 
		for (d in attributes) BDict[b].push(mwEditButtons[b][attributes[d]]);
	}
 
	// Build the new buttons 
	for (i=0;i<XEBOrder.length;i++) {
		bc = BDict[XEBOrder[i]];
		//try { // catch not existing button names
		addCustomButton(bc[0],bc[1],bc[2],bc[3],bc[4]);
		//}
		// catch(e) {continue}
	}
	// Remove the default buttons (if requested by the user)
	// eraseButtons();
};
 
//============================================================
// Table generator 
//============================================================
/** en: Generate an array using Mediawiki syntax
* @author: originally from fr:user:dake
* @version: 0.2 */
function generateTable(caption, exhead, nbCol, nbRow, exfield, align){
	var code = "\n";
	code += '{| class="wikitable" ' + align + '\n'
		+ caption + exhead;
	if (exfield) code += '!\n';
	for (i=1;i<nbCol+1;i++) code += '! FELD ' + i + '\n';
	var items = 0;
	for (var j=0;j<nbRow;j++){
		if (exfield) { 
			items++;
			code += '|-\n! style="background: #FFDDDD;"|ITEM ' + items + '\n';
		}	else code += '|-\n';
		for (i=0;i<nbCol;i++) code += '| Element\n';
	}
	code += '|}\n';
	insertTags('','', code);
	editform.elements['wpSummary'].value+=' table+';
	return false
};
 
 
/** en: Open a popup with parameters to generate an array. 
* The number of rows/columns can be modified.
* @author: originally fr:user:dake 
* @version: 0.2 */
function popupTable(){
  var popup = window.open('about:blank','WPtable','height=400,width=400,scrollbars=yes');
  var javaCode = '<script type="text\/javascript">function insertCode(){'
  +'var caption = (document.paramForm.inputCaption.checked)?"\|\+ TABLE CAPTION \\n":""; '
	+'var exhead = (document.paramForm.inputHead.checked)?\'\|\- style=\"background: #DDFFDD;\"\\n\':""; '
  +'var row = parseInt(document.paramForm.inputRow.value); '
  +'var col = parseInt(document.paramForm.inputCol.value); '
  +'var exfield = document.paramForm.inputItems.checked; '
  +'var align = (document.paramForm.inputAlign.checked)?\'align="center"\':""; '
  +'window.opener.generateTable(caption,exhead,col,row,exfield,align); '
  +'window.close()}<\/script>';
 
  popup.document.write('<html><head><title>Make table<\/title>'
// +'<script type="text\/javascript" src="\/skins-1.5\/common\/wikibits.js"><\/script>'
//+'<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>'
  + javaCode +'<\/head><body>'
  +'<p>Enter the table parameters below: <\/p>'
  +'<form name="paramForm">'
	+'Table caption: <input type="checkbox" name="inputCaption"><p\/>'
  +'Table alignment: center<input type="checkbox" name="inputAlign"><p\/>'
	+'Table headline: colored<input type="checkbox" name="inputHead"><p\/>'
  +'Number of rows: <input type="text" name="inputRow" value="3" size="2"><p\/>'
  +'Number of columns: <input type="text" name="inputCol" value="3" size="2"><p\/>'
  //+'Alternating grey lines: <input type="checkbox" name="inputLine" checked="1" ><p\/>'
  +'Item column: <input type="checkbox" name="inputItems" ><p\/>'
  +'<\/form">'
  +'<i>The default table allows for fields and values only.<\/i><p\/>'
  +'Check "Item column" to allow for the table to have fields, items, and values.<\/i><p\/>'
  +'<p><a href="javascript:insertCode()"> Insert table into window<\/a> &nbsp;&nbsp;&nbsp; |'
  +' &nbsp;&nbsp;&nbsp;<a href="javascript:self.close()">Cancel<\/a><\/p>'
  +'<\/body><\/html>');
  popup.document.close();
  return false
};
 
 
/** en: Removes arbitrary standard buttons from the toolbar
* @author: [[:de:User:Olliminatore]]
* @version: 0.2 (01.10.2006) **/
function eraseButtons(){
	if(typeof rmEditButtons!='object') return;
	if (typeof rmEditButtons[0] == 'string' && rmEditButtons[0].toLowerCase() == 'all') 
		return mwEditButtons=[];
	//Remove the buttons the user doesn't want 
	for(i=0;i<rmEditButtons.length;i++){
		var n=rmEditButtons[i]-i;
		if(n>=0 && n<mwEditButtons.length){
			if(n<mwEditButtons.length){
				var x = -1;
				while((++x)<mwEditButtons.length)
					if(x>=n)
						mwEditButtons[x] = mwEditButtons[x+1];
			}
		mwEditButtons.pop();
		}
	}
};
 
addOnloadHook(initButtons);
 
// Adds extended onclick-function to some buttons 
function extendButtons(){
	if(!(allEditButtons = document.getElementById('toolbar'))) return false;
	if(typeof editform == 'undefined')
		if(!(window.editform = document.editform)) return false;
 
	XEBOrder.getIndex = function (item){
	 if(is_gecko) return this.indexOf(item);
	 else //is IE (Opera < 9)
		 for (var i=0;i < this.length;i++) if (this[i]==item) return Number(i);
   	return -1
	}
	var searchbox = allEditButtons.getElementsByTagName('span')[0];
	if (searchbox) allEditButtons.appendChild(searchbox) // pay Zocky/Search Box
 
	allEditButtons = allEditButtons.getElementsByTagName('img');
 
	var bu_len = mwEditButtons.length;
	var c=0;
 
	if(!allEditButtons.length) return false;
 
	// own signature
	if (bu_len>0){
		if(typeof rmEditButtons=='object' && rmEditButtons.pop()==10) c=1;
			mwEditButtons[bu_len-2+c].tagOpen=usersignature;
		if(usersignature != '-- \~\~\~\~')
			allEditButtons[bu_len-2+c].src=Isrc+'d/d1/Button_mysignature.png';
	}
 
	//  table
	if((c=XEBOrder.getIndex('E')) != -1) allEditButtons[bu_len+c].onclick=popupTable;
 
	// redirect
	c=XEBOrder.getIndex('V');
	if(c != -1)
		allEditButtons[bu_len+c].onclick=function(){
		 if (a = window.prompt("Wohin soll der Redirect\?", "")) {
		 a = '\#REDIRECT \[\[' + a + '\]\]';
		 editform.wpTextbox1.value=a;
		 editform.wpSummary.value=a; // not more needed?
		 editform.wpWatchthis.checked=false
		 }
  		};
 
	// spacer width
	if((c = XEBOrder.getIndex('T1')) != -1) allEditButtons[bu_len+c].width = 6;
};
 
if(!wgIsArticle) // only if edit
	hookEvent("load", extendButtons);
 
 
function editintro()
{
  // Ersten existierenden "editsection"-Link holen
  var spans = document.getElementsByTagName('span');
  var linkpos;
  for(linkpos = 0;
      linkpos < spans.length
        && spans[linkpos].getAttribute('class') != 'editsection';
      ++linkpos)
  {
    // leer
  }
  // Ein Einleitungs-Bearbeitungs-Link ist nur sinvoll,
  // wenn es auch andere Sections gibt
  if (linkpos < spans.length)
  {
    // ersten Editsection-Link kopieren (tiefe Kopie)
    var editintro = spans[linkpos].cloneNode(true);
    // Link anpassen
    var editlink = editintro.getElementsByTagName('a')[0];
    editlink.href = editlink.href.replace(/section=1/,'section=0');
    editlink.setAttribute('title', 'Einleitung bearbeiten');
    // Titelzeile holen
    var pagetitle = document.getElementsByTagName('h1')[0];
    // Editintro-Link einfügen
    pagetitle.insertBefore(editintro, pagetitle.firstChild);
  }
}
 
if (wgIsArticle && wgAction=='view') // bei normaler Betrachtung eines Artikels
  addOnloadHook(editintro);