Utente:Sanjilops/monobook.js
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, e comunque qualche minuto di preghiera non guasta. 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 menu Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.
//disablehideEdit=1;
disablealertLoad=true;
disableaprilfish = 1;
disablereftooltip = false;
function Main() {
FastOpen();
editcurrentid();
if (wgPageName == "Utente:Sanjilops/sandbox") gif_hack();
if (document.getElementById('alert-load')) alert("alert onload presenti");
if (document.getElementById('alert-unload')) alert("alert onunload presenti");
/* Funzioni dell'editor */
if ((wgAction == "edit" || wgAction == "submit") && document.getElementById("toolbar")) {
if (mwCustomEditButtons) {
mwCustomEditButtons[0] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
"speedTip": "A capo",
"tagOpen": "<br />\n",
"tagClose": "",
"sampleText": ""};
mwCustomEditButtons[1] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/05/Button_Anf%C3%BChrung.png",
"speedTip": "Citazione",
"tagOpen": "{" + "{Cit|",
"tagClose": "}" + "}",
"sampleText": "..."};
mwCustomEditButtons[2] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/0c/Button_P_template.png",
"speedTip": "Template",
"tagOpen": "{{",
"tagClose": "}" + "}",
"sampleText": "Template"};
mwCustomEditButtons[3] = {
"imageFile": "http://images.wikia.com/nonciclopedia/images/f/f9/Button_box.png",
"speedTip": "Box",
"tagOpen": '{|width="100%" align="center" style="background: #FFFFFF; color: #000000; border: 1px solid #000000; text-align: left; margin-bottom: 0px; margin-top: 0px; padding-right: 4px; padding-left: 4px;"\n|',
"tagClose": "\n|}\n",
"sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images.wikia.com/nonciclopedia/images/0/0c/Button_Chuck.png",
"speedTip": "tag generico",
"tagOpen": "{{",
"tagClose": "||firma=~~" + "~~{{VF|" + wgCurRevisionId + "}" + "}" + "}" + "}\n\n",
"sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images2.wikia.nocookie.net/nonciclopedia/images/a/a5/Button_Samara.png",
"speedTip": "scadenza",
"tagOpen": "{" + "{scadenza|{" + "{subst:7g}" + "}|note=",
"tagClose": "|firma=~~" + "~~{{VF|" + wgCurRevisionId + "}" + "}" + "}" + "}\n\n",
"sampleText": ""};
}
if(wgCurRevisionId)
mwEditButtons[9].tagOpen = '--~~' + '~~{{VF|' + wgCurRevisionId + '}' + '}';
else
mwEditButtons[9].tagOpen = '--~~' + '~~{{VF|}' + '}';
if (getElementsByClass(document, "editpage-copywarn-tools", 'table')) collapseTable(1);
}
}
addOnloadHook(Main);
function FastOpen() {
var Box = document.getElementById("searchBody");
if (!Box) return;
var form = document.createElement("form");
Box.appendChild(form);
form.style.position = "absolute";
form.style.top = "60px";
form.action = "/index.php";
form.target = "_blank";
var c = document.createElement("input");
form.appendChild(c);
c.type = "text";
c.setAttribute('name', "title");
c.size = "13";
var menu = document.createElement("select");
form.appendChild(menu);
menu.setAttribute('name', "action");
menu.options[menu.length] = new Option("Modifica", "edit", true);
menu.options[menu.length] = new Option("Cronol", "history");
menu.options[menu.length] = new Option("Elimina", "delete");
var p = document.createElement("input");
p.type = "submit";
p.value = "vai";
form.appendChild(p);
}
/* addOnloadHook(function () {
var b = document.getElementById("quicksaveButton");
if (!b) return;
b.removeEventListener('click', quicksave, false);
b.addEventListener('click', quicksaveX, false);
return;
});
addOnloadHook(function () {
var b = document.getElementById("quickpreviewButton");
if (!b) return;
b.removeEventListener('click', quickpreview, false);
b.addEventListener('click', quickpreviewX, false);
return;
});
*/
function quicksaveX () {
var textbox = document.getElementById("wpTextbox1");
textbox.disabled = true;
document.getElementById("wpSave").disabled = true;
document.getElementById("quicksaveButton").disabled = true;
var temp = null;
temp = document.getElementById("quickpreviewButton");
if (temp) temp.disabled = true;
var Source = encodeURIComponent(textbox.value);
var msg_box = document.getElementById("quicksave_msgbox");
if (msg_box == null) {
msg_box = document.createElement('div');
msg_box.id = "quicksave_msgbox";
document.getElementById('content').insertBefore(msg_box, document.getElementById('firstHeading'));
}
else msg_box.innerHTML = '';
var httpRequest = createRequest();
var id = setTimeout(function() { httpRequest.abort(); msg_box.innerHTML = "Salvataggio fallito: il server non risponde.".fontcolor('Red'); Finish(false); }, 30000);
httpRequest.onreadystatechange = function () { Response(httpRequest, id); return;};
var url = wgServer + wgScriptPath + "/api.php";
var param = "action=edit&format=txt&title=" + encodeURIComponent(wgPageName);
param += "&token=" + document.getElementsByName("wpEditToken")[0].value.replace(/\+\\/, '%2' + "B%5" + 'C');
temp = document.getElementById("wpSummary");
if (temp) param += "&summary=" + encodeURIComponent(temp.value);
temp = document.getElementById("wpCaptchaId");
if (temp) param += "&captchaid=" + temp.value + "&captchaword=" + encodeURIComponent(document.getElementById("wpCaptchaWord").value);
temp = document.getElementById("wpMinoredit");
if (temp && temp.checked) param += "&minor=";
temp = document.getElementById("wpWatchthis");
if (temp) {
var Watched = temp.checked;
if (document.getElementById('ca-watch') && Watched) param += "&watch=";
if (document.getElementById('ca-unwatch') && !Watched) param += "&unwatch=";
}
param += "&basetimestamp=" + document.getElementsByName("wpEdittime")[0].value;
param += "&starttimestamp=" + document.getElementsByName("wpStarttime")[0].value;
param += "&text=" + Source;
param += "&md5=" + MD5(textbox.value);
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
httpRequest.setRequestHeader('Content-Length', param.length);
document.getElementsByTagName('body')[0].style.cursor = 'progress';
httpRequest.send(param);
return;
function Response (o, id) {
if (o.readyState != 4) return;
clearTimeout(id);
msg_box.scrollIntoView();
if (o.status != 200) {
if (o.status && (o.status < 199 || o.status > 300)) {
msg_box.innerHTML = "Salvataggio fallito. Risposta del server: ".fontcolor('Red') + o.status.fontcolor('Red');
Finish(false);
}
return;
}
msg_box.innerHTML = o.responseText;
Finish(true);
return;
}
function Finish(success) {
document.getElementById("wpSave").disabled = false;
document.getElementById("quicksaveButton").disabled = false;
document.getElementsByTagName('body')[0].style.cursor = 'auto';
textbox.disabled = false;
return;
}
} // <-quicksaveX()
var disable_gif_hack = false;
function gif_hack () {
if (disable_gif_hack) return false;
var MAX_GIFHACK_COOKIES = 10;
var a_images = getElementsByClass(document.getElementById('bodyContent'), 'image', 'a');
if (!a_images.length) return;
var gif_thumbs = new Array();
var img;
for (var i = 0; i < a_images.length; i++) {
img = a_images[i].getElementsByTagName('img')[0];
if (/\.gif$/i.test(img.src) && /\/images\/thumb\//.test(img.src)) gif_thumbs.push(img)
}
if (!gif_thumbs.length) return;
var ani_gif_urls;
get_urls();
var thumb_name, gif_name, tmp;
for (var I = 0; I < gif_thumbs.length; I++) {
tmp = gif_thumbs[I].src.split('/');
thumb_name = tmp[tmp.length - 1];
thumb_name = thumb_name.replace(/\d+px-/, '');
document.getElementsById("debug").innerHTML += '<br />' + thumb_name;
for (i = 0; i < ani_gif_urls.length; i++) {
tmp = ani_gif_urls[i].split('/');
gif_name = tmp[tmp.length - 1] + ".gif";
if (thumb_name.toLowerCase() == gif_name.toLowerCase()) {
gif_thumbs[I].src = "http://images.wikia.com/nonciclopedia/images/" + ani_gif_urls[i] + ".gif";
break;
}
}
}
return;
function get_urls() {
var cookie = getCookie("ani_gif_urls_0");
if (cookie == null) {
ani_gif_urls = new Array ();
Request(null);
return;
}
var tmp;
for (var i = 1; i < MAX_GIFHACK_COOKIES; i++) {
tmp = getCookie("ani_gif_urls_" + i.toString());
if (tmp = null) break;
cookie += tmp;
}
ani_gif_urls = cookie.split('|');
return;
}
function Request(gcmcontinue) {
var httpRequest = createRequest();
var id = setTimeout(function() { httpRequest.abort();}, 30000);
var param = "/api.php?action=query&format=xml&generator=categorymembers&gcmtitle=Category:Immagini_gif&gcmnamespace=6&gcmprop=title&gcmlimit=500&prop=imageinfo&iiprop=url";
if (gcmcontinue) param += "&gcmcontinue=" + encodeURIComponent(gcmcontinue);
httpRequest.onreadystatechange = function () { Receive(httpRequest, id); return; }
httpRequest.open('GET', wgServer + wgScriptPath + param, true);
httpRequest.send('');
return;
}
function Receive(o, id) {
if (o.readyState != 4) return;
clearTimeout(id);
if (o.status != 200) return;
var xml = o.responseXML;
if (xml == null) return;
if (xml.normalize) xml.normalize();
var ii = xml.getElementsByTagName('ii');
for (var i = 0; i < ii.length; i++) {
ani_gif_urls.push(ii[i].getAttribute('url').replace("http://images.wikia.com/nonciclopedia/images/", ''));
}
if (xml.getElementsByTagName('query-continue').length) Request(xml.getElementsByTagName('categorymembers')[0].getAttribute('gcmcontinue'));
else { // lista finita: salva cookie;
var exp = new Date();
exp.setDate(exp.getDate() + 7);
exp = ";expires=" + exp.toUTCString();
var t = escape(ani_gif_urls.join('|'));
t = t.replace(/\.gif/i, '');
var l = 3200;
var m = Math.floor(t.length / l) + 1;
if (m > MAX_GIFHACK_COOKIES) m = MAX_GIFHACK_COOKIES;
for (var i = 0; i < m; i++) {
document.cookie = "ani_gif_urls_" + i.toString() + '=' + t.substr(i*l, l) + exp;
}
}
return;
}
}