risultati riferimenti, in progress

This commit is contained in:
cesare 2025-03-18 09:38:12 +01:00
parent 6d0dc88adf
commit dd76f21f6a
2 changed files with 44 additions and 29 deletions

View File

@ -1025,10 +1025,7 @@ $(document).ready(function() {
var noteAdded; var noteAdded;
jQuery(document).delegate(' .showcomments', 'click', function() { jQuery(document).delegate(' .showcomments', 'click', function() {
if (cantoDisplayed.includes('#vistaFrasi')) {
showCommentsInResult($(this).attr('id'), $(this).attr('class'))
return
}
var cid = $(this).attr('id'); var cid = $(this).attr('id');
var queryComment = false; var queryComment = false;
var idClass = $(this).attr('class'); var idClass = $(this).attr('class');
@ -1042,7 +1039,14 @@ $(document).ready(function() {
filterOn = false; filterOn = false;
} }
} }
if (!hasCommentsJson(cid)) {
if (cantoDisplayed.includes('#vistaFrasi')) {
commentsSQL=getCommentsInResult($(this).attr('id'), $(this).attr('class'))
if (commentsSQL.length==0)
return
}
if (!cantoDisplayed.includes('#vistaFrasi') && !hasCommentsJson(cid)) {
return return
} }
if (getListaIdCommenti().length > 0) { if (getListaIdCommenti().length > 0) {
@ -1135,32 +1139,43 @@ $(document).ready(function() {
}) })
function showCommentsInResult(tmpcid, tmpclass) { function getCommentsInResult(tmpcid, tmpclass) {
var queryComment = false;
var versicomments=[]
var myid=tmpcid.split('_') var myid=tmpcid.split('_')
//var parentClass = $(this).parent().attr('class');
filterOn = true;
if (tmpclass.includes("filterRiferimentiOn")) {
filterOn = true;
} else {
if (tmpclass.includes("filterRiferimentiOff")) {
filterOn = false;
}
}
var tmpresu = getRisultatiRiferimenti() var tmpresu = getRisultatiRiferimenti()
var resultComments = Object.groupBy(tmpresu, ({ Cantica }) => Cantica); var resultComments = Object.groupBy(tmpresu, ({ Cantica }) => Cantica);
var tcantica='Inferno' var tcantica='Inferno'
if (myid=='2') switch (myid[1]) {
tcantica='Purgatorio' case "2": tcantica = "Purgatorio";
if (myid=='3') break;
tcantica='Paradiso' case "3": tcantica = "Paradiso";
}
if (! tcantica in resultComments) if (! tcantica in resultComments)
return return versicomments
var tmpCanti=resultComments[tcantica] var tmpCanti=resultComments[tcantica]
var cantiComments=Object.groupBy(tmpresu, ({ Canto }) => Canto); var cantiComments=Object.groupBy(tmpCanti, ({ Canto }) => Canto);
if (myid[2].length==1)
myid[2]='0'+myid[2]
if (! myid[2] in cantiComments)
return versicomments
var tmpversi=cantiComments[myid[2]]
var isin=false
versicomments=Object.groupBy(tmpversi, ({ VersoCitazione }) => VersoCitazione);
for (const [keyt, value] of Object.entries(versicomments)) {
if (keyt == myid[3] || keyt.startsWith(myid[3] + '-')) {
isin= true
break
}
}
if (!isin)
versicomments=[]
return versicomments
} }

View File

@ -184,12 +184,13 @@ export async function getVersiConCitazioni(canticapar = '', cantopar = '') {
} }
async function getCitazioniInVerso(canticapar = '', cantopar = '', versovar='') { async function getCitazioniInVerso(canticapar = '', cantopar = '', versopar='') {
//let citcantiche = ['Inferno', 'Purgatorio', 'Paradiso'] //let citcantiche = ['Inferno', 'Purgatorio', 'Paradiso']
if (canticapar == '') { if (canticapar == '') {
return return
} }
const tconn = await db.connect(); const tconn = await db.connect();
var table = await tconn.query(` var table = await tconn.query(`
select Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione, select Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione,
@ -198,17 +199,16 @@ async function getCitazioniInVerso(canticapar = '', cantopar = '', versovar='')
RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto, RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto,
Aut as NomeAutoreCitazione, TiFo as TitoloFonteCitazione, Verso as VersoCitazione, CA as AreaTematica, Aut as NomeAutoreCitazione, TiFo as TitoloFonteCitazione, Verso as VersoCitazione, CA as AreaTematica,
TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie, TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie,
CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, Cantica, Canto n1, n2, n3 CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, Cantica, Canto, n1, n2, n3
from riferimenti from riferimenti
where Cantica='${canticapar}' and Canto='${cantopar}' and Verso='${versovar}' order by n1, n2, n3; where Cantica='${canticapar}' and Canto='${cantopar}' and (Verso='${versopar}' or Verso like '%${versopar}-%') order by n1, n2, n3;
`); `);
var resultvc = table.toArray().map((row) => row.toJSON()); var resultvc = table.toArray().map((row) => row.toJSON());
listariferimentirisultato=listariferimentirisultato.concat(resultvc)
await tconn.close(); await tconn.close();
listariferimentirisultato=listariferimentirisultato.concat(resultvc)
//console.log('CONCAT '+canticapar+', '+ cantopar+', '+versopar+', length:' +listariferimentirisultato.length)
//return resultvc //return resultvc
} }