MediaWiki:Monobook.js
Notarella: Aroppo pubbreca putisse necessità 'e pulezzà 'a caché d' 'o navigatóre pe vedé 'e cagnamienti.
- Firefox / Safari: Sprémme 'o buttóne maiuscole e ffà clic ncopp'a Recarreca, o pure spremme Ctrl-F5 o Ctrl-R (⌘-R ncopp'a Mac)
- Google Chrome: spremme Ctrl-Shift-R (⌘-Shift-R ncopp'a nu Mac)
- Internet Explorer/edge: Spremme 'o buttóne Ctrl pe' tramente ca faie click ncopp'a Refresh, o pure spremmere Ctrl-F5
- Opera: Vaje addò 'o Menu → Mpustaziune (Opera → Mpustaziune ncopp' 'o Mac) e po' ncopp'a Privacy & sicurezza → Pulezza date d' 'o browser → Immaggene e file d' 'a cache.
/* <pre> */
/*** Collegamento diretto alla pagina di upload di Commons nel menu di sinistra, da WP:PT */
function linkUploadToCommons()
{
if (document.getElementById("carrega-para-commons")) return;
var li_carrega = document.getElementById("t-upload");
if (!li_carrega) return;
var afegit = li_carrega.nextSibling;
var ul_eines = li_carrega.parentNode;
var li = document.createElement("li");
li.id = "carrega-para-commons";
li.innerHTML = '<a href="//commons.wikimedia.org/wiki/Commons:Upload/it">Carica su Commons</a>';
if (afegit) ul_eines.insertBefore(li, afegit);
else ul_eines.appendChild(li);
}
$(linkUploadToCommons);
/*** Fine del collegamento diretto alla pagina di upload di Commons */
function LinkAdQ()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
InterwikiLinks[i].className += " FA"
InterwikiLinks[i].title = "La voce è in vetrina in questa lingua.";
}
}
}
}
$( LinkAdQ );
//============================================================
// 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 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);
}
}
/* select subsection of special characters */
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';
}
}
$(aggiungiMenuSubsetCaratteri);
// END Menu caratteri speciali
var mpTitle = "Pagina principale";
var isMainPage = (mw.config.get('wgPageName') == "Pagina_principale");
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
if (isMainPage && !isDiff)
{
mw.util.addCSS('#lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; }');
}
/** "Technical restrictions" title fix *****************************************
*
* Description:
* Maintainers: [[User:Interiot]], [[User:Mets501]]
* copiato da [[:en:MediaWiki:Common.js]]
*/
// For pages that have something like Template:Lowercase, replace the title, but only if it is cut-and-pasteable as a valid wikilink.
// (for instance [[iPod]]'s title is updated. <nowiki>But [[C#]] is not an equivalent wikilink, so [[C Sharp]] doesn't have its main title changed)</nowiki>
//
// The function looks for a banner like this: <nowiki>
// <div id="RealTitleBanner"> <!-- div that gets hidden -->
// <span id="RealTitle">title</span>
// </div>
// </nowiki>An element with id=DisableRealTitle disables the function.
var disableRealTitle = 0; // users can disable this by making this true from their monobook.js
function correctTitle() {
try {
var realTitleBanner = document.getElementById("RealTitleBanner");
if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle) {
var realTitle = document.getElementById("RealTitle");
if (realTitle) {
var realTitleHTML = realTitle.innerHTML;
realTitleText = pickUpText(realTitle);
var isPasteable = 0;
//var containsHTML = /</.test(realTitleHTML); // contains ANY HTML
var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big|a)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
// in più, aggiunto ''a'' per mantenere funzionanti alcuni usi del vecchio Titolo errato - non è detto però che sia sempre voluto
// questo codice era in en.wiki, e se ho ben capito serviva per controllare che il nome nuovo fosse abbastanza simile all'originale, ma non è quello che vogliamo su it.wiki
// // calculate whether the title is pasteable
// var verifyTitle = realTitleText.replace(/^ +/, ""); // trim left spaces
// verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
// questo codice era in en.wiki, e aggiunge il prefisso del namespace se non presente, ma su it.wiki ci si aspetta che ciò non avvenga
// // if the namespace prefix is there, remove it on our verification copy. If it isn't there, add it to the original realValue copy.
// if (wgNamespaceNumber != 0) {
// if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") {
// verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1);
// } else {
// realTitleText = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleText;
// realTitleHTML = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleHTML;
// }
// }
// come sopra, faceva controlli sul titolo
// // verify whether wgTitle matches
// verifyTitle = verifyTitle.replace(/^ +/, "").replace(/ +$/, ""); // trim left and right spaces
// verifyTitle = verifyTitle.replace(/_/g, " "); // underscores to spaces
// verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
// isPasteable = (verifyTitle == wgTitle);
var h1 = document.getElementsByTagName("h1")[0];
if (h1) { // tolto il controllo isPasteable
h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
// if (!containsTooMuchHTML) // ancora, adattamento per it.wiki
realTitleBanner.style.display = "none";
}
document.title = realTitleText + " - Wikipedia";
}
}
} catch (e) {
/* Something went wrong. */
}
}
$(correctTitle);
// similar to innerHTML, but only returns the text portions of the insides, excludes HTML
function pickUpText(aParentElement) {
var str = "";
function pickUpTextInternal(aElement) {
var child = aElement.firstChild;
while (child) {
if (child.nodeType == 1) // ELEMENT_NODE
pickUpTextInternal(child);
else if (child.nodeType == 3) // TEXT_NODE
str += child.nodeValue;
child = child.nextSibling;
}
}
pickUpTextInternal(aParentElement);
return str;
}
function mainPageAppendCompleteListLink() {
try {
var node = document.getElementById( "p-lang" )
.getElementsByTagName('div')[0]
.getElementsByTagName('ul')[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( 'Lista completa' ) );
aNode.setAttribute( 'href' , '//meta.wikimedia.org/wiki/Lista_di_Wikipedie' );
liNode.appendChild( aNode );
liNode.className = 'interwiki-completelist';
node.appendChild( liNode );
} catch(e) {
// lets just ignore what's happened
return;
}
}
if ( mw.config.get('wgTitle') == 'Pagina principale' && mw.config.get('wgNamespaceNumber') == 0 ) {
$( mainPageAppendCompleteListLink );
}
//****************** WIKI MINI ATLAS ******************
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript');
/*
Correzione della posizione del link [modifica] delle sezioni.
Copyright 2006, Marc Mongenet
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See http://www.gnu.org/licenses/gpl.html
The function looks for <span class="editsection">, and move them
at the end of their parent and display them inline in small font.
var oldEditsectionLinks=true disables the function.
*/
setModifySectionStyle = function()
{
try {
if (!(typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false)) return;
var spans = document.getElementsByTagName("span");
for (var s = 0; s < spans.length; ++s) {
var span = spans[s];
if (span.className == "editsection") {
span.style.fontSize = "x-small";
span.style.fontWeight = "normal";
span.style.cssFloat = span.style.styleFloat = "none";
span.parentNode.appendChild(document.createTextNode(" "));
span.parentNode.appendChild(span);
}
}
} catch (e) { /* something went wrong */ }
}
$(setModifySectionStyle);
/*** CODICE PER IL TEMPLATE:GALLERIA ***/
function toggleImage(group, remindex, shwindex) {
document.getElementById("ImageGroupsGr"+group+"Im"+remindex).style.display="none";
document.getElementById("ImageGroupsGr"+group+"Im"+shwindex).style.display="inline";
}
function ImageGroup(){
if (document.URL.match(/printable/g)) return;
var bc=document.getElementById("bodyContent");
var divs=bc.getElementsByTagName("div");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length ; i++) {
if (divs[i].className != "ImageGroup") continue;
UnitNode=undefined;
search=divs[i].getElementsByTagName("div");
for (j = 0; j < search.length ; j++) {
if (search[j].className != "ImageGroupUnits") continue;
UnitNode=search[j];
break;
}
if (UnitNode==undefined) continue;
units=Array();
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (temp.className=="center") units.push(temp);
}
for (j = 0 ; j < units.length ; j++) {
currentimage=units[j];
currentimage.id="ImageGroupsGr"+i+"Im"+j;
var imghead = document.createElement("div");
var leftlink;
var rightlink;
if (j != 0) {
leftlink = document.createElement("a");
leftlink.href = "javascript:toggleImage("+i+","+j+","+(j-1)+");";
leftlink.innerHTML="◀";
} else {
leftlink = document.createElement("span");
leftlink.innerHTML=" ";
}
if (j != units.length - 1) {
rightlink = document.createElement("a");
rightlink.href = "javascript:toggleImage("+i+","+j+","+(j+1)+");";
rightlink.innerHTML="▶";
} else {
rightlink = document.createElement("span");
rightlink.innerHTML=" ";
}
var comment = document.createElement("tt");
comment.innerHTML = "("+ (j+1) + "/" + units.length + ")";
with(imghead) {
style.fontSize="110%";
style.fontweight="bold";
appendChild(leftlink);
appendChild(comment);
appendChild(rightlink);
}
currentimage.insertBefore(imghead,currentimage.childNodes[0]);
if (j != 0) currentimage.style.display="none";
}
}
}
$(ImageGroup);
// 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("§ion=new&preload=") != -1)
addLoadEvent ( function ()
{
document.getElementById('wpSummaryLabel').style.display="none";
document.getElementById('wpSummary').style.display="none";
});
/* </pre> */