diff --git a/NikBrowseSearchCombinedNew.html b/NikBrowseSearchCombinedNew.html index 26b318c..f683dc5 100644 --- a/NikBrowseSearchCombinedNew.html +++ b/NikBrowseSearchCombinedNew.html @@ -898,7 +898,11 @@ name="search-circle"> + id="BottoneCerca">Cerca  + + diff --git a/js/cesareBrowse.js b/js/cesareBrowse.js index eb5d3f3..08c89db 100644 --- a/js/cesareBrowse.js +++ b/js/cesareBrowse.js @@ -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=$('') 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); + // + var spanbadge=$(''); + 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); + // + + var spanbadge=$(''); + 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)