Creazione dei collapse calcolata sui dati e dimensioni attuali

This commit is contained in:
Luca Trupiano 2023-12-13 13:57:05 +01:00
parent d2d30b9566
commit 85868d4997
2 changed files with 20 additions and 25 deletions

View File

@ -11,11 +11,11 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Spectral"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Spectral">
<!-- <!--
--> -->
<link rel="stylesheet" id="style1-Boot" href="./css/bootstrap.min.lida1.css" disabled> <link rel="stylesheet" id="style1-Boot" href="./css/bootstrap.min.lida1.css" disabled>
<link rel="stylesheet" id="style1-Custom" href="./css/custom1_4.3.css" disabled> <link rel="stylesheet" id="style1-Custom" href="./css/custom1_4.3.css" disabled>
<link rel="stylesheet" id="style2-Boot" href="./css/bootstrap.min.lida2.css"> <link rel="stylesheet" id="style2-Boot" href="./css/bootstrap.min.lida2.css">
<link rel="stylesheet" id="style2-Custom" href="./css/custom2_4.3.css"> <link rel="stylesheet" id="style2-Custom" href="./css/custom2_4.3.css">
<link rel="stylesheet" id="style2-Custom" href="./css/collapsemod.css"> <link rel="stylesheet" href="./css/collapsemod.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
@ -484,6 +484,9 @@
<span class="p-3 text-muted bg-lida-vis small" style="opacity: 0.6;">Nessun commento visualizzato</span> <span class="p-3 text-muted bg-lida-vis small" style="opacity: 0.6;">Nessun commento visualizzato</span>
</div> </div>
</div> </div>
<div class="d-flex flex-row justify-content-start">
<div id="Test" class="blog-main-16 mx-3" style="display: none;">abcdefghijklmnopqrstuvwxyzABCD.,</div>
</div>
</div> </div>
<div class="tab-pane fade p-0 bg-lida-vis" id="vis1" role="tabpanel" aria-labelledby="vis1-tab"> <div class="tab-pane fade p-0 bg-lida-vis" id="vis1" role="tabpanel" aria-labelledby="vis1-tab">
<div id='displayinfo' class="p-0"> <div id='displayinfo' class="p-0">

View File

@ -944,7 +944,7 @@ function resetFrasi(){
} }
function createModule(collapse,label, testo, num, id, pos){ function createModule(collapse,label, testo, num, id, pos){
//console.log(label+": "+testo.length); var minLength = ($('#displaynote').width() / $('#Test').width() * 2 * 32);
var divContent = $('<div class="text-muted p-0">'); var divContent = $('<div class="text-muted p-0">');
//var divContent = $('<div class="d-flex align-content-start flex-wrap text-muted">'); //var divContent = $('<div class="d-flex align-content-start flex-wrap text-muted">');
//var divTesto = $('<div class="px-3 py-1">') //var divTesto = $('<div class="px-3 py-1">')
@ -952,23 +952,19 @@ function resetFrasi(){
//divTesto.append(nota); //divTesto.append(nota);
//divContent.append(divTesto); //divContent.append(divTesto);
divContent.append(nota); divContent.append(nota);
if (testo.length > 210) { if ((testo.length + label.length +2) > minLength) {
/* //console.log((testo.length + label.length +2) +" "+($('#displaynote').width() / $('#Test').width() * 2 * 32))
var a = $('#displaynote').width();
var b = $('#Test').width();
var c = (a / b * 2.2 * 52)
console.log($('#Test').text().length)
console.log(c)
*/
var divModule = $('<div class="module pb-0">'); var divModule = $('<div class="module pb-0">');
var divNote = $('<div class="collapse" id="collapse'+num+'Note'+id+ '_' + pos +'" aria-expanded="false">') var divNote = $('<div class="collapse" id="collapse'+num+'Note'+id+ '_' + pos +'" aria-expanded="false">')
divModule.append('<a class="read-more collapsed" data-toggle="collapse" href="#collapse'+num+'Note'+id+ '_' + pos +'" role="button"></a>') divModule.append('<a class="read-more collapsed" data-toggle="collapse" href="#collapse'+num+'Note'+id+ '_' + pos +'" role="button"></a>')
divNote.append(divContent) divNote.append(divContent)
divModule.append(divNote); divModule.append(divNote);
divModule.appendTo(collapse);
} else { } else {
divContent.appendTo(collapse); var divModule = $('<div class="module py-1">');
divModule.append(divContent);
} }
divModule.appendTo(collapse);
} }
function createModuleCommentatore(collapse, commento, num, id, pos){ function createModuleCommentatore(collapse, commento, num, id, pos){
@ -979,6 +975,7 @@ console.log(c)
var autoreCommento = jsonCommento.Autore var autoreCommento = jsonCommento.Autore
//var commentoCommentatore = commento.split(','); //var commentoCommentatore = commento.split(',');
var minLength = ($('#displaynote').width() / $('#Test').width() * 2 * 32);
var divContent = $('<div class="d-flex align-content-start flex-wrap text-muted">'); var divContent = $('<div class="d-flex align-content-start flex-wrap text-muted">');
var divTesto = $('<div class="pl-0 pr-3 py-1">') var divTesto = $('<div class="pl-0 pr-3 py-1">')
var nota; var nota;
@ -1008,22 +1005,17 @@ console.log(c)
} }
divTesto.append(nota); divTesto.append(nota);
divContent.append(divTesto); divContent.append(divTesto);
if (nota.length > 210) { if ((esitoCommento.length + autoreCommento.length + 32) > minLength) {
/*
var a = $('#displaynote').width();
var b = $('#Test').width();
var c = (a / b * 2.2 * 52)
console.log(c)
*/
var divModule = $('<div class="module pb-0">'); var divModule = $('<div class="module pb-0">');
var divNote = $('<div class="collapse" id="collapse'+num+'Note'+id+ '_' + pos +'" aria-expanded="false">') var divNote = $('<div class="collapse" id="collapse'+num+'Note'+id+ '_' + pos +'" aria-expanded="false">')
divModule.append('<a class="read-more collapsed" data-toggle="collapse" href="#collapse'+num+'Note'+id+ '_' + pos +'" role="button"></a>') divModule.append('<a class="read-more collapsed" data-toggle="collapse" href="#collapse'+num+'Note'+id+ '_' + pos +'" role="button"></a>')
divNote.append(divContent) divNote.append(divContent)
divModule.append(divNote); divModule.append(divNote);
divModule.appendTo(collapse);
} else { } else {
divContent.appendTo(collapse); var divModule = $('<div class="module py-1">');
divModule.append(divContent);
} }
divModule.appendTo(collapse);
} }
function hasComments(cid){ function hasComments(cid){