MediaWiki:Monobook.js
Vide Bbuene - Apprisse 'a pubblecazione, tu puè zumbà 'a cache d'u browser tune pe vedè le cangiaminde.
- Firefox / Safari: cazze 'u Shift e condemboraneamende cazze 'u buttone Aggiorne, o cazze 'nzieme Ctrl-F5 o Ctrl-R (⌘-R sus a 'nu Mac);
- Google Chrome: cazze Ctrl-Shift-R (⌘-Shift-R sus a 'nu Mac)
- Internet Explorer / Edge: cazze Ctrl e condemboraneamende cazze Aggiorne o cazze Ctrl-F5.
- Opera: Cazze Ctrl-F5.
/* <pre> */
/*** Collegamento diretto alla pagina di upload di Commons nel menu di sinistra, da WP:PT */
function linkUploadToCommons()
{
if (document.getElementById("carrega-para-commons")) return;
var li_carrega = document.getElementById("t-upload");
if (!li_carrega) return;
var afegit = li_carrega.nextSibling;
var ul_eines = li_carrega.parentNode;
var li = document.createElement("li");
li.id = "carrega-para-commons";
li.innerHTML = '<a href="//commons.wikimedia.org/wiki/Special:Upload">Careche sus a Commons</a>';
if (afegit) ul_eines.insertBefore(li, afegit);
else ul_eines.appendChild(li);
}
$(linkUploadToCommons);
/*** Fine del collegamento diretto alla pagina di upload di Commons */
function LinkAdQ()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
InterwikiLinks[i].className += " FA"
InterwikiLinks[i].title = "La voce è in vetrina in questa lingua.";
}
}
}
}
$( LinkAdQ );
function LinkFA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
InterwikiLinks[i].className += " FA"
InterwikiLinks[i].title = "This is a featured article in another language.";
}
}
}
}
$( LinkFA );
// BEGIN Dynamic Navigation Bars
/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: User:Mike Dillon, User:R. Koot, User:SG
*/
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
// set up the words in your language
var NavigationBarHide = '▲ Scunne';
var NavigationBarShow = '▼ Spanne';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
// JTR - Se sono sulla pagina principale non voglio mai vederla
if ((mw.config.get('wgTitle') == 'Pagene Prengepále')|| (mw.config.get('wgTitle') == "Wikipedia:Prove")) return false;
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (hasClass(NavChild, 'NavPic')) {
NavChild.style.display = 'none';
}
if (hasClass(NavChild, 'NavContent')) {
NavChild.style.display = 'none';
}
if (hasClass(NavChild, 'NavToggle')) {
NavChild.firstChild.data = NavigationBarShow;
}
}
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (hasClass(NavChild, 'NavPic')) {
NavChild.style.display = 'block';
}
if (hasClass(NavChild, 'NavContent')) {
NavChild.style.display = 'block';
}
if (hasClass(NavChild, 'NavToggle')) {
NavChild.firstChild.data = NavigationBarHide;
}
}
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all < div >-elements
for(
var i=0;
NavFrame = document.getElementsByTagName("div")[i];
i++
) {
// if found a navigation bar
if (hasClass(NavFrame, 'NavFrame')) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in < div class="NavFrame" >
NavFrame.insertBefore(
NavToggle,
NavFrame.firstChild
);
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBar(i);
}
}
}
$(createNavigationBarToggleButton);
// END Dynamic Navigation Bars
/** Collapsible tables *********************************************************
*
* Taken from //en.wikipedia.org/wiki/MediaWiki:Common.js
* Description: Allows tables to be collapsed, showing only the header. See
* Wikipedia:NavFrame.
* Maintainers: User:R. Koot
*/
var autoCollapse = 2;
var collapseCaption = "scunne";
var expandCaption = "spanne";
function collapseTable( tableIndex )
{
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.getElementsByTagName( "tr" );
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
function createCollapseButtons()
{
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], "collapsible" ) ) {
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
var Button = document.createElement( "span" );
var ButtonLink = document.createElement( "a" );
var ButtonText = document.createTextNode( collapseCaption );
Button.style.styleFloat = "right";
Button.style.cssFloat = "right";
Button.style.fontWeight = "normal";
Button.style.textAlign = "right";
Button.style.width = "6em";
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( "[" ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( "]" ) );
var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
/* only add button and increment count if there is a header row to work with */
if (Header) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTable( i );
}
}
}
$( createCollapseButtons );
//END Collapsible tables
//============================================================
// Menu caratteri speciali
//============================================================
/**
* Aggiunge il menu a tendina per selezionare un sottoinsieme di caratteri speciali
* Attenzione: l'ordine della lista deve corrispondere a quello di MediaWiki:Edittools !
*/
function addCharSubsetMenu() {
var specialchars = document.getElementById('specialchars');
if (specialchars) {
var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
menu += "<option>Latino esteso</option>";
menu += "<option>Wiki</option>";
menu += "<option>Greco antico</option>";
menu += "<option>Greco moderno</option>";
menu += "<option>Cirillico</option>";
menu += "<option>Arabo</option>";
menu += "<option>Ebraico e yiddish</option>";
menu += "<option>Armeno</option>";
menu += "<option>Geroglifico</option>";
menu += "<option>Vietnamita</option>";
menu += "<option>IPA</option>";
menu += "<option>Matematica</option>";
menu += "</select>";
specialchars.innerHTML = menu + specialchars.innerHTML;
/* default subset - try to use a cookie some day */
chooseCharSubset(0);
}
}
/* select subsection of special characters */
function chooseCharSubset(s) {
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = i == s ? 'inline' : 'none';
l[i].style.visibility = i == s ? 'visible' : 'hidden';
}
}
$(addCharSubsetMenu);
// END Menu caratteri speciali
// INIZIO Collegamenti Interprogetto (codice adattato da de:wikt:Mediawiki:monobook.js)
mw.util.addCSS('#interProject {display: none; speak: none;} #p-tb .pBody {padding-right: 0;}');
function iProject() {
if (document.getElementById("interProject")) {
var iProject = document.getElementById("interProject").innerHTML;
var interProject = document.createElement("div");
interProject.style.marginTop = "0.7em";
interProject.innerHTML = '<h5>altri progetti<\/h5><div class="pBody">'+iProject+'<\/div>';
document.getElementById("p-tb").appendChild(interProject);
}
}
hookEvent("load", iProject);
// FINE Collegamenti Interprogetto
var mpTitle = "Pagina principale";
var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
if (isMainPage && !isDiff)
{
mw.util.addCSS('#lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; }');
}
/** "Technical restrictions" title fix *****************************************
*
* Description:
* Maintainers: [[User:Interiot]], [[User:Mets501]]
* copiato da [[:en:MediaWiki:Common.js]]
*/
// For pages that have something like Template:Lowercase, replace the title, but only if it is cut-and-pasteable as a valid wikilink.
// (for instance [[iPod]]'s title is updated. <nowiki>But [[C#]] is not an equivalent wikilink, so [[C Sharp]] doesn't have its main title changed)</nowiki>
//
// The function looks for a banner like this: <nowiki>
// <div id="RealTitleBanner"> <!-- div that gets hidden -->
// <span id="RealTitle">title</span>
// </div>
// </nowiki>An element with id=DisableRealTitle disables the function.
var disableRealTitle = 0; // users can disable this by making this true from their monobook.js
$(function() {
try {
var realTitleBanner = document.getElementById("RealTitleBanner");
if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle) {
var realTitle = document.getElementById("RealTitle");
if (realTitle) {
var realTitleHTML = realTitle.innerHTML;
realTitleText = pickUpText(realTitle);
var isPasteable = 0;
//var containsHTML = /</.test(realTitleHTML); // contains ANY HTML
var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big|a)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
// in più, aggiunto ''a'' per mantenere funzionanti alcuni usi del vecchio Titolo errato - non è detto però che sia sempre voluto
// questo codice era in en.wiki, e se ho ben capito serviva per controllare che il nome nuovo fosse abbastanza simile all'originale, ma non è quello che vogliamo su it.wiki
// // calculate whether the title is pasteable
// var verifyTitle = realTitleText.replace(/^ +/, ""); // trim left spaces
// verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
// questo codice era in en.wiki, e aggiunge il prefisso del namespace se non presente, ma su it.wiki ci si aspetta che ciò non avvenga
// // if the namespace prefix is there, remove it on our verification copy. If it isn't there, add it to the original realValue copy.
// if (mw.config.get('wgNamespaceNumber') != 0) {
// if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") {
// verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1);
// } else {
// realTitleText = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleText;
// realTitleHTML = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleHTML;
// }
// }
// come sopra, faceva controlli sul titolo
// // verify whether mw.config.get('wgTitle') matches
// verifyTitle = verifyTitle.replace(/^ +/, "").replace(/ +$/, ""); // trim left and right spaces
// verifyTitle = verifyTitle.replace(/_/g, " "); // underscores to spaces
// verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
// isPasteable = (verifyTitle == mw.config.get('wgTitle'));
var h1 = document.getElementsByTagName("h1")[0];
if (h1) { // tolto il controllo isPasteable
h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
// if (!containsTooMuchHTML) // ancora, adattamento per it.wiki
realTitleBanner.style.display = "none";
}
document.title = realTitleText + " - Uicchipèdie";
}
}
} catch (e) {
/* Something went wrong. */
}
});
// similar to innerHTML, but only returns the text portions of the insides, excludes HTML
function pickUpText(aParentElement) {
var str = "";
function pickUpTextInternal(aElement) {
var child = aElement.firstChild;
while (child) {
if (child.nodeType == 1) // ELEMENT_NODE
pickUpTextInternal(child);
else if (child.nodeType == 3) // TEXT_NODE
str += child.nodeValue;
child = child.nextSibling;
}
}
pickUpTextInternal(aParentElement);
return str;
}
/** Fix al layout della Pagina principale *********************************************************
*
* Descrizione: Alcuni al layout, fra cui un link alla lista completa di tutte
* le wikipedia in tutte le lingue disponibili.
* Da un codice di: [[en:User:AzaToth]], [[en:User:R. Koot]]
* Sistemato da: [[n:Utente:Tooby]] <--- liberi di giustiziarlo
*/
function mainPageRenameNamespaceTab() {
try {
var Node = document.getElementById( 'ca-nstab-main' ).firstChild;
if ( Node.textContent ) { // Per DOM Level 3
Node.textContent = 'Pagina principale';
} else if ( Node.innerText ) { // IE doesn't handle .textContent
Node.innerText = 'Pagina principale';
} else { // Fallback
Node.replaceChild( Node.firstChild, document.createTextNode( 'Pagina principale' ) );
}
} catch(e) {
// bailing out!
}
}
function mainPageAppendCompleteListLink() {
try {
var node = document.getElementById( "p-lang" )
.getElementsByTagName('div')[0]
.getElementsByTagName('ul')[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( 'Lista completa' ) );
aNode.setAttribute( 'href' , '//meta.wikimedia.org/wiki/List_of_Wikipedias' );
liNode.appendChild( aNode );
liNode.className = 'interwiki-completelist';
node.appendChild( liNode );
} catch(e) {
// lets just ignore what's happened
return;
}
}
if ( mw.config.get('wgTitle') == 'Pagene Prengepále' && ( mw.config.get('wgNamespaceNumber') == 0 || mw.config.get('wgNamespaceNumber') == 1 ) ) {
$( mainPageRenameNamespaceTab );
}
if ( mw.config.get('wgTitle') == 'Pagina principale' && mw.config.get('wgNamespaceNumber') == 0 ) {
$( mainPageAppendCompleteListLink );
}
mw.loader.load('//it.wikipedia.org/w/index.php?title=Wikipedia:Proposte di trasferimento/transferlist.js&action=raw&ctype=text/javascript');
function show_transfertext()
{
setup_transferlist();
i = 0;
for(i = 0; i <= transferlist.length; i+=4)
{
if (document.title == 'Cangiamende de ' + transferlist[i] + ' - Uicchipèdie' || document.title == transferlist[i] + ' - Uicchipèdie')
{
var itm = document.getElementById('BoxTrasferimento');
if (itm == null) return;
txt = itm.innerHTML;
if (transferlist[i+1] == 'b' || transferlist[i+1] == 'wb')
transferlist[i+1] = '//it.wikibooks.org/wiki/';
if (transferlist[i+1] == 's' || transferlist[i+1] == 'ws')
transferlist[i+1] = '//it.wikisource.org/wiki/';
if (transferlist[i+1] == 'q' || transferlist[i+1] == 'wq')
transferlist[i+1] = '//it.wikiquote.org/wiki/';
if (transferlist[i+1] == 'n' || transferlist[i+1] == 'wn')
transferlist[i+1] = '//it.wikisource.org/wiki/';
if (transferlist[i+1] == 'wikt')
transferlist[i+1] = '//it.wiktionary.org/wiki/';
if (transferlist[i+1] == 'wikispecies' || transferlist[i+1] == 'wsp')
transferlist[i+1] = '//species.wikimedia.org/wiki/';
if (transferlist[i+1] == 'm' || transferlist[i+1] == 'meta')
transferlist[i+1] = '//meta.wikimedia.org/wiki/';
if (transferlist[i+1] == 'commons' || transferlist[i+1] == 'com')
transferlist[i+1] = '//commons.wikimedia.org/wiki/';
if (transferlist[i+3] == "")
transferlist[i+3] = transferlist[i];
txt = '<div class="AvvisoTrasferito">Una vecchia versione di questa pagina è stata <b>trasferita</b> <a href=' + transferlist[i+1] + transferlist[i+3].replace(/ /g, '_') + '>all\'interno di un altro progetto Wikimedia</a> perché: <i>' + transferlist[i+2] + '</i>. Se ritieni la voce enciclopedica puoi riscriverla, controllando che siano stati eliminati i motivi che ne hanno comportato la cancellazione.</div>' + txt;
itm.innerHTML = txt;
break;
}
}
}
$(show_transfertext);
/**
* WikiMiniAtlas is a popup click and drag world map.
* See [[meta:WikiMiniAtlas]] for more information.
* Maintainers: [[w:User:Dschwen]]
*/
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript');
/*
Correzione della posizione del link [modifica] delle sezioni.
Copyright 2006, Marc Mongenet
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See http://www.gnu.org/licenses/gpl.html
The function looks for <span class="editsection">, and move them
at the end of their parent and display them inline in small font.
var oldEditsectionLinks=true disables the function.
*/
setModifySectionStyle = function()
{
try {
if (!(typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false)) return;
var spans = document.getElementsByTagName("span");
for (var s = 0; s < spans.length; ++s) {
var span = spans[s];
if (span.className == "editsection") {
span.style.fontSize = "x-small";
span.style.fontWeight = "normal";
span.style.cssFloat = span.style.styleFloat = "none";
span.parentNode.appendChild(document.createTextNode(" "));
span.parentNode.appendChild(span);
}
}
} catch (e) { /* something went wrong */ }
}
$(setModifySectionStyle);
/* </pre> */
/*** CODICE PER IL TEMPLATE:GALLERIA ***/
function toggleImage(group, remindex, shwindex) {
document.getElementById("ImageGroupsGr"+group+"Im"+remindex).style.display="none";
document.getElementById("ImageGroupsGr"+group+"Im"+shwindex).style.display="inline";
}
function ImageGroup(){
if (document.URL.match(/printable/g)) return;
var bc=document.getElementById("bodyContent");
var divs=bc.getElementsByTagName("div");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length ; i++) {
if (divs[i].className != "ImageGroup") continue;
UnitNode=undefined;
search=divs[i].getElementsByTagName("div");
for (j = 0; j < search.length ; j++) {
if (search[j].className != "ImageGroupUnits") continue;
UnitNode=search[j];
break;
}
if (UnitNode==undefined) continue;
units=Array();
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (temp.className=="center") units.push(temp);
}
for (j = 0 ; j < units.length ; j++) {
currentimage=units[j];
currentimage.id="ImageGroupsGr"+i+"Im"+j;
var imghead = document.createElement("div");
var leftlink;
var rightlink;
if (j != 0) {
leftlink = document.createElement("a");
leftlink.href = "javascript:toggleImage("+i+","+j+","+(j-1)+");";
leftlink.innerHTML="◀";
} else {
leftlink = document.createElement("span");
leftlink.innerHTML=" ";
}
if (j != units.length - 1) {
rightlink = document.createElement("a");
rightlink.href = "javascript:toggleImage("+i+","+j+","+(j+1)+");";
rightlink.innerHTML="▶";
} else {
rightlink = document.createElement("span");
rightlink.innerHTML=" ";
}
var comment = document.createElement("tt");
comment.innerHTML = "("+ (j+1) + "/" + units.length + ")";
with(imghead) {
style.fontSize="110%";
style.fontweight="bold";
appendChild(leftlink);
appendChild(comment);
appendChild(rightlink);
}
currentimage.insertBefore(imghead,currentimage.childNodes[0]);
if (j != 0) currentimage.style.display="none";
}
}
}
$(ImageGroup);