MediaWiki:Monobook.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* <pre> */
var mpTitle = "Pàgina printzipale";
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));
if (mw.config.get('wgIsMainPage') && !isDiff)
{
mw.util.addCSS(' #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } ');
var mpSmallEnabled;
var mpMinWidth = 700;
function mainPageTransform()
{
if ((mw.config.get('wgIsMainPage') || /[\/=:]Pàgina printzipale/.test(document.location)) && document.getElementById('ca-nstab-main'))
document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Pàgina printzipale';
var mpContentEl = document.getElementById("bodyContent");
var mpBrowseEl = document.getElementById("EnWpMpBrowse");
var mpContainEl = document.getElementById("EnWpMpBrowseContainer");
var mpMarginEl = document.getElementById("EnWpMpMargin");
var mpEl = document.getElementById("EnWpMainPage");
if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl)
return;
if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth)
{
mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild);
mpBrowseEl.className = "EnWpMpBrowseBottom";
mpMarginEl.style.marginRight = 0;
mpSmallEnabled = true;
}
else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth)
{
mpEl.insertBefore(mpBrowseEl, mpEl.firstChild);
mpBrowseEl.className = "EnWpMpBrowseRight";
mpMarginEl.style.marginRight = "13.8em";
mpSmallEnabled = false;
}
}
$(mainPageTransform);
if (window.addEventListener)
window.addEventListener("resize", mainPageTransform, false);
else if (window.attachEvent)
window.attachEvent("onresize", mainPageTransform);
}
/** "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 = $(realTitle).text();
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. */
}
}
$(document).ready(correctTitle);
/** Fix al layout della Pagina principale *********************************************************
*
* Descrizione: Alcuni al layout, fra cui un link alla lista completa di tutte
* le wikipedia in tutte le lingue disponibili.
* Da un codice di: [[en:User:AzaToth]], [[en:User:R. Koot]]
* Sistemato da: [[n:Utente:Tooby]] <--- liberi di giustiziarlo
*/
function mainPageRenameNamespaceTab() {
try {
var Node = document.getElementById( 'ca-nstab-main' ).firstChild;
if ( Node.textContent ) { // Per DOM Level 3
Node.textContent = 'Pàgina printzipale';
} else if ( Node.innerText ) { // IE doesn't handle .textContent
Node.innerText = 'Pàgina printzipale';
} else { // Fallback
Node.replaceChild( Node.firstChild, document.createTextNode( 'Pàgina printzipale' ) );
}
} catch(e) {
// bailing out!
}
}
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 integrada' ) );
aNode.setAttribute( 'href' , '//meta.wikimedia.org/wiki/List_of_Wikipedias' );
liNode.appendChild( aNode );
liNode.className = 'interwiki-completelist';
node.appendChild( liNode );
} catch(e) {
// lets just ignore what's happened
return;
}
}
if ( mw.config.get('wgIsMainPage') || ( mw.config.get('wgTitle') == 'Pàgina printzipale' && mw.config.get('wgNamespaceNumber') == 1 ) ) {
$(document).ready( mainPageRenameNamespaceTab );
}
if ( mw.config.get('wgIsMainPage') ) {
$(document).ready( mainPageAppendCompleteListLink );
}
/*
Correzione della posizione del link [modifica] delle sezioni. (grazie a [[:it:Utente:Jalo]])
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 */ }
}
$(document).ready(setModifySectionStyle);