agg. strutture json per commenti

This commit is contained in:
cesare 2023-12-19 15:35:44 +01:00
parent d942ea08dd
commit b3b8d41b97
2 changed files with 50 additions and 11 deletions

View File

@ -29,7 +29,7 @@ $(document).ready(function() {
listaPeriodiRisultato = [];
listaClausoleRisultato=[]
var commentsArray = []
var commentsJson = {}
var resultSentences = new Set()
var cantiche=["Inferno", "Purgatorio","Paradiso"]
var loadedCanti=new Set();
@ -738,6 +738,7 @@ function resetFrasi(){
canto='0'+canto
commentsArray=getVersiConCitazioni(cantica, canto)
commentsJson=getVersiConCitazioniJson (cantica, canto)
commentsArray.forEach(removeHtmlTags2)
var numVerso1;
@ -780,6 +781,12 @@ function resetFrasi(){
if(!hasComments(cid)){
return
}
if(!hasCommentsJson(cid)){
return
}
var parcid=cid.split('_')
var cantica;
switch (parcid[1]){
@ -797,6 +804,22 @@ function resetFrasi(){
var id = cid.substr(9);
var collapseNote;
var saveVersoCitazione = "";
//start commentsJson
var allGrouplKeys = Object.keys(commentsJson);
allGrouplKeys.sort().some(function(k){
if (k==id || ~k.indexOf(id+'-')){
console.log('gruppo commenti '+k)
console.log (commentsJson[k])
//codice per la visualizzazione
}
})
//end commentsJson
for (var pos in commentsArray){
console.log("Id: "+id);
var noteCard = $('<div class="card card-body well well-sm m-1 mt-2 p-0" id="noteCard' + id + '">');
@ -1095,19 +1118,33 @@ function resetFrasi(){
for (var pos in commentsArray){
var comments = commentsArray[pos]
if (comments.verso == id){
console.log(comments)
//console.log(comments)
return (true)
}
}
return false;
}
function hasCommentsJson(cid){
return commentsJson.hasOwnProperty(cid.substr(9));
}
function numberOfComments(cid){
var id = cid.substr(9);
//[....].filter(x => x==2).length
return commentsArray.filter(x => x.verso==id).length
}
function numberOfCommentsJson(cid){
var cntc=0
var id = cid.substr(9);
for (const [key, value] of Object.entries(commentsJson)) {
if(key==id || key.startsWith(id+'-'))
cntc+=commentsJson[key].length
}
return cntc
}
/*FINE GESTIONE CITAZIONI*/
function getCantica(numeroCantica){
@ -1318,7 +1355,9 @@ function resetFrasi(){
var verso = parseInt(formaItem[3]) - 1;
var idCommento = "Commento_"+idcantica+"_"+canto+"_"+verso;
var commNumber = numberOfComments(idCommento);
//var commNumber = numberOfComments(idCommento);
var commNumber=numberOfCommentsJson(idCommento)
//if (hasComments(idCommento)){
if (commNumber>0){
createCommentSpan(idCommento, elverso, commNumber)

View File

@ -940,8 +940,8 @@ function getVersiConCitazioniJson(canticapar='', cantopar=''){
let tca=item['Canto']
if (tca.startsWith('0'))
tca=tca.replace('0','')
let citid=(citcantiche.indexOf(item['Cantica'])+1).toString()+'_'+tca+'_'+item['Verso'].split('-')[0]
console.log(citid)
let citid=(citcantiche.indexOf(item['Cantica'])+1).toString()+'_'+tca+'_'+item['Verso']//.split('-')[0]
//console.log(citid)
var commentsItem = {}
commentsItem['verso'] = citid;
commentsItem['annotazione'] = item['Annotazione'];
@ -1022,13 +1022,13 @@ function getVersiConCitazioniJson(canticapar='', cantopar=''){
commentsItem['CitTopografie'] =item['CTO']
}
if (citazionitemp.hasOwnProperty(item['Verso'])){
citazionitemp[item['Verso']].push(commentsItem)
if (citazionitemp.hasOwnProperty(citid)){
citazionitemp[citid].push(commentsItem)
}
else{
var tmpar=[]
tmpar.push(commentsItem)
citazionitemp[item['Verso']]=tmpar
citazionitemp[citid]=tmpar
}
}
@ -1057,7 +1057,7 @@ function getVersiConCitazioni(canticapar='', cantopar=''){
if (tca.startsWith('0'))
tca=tca.replace('0','')
citid=(citcantiche.indexOf(item['Cantica'])+1).toString()+'_'+tca+'_'+item['Verso'].split('-')[0]
console.log(citid)
//console.log(citid)
var commentsItem = {}
commentsItem['verso'] = citid;
commentsItem['annotazione'] = item['Annotazione'];