Benutzer:Stefan Majewsky/monobook.js
aus Wikipedia, der freien Enzyklopädie
Hinweis: Leere nach dem Speichern den Browser-Cache, um die Änderungen zu sehen: Mozilla/Firefox: Shift-Strg-R, Internet Explorer: Strg-F5, Opera: F5, Safari: ⌘-R (bzw. Strg-R), Konqueror: Strg-R.
/* <pre><nowiki> Top of Javascript */ //Monobook Element Modding. Techniques by Stefan Majewsky (de.wikibooks.org/wiki/Benutzer:Stefan_Majewsky) //Based on http://commons.wikimedia.org/w/index.php?title=MediaWiki:Extra-tabs.js&oldid=3001654 //Creates a new list item. function createListItem(url, name, id) { var listitem = document.createElement('li'); listitem.setAttribute('id', id); var link = document.createElement('a'); if (url!='') { link.setAttribute('href', url); } else { listitem.setAttribute('class','selected'); } link.appendChild(document.createTextNode(name)); listitem.appendChild(link); return listitem; } //Appends a new tab to the register at the top of a page. function appendTab(url, name, id) { // Grab the element we want to append the tab and append the tab to it. var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; tabs.appendChild(createListItem(url, name, id)); } //Appends the into tab near the "Edit" tab. function appendIntroTab(articlename) { // Grab the element we want to append the tab and append the tab to it. var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; tabs.insertBefore(createListItem('http://de.wikipedia.org/w/index.php?title=' + articlename + '&action=edit§ion=0', 'intro', 'ca-editintro'), tabs.getElementsByTagName('li')[3]); } //Adds supplementary links to the personal bar at the top right. function appendPLink(url, name, id) { // Insert the element before the "log out" link. var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[1].getElementsByTagName('ul')[0]; tabs.insertBefore(createListItem(url, name, id), document.getElementById('pt-logout')); } //Adds a supplementary menu at the left navigation. Returns the list where links have to be added. function appendMenu(title, id) { //initialize the single elements var basediv = document.createElement('div'); basediv.setAttribute('class','portlet'); basediv.setAttribute('id',id); var heading = document.createElement('h5'); heading.appendChild(document.createTextNode(title)); var innerdiv = document.createElement('div'); innerdiv.setAttribute('class','pBody'); var linklist = document.createElement('ul'); //ONLY FOR PERSONAL PURPOSE - change the background color of the menu innerdiv.setAttribute('style','background-color: #E2E2F9'); //build menu basediv.appendChild(heading); basediv.appendChild(innerdiv); innerdiv.appendChild(linklist); //insert in column-one after p-tb document.getElementById('column-one').insertBefore(basediv, document.getElementById('p-tb').nextSibling); return linklist; } //Adds a menu item to a menu. function addMenuItem(menu, link, text, id) { var listitem = document.createElement('li'); listitem.setAttribute('id',id); var linkitem = document.createElement('a'); linkitem.setAttribute('href',link); //build link linkitem.appendChild(document.createTextNode(text)); listitem.appendChild(linkitem); menu.appendChild(listitem); } //Adds a horizontal separator to a menu. function addMenuSep(menu) { menu.appendChild(document.createElement('hr')); } //(On special pages) Change the caption of the tab "Special page". function changeSpecialPageCaption(newname) { document.getElementById('ca-nstab-special').getElementsByTagName('a')[0].innerHTML = newname; } //Onload hook. Will be executed after the site has been loaded. function doMonobookTuningOnload() { //append tabs if(wgNamespaceNumber != -1) { //add extra tabs appendTab('http://de.wikipedia.org/wiki/Spezial:Prefixindex/' + wgPageName, 'Unterseiten', 'ca-subpage'); appendTab('http://de.wikipedia.org/wiki/Spezial:Allpages/' + wgPageName, 'Index durchsuchen', 'ca-searchindex'); appendTab('http://de.wikipedia.org/w/index.php?title=' + wgPageName + '&action=purge', 'Cache leeren', 'ca-purge'); appendIntroTab(wgPageName); } //append personal links appendPLink('http://de.wikipedia.org/wiki/Spezial:Mypage/monobook.css','CSS','pt-css'); appendPLink('http://de.wikipedia.org/wiki/Spezial:Mypage/monobook.js','JS','pt-js'); //change tab titles - adapted from [[Benutzer:PDD/changeBeschriftungen.js]] var cbiid, cbielement; var cbliste = { "ca-edit": ["A", "Edit"], "ca-history": ["A", "Historie"], "ca-unwatch": ["A", "Entobachten"] }; for (cbiid in cbliste) { if (cbielement = document.getElementById(cbiid)) { cbielement.getElementsByTagName(cbliste[cbiid][0])[0].innerHTML = cbliste[cbiid][1]; } } } //Onload control. addOnloadHook(doMonobookTuningOnload); //End of Monobook Element Modding. // [[en:User:Lupin/popups.js]] document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* Bottom of Javascript </nowiki></pre> */