From a03677f59e47d61a68541b316cc9eaf8135fb2e1 Mon Sep 17 00:00:00 2001 From: cesare Date: Fri, 21 Mar 2025 10:43:46 +0100 Subject: [PATCH] gestione risultato vuoto, in progress --- js/browseMgr_5.1.js | 179 ++++++++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 83 deletions(-) diff --git a/js/browseMgr_5.1.js b/js/browseMgr_5.1.js index 8bceb0e..5ed6dae 100644 --- a/js/browseMgr_5.1.js +++ b/js/browseMgr_5.1.js @@ -570,7 +570,7 @@ $(document).ready(function() { //rimuove il grafo sintattico se c'è' resetGraphStr() emptyStructCard() - + $(".filterRiferimentiOn").css('display', 'none'); $(".filterRiferimentiOff").css('display', 'none'); @@ -580,12 +580,12 @@ $(document).ready(function() { const cid = $(this).attr('name').replace(" ", "_"); var telive = getListaRis() cantoDisplayed = "#" + cid; - - if(!telive.length > 0 || !showingComments){ + + if (!telive.length > 0 || !showingComments) { $('#displaynote').empty(); $('#displaynote').append($(emptyNoteList)) } - + showingComments = false; if (telive.length > 0) { @@ -1028,7 +1028,7 @@ $(document).ready(function() { var noteAdded; jQuery(document).delegate(' .showcomments', 'click', function() { - + var cid = $(this).attr('id'); var filterOn = true; var risultato; @@ -1044,63 +1044,63 @@ $(document).ready(function() { case "3": cantica = "Paradiso"; } - + if (idsRisultato.length > 0) { risultato = true; } else { risultato = false; } - + idRisultato = cantica + "_Canto_" + parcid[2] + "_" + parcid[3] + "_sp"; - if (idsRisultato.includes(idRisultato)){ + if (idsRisultato.includes(idRisultato)) { risultato = true; - }else{ + } else { risultato = false; } switch (parcid[0]) { - case "Commento": - case "CommentoRes": + case "Commento": + case "CommentoRes": - if (risultato){ - $(".filterRiferimentiOn").css('display', 'none'); - $(".filterRiferimentiOff").css('display', 'inline-block'); - filterOn = true; - }else{ - $(".filterRiferimentiOn").css('display', 'none'); - $(".filterRiferimentiOff").css('display', 'none'); - filterOn = false; - } - break; + if (risultato) { + $(".filterRiferimentiOn").css('display', 'none'); + $(".filterRiferimentiOff").css('display', 'inline-block'); + filterOn = true; + } else { + $(".filterRiferimentiOn").css('display', 'none'); + $(".filterRiferimentiOff").css('display', 'none'); + filterOn = false; + } + break; case "CommentoQuery": - if(parcid[4] == "On"){ - $(".filterRiferimentiOn").css('display','none'); - $(".filterRiferimentiOff").css('display','inline-block'); - filterOn = true; - }else{ - $(".filterRiferimentiOn").css('display','inline-block'); - $(".filterRiferimentiOff").css('display','none'); - filterOn = false; - } - break; + if (parcid[4] == "On") { + $(".filterRiferimentiOn").css('display', 'none'); + $(".filterRiferimentiOff").css('display', 'inline-block'); + filterOn = true; + } else { + $(".filterRiferimentiOn").css('display', 'inline-block'); + $(".filterRiferimentiOff").css('display', 'none'); + filterOn = false; + } + break; } - - + + if (cantoDisplayed.includes('#vistaFrasi')) { - commentsSQL=getCommentsInResult($(this).attr('id'), $(this).attr('class')) - if (commentsSQL.length==0) + commentsSQL = getCommentsInResult($(this).attr('id'), $(this).attr('class')) + if (commentsSQL.length == 0) return } - + if (!cantoDisplayed.includes('#vistaFrasi') && !hasCommentsJson(cid)) { return } - + var commentArea = $('#displaynote'); var idCommento = "CommentoQuery_" + parcid[1] + "_" + parcid[2] + "_" + parcid[3]; - - $(".filterRiferimentiOn").attr("id", idCommento+"_On") - $(".filterRiferimentiOff").attr("id", idCommento+"_Off") - + + $(".filterRiferimentiOn").attr("id", idCommento + "_On") + $(".filterRiferimentiOff").attr("id", idCommento + "_Off") + commentArea.empty() if ($('#noteCard0').length) { $("#noteCard0")[0].remove(); @@ -1112,7 +1112,7 @@ $(document).ready(function() { var currentGroup; allGrouplKeys.sort().some(function(k) { - if (k == id || k.startsWith(id + '-')) { + if (k == id || k.startsWith(id + '-')) { gruppoVersi = k if (gruppoVersi.includes("-")) { versText = ", Versi " + gruppoVersi; @@ -1125,53 +1125,53 @@ $(document).ready(function() { currentGroup.append(createNoteEntry(value, k, i, filterOn, risultato)) }); commentArea.append(currentGroup); - + if (!noteAdded && filterOn) { currentGroup.css('display', 'none'); - } + } } $('#tab-list #vis0-tab').tab('show') }) }) function getCommentsInResult(tmpcid, tmpclass) { - - var versicomments=[] - var myid=tmpcid.split('_') + + var versicomments = [] + var myid = tmpcid.split('_') var tmpresu = getRisultatiRiferimenti() - + var resultComments = Object.groupBy(tmpresu, ({ Cantica }) => Cantica); - - var tcantica='Inferno' + + var tcantica = 'Inferno' switch (myid[1]) { case "2": tcantica = "Purgatorio"; break; case "3": tcantica = "Paradiso"; } - - if (! tcantica in resultComments) + + if (!tcantica in resultComments) return versicomments - var tmpCanti=resultComments[tcantica] - 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); + var tmpCanti = resultComments[tcantica] + 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 + isin = true break } } if (!isin) - versicomments=[] - + versicomments = [] + return versicomments - + } function createNoteGroup(cantica, canto, versi, id, len) { @@ -1213,11 +1213,11 @@ $(document).ready(function() { function createNoteEntry(comments, id, pos, filterOn, risultato) { var idref = comments.IdRiferimento var noteCard = $('
'); - if(risultato){ + if (risultato) { if (isCommentInResult(idref)) { - var noteCard = $('
'); - noteAdded = true; - }else{ + var noteCard = $('
'); + noteAdded = true; + } else { if (filterOn) { noteCard.css("display", "none"); } else { @@ -1225,7 +1225,7 @@ $(document).ready(function() { } } } - + var collapseCardBody = $('
'); var divCampiSingoli = $('
'); //createNoteHeader(noteCard, comments, id, pos, cantica, parcid, saveVersoCitazione); @@ -1275,7 +1275,7 @@ $(document).ready(function() { } collapseCardBody.appendTo(collapseNote); collapseNote.appendTo(noteCard); - + return noteCard; } @@ -1857,7 +1857,7 @@ $(document).ready(function() { managePage(); //$("#loader").fadeOut(300); //$("#cantica0").trigger("click"); - + } else { return; } @@ -1883,7 +1883,7 @@ $(document).ready(function() { filterButton1.appendTo(cardRiferimenti) filterBottonAdded = true; } - + $("#collapseZero").collapse('show'); $("#collapseInferno").collapse('hide'); $("#collapsePurgatorio").collapse('hide'); @@ -2009,9 +2009,9 @@ $(document).ready(function() { var flagRisultato; for (var elverso of versicontesto) { if (versoCommentato(elverso)) { - if (uniq_res.includes(elverso)){ + if (uniq_res.includes(elverso)) { flagRisultato = true; - }else{ + } else { flagRisultato = false; } var tresa = elverso.split('_') @@ -2025,9 +2025,9 @@ $(document).ready(function() { var apio = $("#" + aidCommento) if (apio.length) continue; - elverso=elverso.replace('_Proemio', '_0') + elverso = elverso.replace('_Proemio', '_0') var myverso = $('#' + elverso.replace('sp', 'res')) - createCommentSpan(aidCommento, myverso, 1 ,flagRisultato) + createCommentSpan(aidCommento, myverso, 1, flagRisultato) } } /*var tmpresu=getRisultatiRiferimenti() @@ -2091,8 +2091,11 @@ $(document).ready(function() { var ultimaFormaCanto; let numeroPeriodo = 1; showingComments = false; - - formecantica.map(function(item) { + let startindex=800*(parseInt(canto)-1) + let reformecantica=formecantica.slice(startindex) + + //formecantica.map(function(item) { + reformecantica.map(function(item) { formaItem = item.split("_"); var sentenceid = idcantica + "_" + formaItem[1] + "_s_" + formaItem[5] if (formaItem[1] == canto) { @@ -2209,7 +2212,7 @@ $(document).ready(function() { spanoccorrenza.appendTo(elementoverso) } - function createCommentSpan(idVerso, elementoverso, numberOfComments, flagRisultato=false) { + function createCommentSpan(idVerso, elementoverso, numberOfComments, flagRisultato = false) { var spanoccorrenza = $('