Utente:Sanjilops/monobook.js: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
mNessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 98: | Riga 98: | ||
function quickpreview () { |
function quickpreview () { |
||
⚫ | |||
var previewArea = document.getElementById("wikiPreview"); |
var previewArea = document.getElementById("wikiPreview"); |
||
if (previewArea == null) return false; |
if (previewArea == null) return false; |
||
Riga 120: | Riga 121: | ||
if (start < end) t = textbox.value.slice(start, end); |
if (start < end) t = textbox.value.slice(start, end); |
||
else t = textbox.value; |
else t = textbox.value; |
||
t = t.replace(/\n==/, "__TOC__ |
t = t.replace(/\n==/, "__TOC__\n=="); |
||
t = t.replace(/\n/g, "%0A"); |
t = t.replace(/\n/g, "%0A"); |
||
t = t.replace(/&/g, "%26"); |
t = t.replace(/&/g, "%26"); |
||
t = t.replace(/\[\[ ??categor(?:ia|y):.+?\]\]/gi, ""); |
|||
t = t.replace(/\[\[\w\w:.+?\]\]/gi, ""); // rimuove interlink |
|||
document.getElementsByTagName('body')[0].style.cursor = 'progress'; |
document.getElementsByTagName('body')[0].style.cursor = 'progress'; |
||
quickpreviewRequest(t); |
quickpreviewRequest(t); |
||
Riga 131: | Riga 134: | ||
function quickpreviewRequest(text) { |
function quickpreviewRequest(text) { |
||
const max = 700; |
const max = 700; |
||
var t = text.split(/(%0A){2,}/, 1); |
|||
⚫ | |||
if (t.length > max) t = t.slice(0, max); |
|||
var r = text.slice(t.length); |
|||
var httpRequest = new XMLHttpRequest(); |
var httpRequest = new XMLHttpRequest(); |
||
var id = setTimeout(function() { httpRequest.abort(); alert("Errore: |
var id = setTimeout(function() { httpRequest.abort(); alert("Errore: il server non risponde"); document.getElementsByTagName('body')[0].style.cursor = 'auto';}, 30000); |
||
httpRequest.onreadystatechange = function () { quickpreviewWrite(httpRequest, r, id); }; |
httpRequest.onreadystatechange = function () { quickpreviewWrite(httpRequest, r, id); }; |
||
⚫ | |||
httpRequest.open('GET', url + text.slice(0, max), true); |
httpRequest.open('GET', url + text.slice(0, max), true); |
||
httpRequest.send(''); |
httpRequest.send(''); |
||
Riga 159: | Riga 164: | ||
var t, code = '';; |
var t, code = '';; |
||
t = o.responseXML.getElementsByTagName('text')[0].firstChild; |
t = o.responseXML.getElementsByTagName('text')[0].firstChild; |
||
const max_len = |
const max_len = 4096; |
||
code += t.data; |
code += t.data; |
||
if (t.length > max_len) { |
if (t.length >= max_len) { |
||
code += " |
code += "*** [lunghezza frammento eccessiva] ***"; |
||
} |
} |
||
var previewArea = document.getElementById("wikiPreview"); |
var previewArea = document.getElementById("wikiPreview"); |
||
Riga 176: | Riga 181: | ||
function quickpreviewLoad() { |
function quickpreviewLoad() { |
||
⚫ | |||
var buttons = document.getElementsByClassName("editButtons")[0]; |
var buttons = document.getElementsByClassName("editButtons")[0]; |
||
if (buttons == null) return; |
if (buttons == null) return; |
Versione delle 13:09, 3 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 () {
if (navigator.appName == 'Microsoft Internet Explorer') {alert("Non compatibile con IE. Passa a Firefox!"); return;}
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 = document.getElementsByClassName("mw-newarticletext")[0];
if (temp) temp.style.display = 'none';
temp = document.getElementsByClassName("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;
quickpreview_firstLoad = false;
}
var textbox = document.getElementById("wpTextbox1");
var t;
var start = textbox.selectionStart, end = textbox.selectionEnd;
if (start < end) t = textbox.value.slice(start, end);
else t = textbox.value;
t = t.replace(/\n==/, "__TOC__\n==");
t = t.replace(/\n/g, "%0A");
t = t.replace(/&/g, "%26");
t = t.replace(/\[\[ ??categor(?:ia|y):.+?\]\]/gi, "");
t = t.replace(/\[\[\w\w:.+?\]\]/gi, ""); // rimuove interlink
document.getElementsByTagName('body')[0].style.cursor = 'progress';
quickpreviewRequest(t);
return;
}
function quickpreviewRequest(text) {
const max = 700;
var t = text.split(/(%0A){2,}/, 1);
if (t.length > max) t = t.slice(0, max);
var r = text.slice(t.length);
var httpRequest = new XMLHttpRequest();
var id = setTimeout(function() { httpRequest.abort(); alert("Errore: il server non risponde"); document.getElementsByTagName('body')[0].style.cursor = 'auto';}, 30000);
httpRequest.onreadystatechange = function () { quickpreviewWrite(httpRequest, r, id); };
const url = wgServer + "/api.php?action=parse&title=" + encodeURI(wgPageName) + "&format=xml&prop=text&text=__NOTOC__%0A__NOEDITSECTION__%0A";
httpRequest.open('GET', url + text.slice(0, max), true);
httpRequest.send('');
return;
}
function quickpreviewWrite(o, text, 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);
document.getElementsByTagName('body')[0].style.cursor = 'auto';
}
return;
}
if (o.responseXML == null) {
alert("Anteprima non riuscita (errore del parser?)");
document.getElementsByTagName('body')[0].style.cursor = 'auto';
return;
}
var t, code = '';;
t = o.responseXML.getElementsByTagName('text')[0].firstChild;
const max_len = 4096;
code += t.data;
if (t.length >= max_len) {
code += "*** [lunghezza frammento eccessiva] ***";
}
var previewArea = document.getElementById("wikiPreview");
previewArea.innerHTML += code;
if (text) quickpreviewRequest(text);
else {
document.getElementsByTagName('body')[0].style.cursor = 'auto';
}
return;
}
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 = "quickpreview";
b.marginRight = "0.33em";
b.addEventListener('click', quickpreview, true);
buttons.insertBefore(b, document.getElementById("wpDiff"));
document.getElementById("wpPreview").value = "Anteprima";
buttons.getElementsByClassName("editHelp")[0].style.display = 'none';
return;
}