MediaWiki:Common.js: differenze tra le versioni

Da The Crowdsourced Resource-Based Economy Knowledgebase.
m (una revisione importata)
 
(Una revisione intermedia di un utente non mostrate)
Riga 1: Riga 1:
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */
+
/**
 
+
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
/* Serve per "sabotare" www.wikipedia.it e tutti gli altri siti che ci includono in frame. "Salta fuori" dai frame.
+
* loaded for all users on every wiki page. If possible create a gadget that is
    Va alla pagina del toolserver il cui contenuto è preso dalla pagina [[Utente:Pietrodn/www.wikipedia.it]], modificabile solo dagli admin.
+
* enabled by default instead of adding it here (since gadgets are fully
    Poi reindirizza a http://it.wikipedia.org */
+
* optimized ResourceLoader modules with possibility to add dependencies etc.)
if (mw.config.get('wgIsMainPage') && top != self)
+
*
    top.location.replace('http://toolserver.org/~pietrodn/wikipedia_redirect.php');
+
* Since Common.js isn't a gadget, there is no place to declare its
 
+
* dependencies, so we have to lazy load them with mw.loader.using on demand and
/*
+
* then execute the rest in the callback. In most cases these dependencies will
  * Redirect bad mirrors to it.wikipedia.org
+
  * be loaded (or loading) already and the callback will not be delayed. In case a
  * [[m:User:Hoo man]]
+
  * dependency hasn't arrived yet it'll make sure those are loaded before this.
 
  */
 
  */
( function( mw ) {
+
/*global mw, $, importStylesheet, importScript */
var i, isBad,
+
/*jshint curly:false eqnull:true, strict:false, browser:true, */
badMirrors = [
+
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
'wikipedia.sapere.alice.it',
+
/* Begin of mw.loader.using callback */
'wikipedia.deejay.it',
+
'wikipedia.kataweb.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/FooBar';
+
*/
+
}
+
} )( mediaWiki );
+
  
//DEPRECATO
+
/**
function addLoadEvent(func)
+
* Main Page layout fixes
{
+
*
  if (window.addEventListener)  
+
* Description: Adds an additional link to the complete list of languages available.
    window.addEventListener("load", func, false);
+
* Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
  else if (window.attachEvent)  
+
*/
    window.attachEvent("onload", func);
+
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
 +
    $( document ).ready( function () {
 +
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
 +
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
 +
    } );
 
}
 
}
  
 
+
/**
/*** Collegamento diretto alla pagina di upload di Commons nel portlet Strumenti */
+
* Redirect User:Name/skin.js and skin.css to the current skin's pages
$(function(){
+
* (unless the 'skin' page really exists)
    mw.util.addPortletLink('p-tb', '//commons.wikimedia.org/wiki/Commons:Upload/it',
+
* @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
              'Carica su Commons', 't-uploadcommons', 'Carica file multimediali su Wikimedia Commons', 'm', '#t-specialpages');
+
* @rev: 2
});
+
*/
 
+
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
 
+
    var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
/*** Evidenzia i link agli articoli di qualità su altre wiki */
+
    /* Make sure there was a part before and after the slash
function LinkAdQ()
+
      and that the latter is 'skin.js' or 'skin.css' */
{
+
     if ( titleParts.length == 2 ) {
     if ( document.getElementById( "p-lang" ) ) {
+
         var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
         var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
+
         if ( titleParts.slice( -1 ) == 'skin.js' ) {
 
+
            window.location.href = mw.util.wikiGetlink( userSkinPage + '.js' );
         for ( var i = 0; i < InterwikiLinks.length; i++ ) {
+
        } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
            if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
+
            window.location.href = mw.util.wikiGetlink( userSkinPage + '.css' );
                InterwikiLinks[i].className += " FA";
+
                InterwikiLinks[i].title = "La voce è in vetrina in questa lingua.";
+
} else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
+
                InterwikiLinks[i].className += " GA"
+
                InterwikiLinks[i].title = "La voce è di qualità in questa lingua.";
+
            }
+
 
         }
 
         }
 
     }
 
     }
 
}
 
}
  
$( LinkAdQ );
+
/**
 +
* Map addPortletLink to mw.util
 +
*
 +
* @deprecated: Use mw.util.addPortletLink instead.
 +
*/
 +
window.addPortletLink = function () {
 +
    return mw.util.addPortletLink.apply( mw.util, arguments );
 +
};
  
 +
/**
 +
* Extract a URL parameter from the current URL
 +
*
 +
* @deprecated: Use mw.util.getParamValue with proper escaping
 +
*/
 +
window.getURLParamValue = function () {
 +
    return mw.util.getParamValue.apply( mw.util, arguments );
 +
};
  
/*
+
/**  
Correzione della posizione del link [modifica] delle sezioni.
+
* Test if an element has a certain class
   
+
  *
Copyright 2006, Marc Mongenet
+
  * @deprecated:  Use $(element).hasClass() instead.
   
+
  */
This program is free software; you can redistribute it and/or
+
window.hasClass = function ( element, className ) {
modify it under the terms of the GNU General Public License
+
     return $( element ).hasClass( className );
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.
+
*/
+
+
$(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 */ }
+
});
+
  
/*  
+
/**
  * Modifica il testo della linguetta "Voce" in "Pagina principale"
+
  * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
  * e aggiunge il link alla lista completa di tutte le pagine
+
  * @rev 5
 
  */
 
  */
if (mw.config.get('wgIsMainPage') || mw.config.get('wgPageName') === "Discussione:Pagina_principale")
+
// CSS
$(function() {
+
var extraCSS = mw.util.getParamValue( 'withCSS' );
  if (mw.config.get('wgUserLanguage') === 'it')
+
if ( extraCSS ) {
    $('#ca-nstab-main a').text('Pagina principale');
+
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
 
+
importStylesheet( extraCSS );
  mw.util.addPortletLink('p-lang', '//meta.wikimedia.org/wiki/Lista_di_Wikipedie',
+
} else {
                'Lista completa', 'interwiki-completelist', 'Lista completa delle Wikipedie');
+
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
});
+
}
 +
}
  
/** "Technical restrictions" title fix *****************************************
+
// JS
  *
+
var extraJS = mw.util.getParamValue( 'withJS' );
  *  Descrizionen: Codice per [[Template:Titolo errato]]
+
if ( extraJS ) {
  *  Copiato inizialmente da [[:en:MediaWiki:Common.js]]
+
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
  */
+
importScript( extraJS );
// The function looks for a banner like this: <nowiki>
+
} else {
// <div id="RealTitleBanner">    <!-- div that gets hidden -->
+
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
//  <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 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();
+
 
+
        var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big|a)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
+
 
+
        var h1 = document.getElementsByTagName("h1")[0];
+
        if (h1) {
+
          h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
+
 
+
          realTitleBanner.style.display = "none";
+
        }
+
        document.title = realTitleText + " - Wikipedia";
+
      }
+
    }
+
  } catch (e) {
+
    /* Something went wrong. */
+
  }
+
 
}
 
}
  
$(correctTitle);
+
/**
+
* Import more specific scripts if necessary
/** WikiMiniAtlas *******************************************************
+
*/
  *
+
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
  *  Description: WikiMiniAtlas is a popup click and drag world map.
+
    /* scripts specific to editing pages */
  *               This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
+
    importScript( 'MediaWiki:Common.js/edit.js' );
  *               The script itself is located on meta because it is used by many projects.
+
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
  *              See [[Meta:WikiMiniAtlas]] for more information.  
+
    /* watchlist scripts */
  */
+
    importScript( 'MediaWiki:Common.js/watchlist.js' );
+
}
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
+
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
 
+
    /* file description page scripts */
 
+
    importScript( 'MediaWiki:Common.js/file.js' );
//============================================================
+
}
// Menu caratteri speciali
+
//============================================================
+
  
 
/**
 
/**
  * Aggiunge il menu a tendina per selezionare un sottoinsieme di caratteri speciali
+
  * Load scripts specific to Internet Explorer
* Attenzione:        l'ordine della lista deve corrispondere a quello di MediaWiki:Edittools !
+
 
  */
 
  */
/* select subsection of special characters */
+
if ( $.client.profile().name === 'msie' ) {
function scegliSubsetCaratteri(s) {
+
     importScript( 'MediaWiki:Common.js/IEFixes.js' );
  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');
+
* Fix for Windows XP Unicode font rendering
   
+
  */
  if (specialchars) {
+
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
    var menu = "<select style=\"display:inline\" onChange=\"scegliSubsetCaratteri(selectedIndex)\">";
+
     mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +  
    menu += "<option>Latino esteso</option>";
+
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
    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);
 
  
// END Menu caratteri speciali
+
/**
 
+
* WikiMiniAtlas
/*** RICERCA ***/
+
*
/**  
+
* Description: 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.
*  Descrizione: Cambia Speciale:Ricerca per usare un menu' a
+
  *              See [[Meta:WikiMiniAtlas]] for more information.
* tendina, con come default il motore interno di MediaWiki
+
* Maintainers: [[User:Dschwen]]
*
+
*/
* Creato e gestito da: [[:en:User:Gracenotes]]
+
( function () {
* Importato in it.wiki da: [[Utente:Jalo]]
+
    var require_wikiminiatlas = false;
*/
+
    var coord_filter = /geohack/;
+
    $( document ).ready( function() {
if (mw.config.get('wgPageName') == "Speciale:Ricerca")
+
         $( 'a.external.text' ).each( function( key, link ) {
$(function() {
+
            if ( link.href && coord_filter.exec( link.href ) ) {
        var searchEngines = [];
+
                require_wikiminiatlas = true;
        var createOption = function(site, action, mainQ, addQ, addV) {
+
                // break from loop
                var opt = document.createElement('option');
+
                return false;
                opt.appendChild(document.createTextNode(site));
+
            }
                searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
+
         } );
                return opt;
+
        if ( $( 'div.kmldata' ).length ) {
        };
+
            require_wikiminiatlas = true;
        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);
+
});
+
 
+
// 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].onmouseover=function() { this.hopContent.style.display="block"; };
+
                        x[i].onmouseout=function() { this.hopContent.style.display="none"; };
+
                }
+
 
         }
 
         }
});
+
        if ( require_wikiminiatlas ) {
 +
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
 +
        }
 +
    } );
 +
} )();
  
// BEGIN Dynamic Navigation Bars
+
/**
 
+
* Interwiki links to featured articles ***************************************
 
+
/* Test if an element has a certain class **************************************
+
 
  *
 
  *
  * Description: Uses regular expressions and caching for better performance.
+
  * Description: Highlights interwiki links to featured articles (or
  * Maintainers: User:Mike Dillon, User:R. Koot, User:SG
+
*              equivalents) by changing the bullet before the interwiki link
 +
*              into a star.
 +
  * Maintainers: [[User:R. Koot]]
 
  */
 
  */
var hasClass = (function () {
+
function LinkFA() {
     var reCache = {};
+
     if ( document.getElementById( 'p-lang' ) ) {
    return function (element, className) {
+
         var InterwikiLinks = document.getElementById( 'p-lang' ).getElementsByTagName( 'li' );
         return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
+
    };
+
})();
+
 
+
 
+
// set up the words in your language
+
var NavigationBarHide = '▲ nascondi';
+
var NavigationBarShow = '▼ mostra';
+
 
+
// 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
+
        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
// Parameters:
+
            if ( document.getElementById( InterwikiLinks[i].className + '-fa' ) ) {
//    indexNavigationBar: the index of navigation bar to be toggled
+
                InterwikiLinks[i].className += ' FA';
function toggleNavigationBar(indexNavigationBar)
+
                InterwikiLinks[i].title = 'This is a featured article in another language.';
{
+
            } else if ( document.getElementById( InterwikiLinks[i].className + '-ga' ) ) {
  var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
+
                InterwikiLinks[i].className += ' GA';
  var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
+
                InterwikiLinks[i].title = 'This is a good article in another language.';
 
+
            }
  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
+
$( LinkFA );
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");
+
* Collapsible tables *********************************************************
          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
Description: Allows tables to be collapsed, showing only the header. See
+
  *             [[Wikipedia:NavFrame]].
  *               Wikipedia:NavFrame.
+
  * Maintainers: [[User:R. Koot]]
  * Maintainers: User:R. Koot
+
 
  */
 
  */
  
 
var autoCollapse = 2;
 
var autoCollapse = 2;
var collapseCaption = "nascondi";
+
var collapseCaption = 'hide';
var expandCaption = "mostra";
+
var expandCaption = 'show';
  
function collapseTable( tableIndex )
+
window.collapseTable = function ( tableIndex ) {
{
+
     var Button = document.getElementById( 'collapseButton' + tableIndex );
     var Button = document.getElementById( "collapseButton" + tableIndex );
+
     var Table = document.getElementById( 'collapsibleTable' + tableIndex );
     var Table = document.getElementById( "collapsibleTable" + tableIndex );
+
  
 
     if ( !Table || !Button ) {
 
     if ( !Table || !Button ) {
Riga 431: Riga 205:
 
     }
 
     }
  
     var Rows = Table.getElementsByTagName( "tr" );  
+
     var Rows = Table.rows;
 +
    var i;
  
     if ( Button.firstChild.data == collapseCaption ) {
+
     if ( Button.firstChild.data === collapseCaption ) {
         for ( var i = 1; i < Rows.length; i++ ) {
+
         for ( i = 1; i < Rows.length; i++ ) {
             Rows[i].style.display = "none";
+
             Rows[i].style.display = 'none';
 
         }
 
         }
 
         Button.firstChild.data = expandCaption;
 
         Button.firstChild.data = expandCaption;
 
     } else {
 
     } else {
         for ( var i = 1; i < Rows.length; i++ ) {
+
         for ( i = 1; i < Rows.length; i++ ) {
 
             Rows[i].style.display = Rows[0].style.display;
 
             Rows[i].style.display = Rows[0].style.display;
 
         }
 
         }
 
         Button.firstChild.data = collapseCaption;
 
         Button.firstChild.data = collapseCaption;
 
     }
 
     }
}
+
};
  
function createCollapseButtons()
+
function createCollapseButtons() {
{
+
 
     var tableIndex = 0;
 
     var tableIndex = 0;
     var NavigationBoxes = new Object();
+
     var NavigationBoxes = {};
     var Tables = document.getElementsByTagName( "table" );
+
     var Tables = document.getElementsByTagName( 'table' );
 +
    var i;
 +
 
 +
    function handleButtonLink( index, e ) {
 +
        window.collapseTable( index );
 +
        e.preventDefault();
 +
    }
 +
 
 +
    for ( i = 0; i < Tables.length; i++ ) {
 +
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
 +
 
 +
            /* only add button and increment count if there is a header row to work with */
 +
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
 +
            if ( !HeaderRow ) continue;
 +
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
 +
            if ( !Header ) continue;
  
    for ( var i = 0; i < Tables.length; i++ ) {
 
        if ( hasClass( Tables[i], "collapsible" ) ) {
 
 
             NavigationBoxes[ tableIndex ] = Tables[i];
 
             NavigationBoxes[ tableIndex ] = Tables[i];
             Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
+
             Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
  
             var Button    = document.createElement( "span" );
+
             var Button    = document.createElement( 'span' );
             var ButtonLink = document.createElement( "a" );
+
             var ButtonLink = document.createElement( 'a' );
 
             var ButtonText = document.createTextNode( collapseCaption );
 
             var ButtonText = document.createTextNode( collapseCaption );
  
             Button.style.styleFloat = "right";
+
             Button.className = 'collapseButton'; /* Styles are declared in Common.css */
            Button.style.cssFloat = "right";
+
            Button.style.fontWeight = "normal";
+
            Button.style.textAlign = "right";
+
            Button.style.width = "7em";
+
  
             ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
+
            ButtonLink.style.color = Header.style.color;
             ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
+
             ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
 +
             ButtonLink.setAttribute( 'href', '#' );
 +
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
 
             ButtonLink.appendChild( ButtonText );
 
             ButtonLink.appendChild( ButtonText );
  
             Button.appendChild( document.createTextNode( "[" ) );
+
             Button.appendChild( document.createTextNode( '[' ) );
 
             Button.appendChild( ButtonLink );
 
             Button.appendChild( ButtonLink );
             Button.appendChild( document.createTextNode( "]" ) );
+
             Button.appendChild( document.createTextNode( ']' ) );
  
             var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
+
             Header.insertBefore( Button, Header.firstChild );
            /* only add button and increment count if there is a header row to work with */
+
            tableIndex++;
            if (Header) {
+
                Header.insertBefore( Button, Header.childNodes[0] );
+
                tableIndex++;
+
            }
+
 
         }
 
         }
 
     }
 
     }
  
     for ( var i = 0;  i < tableIndex; i++ ) {
+
     for ( i = 0;  i < tableIndex; i++ ) {
         if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
+
         if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
             collapseTable( i );
+
             window.collapseTable( i );
 +
        }
 +
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
 +
            var element = NavigationBoxes[i];
 +
            while ((element = element.parentNode)) {
 +
                if ( $( element ).hasClass( 'outercollapse' ) ) {
 +
                    window.collapseTable ( i );
 +
                    break;
 +
                }
 +
            }
 
         }
 
         }
 
     }
 
     }
Riga 493: Riga 283:
 
$( createCollapseButtons );
 
$( createCollapseButtons );
  
//END Collapsible tables
+
/**
 +
* Dynamic Navigation Bars (experimental)
 +
*
 +
* Description: See [[Wikipedia:NavFrame]].
 +
* Maintainers: UNMAINTAINED
 +
*/
  
//HIDDENCAT (mostra le categorie nascoste). Scippato ai francesi
+
/* set up the words in your language */
//@ deprecated
+
var NavigationBarHide = '[' + collapseCaption + ']';
function addClass(node, className) {
+
var NavigationBarShow = '[' + expandCaption + ']';
     if (hasClass(node, className)) {
+
 
 +
/**
 +
* Shows and hides content and picture (if available) of navigation bars
 +
* Parameters:
 +
*    indexNavigationBar: the index of navigation bar to be toggled
 +
**/
 +
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
 +
     var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
 +
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
 +
    var NavChild;
 +
 
 +
    if ( !NavFrame || !NavToggle ) {
 
         return false;
 
         return false;
 
     }
 
     }
    node.className += ' '+ className;
 
    return true;
 
}
 
  
function eregReplace(search, replace, subject) {
+
    /* if shown now */
    return subject.replace(new RegExp(search,'g'), replace);
+
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
}
+
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 +
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 +
                NavChild.style.display = 'none';
 +
            }
 +
        }
 +
    NavToggle.firstChild.data = NavigationBarShow;
  
//@ deprecated
+
    /* if hidden now */
function removeClass(node, className) {
+
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
  if (!hasClass(node, className)) {
+
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
    return false;
+
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
  }
+
                NavChild.style.display = 'block';
  node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
+
            }
  return true;
+
        }
}
+
        NavToggle.firstChild.data = NavigationBarHide;
 +
    }
  
function hiddencat()
+
    event.preventDefault();
{
+
};
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');
+
if(!nc)
+
{
+
  removeClass(cl, 'catlinks-allhidden');
+
  addClass(cl, 'catlinks-allhidden-mostra');
+
  var 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') )
+
{
+
  var 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
+
/* adds show/hide-button to navigation bars */
  document.getElementById('mw-hidden-cats-link').innerHTML = '[nascondi]';  
+
function createNavigationBarToggleButton() {
  //document.getElementById('mw-hidden-cats-link').innerHTML = '[<span style="font-style:italic;">nascondi</span>]';
+
    var indexNavigationBar = 0;
}
+
    var NavFrame;
else
+
    var NavChild;
{
+
    /* iterate over all < div >-elements */
  removeClass(hc, 'mw-hidden-cat-user-shown');
+
    var divs = document.getElementsByTagName( 'div' );
  addClass(hc, 'mw-hidden-cats-hidden');
+
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
 +
        /* if found a navigation bar */
 +
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
  
  //Vedi commento sopra
+
            indexNavigationBar++;
  document.getElementById('mw-hidden-cats-link').innerHTML = '[altre]';
+
            var NavToggle = document.createElement( 'a' );
  //document.getElementById('mw-hidden-cats-link').innerHTML = '[<span style="font-style:italic;">altre</span>]';
+
            NavToggle.className = 'NavToggle';
}
+
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
}
+
            NavToggle.setAttribute( 'href', '#' );
+
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
$(hiddencat);
+
  
/* Layout pagina di modifica */
+
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
$( function ()
+
            /**
{
+
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
  if (mw.config.get('wgAction') == "edit")
+
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
  {
+
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
    /* Allarga l'edittools a tutta pagina */
+
            * the content visible without JavaScript support), the new recommended way is to add the class
    $('#Standard').css( 'width', '100%' );
+
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
  }
+
            */
});
+
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
 +
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 +
                    if ( NavChild.style.display === 'none' ) {
 +
                        isCollapsed = true;
 +
                    }
 +
                }
 +
            }
 +
            if ( isCollapsed ) {
 +
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 +
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 +
                        NavChild.style.display = 'none';
 +
                    }
 +
                }
 +
            }
 +
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
 +
            NavToggle.appendChild( NavToggleText );
  
/* Avvisa quando si tenta di creare una voce con titolo non valido  ("Scrivi qui il titolo")*/
+
            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
$ ( function ()
+
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
{
+
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
  if (mw.config.get('wgTitle') == "Scrivi qui il titolo" && mw.config.get('wgAction') == "edit")
+
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
  {
+
                    NavFrame.childNodes[j].appendChild( NavToggle );
    dopoDi = document.getElementById("contentSub");
+
                }
if (!dopoDi) return;
+
            }
    var daInserire = document.createElement('div');
+
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
    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")*/
+
$( createNavigationBarToggleButton );
$ ( 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);
+
  }
+
});
+
  
/** extract a URL parameter from the current URL **********
+
/**
  * From [[en:User:Lupin/autoedit.js]] and [[en:MediaWiki:Common.js]]
+
* Uploadwizard_newusers
 +
  * Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
 
  *
 
  *
  * paramName  : the name of the parameter to extract
+
  * Maintainers: [[User:Krimpet]]
 
  */
 
  */
//DEPRECATO
+
function uploadwizard_newusers() {
function getURLParamValue(param, url) {
+
    if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
  return mw.util.getParamValue(param, url);
+
        var oldDiv = document.getElementById( 'autoconfirmedusers' ),
}
+
            newDiv = document.getElementById( 'newusers' );
+
        if ( oldDiv && newDiv ) {
/** &withJS= URL parameter *******
+
            var userGroups = mw.config.get( 'wgUserGroups' );
* Allow to try custom scripts from MediaWiki space
+
            if ( userGroups ) {
* without editing [[Special:Mypage/monobook.js]]
+
                for ( var i = 0; i < userGroups.length; i++ ) {
*/
+
                    if ( userGroups[i] === 'autoconfirmed' ) {
var extraJS = getURLParamValue("withJS");
+
                        oldDiv.style.display = 'block';
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\\.js$") ) {
+
                        newDiv.style.display = 'none';
  importScript(extraJS);
+
                        return;
 +
                    }
 +
                }
 +
            }
 +
            oldDiv.style.display = 'none';
 +
            newDiv.style.display = 'block';
 +
            return;
 +
        }
 +
    }
 
}
 
}
  
 +
$(uploadwizard_newusers);
  
/*** Codice per il Template:Galleria ***/
+
/**
function toggleImage(group, remindex, shwindex) {
+
* Magic editintros ****************************************************
  document.getElementById("ImageGroupsGr"+group+"Im"+remindex).style.display="none";
+
*
  document.getElementById("ImageGroupsGr"+group+"Im"+shwindex).style.display="inline";
+
* Description: Adds editintros on disambiguation pages and BLP pages.
 +
* Maintainers: [[User:RockMFR]]
 +
*/
 +
function addEditIntro( name ) {
 +
    $( '.editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
 +
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
 +
    } );
 
}
 
}
function ImageGroup(){
 
if (document.URL.match(/printable/g)) return;
 
var bc=mw.util.$content.get(0);
 
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="&nbsp;";
 
}
 
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="&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);
 
  
 +
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
 +
    $( function () {
 +
        if ( document.getElementById( 'disambigbox' ) ) {
 +
            addEditIntro( 'Template:Disambig_editintro' );
 +
        }
 +
    } );
  
// Toglie "Soggetto/Intestazione" nelle creazioni delle discussioni al Bar
+
     $( function () {
if (mw.config.get('wgNamespaceNumber') == 4 &&
+
        var cats = document.getElementById( 'mw-normal-catlinks' );
     mw.config.get('wgPageName').indexOf("Wikipedia:Bar/") == 0 &&
+
         if ( !cats ) {
    mw.config.get('wgAction') == "edit" &&
+
            return;
    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)});
+
});
+
 
+
 
+
/** Workaround temporaneo *************
+
* Workaround per il vecchio codice che usa document.write(): a partire da MediaWiki 1.17 non è più possibile usarlo.
+
* Questo codice sostituisce le funzioni document.write() e document.writeln() con funzioni personalizzate.
+
* Quando possibile, traduce in una chiamata a importScriptURI(); in tutti gli altri casi, ritorna senza far nulla.
+
* E' codice poco robusto e che va rimosso al più presto, dopo aver aggiornato i vecchi codici.
+
*/
+
if (mw.config.get('wgVersion') >= "1.17"){
+
  try{
+
    document.write = document.writeln = function(str){
+
      var start, end;
+
      try{
+
         if (str.indexOf("<script") != -1){
+
          start = str.indexOf("src");
+
          start = str.indexOf("\"", start+1) + 1;
+
          end = str.indexOf("\"", start);
+
          importScriptURI(str.substring(start, end));
+
        } else {
+
          //Ignora la chiamata
+
 
         }
 
         }
      } catch (e) { /* Ignora */ }
+
        cats = cats.getElementsByTagName( 'a' );
    };
+
        for ( var i = 0; i < cats.length; i++ ) {
  } catch (e) { /* Ignora */ }
+
            if ( cats[i].title === 'Category:Living people' || cats[i].title === 'Category:Possibly living people' ) {
 +
                addEditIntro( 'Template:BLP_editintro' );
 +
                break;
 +
            }
 +
        }
 +
    } );
 
}
 
}
  
/** OpenStreetMap nel template Coord **/
+
/**
   
+
* Description: Stay on the secure server as much as possible
// Verwendung von OpenStreetMap in Wikipedia.
+
  * Maintainers: [[User:TheDJ]]
// (c) 2008 by Magnus Manske
+
*/
// Released under GPL
+
if ( document.location && document.location.protocol  && document.location.protocol === 'https:' ) {
// Modified version in order to makes it work with moveCoord() above
+
     /* New secure servers */
// From fr:mediawiki:common.js
+
     importScript( 'MediaWiki:Common.js/secure new.js' );
// modified to makes it work for IT : Otourly
+
 
+
if(typeof(MoveResizeAbsolute_AddMoveArea)!="function") importScriptURI('//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 ;
+
     geohack = true ;
+
    break ;
+
  }
+
  if ( !geohack ) return ;
+
+
  var na = document.createElement ( 'a' ) ;
+
  na.href = 'javascript: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.href = "javascript: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);
 
}
 
 
addOnloadHook(openStreetMap_Init);
 
 
// Autofocus nel campo "ricerca" della homepage
 
$(function() {
 
  if (mw.config.get('wgIsMainPage') && mw.config.get('wgAction') === 'view')
 
    $('#searchInput').focus();
 
});
 
  
//REFERENCE TOOLTIP
+
/* End of mw.loader.using callback */
mw.loader.load("//it.wikipedia.org/w/index.php?title=Wikipedia:Monobook.js/ReferenceTooltip.js&action=raw&ctype=text/javascript");
+
} );
 +
/* DO NOT ADD CODE BELOW THIS LINE */

Versione attuale delle 04:59, 30 mar 2013

/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since Common.js isn't a gadget, there is no place to declare its
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */
/*global mw, $, importStylesheet, importScript */
/*jshint curly:false eqnull:true, strict:false, browser:true, */
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
/* Begin of mw.loader.using callback */
 
/**
 * Main Page layout fixes
 *
 * Description: Adds an additional link to the complete list of languages available.
 * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
 */
if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) {
    $( document ).ready( function () {
        mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
            'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
    } );
}
 
/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
    var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
    /* Make sure there was a part before and after the slash
       and that the latter is 'skin.js' or 'skin.css' */
    if ( titleParts.length == 2 ) {
        var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
        if ( titleParts.slice( -1 ) == 'skin.js' ) {
            window.location.href = mw.util.wikiGetlink( userSkinPage + '.js' );
        } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
            window.location.href = mw.util.wikiGetlink( userSkinPage + '.css' );
        }
    }
}
 
/**
 * Map addPortletLink to mw.util 
 *
 * @deprecated: Use mw.util.addPortletLink instead.
 */
window.addPortletLink = function () {
    return mw.util.addPortletLink.apply( mw.util, arguments );
};
 
/**
 * Extract a URL parameter from the current URL
 *
 * @deprecated: Use mw.util.getParamValue with proper escaping
 */
window.getURLParamValue = function () {
    return mw.util.getParamValue.apply( mw.util, arguments );
};
 
/** 
 * Test if an element has a certain class
 *
 * @deprecated:  Use $(element).hasClass() instead.
 */
window.hasClass = function ( element, className ) {
    return $( element ).hasClass( className );
};
 
/**
 * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
 * @rev 5
 */
// CSS
var extraCSS = mw.util.getParamValue( 'withCSS' );
if ( extraCSS ) {
	if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
		importStylesheet( extraCSS );
	} else {
		mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
	}
}
 
// JS
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' } );
	}
}
 
/**
 * Import more specific scripts if necessary
 */
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
    /* scripts specific to editing pages */
    importScript( 'MediaWiki:Common.js/edit.js' );
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
    /* watchlist scripts */
    importScript( 'MediaWiki:Common.js/watchlist.js' );
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
    /* file description page scripts */
    importScript( 'MediaWiki:Common.js/file.js' );
}
 
/**
 * Load scripts specific to Internet Explorer
 */
if ( $.client.profile().name === 'msie' ) {
    importScript( 'MediaWiki:Common.js/IEFixes.js' );
}
 
/**
 * Fix for Windows XP Unicode font rendering
 */
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' + 
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
}
 
/**
 * WikiMiniAtlas
 *
 * Description: 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. 
 * Maintainers: [[User:Dschwen]]
 */
( function () {
    var require_wikiminiatlas = false;
    var coord_filter = /geohack/;
    $( document ).ready( function() {
        $( 'a.external.text' ).each( function( key, link ) {
            if ( link.href && coord_filter.exec( link.href ) ) {
                require_wikiminiatlas = true;
                // break from loop
                return false;
            }
        } );
        if ( $( 'div.kmldata' ).length ) {
            require_wikiminiatlas = true;
        }
        if ( require_wikiminiatlas ) {
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
        }
    } );
} )();
 
/**
 * Interwiki links to featured articles ***************************************
 *
 * Description: Highlights interwiki links to featured articles (or
 *              equivalents) by changing the bullet before the interwiki link
 *              into a star.
 * Maintainers: [[User:R. Koot]]
 */
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.';
            } else if ( document.getElementById( InterwikiLinks[i].className + '-ga' ) ) {
                InterwikiLinks[i].className += ' GA';
                InterwikiLinks[i].title = 'This is a good article in another language.';
            }
        }
    }
}
 
$( LinkFA );
 
/**
 * Collapsible tables *********************************************************
 *
 * Description: Allows tables to be collapsed, showing only the header. See
 *              [[Wikipedia:NavFrame]].
 * Maintainers: [[User:R. Koot]]
 */
 
var autoCollapse = 2;
var collapseCaption = 'hide';
var expandCaption = 'show';
 
window.collapseTable = function ( tableIndex ) {
    var Button = document.getElementById( 'collapseButton' + tableIndex );
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
    var i;
 
    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 createCollapseButtons() {
    var tableIndex = 0;
    var NavigationBoxes = {};
    var Tables = document.getElementsByTagName( 'table' );
    var i;
 
    function handleButtonLink( index, e ) {
        window.collapseTable( index );
        e.preventDefault();
    }
 
    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
 
            /* only add button and increment count if there is a header row to work with */
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
            if ( !HeaderRow ) continue;
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
            if ( !Header ) continue;
 
            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.className = 'collapseButton';  /* Styles are declared in Common.css */
 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
            ButtonLink.setAttribute( 'href', '#' );
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( '[' ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( ']' ) );
 
            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    }
 
    for ( i = 0;  i < tableIndex; i++ ) {
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
            window.collapseTable( i );
        } 
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
            var element = NavigationBoxes[i];
            while ((element = element.parentNode)) {
                if ( $( element ).hasClass( 'outercollapse' ) ) {
                    window.collapseTable ( i );
                    break;
                }
            }
        }
    }
}
 
$( createCollapseButtons );
 
/**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */
 
/* set up the words in your language */
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';
 
/**
 * Shows and hides content and picture (if available) of navigation bars
 * Parameters:
 *     indexNavigationBar: the index of navigation bar to be toggled
 **/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
    var NavChild;
 
    if ( !NavFrame || !NavToggle ) {
        return false;
    }
 
    /* if shown now */
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    /* if hidden now */
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'block';
            }
        }
        NavToggle.firstChild.data = NavigationBarHide;
    }
 
    event.preventDefault();
};
 
/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
    var indexNavigationBar = 0;
    var NavFrame;
    var NavChild;
    /* iterate over all < div >-elements */
    var divs = document.getElementsByTagName( 'div' );
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
        /* if found a navigation bar */
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
 
            indexNavigationBar++;
            var NavToggle = document.createElement( 'a' );
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
            NavToggle.setAttribute( 'href', '#' );
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
 
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
            /**
             * Check if any children are already hidden.  This loop is here for backwards compatibility:
             * the old way of making NavFrames start out collapsed was to manually add style="display:none"
             * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
             * the content visible without JavaScript support), the new recommended way is to add the class
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
             */
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                    if ( NavChild.style.display === 'none' ) {
                        isCollapsed = true;
                    }
                }
            }
            if ( isCollapsed ) {
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                        NavChild.style.display = 'none';
                    }
                }
            }
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
            NavToggle.appendChild( NavToggleText );
 
            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild( NavToggle );
                }
            }
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        }
    }
}
 
$( createNavigationBarToggleButton );
 
/**
 * Uploadwizard_newusers
 * Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
 *
 * Maintainers: [[User:Krimpet]]
 */
function uploadwizard_newusers() {
    if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
        var oldDiv = document.getElementById( 'autoconfirmedusers' ),
            newDiv = document.getElementById( 'newusers' );
        if ( oldDiv && newDiv ) {
            var userGroups = mw.config.get( 'wgUserGroups' );
            if ( userGroups ) {
                for ( var i = 0; i < userGroups.length; i++ ) {
                    if ( userGroups[i] === 'autoconfirmed' ) {
                        oldDiv.style.display = 'block';
                        newDiv.style.display = 'none';
                        return;
                    }
                }
            }
            oldDiv.style.display = 'none';
            newDiv.style.display = 'block';
            return;
        }
    }
}
 
$(uploadwizard_newusers);
 
/**
 * Magic editintros ****************************************************
 *
 * Description: Adds editintros on disambiguation pages and BLP pages.
 * Maintainers: [[User:RockMFR]]
 */
function addEditIntro( name ) {
    $( '.editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
    } );
}
 
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
    $( function () {
        if ( document.getElementById( 'disambigbox' ) ) {
            addEditIntro( 'Template:Disambig_editintro' );
        }
    } );
 
    $( function () {
        var cats = document.getElementById( 'mw-normal-catlinks' );
        if ( !cats ) {
            return;
        }
        cats = cats.getElementsByTagName( 'a' );
        for ( var i = 0; i < cats.length; i++ ) {
            if ( cats[i].title === 'Category:Living people' || cats[i].title === 'Category:Possibly living people' ) {
                addEditIntro( 'Template:BLP_editintro' );
                break;
            }
        }
    } );
}
 
/**
 * Description: Stay on the secure server as much as possible
 * Maintainers: [[User:TheDJ]]
 */
if ( document.location && document.location.protocol  && document.location.protocol === 'https:' ) {
    /* New secure servers */
    importScript( 'MediaWiki:Common.js/secure new.js' );
}
 
/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */
Strumenti personali

Varianti
Azioni
Navigazione
Strumenti
Share