MediaWiki:ToolsSuperati.js

Da Wikisource.

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
/* neutralizzati per fine lavori 
* cicceide()
* cicceide1()
* cicceide2()
* canz1()
* canz2()
* testoPoesia()

*/
function cicceide(testo) {
testoSel=selection();
testo=testoSel[1].split("\n");
numero=testo[1].toLocaleUpperCase().replace(".","");
testo[0]="<section begin="+numero+" />{" + "{"+"Centrato}}''"+testo[0]+"''\n";
testo[1]="{" + "{"+"Sc|"+numero.toLocaleLowerCase()+".}}</div>\n";
testo[2]="<poem>{" + "{"+"Capolettera|"+testo[2].substring(0,1)+"}}"+testo[2].substring(1);
testo[3]="     "+testo[3];
testo[4]="     "+testo[4];
testo[5]="     {" + "{"+"R|4}}"+testo[5];
testo[7]="     "+testo[7];
testo[8]="     "+testo[8];
testo[9]="     {" + "{"+"R|8}}"+testo[9];
testo[11]="     "+testo[11];
testo[12]="     {" + "{"+"R|11}}"+testo[12];
testo[14]="     "+testo[14];
testo[15]="     {" + "{"+"R|14}}"+testo[15]+"</poem><section end="+numero+" />\n\n";
testoSel[1]=testo.join("\n").replace(/f/g,"s");
scriviBox(testoSel.join(""));
}
 


function cicceide1() {np=r2n(mw.config.get("wgTitle").substring(mw.config.get("wgTitle").lastIndexOf("/")+1)); 
 
if (np.isOdd()) {npp=(np/2)+9; ns="1";}
//else {if (np<80) {npp=(np-1)/2+8; ns="2";}
else {npp=(np-1)/2+9; ns="2";}
//}
schema='{' + '{'+'Qualità|avz=25%|data=17 marzo 2012|arg=da definire}}'+
'{' + '{' + 'IncludiIntestazione|sottotitolo=#np|Argomento=Sonetti|prec=../#p|succ=../#s}}\n\n<pages index="La Cicceide legittima.djvu" from=#npp to=#npp fromsection=#ns tosection=#ns />';
codice=schema
.replace("#np",n2r(np))
.replace("#p",n2r(np-1))
.replace("#s",n2r(np+1))
.replace(/#ns/g,n2r(np))
.replace(/#npp/g,npp);
scriviBox(codice);}  


function cicceide1() {alert("Funzione disabilitata per fine opera.\nSi suggerisce di rimuovere un eventuale bottone di chiamata");}

function cicceide2() {np=r2n(mw.config.get("wgTitle").substring(mw.config.get("wgTitle").lastIndexOf("/")+1)); 
if (np>80) {alert("Silvioooo!\nLe sghignazzate so' finite! ;-) "); return; }
if (np.isOdd()) {npp=(np/2)+176; ns="1";}
else {npp=(np+1)/2+176; ns="2";}

schema='{' + '{'+'Qualità|avz=25%|data=17 marzo 2012|arg=da definire}}'+
'{' + '{'+'IncludiIntestazione|sottotitolo=#np|Argomento=Sonetti|prec=../#p|succ=../#s}}\n\n<pages index="La Cicceide legittima.djvu" from=#npp to=#npp fromsection=#ns tosection=#ns />';
codice=schema
.replace("#np",n2r(np))
.replace("#p",n2r(np-1))
.replace("#s",n2r(np+1))
.replace(/#ns/g,n2r(np))
.replace(/#npp/g,npp);
scriviBox(codice);}



testoPoesia=function(numero) {
   
   var html=$.ajax({url:"http://it.wikisource.org/w/index.php?action=raw&title=Discussioni indice:Le rime di M. Francesco Petrarca I.djvu"+"&random=2",async:false}).responseText; // "&random="+Math.random()
   html=find_stringa(html,"{|","|}").split("\n");
   for (i=0;i<html.length;i+=1) {
       html[i]=html[i].split("||");
   }
   
   for (i=0;i<html.length;i+=1) {
       if (html[i][2]==numero) break;
   }
   testo=$.ajax({url:"http://it.wikisource.org/w/index.php?action=raw&title=Canzoniere (Rerum vulgarium fragmenta)/"+html[i][1]+"&random="+Math.random(),async:false}).responseText;
   testo=find_stringa(testo,"<poem>","</poem>",0);
   return testo;
}


canz1=function() {
var s=selection();
numero=s[1].replace(".","").split(" ");
numero=numero[0].substring(0,1).toLocaleUpperCase()+numero[0].substring(1).toLocaleLowerCase()+" "+numero[1].toLocaleUpperCase();
testo=testoPoesia(numero);
s[1]=testo;
testo=testo.replace(/\n\n/g,"\n")
    .replace(/\{\{r\|\d+\}\}/gi,"")
    .split("\n");

while (testo[0].trim()=="") testo.shift();
for (i=0;i<testo.length;i+=1) {testo[i]=testo[i].substring(0,1).toLocaleUpperCase()+testo[i].substring(1);}
if (numero.substring(0,7)=="Sonetto") {
   firstSpace=testo[0].indexOf(" ");
   testo[0]='<section begin="'+numero+'" />'+  
            "{" + "{"+"Centrato|l=25em|{" + "{"+"Type|f=1.3em|l=6px|w=0.2em|"+numero.toLocaleUpperCase()+".}}}}\n\n"+
            "<poem>\n{" + "{"+"Capolettera|"+testo[0].substring(0,1)+"}}"+
            "{" + "{"+"Sc|"+testo[0].substring(1,2).toLocaleUpperCase()+testo[0].substring(2,firstSpace)+"}}"+
            testo[0].substring(firstSpace);
   testo[1]="     "+testo[1];
   testo[2]="     "+testo[2];
   testo[3]="     {" + "{"+"R|4}}"+testo[3];
   testo[4]=""+testo[4];
   testo[5]="     "+testo[5];
   testo[6]="     "+testo[6];
   testo[7]="     {" + "{"+"R|8}}"+testo[7];
   testo[8]=""+testo[8];
   testo[9]="     "+testo[9];
   testo[10]="     {" + "{"+"R|11}}"+testo[10];
   testo[11]=""+testo[11];
   testo[12]="     "+testo[12];
   testo[13]="     {" + "{"+"R|14}}"+testo[13]+"</poem>\n"+'<section end="'+numero+'" />\n\n\n';
   }
   else {
       for (i=0;i<testo.length;i+=1){
       if ((i+1)%5==0) {testo[i]="{" + "{"+"R|"+(i+1)+"}}"+testo[i];  }
}
       testo[0]='<section begin="'+numero+'" />'+
            "{" + "{"+"Centrato|l=25em|{" + "{"+"Type|f=1.3em|l=6px|w=0.2em|"+numero.toLocaleUpperCase()+".}}}}\n\n"+
            "<poem>\n{" + "{"+"Capolettera|"+testo[0].substring(0,1)+"}}"+
            testo[0].substring(1,2).toLocaleUpperCase()+testo[0].substring(2);
       testo[testo.length-1]=testo[testo.length-1]+"</poem>\n"+'<section end="'+numero+'" />\n\n\n';

   }
   s[1]=testo.join("\n").replace(/é/g,"è")
     .replace(/í/g,"ì")
     .replace(/ú/g,"ù");
scriviBox(s.join(""));
}

function canz2() {
s=selection();
testo=s.join("");
sectionBegin=find_stringa(testo,'<section begin="Canzone',"/>",1);
sectionEnd=find_stringa(testo,'<section end="Canzone',"/>",1);
s[1]=s[1]+"</poem>\n"+sectionEnd+"\n\n"+sectionBegin+"<poem>";
scriviBox(s.join(""));
}