browsing in progress

This commit is contained in:
cesare 2022-11-07 11:52:54 +01:00
parent e5e77c79a2
commit fff18f5d33
3 changed files with 85 additions and 19 deletions

View File

@ -41,9 +41,7 @@
<div class="sidebar-module">
<h4>Canti</h4>
<ol class="list-unstyled" id="listacanti">
<!-- <li><a href="#">Canto I</a></li>
<li><a href="#">Canto II</a></li>
<li><a href="#">Canto III</a></li>-->
</ol>
</div>
<div class="sidebar-module">

View File

@ -7,15 +7,73 @@
const sparqlGenerator = sparqljs.Generator;
const myEngine = new Comunica.QueryEngine();
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
var primaCanticaLoaded=false;
var secondaCanticaLoaded=false;
var terzaCanticaLoaded=false;
var listaVersi = new Set()
//caricamento prima cantica
$('#cantica1').on('click', function() {
alert("test fava")
$('.canto').each(function() {
$(this).attr("style", 'display:none');
});
hideListaCanti()
activateMenuItem ('#cantica1')
jsonQuery = versiCantica("cantica1");
execQuery = new sparqlGenerator().stringify(jsonQuery);
executeQueryVersi(execQuery);
if(!(primaCanticaLoaded)){
jsonQuery = versiCantica("Inferno");
execQuery = new sparqlGenerator().stringify(jsonQuery);
executeQueryVersi(execQuery);
primaCanticaLoaded=true;
}
else{
$("#InfernoCanto_1").attr('style','display:block')
$("#CantiInferno").attr('style','display:block')
}
});
//caricamento seconda cantica
$('#cantica2').on('click', function() {
$('.canto').each(function() {
$(this).attr("style", 'display:none');
});
hideListaCanti()
activateMenuItem ('#cantica2')
if(!(secondaCanticaLoaded)){
jsonQuery = versiCantica("Purgatorio");
execQuery = new sparqlGenerator().stringify(jsonQuery);
executeQueryVersi(execQuery);
secondaCanticaLoaded=true;
}
else{
$("#PurgatorioCanto_1").attr('style','display:block')
$("#CantiPurgatorio").attr('style','display:block')
}
});
//caricamento terza cantica
$('#cantica3').on('click', function() {
$('.canto').each(function() {
$(this).attr("style", 'display:none');
});
hideListaCanti()
activateMenuItem ('#cantica3')
if(!(terzaCanticaLoaded)){
jsonQuery = versiCantica("Paradiso");
execQuery = new sparqlGenerator().stringify(jsonQuery);
executeQueryVersi(execQuery);
terzaCanticaLoaded=true;
}
else{
$("#ParadisoCanto_1").attr('style','display:block')
$("#CantiParadiso").attr('style','display:block')
}
});
@ -39,17 +97,23 @@
$(menuItem).attr("class", $(menuItem).attr("class")+' active');
}
//hides liste canti
function hideListaCanti(){
$("#CantiInferno").attr('style','display:none')
$("#CantiPurgatorio").attr('style','display:none')
$("#CantiParadiso").attr('style','display:none')
}
async function executeQueryVersi(query){
bindingsStream = await myEngine.queryBindings(query, { sources: [ { type: 'sparql', value: sparqlEndpoint }, ], });
alert(query)
try {
var listaCanti = new Set()
listaVersi = new Set()
let cantica=0;
bindingsStream.on('data', (binding) => {
//console.log(binding.toString()); // Quick way to print bindings for testing
//console.log(binding.has('sub')); // Will be true
//cantica
cantica=binding.get('Cantica').value;
//la lista dei canti
listaCanti.add( binding.get('Canto').value)
//la lista dei versi
@ -78,30 +142,33 @@
}
});
var divListaCanti=$('<DIV id="Canti'+cantica+'" />')
for (canto of orderedListaCanti){
var licanto = $('<li class="navig-canto"/>')
licanto.attr('name', canto)
licanto.attr('name', cantica+canto)
licanto.attr('href', "#")
licanto.attr("style", "line-height: 1.2em")
licanto.append(canto)
licanto.appendTo('#listacanti')
//licanto.appendTo('#listacanti')
licanto.appendTo(divListaCanti)
var divcanto=$('<div />')
var titolocanto=$('<h1 class="titolo-canto" />')
titolocanto.append(canto)
divcanto.attr('class', 'canto')
divcanto.attr('style', 'display:none')
divcanto.attr('id', canto.replace(" ","_"))
divcanto.attr('id', (cantica+canto).replace(" ","_"))
titolocanto.appendTo(divcanto)
divcanto.appendTo(' .blog-main')
}
divListaCanti.appendTo('#listacanti')
for (verso of orderedListaVersi){
var elementoverso=$('<p />')
elementoverso.append(verso.numverso+". "+verso.verso)
elementoverso.attr("style", "line-height: 0.5em")
elementoverso.appendTo('#'+verso.canto.replace(" ","_"))
elementoverso.appendTo('#'+cantica+verso.canto.replace(" ","_"))
}

View File

@ -208,8 +208,9 @@ function writesearchValue(form) {
function versiCantica(cantica) {
var SparqlParser = sparqljs.Parser;
var parser = new SparqlParser();
return parser.parse(qVersiCantica);
parsedqVersiCantica= parser.parse(qVersiCantica);
parsedqVersiCantica.where[1].expression.args[1].value =cantica;
return (parsedqVersiCantica)
}