Utente:Phe/common.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Phe (discussione | contributi)
Contenuto sostituito con ' mw.loader.load('/https://fr.wikisource.org/w/index.php?title=Utilisateur:Phe/hocr.js&action=raw&ctype=text/javascript&dontcountme=s');'
Riga 1:
mw.loader.load('/https://fr.wikisource.org/w/index.php?title=Utilisateur:Phe/hocr.js&action=raw&ctype=text/javascript&dontcountme=s');
// Please test these functions into Indice:La pastorizia.djvu (pages from 70)
 
 
// Returns the index of lista (a list of strings) with the highest "index of similarity" for s1
function bestMatch(s1,lista) {
var best=0;
var bestEl=0;
for (var i=0;i<lista.length;i+=1) {
similCor=simil(s1,lista[i]); if (similCor>best) {best=similCor; bestEl=i;}
}
return bestEl;}
// In Genko browsers gives the text before and after the pointer (-10-+10 characters)
function getIntorno() {boxTesto=$("textarea")[1]; var intorno=$(boxTesto).val().substring(boxTesto.selectionStart-10,boxTesto.selectionStart+10); return intorno;}
// When exists a datiPagina object, where datiPagina["righe"] is the list of coordinates x1,y1,x2,y2 and text of the line,
// the function gets the text around the pointer, selects the better matching line, and calls highlightLine()
function evidenziaRiga() {
var s1=getIntorno();
var best=0;
var bestEl=0;
for (var i=0;i<datiPagina["righe"].length;i+=1) {
similCor=simil(s1,datiPagina["righe"][i][4]); if (similCor>best) {best=similCor; bestEl=i;}
}
highlightLine(bestEl);}
 
// Line highlighting; when exists a datiPagina object, where datiPagina["righe"] is the list of coordinates x1,y1,x2,y2
// and text of the line, it highlights the line with index riga into the image
function highlightLine(riga) {
$("#lineHighlighting").remove();
if (datiPagina["righe"][riga]==undefined) {alert("Numero riga fuori scala o datiPagina non caricati"); return;}
fattoreScala=$('#ProofReadImage').attr("width")/datiPagina["xypagina"][0];
altezzaImmagine=datiPagina["xypagina"][1]*fattoreScala;
posizioneX=datiPagina["righe"][riga][0]*fattoreScala;
posizioneY=(datiPagina["xypagina"][1]-datiPagina["righe"][riga][3])*fattoreScala;
larghezzaRiga=(datiPagina["righe"][riga][2]-datiPagina["righe"][riga][0])*fattoreScala;
altezzaRiga=(datiPagina["righe"][riga][3]-datiPagina["righe"][riga][1])*fattoreScala;
$('<div id="lineHighlighting" style="position:absolute;top:'+posizioneY+'px;left:'+posizioneX+'px;width:'+larghezzaRiga+'px;height:'+altezzaRiga+'px; background-color: #aaaaff; opacity:0.3; filter:alpha(opacity=30); /* For IE8 and earlier */"></div>').appendTo('#pr_container');
}
 
if (mw.config.get('proofreadPageIsEdit') == 1) {
$("#wpTextbox1").dblclick( function () { evidenziaRiga(); });
}
 
/*
//Creates a small tattoo named "Phe script" into the right bottom corner of the screen to run evidenziaRiga()
if (wgAction=="edit" || wgAction=="submit"){
var tattooDiv='<div id="tattoo" style="position:fixed;background-color:transparent;bottom:2px;right:80px;z-index:1003;display:block">';
tattooDiv+='<small><a href="javascript:evidenziaRiga()">Phe script </a></small>';
tattooDiv+='</div>';
document.getElementById("editform").innerHTML += tattooDiv;
} */
// Shows a fixed small green arrow/link to evidenziaRiga(), but only when datiPagina["righe"] is defined
$(document).ready(function() {if (wgCanonicalNamespace == "Pagina" && wgAction == "edit" && datiPagina["righe"]!=undefined)
$('<div style="position:absolute;top:50px;right:0px;z-index:500;"><a href="javascript:evidenziaRiga()"><img src="http://upload.wikimedia.org/wikipedia/commons/7/73/Arrow_green.svg" /></a></div>').appendTo($(".wikiEditor-ui-text"));
}
);