User:ManuelGR/monobook.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
Warning: Malicious code can compromise your account. Page preview will cause your web browser to execute this page's content as code under some skins, including Monobook. If you have any questions about any code you plan to add, you can ask at the appropriate reading room. |
![]() |
The accompanying .css page for this skin can be added at User:ManuelGR/monobook.css. |
/**
* rechercher les éléments de la page dont le paramètre "class" est celui recherché
* http://developer.mozilla.org/en/docs/DOM:document.getElementsByClassName
*/
function getElementsByClass(searchClass,node,tag) {
if ( node == null ) node = document;
if ( tag == null ) tag = '*';
return getElementsByClassName(node, tag, searchClass);
}
/**
* Change the presentation of the page title.
*
* @todo : http://fr.wikibooks.org/wiki/Eros
* @author : DavidL, Tavernier (rewrite)
*/
function setupTitle() {
if ( (wgAction != 'view')
|| wgNamespaceNumber //only on main space (0)
|| document.getElementById('contentSub2') ) //while the page is deleted, avoiding to catch the "N revisions deleted"
return false;
var title = getElementsByClass("firstHeading")[0];
var hasInnerText = (title.innerText != undefined); //IE hack stuff
saveTitle = hasInnerText ? title.innerText : title.textContent;
var subpages = getElementsByClass("subpages");
if (subpages == "") // return if it's not a subpage
return false;
var links = subpages[0].getElementsByTagName("a");
title.innerHTML = "";
var endTitle = "";
for (var subpage=0; subpage<links.length; subpage++) {
var textContent = hasInnerText ?
links[subpage].innerText : links[subpage].textContent;
title.innerHTML += "<a href=\""
+ links[subpage].getAttribute("href")
+ "\" title=\""
+ links[subpage].getAttribute("title")
+ "\"\>"
+ textContent
+ "</a>\n<br />"
endTitle += textContent + "/";
}
endTitle = saveTitle.replace(endTitle, "");
title.innerHTML += endTitle; //a wgSubPageName should be more convenient...
subpages[0].textContent = saveTitle; // for copypaste the full title (bonus)
subpages[0].innerText = saveTitle; //hack
}
if ( typeof ( g_setuptitle ) == "undefined" )
addOnloadHook(setupTitle);