monobook.js: Unterschied zwischen den Versionen
Aus RMG-Wiki
Zeile 23: | Zeile 23: | ||
var Isrc=''; | var Isrc=''; | ||
var BDict={ | 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!!!', | '_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'], | '{|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;">', '|}', ''], | '_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__'], | '_KI':['http://wikis.zum.de/rmg/images/4/44/Button_Kein_Inhaltsverzeichnis.PNG', 'Verhindert die Ertellung eines Inhaltsverzeichnisses', '','','__NOTOC__'], | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}; | }; | ||
Version vom 27. September 2008, 15:37 Uhr
//============================================================ // 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"]; // 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__'], }; 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> |' +' <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); //------------------------------ // 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]] if (wgIsArticle) addOnloadHook(function() { // somehow it gets run twice on some pages - stop that if (window.addEditTopLinkDone) return; window.addEditTopLinkDone = true; // if there are no edit-section links then stop 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 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'; // create link var link = document.createElement("A"); link.href = '/rmg/index.php/Benutzer:Zehe_Albin/Rechtschreibprüfung'; link.title = "Link zur Rechtschreibprüfung"; link.appendChild(document.createTextNode('Rechtschreibprüng')); // 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); }); // *************************************** // Minimale Rechtschreibprüfung von APPER // *************************************** var words = ""; function spellcheck() { if (navigator.userAgent.indexOf("Firefox") > 0) // Firefox { if (document.body.className == "ns-0") // Beim Firefox nur für Artikel { words = document.getElementById("bodyContent").textContent; } } else // Opera + IE { // Bei Opera immer, sonst nur ns-0 if ((navigator.userAgent.indexOf("Opera") > 0) || (document.body.className == "ns-0")) { words = document.getElementById("bodyContent").innerText; } } if (words != "") { // In 1000-Zeichen-Pakete zerlegen ... ein wenig überlappen lassen for(i=0; i<=(words.length/1000); i++) { // Woerter an meinen Server senden var scJS = document.createElement('script'); scJS.type = 'text/javascript'; scJS.src = 'http://www.apper.de/wikipedia/sc/check.php?word=' + escape(words.substr(i*1000,1010)); document.getElementsByTagName('head')[0].appendChild(scJS); } } } function markWord(node, text) { var pos, len, newnodes = 0; var newnode, middlenode, endnode; // textnode - search for word if (node.nodeType == 3) { pos = node.data.search(text); if(pos >= 0) { // create new span-element newnode = document.createElement("span"); newnode.style.backgroundColor = "#FF9191"; // get length of the matching part len = node.data.match(text)[0].length; // splits content in three parts: begin, middle and end middlenode = node.splitText(pos); endnode = middlenode.splitText(len); // appends a copy of the middle to the new span-node newnode.appendChild(middlenode.cloneNode(true)); // replace middlenode with the new span-node middlenode.parentNode.replaceChild(newnode, middlenode); newnodes = 1; } } else if ((node.nodeType == 1) // element node && (node.hasChildNodes()) // with child nodes && (node.tagName.toLowerCase() != "script") // no script, style and form && (node.tagName.toLowerCase() != "style") && (node.tagName.toLowerCase() != "form")) { var this_child; for (this_child = 0; this_child < node.childNodes.length; this_child++) { this_child = this_child + markWord(node.childNodes[this_child], text); } } return newnodes; } var rechtschreibpruefung = true; // Rechtschreibprüfung aktivieren? var AutorunRP = true; // false = RP durch Anklicken; true = automatische RP // Ende Rechtschreibprüfung //-------------------- // Rechtschreibprüfung von Apper. // Siehe de:Benutzer:APPER/RP //document.write('<SCRIPT SRC="http://de.wikipedia.org/w/index.php?title=Benutzer:APPER/RP/js&action=raw&ctype=text/javascript"><\/SCRIPT>'); // </nowiki> <- nicht löschen !!! MyChar[0] = "{\{Zeile|"; MyCharEnd[0]="}\}"; MyCharDefault[0]="+5"; MyCharText[0]="Zeile" MyChar[1] = "{\{Seite|"; MyCharEnd[1]="}\}"; MyCharDefault[1]="+1"; MyCharText[1]="Seite" MyChar[2]= "<ref>" MyCharEnd[2]="</ref>" MyCharText[2] = "ref" MyChar[3]= "----\\n<div style=font-size:80%>\\n" MyCharEnd[3]="<references/>\\n</div>\\n" MyCharText[3] = "Anm" MyChar[4] = "</poem>" MyCharText[4] = "poem" MyChar[5]= "<!--" MyCharEnd[5]="-->" MyCharText[5] = "Komm" MyChar[6] = "\\'\\'\\'"; MyCharText[6] ="F"; MyChar[7] = "\\'\\'"; MyCharText[7] ="K"; MyChar[8] = "<u>\\'\\'</u>"; MyCharText[8] ="U"; MyChar[9] = "<big>\\'\\'</big>"; MyCharText[9] ="B"; MyChar[10] = "<small></small>"; MyCharText[10] ="S"; MyChar[11] = "<s> </s>"; MyCharText[11] ="D"; MyChar[12]= "|BEARBEITUNGSSTAND=" MyCharText[12] = "BS" MyChar[13]= "ohne Quelle" MyCharText[13] = "oQ" MyChar[14]= "unkorrigiert" MyCharText[14] = "un" MyChar[15]= "teilkorrigiert" MyCharText[15] = "teil" MyChar[16]= "korrigiert" MyCharText[16] = "kor" MyChar[17]= "fertig" MyCharText[17] = "fer" MyChar[18] = "\n----\n"; MyCharText[18] ="Line"; MyChar[19]= "{{prettytable}}" MyCharText[19] = "PT" MyChar[20] = "{{Inuse|--[[Benutzer:Joschy|Joschy]]}}
"; MyCharText[20] ="InUse"; MyChar[21] = "\n--~~~~\n"; MyCharText[21] ="Sign"; MyChar[22] = "|unkorrigiert<!-- teilkorrigiert, korrigiert, fertig -->}}\n"; MyCharText[22] = "BSV" MyChar[23]= "[[Kategorie:" MyCharEnd[23]= "]]" MyCharText[23] = "Kat" MyChar[24]= "[[Bild:" MyCharEnd[24]= "]]" MyCharText[24] = "Bild" MyChar[25]= "[[Benutzer:" MyCharEnd[25]= "]]" MyCharText[25] = "User" MyChar[26]= "<br />" MyCharText[26] = "br" MyChar[27]= " " MyCharText[27] = "nbs" {{Stub}} {{Rechtshinweis}} {{Stub}} var rechtschreibpruefung = true; // Rechtschreibprüfung aktivieren? var AutorunRP = true; // false = RP durch Anklicken; true = automatische RP //----------------- // Minimale Rechtschreibprüfung: Version 2 // Siehe Wikipedia:Helferlein/Rechtschreibprüfung // // Der Text eines Artikels (in der normalen Artikelansicht, nicht beim Bearbeiten) wird an den // Toolserver geschickt, gegen eine Wortliste geprüft und fehlerhafte Wörter werden dann im // Text rot hervorgehoben. function spellcheck() { // Anfrage an Toolserver senden var scJS = document.createElement('script'); scJS.type = 'text/javascript'; scJS.src = 'http://toolserver.org/~apper/sc/checkArticle.php?pageName=' + wgPageName; document.getElementsByTagName('head')[0].appendChild(scJS); } function markWordStart(text, hint) { if (typeof bodyContent == 'undefined' && !(bodyContent = document.getElementById('bodyContent'))) bodyContent = document.getElementById('article'); markWord(bodyContent, text, hint); } function markWord(node, text, hint) { var pos, len, newnodes = 0; var newnode, middlenode, endnode; // textnode - search for word if (node.nodeType == 3) { pos = node.data.search(text); if(pos >= 0) { // create new span-element newnode = document.createElement("span"); newnode.style.backgroundColor = "#FF9191"; newnode.title = hint; // get length of the matching part len = node.data.match(text)[0].length; // splits content in three parts: begin, middle and end middlenode = node.splitText(pos); endnode = middlenode.splitText(len); // appends a copy of the middle to the new span-node newnode.appendChild(middlenode.cloneNode(true)); // replace middlenode with the new span-node middlenode.parentNode.replaceChild(newnode, middlenode); newnodes = 1; } } else if ((node.nodeType == 1) // element node && (node.hasChildNodes()) // with child nodes && (node.tagName.toLowerCase() != "script") // no script, style and form && (node.tagName.toLowerCase() != "style") && (node.tagName.toLowerCase() != "form")) { var this_child; for (this_child = 0; this_child < node.childNodes.length; this_child++) { this_child = this_child + markWord(node.childNodes[this_child], text, hint); } } return newnodes; } function RP_load() { // Variablenabfrage, ob '''keine''' automatische RP bei jedem Aufruf eines Artikels gewünscht ist. // wenn automatische RP nicht gewünscht ist, dann einfach "'''var DontAutorunRP = true;'''" vor die Einbindung schreiben // ansonsten einfach weg lassen. if ( typeof DontAutorunRP == 'undefined' || DontAutorunRP == false ) { // Nur beim Betrachten, aber nicht auch unnötigerweise beim Bearbeiten, auf der Versionsgschichte // etc. laden: spart Wartezeit beim Benutzer und Ressourcen auf dem Toolserver // Standardmäßig RP nur auf Artikelseiten, wenn RPonAllPages "true" RP in allen Seiten if (wgAction == 'view' && (wgNamespaceNumber == 0 || (typeof RPonAllPages != 'undefined' && RPonAllPages == true))) { spellcheck(); } } } addOnloadHook( RP_load ); //----------------