Utente:FRacco/Sandbox2: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Aggiornamento codici dicembre 2013
D'oh!!!
Riga 1:
 
== Aggiornamento codici dicembre 2013 ...D'OH! ==
 
=== [[MediaWiki:Common.js]] ===
<pre>
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti */
 
// <nowiki> Codice JavaScript: inizio...
 
/* Modifica il testo della linguetta "Voce" in "Pagina principale"
* e aggiunge il link all'elenco completo di tutte le lingue
*
* Ultimo controllo al codice: 12/12/2013 */
 
if ( mw.config.get( 'wgIsMainPage' ) || mw.config.get( 'wgPageName' ) === 'Discussione:Pagina_principale' ) {
$( document ).ready( function() {
if ( mw.config.get( 'wgUserLanguage' ) === 'it' )
$( '#ca-nstab-main a' ).text( 'Pagina principale' );
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Wikiquote/it#Lista_delle_Wikiquote',
'Elenco completo', 'interwiki-completelist', 'Elenco completo delle Wikiquote' );
} );
};
 
 
/* Change Special:Search to use a drop-down menu
*
* Description: Change Special:Search to use a drop-down menu,
* with the default being the internal MediaWiki engine
*
* Created and maintained by: [[w:en:User:Gracenotes]]
*
* Ultimo controllo al codice: 20/02/2014 */
 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' )
$( 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', 'Special:Search' ) );
selectBox.appendChild( createOption( 'Google', '//www.google.com/search', 'q', 'sitesearch', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:it.wikiquote.org' ) );
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 );
} );
 
 
/* Correzione della posizione del link [modifica] delle sezioni.
*
* Copyright 2006, Marc Mongenet
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* See www.gnu.org/licenses/gpl.html
*
* The function looks for <span class="mw-editsection">, and move them
* at the end of their parent and display them inline in small font.
* var oldEditsectionLinks=true disables the function.
*
* Ultimo controllo al codice: 12/12/2013 */
 
var setModifySectionStyle = $( function() {
try {
if ( !( typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false ) ) return;
var spans = document.getElementsByTagName( 'span' );
for ( var s = 0; s < spans.length; s++ ) {
var span = spans[s];
if ( span.className == 'mw-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 */ }
} );
 
$( document ).ready( setModifySectionStyle );
 
 
/* Test if an element has a certain class
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[wikt:en:User:Mike Dillon]], [[w:en:User:R. Koot]], [[w:en:User:SG]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
// DEPRECATO; sostituito con $( element ).hasClass( className )
 
var hasClass = function( element, className ) {
return $( element ).hasClass( className );
};
 
 
/* Working-code of "Metaboxes"
*
* Descrizione: Codice di gestione del [[Template:Metabox]]
*
* Vedi: [[w:ca:Plantilla:Metacaixa]]
* Creato da: [[w:ca:User:Peleguer]]
*
* Traduzione delle variabili:
*
* MetaCaixa = MetaBox
* MetaCaixaInit = inizializza i metabox
* MetaCaixaMostraPestanya = mostra la scheda del metabox
* mc/Mc = metabox
* bt/Bt = bottone
* ps/Ps = scheda
* mcBoto = bottone del metabox
* mcBotoSel = bottone selezionato del metabox
* mcContingut = contenuto del metabox
* mcPestanya = scheda del metabox
*
* Ultimo controllo al codice: 12/12/2013 */
 
function MetaCaixaInit() {
 
// Se ci sono dei metabox nella pagina, assegna gli eventi ai bottoni
 
var i = 0; //inizializza il contatore dei metabox
for ( i = 0; i <= 9; i++ ) {
var vMc = document.getElementById( "mc" + i );
if ( !vMc ) break;
var j = 1; //inizializza il contatore dei bottoni del metabox
var vPsIni = 0; //inizializza la scheda visibile inizialmente
for ( j = 1; j <= 9; j++ ) {
var vBt = document.getElementById( "mc" + i + "bt" + j );
if ( !vBt ) break;
vBt.onclick = MetaCaixaMostraPestanya; //assegna ad ogni bottone l'evento onclick
if ( vBt.className === "mcBotoSel" )
vPsIni = j; //memorizza la scheda visibile inizialmente
}
if (vPsIni === 0) { //se non c'è una scheda visibile inizialmente, ne assegna una casuale
vPsIni = 1 + Math.floor( ( j - 1 ) * Math.random() );
document.getElementById( "mc" + i + "ps" + vPsIni ).style.display = "block";
document.getElementById( "mc" + i + "ps" + vPsIni ).style.visibility = "visible";
document.getElementById( "mc" + i + "bt" + vPsIni ).className = "mcBotoSel";
}
}
};
 
function MetaCaixaMostraPestanya() {
 
// Eseguita al click sul bottone della scheda,
// rende visibile la scheda selezionata, nasconde le altre
 
var vMcNom = this.id.substr( 0, 3 ); //dal nome del pulsante, si deduce il nome del metabox
var vIndex = this.id.substr( 5, 1 ); //e l'indice della scheda
var i = 1;
for ( i = 1; i <= 9; i++ ) { //ricerca tutte le schede del metabox
var vPsElem = document.getElementById( vMcNom + "ps" + i );
if ( !vPsElem ) break;
if ( vIndex == i ) { //se la scheda è quella selezionata, la visualizza e aggiorna il bottone
vPsElem.style.display = "block";
vPsElem.style.visibility = "visible";
document.getElementById( vMcNom + "bt" + i ).className = "mcBotoSel";
} else { //altrimenti la nasconde e aggiorna il bottone
vPsElem.style.display = "none";
vPsElem.style.visibility = "hidden";
document.getElementById( vMcNom + "bt" + i ).className = "mcBoto";
}
}
return false; //evita di ricaricare la pagina
};
 
$( document ).ready( MetaCaixaInit );
 
 
/* Simula i titoli delle sezioni senza indicizzazione e senza link di modifica
*
* Per garantire l'accessibilità anche agli utenti che non utilizzano JavaScript
* nel [[Mediawiki:Common.css]] vengono definite le classi: nojs-h1... h2/h3/h4/h5/h6,
* che qui vengono rimosse.
*
* Vedi: [[Template:Titolo sezione]]
* Creato da: [[q:it:User:FRacco]]
*
* Ultimo controllo al codice: 12/12/2013 */
 
var headersClass = $( function() {
for ( j = 1; j <= 6; j++ ) {
$( ".h" + j ).removeClass( "nojs-h" + j ).html( function( undefined, text ) {
return "<h" + j + ">" + text + "</h" + j + ">";
} );
};
} );
 
$( document ).ready( headersClass );
 
 
/* Collegamento diretto alla pagina di upload di Commons nel portlet Strumenti */
 
$( function() {
mw.util.addPortletLink( 'p-tb', '//commons.wikimedia.org/wiki/Special:UploadWizard', 'Carica su Commons',
't-uploadcommons', 'Carica file multimediali su Commons', 'm', '#t-specialpages');
} );
 
 
/* Attiva i pulsanti per Wikiquote della la barra di modifica (versione classica e versione avanzata) */
 
importScript( "MediaWiki:Toolbar.js" );
 
 
/* Attiva la visualizzazione delle note sopra la nota stessa all'interno di un riquadro (REFERENCE TOOLTIP) */
 
importScript( "MediaWiki:ReferenceTooltip.js" );
importStylesheet( "MediaWiki:ReferenceTooltip.css" );
 
 
/* Attiva tutti gli effetti di apertura e chiusura di oggetti e tabelle "collassabili" */
 
importScript( "MediaWiki:Apri-chiudi.js" );
importStylesheet( "MediaWiki:Apri-chiudi.css" );
 
 
/* Più lingue selezionabili: importazione da Commons */
 
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-LanguageSelect.js&action=raw&ctype=text/javascript' );
 
 
/* Interprogetto: importazione da Commons
*
* Funzione di gestione dei collegamenti dell'interprogetto nella barra di sinistra */
 
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:InterProject.js&action=raw&ctype=text/javascript' );
 
// Codice JavaScript: ...fine </nowiki>
</pre>
 
----
 
== Aggiornamento codici dicembre 2013 ==