User:Candalua/vector.js
Jump to navigation
Jump to search
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> */
//disable ThomasV's "simplified lst"
self.proofreadpage_raw_lst=true;
//Aggiunge un pulsante generico alla Toolbar
function addToolbarButton(id, href, src, alt, title) {
var toolbar = document.getElementById("toolbar");
if(toolbar) {
var tmp = document.createElement("a");
tmp.id = id;
tmp.href = href;
var imag = document.createElement("img");
imag.setAttribute('src', src);
imag.setAttribute('alt', alt);
imag.setAttribute('title', title);
tmp.appendChild(imag);
toolbar.appendChild(tmp);
}
}
$( function() {
//mostra par default l'header
if ( document.getElementById("prp_header") ) document.getElementById("prp_header").style.cssText = '';
addToolbarButton('tb-split1', "javascript:insertTags('{{Split|','}}','')",
'http://upload.wikimedia.org/wikipedia/commons/9/96/1.svg', '[S1]', 'Inizio Split');
addToolbarButton('tb-split2', "javascript:insertTags('{{{{Split|end}}{{Split}}','','')",
'http://upload.wikimedia.org/wikipedia/commons/4/4d/2.svg', '[S2]', 'Split');
addToolbarButton('tb-split2p', "javascript:insertTags('</poem>{{Split|end}}{{Split}}<poem>','','')",
'http://upload.wikimedia.org/wikipedia/commons/4/4d/2.svg', '[S2P]', 'Split con poem');
addToolbarButton('tb-split3', "javascript:insertTags('{{Split|end}}','','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', '[S3]', 'Fine Split');
addToolbarButton('tb-poem', "javascript:insertTags('<poem>','</poem>','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', '<poem>', 'poem');
addToolbarButton('tb-center', "javascript:insertTags('<center>','</center>','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', '<center>', 'center');
addToolbarButton('tb-big', "javascript:insertTags('<big>','</big>','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', '<big>', 'big');
addToolbarButton('tb-span', "javascript:insertTags('<span style=\"font-size:200%\">','</span>','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', '<span>', 'font-size');
addToolbarButton('tb-ottave', "javascript:ottave()",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', 'Ottave', 'ottave');
addToolbarButton('tb-sec1', "javascript:insertTags('<section begin=1/>','','')",
'http://upload.wikimedia.org/wikipedia/commons/9/96/1.svg', '[s1]', 'Inizio section');
addToolbarButton('tb-sec2', "javascript:insertTags('<section end=1/><section begin=2/>','','')",
'http://upload.wikimedia.org/wikipedia/commons/4/4d/2.svg', '[s2]', 'section');
addToolbarButton('tb-sec2p', "javascript:insertTags('</poem><section end=1/><section begin=2/><poem>','','')",
'http://upload.wikimedia.org/wikipedia/commons/4/4d/2.svg', '[s2P]', 'section con poem');
addToolbarButton('tb-sec3', "javascript:insertTags('<section end=2/>','','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', '[s3]', 'Fine section');
addToolbarButton('tb-testa', "javascript:insertTags('<poem><center><big>','\n\n{{C|SONETTO}}</big></center>\n','')",
'http://upload.wikimedia.org/wikipedia/commons/8/8c/3.svg', 'testa', 'testa');
})
function scriviNumero(line, num, tl) {
var str = line;
var n = 0;
while (str.charAt(0) && str.charAt(0) == ' ') {
str = str.substring(1);
n++;
}
while (str.charAt(0) && str.charAt(0) == ':') {
str = str.substring(1);
n++;
}
if (n > 0) line = line.substring(0, n) + "{{"+tl+"|" + num + "}}" + line.substring(n);
else line = "{{"+tl+"|" + num + "}}" + line;
return line;
}
function numeroRiga(evt) {
if (evt.ctrlKey && evt.shiftKey) {
var testoCasella = document.getElementById("wpTextbox1").value;
var begin = testoCasella.lastIndexOf("<poem>");
var end = testoCasella.lastIndexOf("</poem>");
var prima = testoCasella.substring(0, begin+6);
var dopo = testoCasella.substring(end);
var lines = testoCasella.substring(begin+6, end).split("\n");
var num = 0;
var center = false;
var mod = 0;
var range = evt.charCode - 32;
//SHIFT + CTRL + Q: aggiunge il numero di riga al termine ogni strofa
if (evt.charCode == 81 || evt.charCode == 113) {
mod = 1;
}
//SHIFT + CTRL + [1..9]: aggiunge il numero di riga ogni x righe
else if ( (evt.charCode >= 33 && evt.charCode <= 41) || evt.charCode == 163 || evt.charCode == 47) {
mod = 2;
if (evt.charCode == 163) range = 3;
if (evt.charCode == 47) range = 7;
}
if (mod > 0) {
if (wgCanonicalNamespace == "Page") {
var num = parseInt(prompt("da che numero parto?", "0"));
}
for (var i=0; i < lines.length; i++) {
if (lines[i].toLowerCase().lastIndexOf("<center>") > -1) center = true;
if (!center && lines[i].replace(/\s/g,"") != "") {
num++;
if (mod == 1 && (i+1 >= lines.length || lines[i+1].replace(/\s/g,"") == "") ) {
lines[i] = scriviNumero(lines[i], num, "R");
}
if (mod == 2 && num % range == 0) {
lines[i] = scriviNumero(lines[i], num, "R");
}
}
if (lines[i].toLowerCase().lastIndexOf("</center>") > -1) center = false;
}
var out = lines[0];
for (var i=1; i < lines.length; i++) {
out = out + "\n" + lines[i];
}
document.getElementById("wpTextbox1").value = prima + out + dopo;
}
}
}
document.onkeypress = numeroRiga;
function ottave() {
var testoCasella = document.getElementById("wpTextbox1").value;
var begin = testoCasella.lastIndexOf("<poem>");
var end = testoCasella.lastIndexOf("</poem>");
var prima = testoCasella.substring(0, begin+6);
var dopo = testoCasella.substring(end);
var lines = testoCasella.substring(begin+6, end).split("\n");
var center = false;
var begin = false;
var num = parseInt(prompt("da che numero parto?", "0"));
for (var i=0; i < lines.length; i++) {
if (lines[i].toLowerCase().lastIndexOf("<center>") > -1) center = true;
if (lines[i].replace(/\s/g,"") == "") begin = true;
else {
if (!center && begin) {
begin = false;
num++;
lines[i] = scriviNumero(lines[i], num, "O");
}
}
if (lines[i].toLowerCase().lastIndexOf("</center>") > -1) center = false;
}
var out = lines[0];
for (var i=1; i < lines.length; i++) {
out = out + "\n" + lines[i];
}
document.getElementById("wpTextbox1").value = prima + out + dopo;
}
function postOCR() {
var editbox = document.getElementsByName('wpTextbox1')[0];
editbox.value = editbox.value.replace(/ /g, " ")
.replace(/ ,/g, ",")
.replace(/ ;/g, ";")
.replace(/ :/g, ":")
.replace(/ \./g, ".")
.replace(/ !/g, "!")
.replace(/ \?/g, ";")
.replace(/'1/g, "'l")
.replace(/1'/g, "'l'")
.replace(/I'/g, "l'")
.replace(/l' /g, "l'")
.replace(/L' /g, "L'")
.replace(/h' /g, "h'")
.replace(/s' /g, "s'")
.replace(/ \n/g, "\n")
.replace(/-\n/g, "")
.replace(/é/g, "è")
.replace(/ó/g, "ò")
.replace(/á/g, "à")
.replace(/ piu /g, " più ")
.replace(/zja/g, "zia")
.replace(/zjo/g, "zio")
.replace(/cbi/g, "chi")
.replace(/cbe/g, "che")
.replace(/gbi/g, "ghi")
.replace(/gbe/g, "ghe")
.replace(/cussi/g, "cussì")
.replace(/perche/g, "perchè")
.replace(/Perche/g, "Perchè")
.replace(/ pb /g, " pò ")
.replace(/ hb /g, " hò ")
.replace(/ alia /g, " alla ")
.replace(/ va /g, " và ")
.replace(/ ancuo /g, " ancuò ")
.replace(/quesr/g, "quest")
.replace(/ y /g, ", ")
.replace(/ y\n/g, ",\n")
.replace(/ 3 /g, ", ")
.replace(/ 3\n/g, ",\n")
}
//NASCONDI IL COPYWARN SOTTO LA CASELLA DI MODIFICA (da Utente:Alex_brollo/vector.js)
$( function ()
{
els = document.getElementsByTagName('div');
for (i = 0; i < els.length; i++) {
if ( els[i].className == "mw-newarticletext" || els[i].className == "mw-tos-summary") {
els[i].style.display="none";
}
}
if (document.getElementById("editpage-copywarn"))
document.getElementById("editpage-copywarn").style.display="none";
if (document.getElementById("editpage-copywarn2"))
document.getElementById("editpage-copywarn2").style.display="none";
if (document.getElementById("editpage-copywarn3"))
document.getElementById("editpage-copywarn3").style.display="none";
if (document.getElementById("editpage-tos-summary"))
document.getElementById("editpage-tos-summary").style.display="none";
})
/* </pre> */