aggiunti badges, aggiunta funzionalità cerca cat gramm in html Nick

This commit is contained in:
cesare 2022-11-18 11:13:18 +01:00
parent f264bd78a4
commit af3eea70f9
2 changed files with 63 additions and 19 deletions

View File

@ -898,7 +898,11 @@
name="search-circle"></ion-icon></label>
<button type="submit"
class="btn bg-light-gray b--gray btn-outline-primary"
id="BottoneCerca">Cerca</button>
id="BottoneCerca">Cerca</button>&nbsp
<button class="btn bg-light-gray b--gray btn-outline-primary" type="submit" id='searchcomm'>Cerca cat. gramm.</button>
<button class="btn btn-sm btn-outline-lida4 m-2 my-sm-0" type="submit" id='cleanresult' aria-expanded="false" aria-controls="collapseExample">
Reset
</button>
</div>
</div>
</div>

View File

@ -14,7 +14,7 @@ $(document).ready(function() {
const ddmenus={"Inferno":"#dmc1",
"Purgatorio": "#dmc2",
"Paradiso": "#dmc3"}
var listarisultativersi=[];
var currentMinimap=''
@ -36,7 +36,7 @@ $(document).ready(function() {
}
$('.labelCantica span').html("Inferno");
});
@ -58,7 +58,7 @@ $(document).ready(function() {
}
$('.labelCantica span').html("Purgatorio");
});
//caricamento terza cantica
@ -78,9 +78,7 @@ $(document).ready(function() {
$("#CantiParadiso").attr('style', 'display:block')
}
$('.labelCantica span').html("Paradiso");
});
var mmih=0
@ -199,12 +197,13 @@ jQuery(document).delegate('#cleanresult', 'click', function(e) {
function cleanSearchResult(){
for (verso of listarisultativersi){
for (verso of listarisultati){
idverso='#'+verso
console.log(idverso)
//$(idverso).attr('class', $(idverso).attr('class').replace(" dark-blue", ""))
//console.log(idverso)
$(idverso).attr('class', 'f6 font-weight-lighter')
}
$( ".badge" ).remove();
listarisultati=[]
if (currentMinimap!='')
showMinimap(currentMinimap)
}
@ -378,7 +377,7 @@ jQuery(document).delegate('#cleanresult', 'click', function(e) {
console.log (minimapSize.style.paddingTop)
viewer.style.paddingTop = `${(winRatio) * 100}%`;
viewer.style.paddingTop = `${(winRatio) * 53}%`;
@ -420,6 +419,8 @@ jQuery(document).delegate('#cleanresult', 'click', function(e) {
//end minimap management
// Search functions
async function executeQueryVersi(query) {
bindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
alert(query)
@ -532,6 +533,8 @@ jQuery(document).delegate('#cleanresult', 'click', function(e) {
var spanoccorrenza=$('<span />')
var pos=parseInt(element.pos)
spanoccorrenza.attr('id', element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso+"_"+pos)
if (listarisultati.includes(spanoccorrenza.attr('id')))
spanoccorrenza.attr('class', "f6 b dark-blue ")
spanoccorrenza.append(managePunctuation(element.form))
elementoverso=$('#'+element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso)
spanoccorrenza.appendTo(elementoverso)
@ -549,33 +552,70 @@ jQuery(document).delegate('#cleanresult', 'click', function(e) {
};
//execute query
var listarisultati=[];
async function executeQuerySearch(query) {
seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
//console.log(query)
alert(query)
try {
var resultVersi = new Set()
var result = new Set()
var resultsInCantica=[]
var resultsInCanto=[]
seachbBindingsStream.on('data', (binding) => {
//cantica
cantica = binding.get('Cantica').value;
resultsInCantica.push(cantica);
//canto
canto=binding.get('Canto').value;
resultsInCanto.push(cantica+canto)
//numero del verso
numverso=binding.get('NumeroVerso').value;
//posizione delframmento
pos=binding.get('pos').value;
resultVersi.add(cantica+"_"+canto.replace(" ", "_")+"_"+numverso+"_"+pos)
result.add(cantica+"_"+canto.replace(" ", "_")+"_"+numverso+"_"+pos)
});
seachbBindingsStream.on('end', () => {
listarisultativersi = Array.from(resultVersi)
for (verso of listarisultativersi){
idverso='#'+verso
//console.log(idverso)
$(idverso).attr('class', "f6 b dark-blue ")
listarisultati = Array.from(result)
cantiche=["Inferno", "Purgatorio", "Paradiso"]
//evidenzia risultati
for (ris of listarisultati){
idris='#'+ris
$(idris).attr('class', "f6 b dark-blue ")
}
//aggiunge badge con totale risultati accanto alle cantiche
i=0
for(cantica of cantiche){
i+=1
let count = resultsInCantica.reduce((n, x) => n + (x === cantica), 0);
//<span class="badge badge-primary badge-pill"></span>
var spanbadge=$('<span />');
spanbadge.attr('class', 'badge badge-primary badge-pill');
spanbadge.append(count)
spanbadge.insertAfter($('#cantica'+i))
}
//aggiunge badge con totale risultati accanto ai canti
for(cantica of cantiche){
for( k of Array(35).keys()){
if (k==0)
continue
let count = resultsInCanto.reduce((n, x) => n + (x === cantica+'Canto '+k), 0);
//<span class="badge badge-primary badge-pill"></span>
var spanbadge=$('<span />');
spanbadge.attr('class', 'badge badge-notification ');
spanbadge.append('('+count+')')
//$("[name='nameofobject']")
spanbadge.appendTo($('[name="'+cantica+'Canto '+k+'"]'))
//spanbadge.insertAfter($('[name="'+cantica+'Canto '+k+'"]'))
}
}
//aggiorna minimap
if (currentMinimap!=''){
showMinimap(currentMinimap)