2022-11-06 17:12:56 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
|
|
|
|
const sparqlGenerator = sparqljs.Generator;
|
|
|
|
const myEngine = new Comunica.QueryEngine();
|
|
|
|
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
|
2022-11-07 11:52:54 +01:00
|
|
|
var primaCanticaLoaded=false;
|
|
|
|
var secondaCanticaLoaded=false;
|
|
|
|
var terzaCanticaLoaded=false;
|
2022-11-06 17:12:56 +01:00
|
|
|
var listaVersi = new Set()
|
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
//caricamento prima cantica
|
2022-11-06 17:12:56 +01:00
|
|
|
$('#cantica1').on('click', function() {
|
2022-11-07 11:52:54 +01:00
|
|
|
$('.canto').each(function() {
|
|
|
|
$(this).attr("style", 'display:none');
|
|
|
|
});
|
|
|
|
hideListaCanti()
|
2022-11-06 17:12:56 +01:00
|
|
|
activateMenuItem ('#cantica1')
|
2022-11-07 11:52:54 +01:00
|
|
|
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')
|
|
|
|
|
|
|
|
}
|
2022-11-06 17:12:56 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery(document).delegate('.navig-canto', 'click', function(e) {
|
|
|
|
$('.canto').each(function() {
|
|
|
|
$(this).attr("style", 'display:none');
|
|
|
|
});
|
|
|
|
$("#"+$(this).attr('name').replace(" ","_")).attr('style','display:block')
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
//Utility functions
|
|
|
|
|
|
|
|
//activate navigation menu items
|
|
|
|
|
|
|
|
function activateMenuItem(menuItem){
|
|
|
|
$('.blog-nav-item').each(function() {
|
|
|
|
$(this).attr("class", $(this).attr("class").replace(' active',''));
|
|
|
|
});
|
|
|
|
$(menuItem).attr("class", $(menuItem).attr("class")+' active');
|
|
|
|
}
|
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
//hides liste canti
|
|
|
|
|
|
|
|
function hideListaCanti(){
|
|
|
|
$("#CantiInferno").attr('style','display:none')
|
|
|
|
$("#CantiPurgatorio").attr('style','display:none')
|
|
|
|
$("#CantiParadiso").attr('style','display:none')
|
|
|
|
}
|
2022-11-06 17:12:56 +01:00
|
|
|
async function executeQueryVersi(query){
|
|
|
|
bindingsStream = await myEngine.queryBindings(query, { sources: [ { type: 'sparql', value: sparqlEndpoint }, ], });
|
|
|
|
alert(query)
|
|
|
|
try {
|
|
|
|
var listaCanti = new Set()
|
|
|
|
listaVersi = new Set()
|
2022-11-07 11:52:54 +01:00
|
|
|
let cantica=0;
|
2022-11-06 17:12:56 +01:00
|
|
|
bindingsStream.on('data', (binding) => {
|
2022-11-07 11:52:54 +01:00
|
|
|
//cantica
|
|
|
|
cantica=binding.get('Cantica').value;
|
2022-11-06 17:12:56 +01:00
|
|
|
//la lista dei canti
|
|
|
|
listaCanti.add( binding.get('Canto').value)
|
|
|
|
//la lista dei versi
|
|
|
|
var obj = new Object();
|
|
|
|
obj.numverso = binding.get('NumeroVerso').value;
|
|
|
|
obj.verso = binding.get('Verso').value;
|
|
|
|
obj.canto = binding.get('Canto').value;
|
|
|
|
obj.from = binding.get('from').value;
|
|
|
|
obj.to = binding.get('to').value;
|
|
|
|
listaVersi.add(obj)
|
|
|
|
|
|
|
|
});
|
|
|
|
bindingsStream.on('end', () => {
|
|
|
|
|
|
|
|
var orderedListaCanti = Array.from(listaCanti)
|
|
|
|
orderedListaCanti = orderedListaCanti.sort((a, b) => {
|
|
|
|
if (parseInt(a.split(" ")[1]) < parseInt(b.split(" ")[1])) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var orderedListaVersi = Array.from(listaVersi)
|
|
|
|
orderedListaVersi = orderedListaVersi.sort((a, b) => {
|
|
|
|
if (parseInt(a.numverso) < parseInt(b.numverso)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
var divListaCanti=$('<DIV id="Canti'+cantica+'" />')
|
2022-11-06 17:12:56 +01:00
|
|
|
for (canto of orderedListaCanti){
|
|
|
|
var licanto = $('<li class="navig-canto"/>')
|
2022-11-07 11:52:54 +01:00
|
|
|
licanto.attr('name', cantica+canto)
|
2022-11-06 17:12:56 +01:00
|
|
|
licanto.attr('href', "#")
|
2022-11-07 11:52:54 +01:00
|
|
|
licanto.attr("style", "line-height: 1.2em")
|
2022-11-06 17:12:56 +01:00
|
|
|
licanto.append(canto)
|
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
//licanto.appendTo('#listacanti')
|
|
|
|
licanto.appendTo(divListaCanti)
|
2022-11-06 17:12:56 +01:00
|
|
|
var divcanto=$('<div />')
|
|
|
|
var titolocanto=$('<h1 class="titolo-canto" />')
|
|
|
|
titolocanto.append(canto)
|
|
|
|
divcanto.attr('class', 'canto')
|
|
|
|
divcanto.attr('style', 'display:none')
|
2022-11-07 11:52:54 +01:00
|
|
|
divcanto.attr('id', (cantica+canto).replace(" ","_"))
|
2022-11-06 17:12:56 +01:00
|
|
|
titolocanto.appendTo(divcanto)
|
|
|
|
divcanto.appendTo(' .blog-main')
|
|
|
|
}
|
2022-11-07 11:52:54 +01:00
|
|
|
divListaCanti.appendTo('#listacanti')
|
2022-11-06 17:12:56 +01:00
|
|
|
|
|
|
|
for (verso of orderedListaVersi){
|
|
|
|
var elementoverso=$('<p />')
|
|
|
|
elementoverso.append(verso.numverso+". "+verso.verso)
|
|
|
|
elementoverso.attr("style", "line-height: 0.5em")
|
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
elementoverso.appendTo('#'+cantica+verso.canto.replace(" ","_"))
|
2022-11-06 17:12:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
catch(err) {
|
|
|
|
console.log(err.message);
|
|
|
|
$("#loader").hide();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|