ottimizzazione codice, corretto gen id per commenti

This commit is contained in:
cesare 2024-02-13 16:23:38 +01:00
parent 5963023a46
commit 3c359a6c03
2 changed files with 28 additions and 11 deletions

View File

@ -1149,10 +1149,10 @@ function resetFrasi(){
var divContent2 = $('<div class="text-muted p-0">');
var uniqueIdMulti1 = 'coll'+num+'SN'+id+'_'+pos;
var uniqueIdMulti2 = 'coll'+num+'CN'+id+'_'+pos;
var divMultiCollapse1 = $('<div class="collapse multi-collapse'+pos+' show text-muted p-0" id="' + uniqueIdMulti1 + '">');
var divMultiCollapse2 = $('<div class="collapse multi-collapse'+pos+' text-muted p-0" id="' + uniqueIdMulti2 + '">');
var label1 = '<b>Nota / <a href="" data-toggle="collapse" data-target=".multi-collapse'+pos+'" aria-controls="' + uniqueIdMulti1 + ' ' + uniqueIdMulti2 +'">Nota completa</a>: </b>'
var label2 = '<b><a href="" data-toggle="collapse" data-target=".multi-collapse'+pos+'" aria-controls="' + uniqueIdMulti1 + ' ' + uniqueIdMulti2 +'">Nota</a> / Nota completa: </b>'
var divMultiCollapse1 = $('<div class="collapse multi-collapse'+id+'_'+pos+' show text-muted p-0" id="' + uniqueIdMulti1 + '">');
var divMultiCollapse2 = $('<div class="collapse multi-collapse'+id+'_'+pos+' text-muted p-0" id="' + uniqueIdMulti2 + '">');
var label1 = '<b>Nota / <a href="" data-toggle="collapse" data-target=".multi-collapse'+id+'_'+pos+'" aria-controls="' + uniqueIdMulti1 + ' ' + uniqueIdMulti2 +'">Nota completa</a>: </b>'
var label2 = '<b><a href="" data-toggle="collapse" data-target=".multi-collapse'+id+'_'+pos+'" aria-controls="' + uniqueIdMulti1 + ' ' + uniqueIdMulti2 +'">Nota</a> / Nota completa: </b>'
var nota1 = '<span class="blog-main-16">'+testo1+'</span>';
var nota2 = '<span class="blog-main-16">'+testo2+'</span>';
@ -1469,17 +1469,32 @@ function resetFrasi(){
function executeLocalSearch(testo, forme, limit, cantica, cont, resultsInCantica, resultsInCanto){
for (var ip=0; ip<=limit; ip++){
var fnd=true
if(cont.length && !cont.includes(parseInt(forme[ip].split('_')[1]))){
fnd=false;
break
continue
}
var fnd=true
var strlen=0;
var tmpa=[]
for (var frind=0; frind<testo.length; frind++){
if (testo[frind].toLowerCase()!=forme[ip+frind].split('_')[0].toLowerCase().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"")){
var itm=forme[ip+frind].split('_')[0].toLowerCase().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"")
tmpa.push(itm)
}
fnd=(testo.join(' ').toLowerCase()===tmpa.join(' ') || tmpa.join(' ').startsWith(testo.join(' ').toLowerCase()))
/*
//console.log(JSON.stringify(testo)+' - '+JSON.stringify(tmpa))
fnd= (JSON.stringify(testo)==JSON.stringify(tmpa));
*/
/*
for (var frind=0; frind<testo.length; frind++){
var targetSt=forme[ip+frind].split('_')[0].toLowerCase().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"")
if (testo[frind].toLowerCase()!==targetSt){
fnd=false;
break
}
}
*/
if (fnd){
//console.log('ipfound: '+forme[ip].split('_')[2]+' - '+forme[(ip+testo.length-1)].split('_')[2])
@ -1487,6 +1502,7 @@ function resetFrasi(){
resultsInCanto.push(cantica+'Canto '+forme[ip].split('_')[1])
var tstar= parseInt(forme[ip].split('_')[2])
var tstop=parseInt(forme[(ip+testo.length-1)].split('_')[2])
for (var mpo=tstar;mpo<tstop+1; mpo++){
listarisultati.push(mpo)
@ -1963,8 +1979,9 @@ function resetFrasi(){
}
catch (err) {
console.log(err.message);
$("#loader").fadeOut(300);
console.log(err.message);
};

View File

@ -505,7 +505,7 @@ function getFiltroContestoJson(datiContesto) {
cantica++;
for (const [index, element] of contestoCantica.entries()) {
if (element == 1){
console.log('Cantica ' + cantica + ', Canto ' + (parseInt(index) + 1));
//console.log('Cantica ' + cantica + ', Canto ' + (parseInt(index) + 1));
contextids.push (parseInt(index) + 1)
}
}
@ -839,7 +839,7 @@ function buildFilterContextJson( contextcantiche) {
var cantichecontextfilter=[]
var cgroup=JSON.parse(contextgroup)
if(contextcantiche.hasOwnProperty(ky)){
console.log(`test ${ky} : ${contextcantiche[ky]}`)
///console.log(`test ${ky} : ${contextcantiche[ky]}`)
var cfilter=JSON.parse(canticacontexttemplate);