Utente:Sanjilops/monobook.js: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
mNessun oggetto della modifica |
mNessun oggetto della modifica |
||
Riga 178:
for (i=0; i<R.length; i++) {
catname = R.item(i).firstChild.nodeValue;
catl = '<span
if (hiddenCats.indexOf(HCsep + catname + HCsep) == -1) normalcatlinks.push(catl);
else hiddencatlinks.push(catl);
|
Versione delle 21:24, 10 mag 2009
//disablehideEdit=1;
disablealertLoad=1;
disableaprilfish = 1;
function Main() {
FastOpen();
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")) {
quickpreviewLoad();
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|}' + '}';
}
}
addOnloadHook(Main);
function FastOpen() {
var Box = document.getElementById("searchBody");
if (!Box) return;
var form = document.createElement("form");
Box.appendChild(form);
form.action = "/index.php";
form.target = "_blank";
var c = document.createElement("input");
form.appendChild(c);
c.type = "text";
c.setAttribute('name', "title");
c.size = "20";
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");
form.appendChild(p);
p.type = "submit";
p.value = "vai";
}
var quickpreview_firstLoad = true;
function quickpreview () {
document.getElementById("quickpreviewButton").disabled = true;
var previewArea = document.getElementById("wikiPreview");
if (previewArea == null) return false;
previewArea.innerHTML = '';
if (quickpreview_firstLoad) {
previewArea.style.display = 'block';
var temp = document.getElementById("editintro");
if (temp) temp.style.display = 'none';
temp = getElementsByClass(document, "mw-newarticletext")[0];
if (temp) temp.style.display = 'none';
temp = getElementsByClass(document, "mw-warning-with-logexcerpt")[0];
if (temp) temp.style.display = 'none';
temp = document.getElementById("contentSub2");
if (temp) temp.style.display = 'none';
document.getElementById("firstHeading").innerHTML = wgPageName.replace(/_/g, ' ');
quickpreview_firstLoad = false;
}
var textbox = document.getElementById("wpTextbox1");
var Source;
var start = textbox.selectionStart, end = textbox.selectionEnd;
if (start < end) Source = textbox.value.slice(start, end);
else Source = textbox.value + '\n';
Source = Source.replace(/&/g, "%26");
document.getElementsByTagName('body')[0].style.cursor = 'progress';
var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
var id = setTimeout(function() { httpRequest.abort(); alert("Errore: il server non risponde"); Finish(false); }, 30000);
httpRequest.onreadystatechange = function () { Write(httpRequest, id); return;};
const url = wgServer + wgScriptPath + "/api.php";
const param = "action=parse&title=" + encodeURI(wgPageName) + "&format=xml&prop=text|categories&pst&text=__NOEDITSECTION__";
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
httpRequest.setRequestHeader('Content-Length', param.length + Source.length);
httpRequest.send(param + Source);
return;
function Write(o, id) {
if (o.readyState != 4) return;
clearTimeout(id);
if (o.status != 200) {
if (o.status && (o.status < 199 || o.status > 300)) {
alert("Anteprima non riuscita. Risposta del server: " + o.status);
Finish(false);
}
return;
}
if (o.responseXML == null) {
alert("Anteprima non riuscita (errore del parser?)");
Finish(false);
return;
}
if(o.responseXML.normalize) o.responseXML.normalize();
var R = o.responseXML.getElementsByTagName('text')[0].firstChild;
var code = R.data;
previewArea.innerHTML += code;
// aggiungi categorie
R = o.responseXML.getElementsByTagName('categories')[0].getElementsByTagName('cl');
if (R.length > 0) {
var catlinksBox = document.getElementById("catlinks");
if (catlinksBox != null) catlinksBox.innerHTML = '';
else {
catlinksBox = document.createElement('div');
catlinksBox.id = "catlinks";
catlinksBox.className = "catlinks";
document.getElementById("bodyContent").insertBefore(catlinksBox, getElementsByClass(document.getElementById("bodyContent"), "visualClear", 'div')[0]);
}
var normalcatlinks = new Array();
var hiddencatlinks = new Array();
var catname, catl, i;
const HCsep = '|';
const hiddencategories = new Array("Articoli_da_cancellare", "Articoli_da_formattare", "Articoli_da_restaurare", "Articoli_da_rifinire", "Articoli_da_sorvegliare", "Articoli_da_unire", "Articoli_in_costruzione", "Articoli_in_scadenza", "Articoli_orfani", "Articoli_prenotati", "Articoli_senza_immagini", "Articoli_sotto_accusa", "Immagini_da_modificare", "Immagini_da_rinominare", "Immagini_da_tradurre", "Immagini_sotto_copyright", "Immagini/Categorie_di_sistema", "Pagine_da_cancellare", "Pagine_da_controllare", "Pagine_in_costruzione", "Pagine_in_restauro", "Pagine_sotto_accusa", "Stub");
const hiddenCats = HCsep + hiddencategories.join(HCsep) + HCsep;
for (i=0; i<R.length; i++) {
catname = R.item(i).firstChild.nodeValue;
catl = '<span><a href="/wiki/Categoria:' + encodeURI(catname) + '" title="Categoria:' + catname.replace(/_/g, ' ') + '>' + catname.replace(/_/g, ' ') + '</a></span>';
if (hiddenCats.indexOf(HCsep + catname + HCsep) == -1) normalcatlinks.push(catl);
else hiddencatlinks.push(catl);
}
var tmp = '';
if (normalcatlinks.length > 0) {
var normalcatlinksBox = document.createElement('div');
normalcatlinksBox.id = "mw-normal-catlinks";
catlinksBox.appendChild(normalcatlinksBox);
tmp = "<a title='Speciale:Categorie' href='/wiki/Speciale:Categorie'>Categori" + ((normalcatlinks.length > 1)? "e</a>: " + normalcatlinks.join(" | ") : "a</a>: " + normalcatlinks[0]);
normalcatlinksBox.innerHTML = tmp;
}
if (hiddencatlinks.length > 0) {
var hiddencatlinksBox = document.createElement('div');
hiddencatlinksBox.id = "mw-hidden-catlinks";
hiddencatlinksBox.className = "mw-hidden-cats-hidden";
if (normalcatlinks.length == 0) catlinksBox.className += " catlinks-allhidden";
catlinksBox.appendChild(hiddencatlinksBox);
tmp = "Categori" + ((hiddencatlinks.length > 1)? "e nascoste: " + hiddencatlinks.join(" | ") : "a nascosta: " + hiddencatlinks[0]);
hiddencatlinksBox.innerHTML = tmp;
}
}
// mostra il toggle dell'indice
if (window.showTocToggle) { window.tocShowText = "mostra"; window.tocHideText = "nascondi"; showTocToggle(); }
// carica onloadhooks
addCss();
createCollapseButtons ();
createNavigationBarToggleButton(); // navframe
createToggleLinks(); // morph
rewriteTitle();
change_subtitle();
randomlist();
UserNameReplace();
Finish(true) // caricamento terminato
return;
}
function Finish(success) {
document.getElementsByTagName('body')[0].style.cursor = 'auto';
document.getElementById("quickpreviewButton").disabled = false;
return;
}
} // <- quickpreview();
function quickpreviewLoad() {
var buttons = document.getElementsByClassName("editButtons")[0];
if (buttons == null) return;
var b = document.createElement('input');
b.type = 'button';
b.value = "Ant. rapida";
b.id = "quickpreviewButton";
b.marginRight = "0.33em";
b.addEventListener('click', quickpreview, true);
buttons.insertBefore(b, document.getElementById("wpDiff"));
document.getElementById("wpPreview").value = "Anteprima";
document.getElementById("wpDiff").value = "Cambiamenti";
buttons.getElementsByClassName("editHelp")[0].style.fontSize = 'x-small';
return;
}