MediaWiki:Common.js

Versione del 22 mar 2008 alle 18:29 di Jalo (discussione | contributi) (secondo tentativo)

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */

/*** RICERCA ***/
/** 
*******************************************************
*
*  Descrizione: 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 (wgPageName == "Speciale:Ricerca") {
         var searchEngines = [];
         addOnloadHook(SpecialSearchEnhanced);
 }
 
 function SpecialSearchEnhanced() {
         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['search'];

         if (searchForm.lsearchbox) {
             var searchBox = searchForm.lsearchbox;
         } else {
             var searchBox = 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', 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';
         if (document.getElementById('loadStatus')) {
             var lStat = document.getElementById('loadStatus');
         } else {
             var lStat = searchForm.fulltext;
         }
         lStat.parentNode.insertBefore(selectBox, lStat);
}

// Serve per far funzionare il Cassetto2 con IE6.
if (window.attachEvent && !window.XMLHttpRequest) window.attachEvent("onload", function() {
        var x=document.getElementById("bodyContent").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"; };
                }
        }
});