MediaWiki:Common.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
uniformato stile standard commenti
 
(104 versioni intermedie di 14 utenti non mostrate)
Riga 1:
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */
 
/**
* Mantenere il codice di MediaWiki:Common.js il più breve possibile, in quanto è caricato
* Redirect bad mirrors to it.wikipedia.org
* da ciascuna pagina, per tutti gli utenti che navigano sulla versione desktop.
* [[m:User:Hoo man]]
* Creare piuttosto accessori abilitati di default (gli accessori sono infatti moduli
* ottimizzati del ResourceLoader con la possibilità di aggiungere dipendenze, ecc.).
*/
/* global mediaWiki, jQuery */
( function( mw ) {
var i, isBad,
badMirrors = [
'wikipedia.sapere.alice.it',
'212.48.3.33',
'wikipedia.virgilio.it',
'213.92.16.218',
];
for( i = 0; i < badMirrors.length; i++ ) {
if ( document.___location.href.indexOf( badMirrors[ i ] ) !== -1 ) {
isBad = true;
break;
}
}
if ( isBad ) {
// redirect users to the same page on itwiki
//document.___location.href = '//it.wikipedia.org/wiki/' + mw.config.get( 'wgPageName' );
// redirect users to a landing page
document.___location.href = '//it.wikipedia.org/wiki/Wikipedia:Live_mirror';
}
} )( mediaWiki );
 
( function ( mw, $ ) {
'use strict';
 
// ============================
/**
// Caricamento script
* Collegamento diretto alla pagina di upload di Commons nel portlet Strumenti
// ============================
*/
$(function(){
mw.util.addPortletLink('p-tb', '//commons.wikimedia.org/wiki/Commons:Upload/it',
'Carica su Commons', 't-uploadcommons', 'Carica file multimediali su Wikimedia Commons', 'm', '#t-specialpages');
});
 
/**
* Ricerca in Wikidata
*/
if (
mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||
( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false )
) {
mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript' );
}
 
// ============================
/**
// Modifica HTML pagine
* Evidenzia i link agli articoli di qualità su altre wiki
// ============================
*/
function LinkAdQ()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
 
/**
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
* Aggiunge un combobox a [[MediaWiki:Edittools]] per selezionare un gruppo di caratteri speciali.
var className = InterwikiLinks[i].className.match(/interwiki-[-\w]+/);
*/
if ( document.getElementById( className + '-fa' ) && InterwikiLinks[i].className.indexOf( 'badge-featuredarticle' ) === -1 ) {
function comboboxEdittools() {
InterwikiLinks[i].className += " FA";
var $specialChars = $( '#specialchars' );
InterwikiLinks[i].title = "La voce è in vetrina in questa lingua.";
if ( $specialChars.length ) {
} else if ( document.getElementById( className + '-ga' ) && InterwikiLinks[i].className.indexOf( 'badge-goodarticle' ) === -1 ) {
var $select = $( '<select>' ).change( function () {
InterwikiLinks[i].className += " GA";
$specialChars.find( 'p' ).hide();
InterwikiLinks[i].title = "La voce è di qualità in questa lingua.";
$specialChars.find( 'option:selected' ).data().show();
}
} );
}
$specialChars.find( 'p' ).each( function () {
}
$( '<option>' ).html( $( this ).attr( 'id' ).replace( /_/g, ' ' ) )
}
.data( $( this ) ).appendTo( $select );
} );
$specialChars.prepend( $select );
$select.change();
}
}
 
$( LinkAdQcomboboxEdittools );
 
// ============================
/**
// Supporto ai template
* In "Pagina principale" aggiunge il link alla lista completa di tutte le pagine
// ============================
*/
if ( mw.config.get( 'wgIsMainPage' ) || mw.config.get( 'wgPageName' ) === "Discussione:Pagina_principale" ) {
$( function() {
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Lista_di_Wikipedie',
'Lista completa', 'interwiki-completelist', 'Lista completa delle Wikipedie' );
} );
}
 
/**
* Utilizzata con [[template:Galleria]] per creare una galleria di immagini,
* "Technical restrictions" title fix
* cerca un HTML (creato dal template) contenente:
*
* <div class="ImageGroup"><div class="ImageGroupUnits">immagini</div></div>
* Descrizionen: Codice per [[Template:Titolo errato]]
* Idea Copiato inizialmenteoriginale da [[:enfr:MediaWiki:Common.js]] del 2007.
* @author [[it:User:Rotpunkt]]
*
*/
* The function looks for a banner like this: <nowiki>
function updateImageGroup( currImg, $images, $countInfo, $prevLink, $nextLink ) {
* <div id="RealTitleBanner"> <!-- div that gets hidden -->
$images.hide().eq( currImg ).show();
* <span id="RealTitle">title</span>
$countInfo.html( '(' + ( currImg + 1 ) + '/' + $images.length + ')' );
* </div>
$prevLink.toggle( currImg !== 0 );
* </nowiki>An element with id=DisableRealTitle disables the function.
$nextLink.toggle( currImg !== $images.length - 1 );
*/
}
var disableRealTitle = 0; // users can disable this by making this true from their user script
function correctTitle() {
try {
var realTitleBanner = document.getElementById("RealTitleBanner");
if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle) {
var realTitle = document.getElementById("RealTitle");
if (realTitle) {
var realTitleHTML = realTitle.innerHTML;
var realTitleText = $(realTitle).text();
 
function initImageGroup() {
var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big|a)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
$( 'div.ImageGroup > div.ImageGroupUnits' ).each( function ( i, imageGroupUnits ) {
 
var currImg = 0;
var h1 = document.getElementsByTagName("h1")[0];
var $images = $( imageGroupUnits ).children( '.center, .mw-halign-center' );
if (h1) {
var $countInfo = $( '<kbd>' ).css( 'font-size', '110%' );
h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
var $prevLink = $( '<a>' )
 
.attr( 'href', '#' ).attr( 'title', 'Immagine precedente' )
realTitleBanner.style.display = "none";
.text( '◀' ).css( 'text-decoration', 'none' )
}
.click( function ( e ) {
document.title = realTitleText + " - Wikipedia";
e.preventDefault();
}
updateImageGroup( currImg -= 1, $images, $countInfo, $prevLink, $nextLink );
}
} );
} catch (e) {
var $nextLink = $( '<a>' )
/* Something went wrong. */
.attr( 'href', '#' ).attr( 'title', 'Immagine successiva' )
}
.text( '▶' ).css( 'text-decoration', 'none' )
}
.click( function ( e ) {
 
e.preventDefault();
$(correctTitle);
updateImageGroup( currImg += 1, $images, $countInfo, $prevLink, $nextLink );
 
} );
/**
updateImageGroup( currImg, $images, $countInfo, $prevLink, $nextLink );
* WikiMiniAtlas
$( imageGroupUnits ).prepend( $prevLink, $countInfo, $nextLink );
* WikiMiniAtlas is a popup click and drag world map.
} );
* This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
* The script itself is located on meta because it is used by many projects.
* See [[Meta:WikiMiniAtlas]] for more information.
*/
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
 
/**
* 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 scegliSubsetCaratteri(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';
}
}
 
function aggiungiMenuSubsetCaratteri() {
var specialchars = document.getElementById('specialchars');
if (specialchars) {
var menu = "<select style=\"display:inline\" onChange=\"scegliSubsetCaratteri(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 */
scegliSubsetCaratteri(0);
}
}
$(aggiungiMenuSubsetCaratteri);
 
/**
* RICERCA
*
* Cambia Speciale:Ricerca per usare un menu' a
* tendina, con come default il motore interno di MediaWiki
*
* Creato e gestito da: [[:en:User:Gracenotes]]
* Importato in it.wiki da: [[Utente:Jalo]]
*/
if (mw.config.get('wgPageName') == "Speciale:Ricerca")
$(function() {
var searchEngines = [];
var createOption = function(site, action, mainQ, addQ, addV) {
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(site));
searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
return opt;
};
var searchForm = document.forms.powersearch || document.forms.search;
var searchBox = searchForm.lsearchbox || searchForm.search;
 
var selectBox = document.createElement('select');
selectBox.id = 'searchEngine';
searchForm.onsubmit = function() {
var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex];
searchForm.action = optSelected[0];
searchBox.name = optSelected[1];
searchForm.title.value = optSelected[3];
searchForm.title.name = optSelected[2];
};
 
selectBox.appendChild(createOption('MediaWiki', mw.config.get('wgScriptPath') + '/index.php', 'search', 'title', 'Speciale:Ricerca'));
selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'sitesearch', 'it.wikipedia.org'));
selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'it.wikipedia.org'));
selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://it.wikipedia.org'));
selectBox.appendChild(createOption('Wikiwix', 'http://it.wikiwix.com/', 'action', 'lang', 'it'));
selectBox.appendChild(createOption('Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'it'));
searchBox.style.marginLeft = '0px';
// 'searchText' is the firt search text. 'powerSearchText' is the second, used only if the first is not existent (e.g.: not yet done any search)
buttonSearch = document.getElementById('searchText') || document.getElementById('powerSearchText');
 
buttonSearch.parentNode.insertBefore(selectBox, buttonSearch.nextSibling);
});
 
function hopMouseOverHandler(event) {
event.data.hopContent.style.display = "block";
}
 
function hopMouseOutHandler(event) {
event.data.hopContent.style.display = "none";
}
 
/**
* Serve per far funzionare il Cassetto2 con IE6.
*/
if (window.attachEvent && !window.XMLHttpRequest) window.attachEvent("onload", function() {
var x = mw.util.$content.get(0).getElementsByTagName("div");
for (var i=0; i<x.length; i++) {
if (x[i].className != "HopFrame") continue;
var y=x[i].getElementsByTagName("div"); var j;
for (j=0; j<y.length; j++)
if (y[j].className == "HopContent") {x[i].hopContent = y[j]; break;}
if (j<y.length) {
$(x[i]).mouseover(x[i], hopMouseOverHandler);
$(x[i]).mouseout(x[i], hopMouseOutHandler);
}
}
});
 
// BEGIN Dynamic Navigation Bars
 
 
/**
* Test if an element has a certain class.
* 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);
};
})();
 
/**
* Collapsible tables
* Taken from //en.wikipedia.org/wiki/MediaWiki:Common.js
* Allows tables to be collapsed, showing only the header. See Wikipedia:NavFrame.
* Maintainers: User:R. Koot
*/
 
var autoCollapse = 2;
var collapseCaption = "nascondi";
var expandCaption = "mostra";
 
function collapseTable( tableIndex )
{
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
var i;
 
if ( !Table || !Button ) {
return false;
}
 
var Rows = Table.getElementsByTagName( "tr" );
 
if ( Button.firstChild.data == collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
 
function buttonLinkClickHandler(event) {
event.preventDefault();
collapseTable(event.data);
}
 
function createCollapseButtons()
{
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( "table" );
var i;
 
for ( 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 = "7em";
 
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
$(ButtonLink).attr('href', '#').click(tableIndex, buttonLinkClickHandler);
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++;
}
}
}
 
var cTables = tableIndex + $('table.navbox.mw-collapsible').length;
for ( i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( cTables >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTable( i );
}
}
}
 
$( createCollapseButtons );
 
/**
* HIDDENCAT (mostra le categorie nascoste). Copiato da fr.wiki.
*/
 
//@ deprecated
function addClass(node, className) {
if (hasClass(node, className)) {
return false;
}
node.className += ' '+ className;
return true;
}
 
function eregReplace(search, replace, subject) {
return subject.replace(new RegExp(search,'g'), replace);
}
 
//@ deprecated
function removeClass(node, className) {
if (!hasClass(node, className)) {
return false;
}
node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
return true;
}
 
function hiddencat()
{
var cl = document.getElementById('catlinks'); if(!cl) return;
var hc = document.getElementById('mw-hidden-catlinks'); if(!hc) return;
var nc = document.getElementById('mw-normal-catlinks');
var ahc;
if(!nc)
{
removeClass(cl, 'catlinks-allhidden');
addClass(cl, 'catlinks-allhidden-mostra');
ahc = '<div id="mw-normal-catlinks"><a href="/wiki/Categoria:Categorie" title="Categoria:Categorie">Categorie</a>&nbsp;:&#32;<span dir="ltr"><a onclick="javascript:toggleHiddenCats();" id="mw-hidden-cats-link" style="cursor:pointer; color:#002BB8;" title="Questa voce contiene categorie nascoste">[altre]</a></span></div>';
document.getElementById('catlinks').innerHTML = ahc + cl.innerHTML;
}
else if( hasClass(hc, 'mw-hidden-cats-hidden') )
{
ahc = ' | <a onclick="javascript:toggleHiddenCats();" id="mw-hidden-cats-link" style="cursor:pointer; color:#002BB8;" title="Questa voce contiene categorie nascoste">[altre]</a>';
document.getElementById('mw-normal-catlinks').innerHTML += ahc;
}
}
function toggleHiddenCats()
{
var hc = document.getElementById('mw-hidden-catlinks');
if( hasClass(hc, 'mw-hidden-cats-hidden') )
{
removeClass(hc, 'mw-hidden-cats-hidden');
addClass(hc, 'mw-hidden-cat-user-shown');
 
//L'elemento <span /> crea problemi a HotCat
document.getElementById('mw-hidden-cats-link').innerHTML = '[nascondi]';
//document.getElementById('mw-hidden-cats-link').innerHTML = '[<span style="font-style:italic;">nascondi</span>]';
}
else
{
removeClass(hc, 'mw-hidden-cat-user-shown');
addClass(hc, 'mw-hidden-cats-hidden');
 
//Vedi commento sopra
document.getElementById('mw-hidden-cats-link').innerHTML = '[altre]';
//document.getElementById('mw-hidden-cats-link').innerHTML = '[<span style="font-style:italic;">altre</span>]';
}
}
$(hiddencat);
 
/**
* Layout pagina di modifica
*/
$( function ()
{
if (mw.config.get('wgAction') == "edit")
{
/* Allarga l'edittools a tutta pagina */
$('#Standard').css( 'width', '100%' );
}
});
 
/**
* Avvisa quando si tenta di creare una voce con titolo non valido ("Scrivi qui il titolo")
*/
$ ( function ()
{
if (mw.config.get('wgTitle') == "Scrivi qui il titolo" && mw.config.get('wgAction') == "edit")
{
dopoDi = document.getElementById("contentSub");
if (!dopoDi) return;
var daInserire = document.createElement('div');
daInserire.innerHTML = "<b>Stai creando una voce senza specificarne un titolo valido. Per favore, torna indietro e inserisci un titolo valido.</b>";
daInserire.className = "toccolours itwiki_template_avviso rad";
daInserire.style.marginBottom = "0.5em";
daInserire.style.background = "#FC9";
daInserire.style.borderColor = "red";
daInserire.style.textAlign = "center";
daInserire.style.fontSize = "120%";
dopoDi.parentNode.insertBefore(daInserire, dopoDi.nextSibling);
}
});
 
/**
* Avvisa quando si tenta di creare una discussione al bar con titolo non valido ("Scrivi qui il titolo")
*/
$ ( function ()
{
if (mw.config.get('wgTitle') == "Wikipedia:Bar/Discussioni/SCRIVI QUI SOLO IL TITOLO" && mw.config.get('wgAction') == "edit")
{
dopoDi = document.getElementById("contentSub");
if (!dopoDi) return;
var daInserire = document.createElement('div');
daInserire.innerHTML = "<b>Stai creando una discussione del bar senza specificarne un titolo valido. Per favore, torna indietro e inserisci un titolo valido.</b>";
daInserire.className = "toccolours itwiki_template_avviso rad";
daInserire.style.marginBottom = "0.5em";
daInserire.style.background = "#FC9";
daInserire.style.borderColor = "red";
daInserire.style.textAlign = "center";
daInserire.style.fontSize = "120%";
dopoDi.parentNode.insertBefore(daInserire, dopoDi.nextSibling);
}
});
 
/**
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @rev 5
*/
var extraJS = mw.util.getParamValue( 'withJS' );
if ( extraJS ) {
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
importScript( extraJS );
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
}
}
 
$( initImageGroup );
/**
* 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 leftlinkClickHandler(event) {
event.preventDefault();
toggleImage(event.data.i, event.data.j, event.data.j - 1);
}
 
function rightlinkClickHandler(event) {
event.preventDefault();
toggleImage(event.data.i, event.data.j, event.data.j + 1);
}
 
/**
function ImageGroup(){
* Utilizzata con [[Template:Navbox]]: se presente più di un navbox con
if (document.___URL.match(/printable/g)) return;
* classe mw-collapsible, quelli con autocollapse si chiudono da soli.
var bc=mw.util.$content.get(0);
*/
var divs=bc.getElementsByTagName("div");
function checkAutocollapse( $content ) {
var i = 0, j = 0;
var $navbox = $content.filter( '.navbox' );
var units, search;
if ( $navbox.length > 1 ) {
var currentimage;
$navbox.filter( '.autocollapse' ).find( '.mw-collapsible-toggle' ).click();
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).attr('href', '#').click({ i: i, j: j }, leftlinkClickHandler);
leftlink.innerHTML="◀";
} else {
leftlink = document.createElement("span");
leftlink.innerHTML="&nbsp;";
}
if (j != units.length - 1) {
rightlink = document.createElement("a");
$(rightlink).attr('href', '#').click({ i: i, j: j }, rightlinkClickHandler);
rightlink.innerHTML="▶";
} else {
rightlink = document.createElement("span");
rightlink.innerHTML="&nbsp;";
}
var comment = document.createElement("tt");
comment.innerHTML = "("+ (j+1) + "/" + units.length + ")";
imghead.style.fontSize="110%";
imghead.style.fontweight="bold";
imghead.appendChild(leftlink);
imghead.appendChild(comment);
imghead.appendChild(rightlink);
currentimage.insertBefore(imghead,currentimage.childNodes[0]);
if (j !== 0) currentimage.style.display="none";
}
}
}
$(ImageGroup);
 
mw.hook( 'wikipage.collapsibleContent' ).add( checkAutocollapse );
/**
}( mediaWiki, jQuery ) );
* Toglie "Soggetto/Intestazione" nelle creazioni delle discussioni al Bar
*/
if (mw.config.get('wgNamespaceNumber') == 4 &&
mw.config.get('wgPageName').indexOf("Wikipedia:Bar/") === 0 &&
mw.config.get('wgAction') == "edit" &&
document.___URL.indexOf("&section=new&preload=") != -1)
$( function ()
{
document.getElementById('wpSummaryLabel').style.display="none";
document.getElementById('wpSummary').style.display="none";
});
 
 
/**
* Cambia posizione e link del link "modifica" delle sezioni
* Fatto in Common.css, questo è un fix per IE7
*/
if ($.client.profile().name == 'msie' && $.client.profile().versionNumber < 8)
$(function(){
$('.editsection').each(function(i, e){$(e).parent().append(e)});
});
 
/**
* OpenStreetMap nel template Coord
* Verwendung von OpenStreetMap in Wikipedia.
* (c) 2008 by Magnus Manske
* Released under GPL
* Modified version in order to makes it work with moveCoord() above
* From fr:mediawiki:common.js
* modified to makes it work for IT : Otourly
*/
if ( typeof MoveResizeAbsolute_AddMoveArea !== 'function' ) {
mw.loader.load( '//it.wikipedia.org/w/index.php?title=MediaWiki:Gadget-MoveResizeAbsolute.js&action=raw&ctype=text/javascript' );
}
function openStreetMap_Init () {
var c = document.getElementById ( 'coordinates' ) ;
if ( !c ) return ;
var a = c.getElementsByTagName ( 'a' ) ;
var geohack = false;
for ( var i = 0 ; i < a.length ; i++ ) {
var h = a[i].href ;
if ( !h.match(/geohack/) ) continue ;
// evita i link per gli altri pianeti; altrimenti appare erroneamente la Terra
if ( h.match(/globe:/) && !h.match(/globe:earth/) ) continue ;
geohack = true ;
break ;
}
if ( !geohack ) return ;
var na = document.createElement ( 'a' ) ;
$( na ).attr( 'href', '#' ).click(function ( event ) {
event.preventDefault();
openStreetMap_Toggle();
});
na.title = 'Mostrare / nascondere la mappa' ;
na.appendChild ( document.createTextNode ( 'Mappa' ) ) ;
c.appendChild ( document.createTextNode ( ' (' ) ) ;
c.appendChild ( na ) ;
c.appendChild ( document.createTextNode ( ') ' ) ) ;
}
function openStreetMap_Toggle () {
var c = document.getElementById ( 'coordinates' ) ;
if ( !c) return ;
var osm = document.getElementById ( 'OpenStreetMap' ) ;
if (osm) {
if ( osm.style.display == 'none' ) {
osm.style.display = 'block' ;
} else {
osm.style.display = 'none' ;
}
return;
}
var found_link = false ;
var a = c.getElementsByTagName ( 'a' ) ;
var h;
for ( var i = 0 ; i < a.length ; i++ ) {
h = a[i].href ;
if ( !h.match(/geohack/) ) continue ;
found_link = true ;
break ;
}
if ( !found_link ) return ; // No geohack link found
h = h.split('params=')[1] ;
var LarghezzaSchermo = MoveResizeAbsolute_GetScreenWidth();
var AlterigiaSchermo = MoveResizeAbsolute_GetScreenHeight();
var OSMDiv = document.createElement('div');
OSMDiv.id = 'OpenStreetMap' ;
OSMDiv.style.position = "absolute";
OSMDiv.style.zIndex = 5000;
OSMDiv.style.top = (AlterigiaSchermo*10/100) + "px";
OSMDiv.style.left = (LarghezzaSchermo*15/100) + "px";
OSMDiv.style.width = "70%";
OSMDiv.style.height = (AlterigiaSchermo*80/100) + "px";
OSMDiv.style.border = "2px solid black";
OSMDiv.style.backgroundColor = "white";
OSMDiv.style.overflow = "hidden";
var MoveArea = document.createElement('div');
MoveArea.style.position = "relative";
MoveArea.style.top = "0";
MoveArea.style.width = "100%";
MoveArea.style.height = "50px";
MoveArea.title = "Clicca e trascina per ridimensionare la mappa";
var CloseLink = document.createElement('a');
CloseLink.setAttribute("style", "float:right;margin:10px;");
CloseLink.innerHTML = "Nascondere";
CloseLink.title = "Clicca per nascondere";
$( CloseLink ).attr( 'href', '#' ).click(function ( event ) {
event.preventDefault();
openStreetMap_Toggle();
});
MoveArea.appendChild(CloseLink);
var iFrame = document.createElement ( 'iframe' ) ;
var url = '//toolserver.org/~kolossos/openlayers/kml-on-ol.php?' + 'lang=' + mw.config.get('wgUserLanguage') + '&params=' + h + '&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgTitle' ) ) + ( window.___location.protocol == 'https:' ? '&secure=1' : '' ) ;
iFrame.style.width = '100%' ;
iFrame.style.height = ((AlterigiaSchermo*80/100)-100) + 'px' ;
iFrame.style.clear = 'both' ;
iFrame.src = url ;
var ResizeArea = document.createElement('div');
ResizeArea.style.position = "relative";
ResizeArea.style.top = "0";
ResizeArea.style.width = "100%";
ResizeArea.style.height = "50px";
ResizeArea.title = "Clicca e trascina per ridimensionare la mappa";
OSMDiv.appendChild(MoveArea);
OSMDiv.appendChild(iFrame);
OSMDiv.appendChild(ResizeArea);
document.body.appendChild ( OSMDiv ) ;
var ElementsToMove = new Array(OSMDiv);
var ElementsToResize = new Array(OSMDiv, iFrame);
var ElementsMinWidth = new Array(150, 150);
var ElementsMinHeights = new Array(200, 100);
MoveResizeAbsolute_AddMoveArea(MoveArea, ElementsToMove);
MoveResizeAbsolute_AddResizeArea(ResizeArea, ElementsToResize, ElementsMinWidth, ElementsMinHeights);
}
$(openStreetMap_Init);
 
/**
* Classe autocollapse con mw-collapsible: se presente più di una table con classe mw-collapsible o collapsible,
* quelle con anche la classe autocollapse si chiudono da sole. Deve essere presente anche la classe navbox.
*/
$(function () {
if ($('table.navbox.mw-collapsible').length + $('table.navbox.collapsible').length > 1) {
$('table.navbox.mw-collapsible.autocollapse').each(function (i, el) {
if (!$(el).hasClass('mw-collapsed')) {
// makeCollapsible a volte è eseguita prima, a volte successivamente al Common.js,
// se è già stata eseguita, non resta che simulare un click.
if ($(el).data('mw-made-collapsible')) {
// hide() chiude la tabella più velocemente di fadeOut
$(el).find('tr:not(:first)').hide();
$(el).find('.mw-collapsible-toggle > a').click();
} else {
$(el).addClass('mw-collapsed');
}
}
});
}
});
 
/**
* Reference tooltips
*/
mw.loader.load( '//it.wikipedia.org/w/index.php?title=Wikipedia:Monobook.js/ReferenceTooltip.js&action=raw&ctype=text/javascript' );
 
/**
* Esempio di diff in Aiuto:Diff
*/
if ( mw.config.get( 'wgPageName' ) === 'Aiuto:Diff' ) {
mw.loader.load( 'mediawiki.action.history.diff' );
}
 
/**
* Ricerca in Wikidata
*/
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||
( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript' );
}
 
/**
* Menu interprogetto nella sidebar, vedi anche [[Modulo:Interprogetto]]
*/
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:InterProject.js&action=raw&ctype=text/javascript' );