gestione risultati, in progress
This commit is contained in:
parent
86534b5b82
commit
16fefbe371
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getFormaCntxt, getListaIdCommenti, queryRiferimentimul } from './dataMgr_5.1.js';
|
||||
import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getFormaCntxtLastPosition, getListaIdCommenti, queryRiferimentimul } from './dataMgr_5.1.js';
|
||||
import { getJsonQuery, emptyStructCard } from './script_5.1.js';
|
||||
import { resetGraphStr } from './syntgraph_5.1.js'
|
||||
|
||||
|
@ -190,7 +190,7 @@ $(document).ready(function() {
|
|||
if ($(this).hasClass("disabled")) {
|
||||
return;
|
||||
};
|
||||
var posizioniEspansione = []
|
||||
//var posizioniEspansione = []
|
||||
var cid = $(this).attr('id');
|
||||
var parcid = cid.split('_');
|
||||
var posVerso
|
||||
|
@ -213,12 +213,13 @@ $(document).ready(function() {
|
|||
var setVersicontestoExp = new Set()
|
||||
for (var forma of versiContestoExp) {
|
||||
if (!setVersicontestoExp.has(forma.verso)) {
|
||||
divVersoExp = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
|
||||
//divVersoExp = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
|
||||
divVersoExp=createDivVersoGenericLi(forma.cantica + 1, forma.verso, forma.canto)
|
||||
$(reit).append(divVersoExp)
|
||||
setVersicontestoExp.add(forma.verso)
|
||||
}
|
||||
createSpanFormeNew(forma.testo, forma.catg, 'e' + forma.posizione, forma.periodo, forma.funzperiodo, divVersoExp)
|
||||
posizioniEspansione.push('e' + forma.posizione)
|
||||
//posizioniEspansione.push('e' + forma.posizione)
|
||||
}
|
||||
|
||||
if (cid.includes('_er_')) {
|
||||
|
@ -308,18 +309,21 @@ $(document).ready(function() {
|
|||
|
||||
}
|
||||
|
||||
function countResultContexts() {
|
||||
function countResultContexts() {
|
||||
var numeroRisultati = 0;
|
||||
if (listarisultati.length) {
|
||||
var ultimaPosizione = -1;
|
||||
for (var risultato of listarisultati) {
|
||||
|
||||
if (risultato <= ultimaPosizione) {
|
||||
continue;
|
||||
}
|
||||
numeroRisultati = numeroRisultati + 1;
|
||||
//ultimaPosizione=await getFormaCntxtLastPosition(risultato, contextLength)
|
||||
ultimaPosizione = getContextLastPosition(risultato, contextLength);
|
||||
}
|
||||
numeroContesti = numeroRisultati
|
||||
console.log('num contesti '+numeroContesti)
|
||||
return (numeroRisultati)
|
||||
}
|
||||
|
||||
|
@ -333,7 +337,7 @@ $(document).ready(function() {
|
|||
return (numeroRisultati)
|
||||
}
|
||||
|
||||
function getResInPage(startcont, endcont) {
|
||||
function getResInPage(startcont, endcont) {
|
||||
var res = [];
|
||||
var contaContesti = 0
|
||||
//console.log(listaClausoleRisultato)
|
||||
|
@ -349,6 +353,7 @@ $(document).ready(function() {
|
|||
}
|
||||
if (contaContesti > endcont)
|
||||
break;
|
||||
//ultimaPosizione=await getFormaCntxtLastPosition(risultato, contextLength)
|
||||
ultimaPosizione = getContextLastPosition(risultato, contextLength);
|
||||
}
|
||||
//ordino la lista dei risultati
|
||||
|
@ -378,8 +383,10 @@ $(document).ready(function() {
|
|||
var ultimaPosizione = 0;
|
||||
var numeroVersi;
|
||||
//const intsup = Math.min(start + offset, listarisultati.length)
|
||||
var t0 = performance.now();
|
||||
var resincontext = getResInPage(start, start + offset)
|
||||
|
||||
var t1 = performance.now();
|
||||
|
||||
for (let i = 0; i < resincontext.length; i++) {
|
||||
//risultato = listarisultati[i];
|
||||
var risultato = resincontext[i];
|
||||
|
@ -421,7 +428,8 @@ $(document).ready(function() {
|
|||
canto = forma.canto
|
||||
}
|
||||
if (!setVersicontesto.has(forma.verso)) {
|
||||
divVerso = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
|
||||
//divVerso = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
|
||||
divVerso=createDivVersoGenericLi(forma.cantica + 1, forma.verso, forma.canto)
|
||||
versiIniziali.append(divVerso)
|
||||
listaVersi.append(versiIniziali)
|
||||
elencoRisutati.append(listaVersi)
|
||||
|
@ -481,14 +489,22 @@ $(document).ready(function() {
|
|||
comandi.appendTo(elencoRisutati);
|
||||
|
||||
}
|
||||
|
||||
var t2=performance.now()
|
||||
console.log('res in context '+(t1-t0))
|
||||
console.log('list creation '+(t2-t1))
|
||||
//evidenzio resultati
|
||||
|
||||
var clausesinrs=[]
|
||||
for (var ris of listarisultati) {
|
||||
let idris = '#e' + ris
|
||||
if ($(idris).attr('class')!=null){
|
||||
console.log($(idris).attr('class').replace(' frm', ''))
|
||||
clausesinrs.push($(idris).attr('class').replace(' frm', ''))
|
||||
}
|
||||
|
||||
$(idris).addClass("font-weight-bold mark ")
|
||||
}
|
||||
|
||||
var t3=performance.now()
|
||||
console.log('mar res '+(t2-t3))
|
||||
//evidenzio i periodi se unità di ricerca è impostato come periodo
|
||||
if (listaPeriodiRisultato.length) {
|
||||
for (var msid of listaPeriodiRisultato) {
|
||||
|
@ -497,15 +513,23 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
}
|
||||
var t4=performance.now()
|
||||
console.log('load per '+(t3-t4))
|
||||
//evidenzio le frasi se unità di ricerca è frase
|
||||
if (listaClausoleRisultato.length) {
|
||||
for (var clsid of listaClausoleRisultato) {
|
||||
for (var clsid of clausesinrs){
|
||||
let tmpid = clsid.split(' ')
|
||||
loadClausola(tmpid[0], tmpid[1], 0,0)
|
||||
}
|
||||
/*for (var clsid of listaClausoleRisultato) {
|
||||
let tmpid = clsid.split('-')
|
||||
//loadFrase(tmpid[0], tmpid[1])
|
||||
loadClausola(tmpid[0], tmpid[1], tmpid[2], tmpid[3])
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
var t5=performance.now()
|
||||
console.log('load cla '+(t4-t5))
|
||||
|
||||
|
||||
}
|
||||
|
@ -695,8 +719,20 @@ $(document).ready(function() {
|
|||
|
||||
if (!isPeriodoInCanto(idperiodo, cantoDisplayed) && !(cantoDisplayed.includes('#vistaFrasi')))
|
||||
return
|
||||
|
||||
$(cantoDisplayed).find(' .' + idperiodo).each(function() {
|
||||
|
||||
$(cantoDisplayed).find(' .' + idperiodo+'.'+funzionefrase).each(function() {
|
||||
var tpstp = $(this).attr('class').split(" ")[1]
|
||||
$(this).css('color', colorssp(mapsynttypestopalette[tpstp]));
|
||||
|
||||
|
||||
})
|
||||
|
||||
minim.contents().find(' .' + idperiodo+'.'+funzionefrase).each(function() {
|
||||
var mtpstp = $(this).attr('class').split(" ")[1]
|
||||
$(this).css('color', colorssp(mapsynttypestopalette[mtpstp]));
|
||||
})
|
||||
|
||||
/*$(cantoDisplayed).find(' .' + idperiodo).each(function() {
|
||||
var vid = parseInt($(this).attr('id').replace('e', ''))
|
||||
if (vid >= parseInt(fromn)
|
||||
&& vid <= parseInt(ton)) {
|
||||
|
@ -706,9 +742,9 @@ $(document).ready(function() {
|
|||
$(this).css('color', colorssp(mapsynttypestopalette[pstp]));
|
||||
}
|
||||
|
||||
})
|
||||
})*/
|
||||
|
||||
minim.contents().find(' .' + idperiodo).each(function() {
|
||||
/*minim.contents().find(' .' + idperiodo).each(function() {
|
||||
var vid = parseInt($(this).attr('id').replace('e', ''))
|
||||
if (vid >= parseInt(fromn)
|
||||
&& vid <= parseInt(ton)) {
|
||||
|
@ -717,7 +753,7 @@ $(document).ready(function() {
|
|||
$(this).css('color', colorssp(mapsynttypestopalette[mpstp]));
|
||||
}
|
||||
|
||||
})
|
||||
})*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -896,6 +932,7 @@ $(document).ready(function() {
|
|||
var pio = $("#" + idCommento + t)
|
||||
if (pio.length)
|
||||
break;
|
||||
|
||||
if(t=='Proemio'){
|
||||
console.log(idminimap+' '+t)
|
||||
var elcanto=$("#" + 'Titolo'+idminimap)
|
||||
|
@ -1024,7 +1061,7 @@ $(document).ready(function() {
|
|||
var collapseNote = $('<div class="collapse show">');
|
||||
collapseNote.attr('id', "collapseNote" + id + '_' + pos)
|
||||
|
||||
if (comments.TestoFonteCitazione != null && comments.TestoFonteCitazione != "nan") {
|
||||
if (comments.TestoFonteCitazione != null && comments.TestoFonteCitazione != "nan" && comments.TestoFonteCitazione.trim() != "") {
|
||||
createModule(collapseCardBody, "Testo della fonte: ", removeHtmlTags(comments.TestoFonteCitazione), "1", id, pos)
|
||||
}
|
||||
if (comments.NaturaRiferimento != null) {
|
||||
|
@ -1157,10 +1194,11 @@ $(document).ready(function() {
|
|||
} else {
|
||||
luogoFonte = comments.LuogoFonteCitazione;
|
||||
}
|
||||
if (comments.URLFonteCitazione != null) {
|
||||
if (comments.URLFonteCitazione != null && comments.URLFonteCitazione.trim() != '') {
|
||||
rigaNota.append(' <b>Coordinate della fonte:</b><a href="' + comments.URLFonteCitazione + '"target="_blank"><i> ' + luogoFonte + '</i></a><br>');
|
||||
} else {
|
||||
rigaNota.append(' <b>Coordinate della fonte:</b><i> ' + luogoFonte + '</i><br>');
|
||||
if (luogoFonte!=null && luogoFonte.trim()!='')
|
||||
rigaNota.append(' <b>Coordinate della fonte:</b><i> ' + luogoFonte + 'ttttt</i><br>');
|
||||
}
|
||||
rigaNota.appendTo(commentHeader);
|
||||
buttons.appendTo(commentHeader);
|
||||
|
@ -1657,23 +1695,15 @@ $(document).ready(function() {
|
|||
if (formaItem[1] == canto) {
|
||||
if (!setVersiCanto.has(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])) {
|
||||
|
||||
var verso = parseInt(formaItem[3]) - 1;
|
||||
//var idCommento = "Commento_" + idcantica + "_" + canto + "_" + verso;
|
||||
//var commNumber = numberOfComments(idCommento);
|
||||
//var commNumber = numberOfCommentsJson(idCommento)
|
||||
|
||||
|
||||
|
||||
//var verso = parseInt(formaItem[3]) - 1;
|
||||
|
||||
|
||||
if (currSentenceId != null && currSentenceId != sentenceid) {
|
||||
|
||||
createSpanPeriodiTag(closeSTag, 'c', formaItem[2] - 1, currSentenceId, elverso, periodinum[currSentenceId])
|
||||
currSentenceId = null
|
||||
}
|
||||
/*if (commNumber > 0) {
|
||||
createCommentSpan(idCommento, elverso, commNumber)
|
||||
//console.log("Numero commenti: "+commNumber)
|
||||
}*/
|
||||
|
||||
//elverso=createDivVersoNew(cantica, formaItem[3], 'Canto_' + formaItem[1])
|
||||
elverso = createDivVersoLI(cantica, formaItem[3], 'Canto_' + formaItem[1])
|
||||
setVersiCanto.add(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])
|
||||
|
@ -1733,7 +1763,7 @@ $(document).ready(function() {
|
|||
|
||||
function createProemioSpan(idVerso, elementoverso, numberOfComments, spanid) {
|
||||
var spanoccorrenza = $('<span />')
|
||||
spanoccorrenza.attr('id', spanid)
|
||||
spanoccorrenza.attr('id', spanid+'_sp')
|
||||
var proemiooccorrenza = $('<button />')
|
||||
proemiooccorrenza.attr('id', idVerso)
|
||||
|
||||
|
@ -1820,43 +1850,39 @@ $(document).ready(function() {
|
|||
var spanoccorrenza = $('<span />')
|
||||
var nbsp = $('<span> </span>')
|
||||
spanoccorrenza.attr('id', pos)
|
||||
//spanoccorrenza.attr('data-cg', catgramm)
|
||||
|
||||
spanoccorrenza.attr('title', catgramm)
|
||||
spanoccorrenza.attr('class', sentenceid + " " + clausefunct + ' ' + formaClass)
|
||||
spanoccorrenza.append(forma)
|
||||
spanoccorrenza.appendTo(elementoverso)
|
||||
nbsp.appendTo(elementoverso)
|
||||
}
|
||||
/* function createDivVersoNew(cantica, num, canto) {
|
||||
|
||||
var elementoverso = createDivVersoGeneric(cantica, num, canto)
|
||||
|
||||
elementoverso.appendTo('#' + cantica + canto)
|
||||
return elementoverso
|
||||
|
||||
}*/
|
||||
|
||||
function createDivVersoLI(cantica, num, canto) {
|
||||
|
||||
var elementoverso = createDivVersoGenericLi(cantica, num, canto)
|
||||
let cantoContainer = $('#' + cantica + canto);
|
||||
elementoverso.appendTo(cantoContainer.find('ol'))
|
||||
return elementoverso
|
||||
|
||||
}
|
||||
var elementoverso = createDivVersoGenericLi(cantica, num, canto)
|
||||
let cantoContainer = $('#' + cantica + canto);
|
||||
elementoverso.appendTo(cantoContainer.find('ol'))
|
||||
var elementoversospan=$('<span />')
|
||||
elementoversospan.attr('id', cantica + "_" + canto + "_" + num+'_sp')
|
||||
elementoverso.append(elementoversospan)
|
||||
/*return elementoverso*/
|
||||
return elementoversospan
|
||||
|
||||
}
|
||||
function createDivVersoGenericLi(cantica, num, canto) {
|
||||
let digits = num.length
|
||||
/*let digits = num.length*/
|
||||
|
||||
var spannum = $('<span />')
|
||||
/*var spannum = $('<span />')
|
||||
|
||||
if (digits == 1)
|
||||
spannum.append('\xa0\xa0')
|
||||
if (digits == 2)
|
||||
spannum.append('\xa0')
|
||||
spannum.append(num + '. ')
|
||||
spannum.append(num + '. ')*/
|
||||
var elementoverso = $('<li />')
|
||||
//var elementoverso=$('<p />')
|
||||
/*var elementoversospan=$('<span />')*/
|
||||
//elementoverso.append(spannum)
|
||||
elementoverso.attr("value", num)
|
||||
|
||||
|
@ -1866,6 +1892,7 @@ $(document).ready(function() {
|
|||
//elementoverso.attr('class', 'text-nowrap ')//+cantica+' '+canto)
|
||||
|
||||
elementoverso.attr('id', cantica + "_" + canto + "_" + num)
|
||||
/*elementoverso.append(elementoversospan)*/
|
||||
elementoverso.append('\xa0')
|
||||
return elementoverso
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ const conn = await db.connect();
|
|||
|
||||
await conn.query(`
|
||||
CREATE TABLE riferimenti AS
|
||||
SELECT * FROM "https://lida.dantenetwork.it/js/data/riferimenti_4.parquet";
|
||||
SELECT * FROM "https://lida.dantenetwork.it/js/data/riferimenti_5.parquet";
|
||||
CREATE TABLE commedia AS
|
||||
SELECT * FROM "https://lida.dantenetwork.it/js/data/com.parquet";
|
||||
|
||||
|
@ -316,7 +316,7 @@ function showResult(resxcantica, cid) {
|
|||
}
|
||||
spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]'))
|
||||
for (const tmpvi of tmpv) {
|
||||
let myveid = '#' + cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0]
|
||||
let myveid = '#' + cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0]+'_sp'
|
||||
//console.log(myveid)
|
||||
listaidversi.push(myveid)
|
||||
listaidcommenti.push(tmpvi.IdRiferimento)
|
||||
|
@ -417,8 +417,9 @@ export async function queryRiferimenti(filtro, cid) {
|
|||
|
||||
await tconn.close();
|
||||
var resxcantica = Object.groupBy(result4, ({ Cantica }) => Cantica);
|
||||
|
||||
listaidversi = []
|
||||
return (showResult(resxcantica, cid))
|
||||
|
||||
/*listaidversi = []
|
||||
var numcid = cid.split('_')[1]
|
||||
for (var cantica in resxcantica) {
|
||||
var $nctags = $(' .navig-canto')
|
||||
|
@ -447,7 +448,7 @@ export async function queryRiferimenti(filtro, cid) {
|
|||
}
|
||||
spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]'))
|
||||
for (const tmpvi of tmpv) {
|
||||
let myveid = '#' + cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0]
|
||||
let myveid = '#' + cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0]+'_sp'
|
||||
|
||||
listaidversi.push(myveid)
|
||||
listaidcommenti.push(tmpvi.IdRiferimento)
|
||||
|
@ -461,8 +462,8 @@ export async function queryRiferimenti(filtro, cid) {
|
|||
drawMinimap(cid, true)
|
||||
|
||||
}
|
||||
/*console.log(resxcantica)*/
|
||||
return listaidversi
|
||||
console.log(resxcantica)
|
||||
return listaidversi*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -518,20 +519,21 @@ function filtroContesto(marray, cantica, op) {
|
|||
return filtrost
|
||||
}
|
||||
|
||||
//Contesto
|
||||
//Contesto per lista risultati
|
||||
|
||||
export async function getFormaCntxt(formaid, numversi = 3) {
|
||||
const tconn = await db.connect();
|
||||
export async function getFormaCntxtLastPosition(formaid, numversi = 3) {
|
||||
const tconn = await db.connect();
|
||||
var querycnt = "select * from commedia where index>=((select index from commedia where Position='" + formaid + "')-25) order by index limit 50"
|
||||
console.log(" " + formaid)
|
||||
var rs = await tconn.query(querycnt)
|
||||
/*console.log(" " + formaid)*/
|
||||
var rs = await tconn.query(querycnt)
|
||||
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||
|
||||
|
||||
console.log(result4)
|
||||
console.log('-----------------------------------------')
|
||||
/*console.log(result4.at(-1)['Position'])
|
||||
console.log('-----------------------------------------')*/
|
||||
|
||||
|
||||
await tconn.close();
|
||||
await tconn.close();
|
||||
return (result4.at(-1)['Position'])
|
||||
|
||||
}
|
||||
|
|
|
@ -210,22 +210,22 @@ function getContextLastPosition(formaid, numversi = 3) {
|
|||
var listaforme = formeprima;
|
||||
|
||||
var limitv = Math.max((numversi), 3)
|
||||
var maxpos = 0;
|
||||
|
||||
var offset = parseInt(formaid);
|
||||
|
||||
if (parseInt(formaid) > 33373 && parseInt(formaid) < 66588) {
|
||||
listaforme = formeseconda;
|
||||
cantica = 1;
|
||||
offset = parseInt(formaid) - 33374
|
||||
offset = offset - 33374
|
||||
|
||||
}
|
||||
if (parseInt(formaid) > 66587 && parseInt(formaid) < 99314) {
|
||||
listaforme = formeterza;
|
||||
cantica = 2;
|
||||
offset = parseInt(formaid) - 66588
|
||||
offset = offset - 66588
|
||||
|
||||
}
|
||||
maxpos = listaforme.length - 1
|
||||
var maxpos = listaforme.length - 1
|
||||
var pos = 0
|
||||
var startindex = Math.max(0, (offset - 25))
|
||||
|
||||
|
|
Loading…
Reference in New Issue