Utente:John Vandenberg/monobook.js
(Reindirizzamento da Utente:Jayvdb/monobook.js)
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
/**********************
*** Automatically generate page footer from values in {{header}}
*** by [[user:GrafZahl]]
**********************/
/*
* Proposed algorithm:
* 1. find the Capitolo tables using a class.
* 2. if there are two Capitolo tables, the page already has a header and footer, and we should not add another.
* if there is only one Capitolo table, we will assume it is at the top and there is no footer
* 3. duplicate the header table and place the duplicate at the bottom.
* 4. profit.
*/
function DisplayFooter() {
if(document.getElementById && wgNamespaceNumber==0) {
nofooter = document.getElementById('nofooter');
hp = document.getElementById('headerprevious');
hn = document.getElementById('headernext');
content = document.getElementById('bodyContent');
catlinks = document.getElementById('catlinks');
footer = document.createElement('table');
//header_template = document.getElementById('headertemplate');
if( (!((content) && (footer))) || (!(hp || hn)) ||
(nofooter))
return;
footer.setAttribute('class', 'headertemplate');
footer.setAttribute('id', 'footertemplate');
footer.setAttribute('style', 'margin-top:1em; clear:both;');
/* Begin footer HTML code */
tr = document.createElement('tr');
td = document.createElement('td');
td.setAttribute('align', 'left');
td.setAttribute('width', '33%');
if (hp) {
fp = hp.cloneNode(true);
fp.setAttribute('id', 'footerprevious');
td.appendChild(fp);
}
tr.appendChild(td);
td = document.createElement('td');
td.setAttribute('align', 'center');
td.setAttribute('width', '34%');
a = document.createElement('a');
a.setAttribute('href', '#top');
text = document.createTextNode('Return to the top of the page.');
a.appendChild(text);
td.appendChild(a);
tr.appendChild(td);
td = document.createElement('td');
td.setAttribute('align', 'right');
td.setAttribute('width', '33%');
if (hn) {
fn = hn.cloneNode(true);
fn.setAttribute('id', 'footernext');
td.appendChild(fn);
}
tr.appendChild(td);
footer.appendChild(tr);
/* End footer HTML code */
if(catlinks) // place footer before category box
content.insertBefore(footer, catlinks);
else
content.appendChild(footer);
}
}
$(DisplayFooter);
// </source>
function removeOnloadHook(hookFunct) {
// Remove add-on scripts to add onload functions
var i;
for (i=0;i<onloadFuncts.length;i++)
{
if (onloadFuncts[i] == hookFunct) {
onloadFuncts[i] = function () {}
return;
}
}
}
removeOnloadHook(interwikiExtra);
function interwikiExtra2()
{
var spans = document.getElementsByTagName("span");
var a;
// iterate over all <span>-elements
for(var i=0; a = spans[i]; i++) {
// if found a linkInfo span
if(a.className == "interwiki-info") {
// iterate over all <li>-elements
var count=0;
var lis = document.getElementsByTagName("li");
for(var j=0; b = lis[j]; j++) {
if(b.className == "interwiki-" + a.id) {
b.innerHTML = b.innerHTML + " "+a.title;
if(a.title == "(orig.)") { b.title = "Testo originale"; }
}
else if(b.className == "interwiki-" + a.id.substr(0,a.id.length-1)) {
count = count+1;
if(a.id.charAt(a.id.length-1) == count) {
b.innerHTML = b.innerHTML + " "+a.title;
}
}
}
}
if(a.className == "AltraVersione") {
var p = a.title.indexOf("|");
var pvers = document.getElementById("p-version");
if (pvers == null) {
var c = document.getElementById("column-one");
c.innerHTML = c.innerHTML
+ "<div class=\"portlet\" id=\"p-version\">"
+ "<h5>Altre versioni</h5>"
+ "<div class=\"pBody\">"
+ "<ul>"
+ "</ul>"
+ "</div>";
pvers = document.getElementById("p-version");
}
var url = a.title.substr(0,p);
if (url.substring(0,3) != 'http') {
url = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace(/\$1/,url.replace(/ /g,'_') );
}
var e = pvers.getElementsByTagName("ul")[0];
e.innerHTML = e.innerHTML
+ "<li class=\"\"><a href='"
+ url
+ "'>" + a.title.substr(p+1,a.title.length-1)+ "</a> " +"</li>"
}
}
}
$(interwikiExtra2);