aggiustato filtro default

This commit is contained in:
nicola 2025-03-19 17:31:48 +01:00
parent 0ac771833b
commit 3bb611c248
1 changed files with 90 additions and 95 deletions

View File

@ -55,7 +55,6 @@ $(document).ready(function() {
var filterBottonAdded = false;
var listarisultati = [];
var showingComments = false;
var filterOn = true;
listaPeriodiRisultato = [];
listaClausoleRisultato = []
/*var commentsArray = []
@ -1027,19 +1026,66 @@ $(document).ready(function() {
jQuery(document).delegate(' .showcomments', 'click', function() {
var cid = $(this).attr('id');
var queryComment = false;
var idClass = $(this).attr('class');
//var parentClass = $(this).parent().attr('class');
filterOn = true;
if (idClass.includes("filterRiferimentiOn")) {
filterOn = true;
} else {
if (idClass.includes("filterRiferimentiOff")) {
filterOn = false;
}
var filterOn = true;
var risultato;
var parcid = cid.split("_")
var idsRisultato = getListaRis();
var cantica;
var idRisultato;
switch (parcid[1]) {
case "1": cantica = "Inferno";
break;
case "2": cantica = "Purgatorio";
break;
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)){
risultato = true;
}else{
risultato = false;
}
switch (parcid[0]) {
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;
/*case "CommentoRes":
$(".filterRiferimentiOn").css('display', 'none');
$(".filterRiferimentiOff").css('display', 'inline-block');
filterOn = true;
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 (cantoDisplayed.includes('#vistaFrasi')) {
commentsSQL=getCommentsInResult($(this).attr('id'), $(this).attr('class'))
if (commentsSQL.length==0)
@ -1049,60 +1095,26 @@ $(document).ready(function() {
if (!cantoDisplayed.includes('#vistaFrasi') && !hasCommentsJson(cid)) {
return
}
if (getListaIdCommenti().length > 0) {
if (filterOn) {
if (idClass.includes("risultato")) {
$(".filterRiferimentiOn").css('display', 'inline-block');
$(".filterRiferimentiOff").css('display', 'none');
} else {
$(".filterRiferimentiOn").css('display', 'none');
$(".filterRiferimentiOff").css('display', 'none');
}
} else {
$(".filterRiferimentiOff").css('display', 'inline-block');
$(".filterRiferimentiOn").css('display', 'none');
}
} else {
$(".filterRiferimentiOn").css('display', 'none');
$(".filterRiferimentiOff").css('display', 'none');
}
var parcid = cid.split('_')
var cantica;
var verso = parcid[3];
switch (parcid[1]) {
case "1": cantica = "Inferno";
break;
case "2": cantica = "Purgatorio";
break;
case "3": cantica = "Paradiso";
}
var commentArea = $('#displaynote');
var idCommento = "CommentoQuery_" + parcid[1] + "_" + parcid[2] + "_" + parcid[3];
$(".filterRiferimentiOn").attr("id", idCommento)
$(".filterRiferimentiOn").attr("id", idCommento+"_On")
$(".filterRiferimentiOff").attr("id", idCommento+"_Off")
if (parcid[0] == "CommentoQuery") { // verificare
queryComment = true;
}
commentArea.empty()
if ($('#noteCard0').length) {
$("#noteCard0")[0].remove();
}
var id = cid.substr(9);
id = parcid.at(-1)
var id = parcid[3];
var gruppoVersi;
var versText = "";
//var allGrouplKeys = Object.keys(commentsJson);
var allGrouplKeys = Object.keys(commentsSQL);
var currentGroup;
allGrouplKeys.sort().some(function(k) {
if (k == id || k.startsWith(id + '-')) { //~k.indexOf(id + '-')) {
//console.log(commentsSQL[k].length)
//gruppoVersi = k.split("_").slice(-1)[0]
if (k == id || k.startsWith(id + '-')) {
gruppoVersi = k
if (gruppoVersi.includes("-")) {
versText = ", Versi " + gruppoVersi;
@ -1110,33 +1122,21 @@ $(document).ready(function() {
versText = ", Verso " + gruppoVersi;
}
currentGroup = createNoteGroup(cantica, getRoman(parcid[2]), versText, k, commentsSQL[k].length, queryComment)
currentGroup = createNoteGroup(cantica, getRoman(parcid[2]), versText, k, commentsSQL[k].length)
noteAdded = false;
commentsSQL[k].forEach(function(value, i) {
currentGroup.append(createNoteEntry(value, k, i, queryComment))
currentGroup.append(createNoteEntry(value, k, i, filterOn, risultato))
});
if (queryComment) {
if (noteAdded) {
commentArea.append(currentGroup);
if (filterOn) {
$(".filterRiferimentiOff").css('display', 'inline-block');
$(".filterRiferimentiOn").css('display', 'none');
} else {
$(".filterRiferimentiOn").css('display', 'inline-block');
$(".filterRiferimentiOff").css('display', 'none');
}
} else {
if (k.includes("-") && !filterOn) {
commentArea.append(currentGroup);
}
}
} else {
if (!filterOn) {
commentArea.append(currentGroup);
} else {
if (!k.includes("-")) {
commentArea.append(currentGroup);
}
}
}
$('#tab-list #vis0-tab').tab('show')
})
})
function getCommentsInResult(tmpcid, tmpclass) {
@ -1179,7 +1179,7 @@ $(document).ready(function() {
}
function createNoteGroup(cantica, canto, versi, id, len, queryComment) {
function createNoteGroup(cantica, canto, versi, id, len) {
var noteGroupCard = $('<div class="card card-body noteCardGroup well well-sm mx-1 my-2 p-0" id="noteGroupCard' + id + '">');
var commentHeader = $('<div class="d-flex align-content-start flex-nowrap text-muted" id="commentoGruppoVersi' + id + '">')
var rigaNota = $('<div class="p-0 m-0">');
@ -1215,16 +1215,14 @@ $(document).ready(function() {
return false;
}
function createNoteEntry(comments, id, pos, queryComment) {
function createNoteEntry(comments, id, pos, filterOn, risultato) {
var idref = comments.IdRiferimento
var noteCard = $('<div class="card card-body well well-sm mx-1 mb-1 mt-0 p-0 border-lida08" id="noteCard' + id + '_' + pos + '"' + ' name= "' + idref + '">');
if (isCommentInResult(idref)) {
var noteCard = $('<div class="card card-body bg-light border-success well well-sm mx-1 mb-1 mt-0 p-0" id="noteCard' + id + '_' + pos + '"' + ' name= "' + idref + '">');
noteAdded = true;
}
else {
var noteCard = $('<div class="card card-body well well-sm mx-1 mb-1 mt-0 p-0 border-lida08" id="noteCard' + id + '_' + pos + '"' + ' name= "' + idref + '">');
if (queryComment) {
if(risultato){
if (isCommentInResult(idref)) {
var noteCard = $('<div class="card card-body bg-light border-success well well-sm mx-1 mb-1 mt-0 p-0" id="noteCard' + id + '_' + pos + '"' + ' name= "' + idref + '">');
}else{
if (filterOn) {
noteCard.css("display", "none");
} else {
@ -1232,6 +1230,7 @@ $(document).ready(function() {
}
}
}
var collapseCardBody = $('<div class="card-body px-0 py-1 mx-3 my-0 border-top rounded" >');
var divCampiSingoli = $('<div class="d-flex align-content-start flex-wrap text-muted">');
//createNoteHeader(noteCard, comments, id, pos, cantica, parcid, saveVersoCitazione);
@ -1516,7 +1515,7 @@ $(document).ready(function() {
function hasCommentsJson(cid) {
var id = cid.split('_').at(-1)
var id = cid.split('_')[3]
for (const [keyt, value] of Object.entries(commentsSQL)) {
if (keyt == id || keyt.startsWith(id + '-')) {
return true
@ -1872,8 +1871,6 @@ $(document).ready(function() {
filterButton.attr('id', 'filterRiferimentiOn')
filterButton.attr('class', 'btn btn-sm btn-outline-primary filterRiferimentiOn showcomments border-0 rounded text-primary px-1 pt-1 pb-0 ml-1');
var filterIcon = '<ion-icon name="funnel"></ion-icon>';
//var filterIcon = '<img id="filterImgOn" src="./images/filterOn.png" width="50%" height="50%">'
//var filterIcon1 = '<img id="filterImgOff" src="./images/filterOff.png" width="50%" height="50%">'
var filterIcon1 = '<ion-icon name="funnel"></ion-icon>';
var filterButton1 = $('<button />');
filterButton1.attr('id', 'filterRiferimentiOff')
@ -1903,7 +1900,6 @@ $(document).ready(function() {
elencoRiferimenti = $("#vistaFrasi");
elencoRiferimenti.empty();
$("#displaynote").empty();
filterOn = true;
$(".filterRiferimentiOn").css('display', 'none');
$(".filterRiferimentiOff").css('display', 'none');
@ -2093,9 +2089,8 @@ $(document).ready(function() {
var ultimaFormaCanto;
let numeroPeriodo = 1;
showingComments = false;
let initmap=850*(parseInt(canto)-1)
var subformecantica=formecantica.slice(initmap)
subformecantica.map(function(item) {
formecantica.map(function(item) {
formaItem = item.split("_");
var sentenceid = idcantica + "_" + formaItem[1] + "_s_" + formaItem[5]
if (formaItem[1] == canto) {
@ -2320,15 +2315,15 @@ $(document).ready(function() {
if (digits == 2)
spannum.append('\xa0')
spannum.append(num + '. ')*/
var elementoverso = $('<li class="f6 mb-0 text-muted text-nowrap font-weight-lighter " value="'+num+'"/>')
var elementoverso = $('<li />')
/*var elementoversospan=$('<span />')*/
//elementoverso.append(spannum)
//elementoverso.attr("value", num)
elementoverso.attr("value", num)
//elementoverso.attr("style", "line-height: 1.0em")
//elementoverso.attr('class', 'f6 mb-0 text-muted text-nowrap font-weight-lighter ')//+cantica+' '+canto)
elementoverso.attr('class', 'f6 mb-0 text-muted text-nowrap font-weight-lighter ')//+cantica+' '+canto)
//elementoverso.attr('class', 'text-nowrap ')//+cantica+' '+canto)
elementoverso.attr('id', cantica + "_" + canto + "_" + num)
@ -2381,7 +2376,7 @@ $(document).ready(function() {
var canto = "Canto " + i
var cantoRomano = "Canto " + getRoman(i)
var divcanto = $('<div class="canto pt-3"/>')
var divcanto = $('<div />')
var titolocanto = $('<h4 class="titolo-canto pb-2" />')
//titolocanto.append(cantica + ", " + cantoRomano)
var spantitolocanto = $('<span />')
@ -2389,14 +2384,14 @@ $(document).ready(function() {
spantitolocanto.append(cantica + ", " + cantoRomano)
titolocanto.append(spantitolocanto)
//divcanto.attr('class', 'canto pt-3')
divcanto.attr('class', 'canto pt-3')
divcanto.css("display", "none")
divcanto.attr('id', (cantica + canto).replace(" ", "_"))
titolocanto.appendTo(divcanto)
//nuovo
var olversi = $('<ol class="pb-4 pr-4"/>')
//olversi.attr('class', 'pb-4 pr-4')
var olversi = $('<ol />')
olversi.attr('class', 'pb-4 pr-4')
olversi.appendTo(divcanto)
//fine nuovo
divcanto.appendTo('#displaycanto')