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"> <div class="sidebar-module">
<h4>Canti</h4> <h4>Canti</h4>
<ol class="list-unstyled" id="listacanti"> <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> </ol>
</div> </div>
<div class="sidebar-module"> <div class="sidebar-module">

View File

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