2022-11-06 17:12:56 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2022-11-08 10:44:20 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
const cantobadgeclass='badge badge-outline-info badge-pill'
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
const sparqlGenerator = sparqljs.Generator;
|
|
|
|
const myEngine = new Comunica.QueryEngine();
|
|
|
|
const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commediaontosintgra/query";
|
2022-12-05 11:41:58 +01:00
|
|
|
//const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/hdntest/query";
|
2022-11-08 10:44:20 +01:00
|
|
|
var primaCanticaLoaded = false;
|
|
|
|
var secondaCanticaLoaded = false;
|
|
|
|
var terzaCanticaLoaded = false;
|
2022-12-06 11:25:04 +01:00
|
|
|
var listaVersi = new Set()
|
|
|
|
const ddmenus={"Inferno":"#dmc1",
|
|
|
|
"Purgatorio": "#dmc2",
|
|
|
|
"Paradiso": "#dmc3"}
|
|
|
|
|
|
|
|
var currentMinimap=''
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
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-11 22:11:22 +01:00
|
|
|
hideMinimap();
|
2022-12-06 11:25:04 +01:00
|
|
|
activateMenuItem('#cantica1')
|
2022-11-08 10:44:20 +01:00
|
|
|
if (!(primaCanticaLoaded)) {
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
//jsonQuery = versiCantica("Inferno");
|
|
|
|
//execQuery = new sparqlGenerator().stringify(jsonQuery);
|
|
|
|
//executeQueryVersi(execQuery);
|
2022-12-05 11:41:58 +01:00
|
|
|
showCantica('Inferno')
|
2022-11-08 10:44:20 +01:00
|
|
|
primaCanticaLoaded = true;
|
2022-11-17 17:49:34 +01:00
|
|
|
$(".labelCantica").attr('style', "display: block;");
|
2022-11-08 10:44:20 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-12-06 11:25:04 +01:00
|
|
|
//$("#InfernoCanto_1").attr('style', 'display:block')
|
2022-11-08 10:44:20 +01:00
|
|
|
$("#CantiInferno").attr('style', 'display:block')
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
});
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
//caricamento seconda cantica
|
|
|
|
$('#cantica2').on('click', function() {
|
2022-11-11 22:11:22 +01:00
|
|
|
hideMinimap();
|
2022-12-06 11:25:04 +01:00
|
|
|
activateMenuItem('#cantica2')
|
2022-11-08 10:44:20 +01:00
|
|
|
if (!(secondaCanticaLoaded)) {
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
//jsonQuery = versiCantica("Purgatorio");
|
|
|
|
//execQuery = new sparqlGenerator().stringify(jsonQuery);
|
|
|
|
//executeQueryVersi(execQuery);
|
2022-12-05 11:41:58 +01:00
|
|
|
showCantica('Purgatorio')
|
2022-11-08 10:44:20 +01:00
|
|
|
secondaCanticaLoaded = true;
|
2022-11-17 17:49:34 +01:00
|
|
|
$(".labelCantica").attr('style', "display: block;");
|
2022-11-07 11:52:54 +01:00
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
else {
|
2022-12-06 11:25:04 +01:00
|
|
|
//$("#PurgatorioCanto_1").attr('style', 'display:block')
|
2022-11-08 10:44:20 +01:00
|
|
|
$("#CantiPurgatorio").attr('style', 'display:block')
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
});
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-07 11:52:54 +01:00
|
|
|
//caricamento terza cantica
|
|
|
|
$('#cantica3').on('click', function() {
|
2022-11-11 22:11:22 +01:00
|
|
|
hideMinimap();
|
2022-11-08 10:44:20 +01:00
|
|
|
activateMenuItem('#cantica3')
|
|
|
|
if (!(terzaCanticaLoaded)) {
|
2022-12-05 11:41:58 +01:00
|
|
|
showCantica('Paradiso')
|
2022-11-08 10:44:20 +01:00
|
|
|
terzaCanticaLoaded = true;
|
2022-11-17 17:49:34 +01:00
|
|
|
$(".labelCantica").attr('style', "display: block;");
|
2022-11-07 11:52:54 +01:00
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
else {
|
2022-12-06 11:25:04 +01:00
|
|
|
//$("#ParadisoCanto_1").attr('style', 'display:block')
|
2022-11-08 10:44:20 +01:00
|
|
|
$("#CantiParadiso").attr('style', 'display:block')
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
}
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
});
|
2022-12-06 11:25:04 +01:00
|
|
|
var mmih=0
|
|
|
|
var mmiw=0
|
|
|
|
var minimapScrolling=false;
|
|
|
|
var displayId='displaycanto'
|
2022-11-17 10:15:29 +01:00
|
|
|
var minimapTopPos;
|
2022-12-06 11:25:04 +01:00
|
|
|
$( "#"+displayId).scroll(function() {
|
|
|
|
if (minimapScrolling){
|
|
|
|
minimapScrolling=false
|
|
|
|
console.log ('no scroll')
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
console.log ('yes scrolling')
|
|
|
|
console.log("viewer top pos before: "+$('#minimapviewer').offset().top)
|
|
|
|
trackScrollCanto()
|
|
|
|
console.log("viewer top pos after: "+$('#minimapviewer').offset().top)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
jQuery(document).delegate('.navig-canto', 'click', function(e) {
|
|
|
|
$('.canto').each(function() {
|
2022-11-08 10:44:20 +01:00
|
|
|
$(this).attr("style", 'display:none');
|
2022-11-06 17:12:56 +01:00
|
|
|
});
|
2022-11-08 10:44:20 +01:00
|
|
|
$("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display:block')
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
mmiw=$("#"+displayId).innerWidth();
|
|
|
|
mmih=$("#"+displayId).innerHeight();
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
showMinimap($(this).attr('name').replace(" ", "_"))
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
currentMinimap=$(this).attr('name').replace(" ", "_");
|
2022-11-17 10:15:29 +01:00
|
|
|
//mmviewer diventa draggable
|
2022-12-06 11:25:04 +01:00
|
|
|
minimapTopPos=$('#minimapviewer').offset().top
|
|
|
|
console.log("top viewer init "+minimapTopPos)
|
|
|
|
|
|
|
|
$('#minimapviewer').draggable({
|
|
|
|
axis: "y",
|
|
|
|
containment : $('#displayminimap'),
|
|
|
|
scroll : false,
|
|
|
|
stop: function( event, ui ) {minimapScrolling=true;},
|
|
|
|
stop: function( event, ui ) {minimapScrolling=false;},
|
|
|
|
drag: function( event, ui ) {
|
|
|
|
|
|
|
|
minimapScrolling=true;
|
|
|
|
trackScrollViewer(ui.offset.top-minimapTopPos);
|
|
|
|
//trackScrollViewer(ui.offset.top);
|
|
|
|
console.log(ui);
|
|
|
|
//document.getElementById(displayId).style.transform=`translateY(${viewer.scrollTop * realScale}px)`;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//$('#minimapviewer').on('drag', trackScrollViewer)
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
});
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-11 22:11:22 +01:00
|
|
|
//Query
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
//$('#searchcomm').on('click', function() {
|
|
|
|
jQuery(document).delegate('#searchcomm', 'click', function(e) {
|
|
|
|
|
|
|
|
cleanSearchResult()
|
|
|
|
esprlogica=[]
|
|
|
|
|
|
|
|
esprlogica.push('Clausola1')
|
|
|
|
condizioni={"EsprLogica": esprlogica}
|
|
|
|
clausola={}
|
|
|
|
clausola['typeGramm0']=$('#queryText').val()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clausola['queryText']=""
|
|
|
|
condizioni['Clausola1']=clausola
|
|
|
|
jsonQuery=buildSQ(condizioni)
|
|
|
|
myquery =new sparqlGenerator().stringify(jsonQuery)
|
|
|
|
|
|
|
|
executeQuerySearch(myquery)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
2022-11-14 09:22:00 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
//Reset
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
jQuery(document).delegate('#cleanresult', 'click', function(e) {
|
|
|
|
console.log('clean')
|
|
|
|
cleanSearchResult()
|
|
|
|
esprlogica=[]
|
|
|
|
$('#queryText').val("")
|
|
|
|
|
|
|
|
});
|
2022-12-06 10:01:42 +01:00
|
|
|
|
|
|
|
//Utility functions
|
|
|
|
|
|
|
|
//activate navigation menu items
|
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
function activateMenuItem(menuItem) {
|
|
|
|
//$('.blog-nav-item').each(function() {
|
|
|
|
// $(this).attr("class", $(this).attr("class").replace(' active', ''));
|
|
|
|
//});
|
|
|
|
//$(menuItem).attr("class", $(menuItem).attr("class") + ' active');
|
|
|
|
}
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function managePunctuation(stringa) {
|
|
|
|
var tempstringa=stringa.replaceAll(" ,", ",")
|
|
|
|
tempstringa=tempstringa.replaceAll(" .", ".")
|
|
|
|
tempstringa=tempstringa.replaceAll(" :", ":")
|
|
|
|
tempstringa=tempstringa.replaceAll(" !", "!")
|
|
|
|
tempstringa=tempstringa.replaceAll(" ?", "?")
|
|
|
|
tempstringa=tempstringa.replaceAll(" ;", ";")
|
|
|
|
tempstringa=tempstringa.replaceAll("%20", " ")
|
|
|
|
return tempstringa
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanSearchResult(){
|
|
|
|
|
|
|
|
for (verso of listarisultati){
|
|
|
|
idverso='#'+verso
|
|
|
|
//console.log(idverso)
|
|
|
|
//$(idverso).attr('class', 'f6 font-weight-lighter')
|
|
|
|
$(idverso).attr('class', 'f6text-secondary text-nowrap font-weight-lighter')
|
|
|
|
}
|
|
|
|
$( ".badge" ).remove();
|
|
|
|
listarisultati=[]
|
|
|
|
if (currentMinimap!='')
|
|
|
|
showMinimap(currentMinimap)
|
2022-11-11 22:11:22 +01:00
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-11-15 10:41:16 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
//minimap management
|
2022-11-08 10:44:20 +01:00
|
|
|
let minimap = document.createElement('div');
|
|
|
|
let minimapSize = document.createElement('div');
|
|
|
|
let viewer = document.createElement('div');
|
|
|
|
let minimapContent = document.createElement('iframe');
|
2022-12-06 11:25:04 +01:00
|
|
|
let scale=0.1;
|
2022-11-08 10:44:20 +01:00
|
|
|
let realScale;
|
2022-12-06 11:25:04 +01:00
|
|
|
let mappedElement=''
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
function showMinimap(element) {
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
mmplace=document.getElementById('displayminimap')
|
|
|
|
//mmplace=document.getElementById('displaycanto')
|
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
minimap.className = 'minimap__container'
|
|
|
|
minimapSize.className = 'minimap__size'
|
|
|
|
viewer.className = 'minimap__viewer'
|
2022-12-06 11:25:04 +01:00
|
|
|
viewer.id='minimapviewer'
|
2022-12-05 11:41:58 +01:00
|
|
|
minimapContent.className = 'minimap__content'
|
2022-11-15 10:41:16 +01:00
|
|
|
//class="col-3 px-0"
|
2022-11-08 10:44:20 +01:00
|
|
|
minimap.append(minimapSize, viewer, minimapContent);
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
//document.body.appendChild(minimap)
|
2022-12-05 11:41:58 +01:00
|
|
|
mmplace.appendChild(minimap)
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
let html = document.getElementById(element).outerHTML//innerHTML
|
2022-11-15 16:01:23 +01:00
|
|
|
//console.log(html)
|
2022-12-06 11:25:04 +01:00
|
|
|
if (html==null | html=='')
|
2022-12-05 11:41:58 +01:00
|
|
|
return;
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
let iFrameDoc = minimapContent.contentWindow.document;
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
var cssLinkb = document.createElement("link");
|
|
|
|
cssLinkb.href = "https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css";
|
2022-12-06 11:25:04 +01:00
|
|
|
cssLinkb.rel = "stylesheet";
|
2022-11-17 16:37:08 +01:00
|
|
|
cssLinkb.type = "text/css";
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-18 14:55:06 +01:00
|
|
|
var cssLinkscroll = document.createElement("link");
|
|
|
|
cssLinkscroll.href = "./css/browsingldc.css";
|
2022-12-06 11:25:04 +01:00
|
|
|
cssLinkscroll.rel = "stylesheet";
|
2022-11-18 14:55:06 +01:00
|
|
|
cssLinkscroll.type = "text/css";
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
iFrameDoc.open();
|
|
|
|
iFrameDoc.write(html);
|
|
|
|
iFrameDoc.close();
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
iFrameDoc.head.appendChild(cssLinkb);
|
2022-11-18 14:55:06 +01:00
|
|
|
iFrameDoc.head.appendChild(cssLinkscroll);
|
2022-12-06 11:25:04 +01:00
|
|
|
mappedElement=element
|
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
getDimensionsDiv()
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
window.addEventListener('scroll', trackScroll)
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
//document.getElementById(displayId).addEventListener('resize', getDimensionsDiv)
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
window.addEventListener('resize', getDimensionsDiv)
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getDimensions(){
|
|
|
|
cantoplace=document.getElementById(displayId)
|
|
|
|
let bodyWidth= cantoplace.clientWidth;
|
|
|
|
let bodyRatio= bodyWidth/cantoplace.clientHeight
|
|
|
|
//let winRatio=cantoplace.clientWidth / getInnerHeight(cantoplace)
|
|
|
|
let winRatio= window.innerHeight / window.innerWidth;
|
|
|
|
|
|
|
|
|
|
|
|
minimap.style.width='55%';
|
|
|
|
viewer.style.width='55%'
|
|
|
|
|
|
|
|
realScale=minimap.clientWidth / bodyWidth;
|
|
|
|
|
|
|
|
minimapSize.style.paddingTop=`${bodyRatio * 100}%`
|
|
|
|
viewer.style.paddingTop=`${winRatio * 100}%`;
|
|
|
|
minimapContent.style.transform=`scale(${realScale})`;
|
|
|
|
minimapContent.style.width=`${(100/realScale)}%`;
|
|
|
|
minimapContent.style.height=`${(100 / realScale)}%`;
|
|
|
|
|
|
|
|
}
|
|
|
|
function getInnerHeight( elm ){
|
|
|
|
var computed = getComputedStyle(elm),
|
|
|
|
padding = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom);
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
return elm.clientHeight - padding
|
2022-12-06 10:01:42 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
function getDimensionsDiv(){
|
|
|
|
|
|
|
|
|
|
|
|
cantoplace=document.getElementById(displayId)
|
|
|
|
|
|
|
|
elementplace=document.getElementById(mappedElement)
|
|
|
|
|
|
|
|
bodyWidth= elementplace.clientWidth;
|
|
|
|
bodyRatio= elementplace.clientHeight / bodyWidth;
|
|
|
|
//let bodyWidth= cantoplace.clientWidth;
|
|
|
|
//let bodyRatio= cantoplace.clientHeight / bodyWidth;
|
|
|
|
//let winRatio= window.innerHeight / (window.innerWidth);
|
|
|
|
let winRatio= getInnerHeight(cantoplace) / (cantoplace.clientWidth);
|
|
|
|
|
|
|
|
|
|
|
|
//minimap.style.width='15%';
|
|
|
|
minimap.style.width='100%';
|
|
|
|
|
|
|
|
|
|
|
|
realScale=minimap.clientWidth / bodyWidth;
|
|
|
|
|
|
|
|
minimapSize.style.paddingTop=`${bodyRatio * 100}%`
|
|
|
|
viewer.style.paddingTop=`${winRatio * 100}%`;
|
|
|
|
minimapContent.style.transform=`scale(${realScale})`;
|
|
|
|
minimapContent.style.width=`${(100/realScale)}%`;
|
|
|
|
minimapContent.style.height=`${(100 / realScale)}%`;
|
|
|
|
//minimapContent.style.height=`100%`;
|
|
|
|
minimapContent.style.float='right';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function trackScroll(){
|
|
|
|
//console.log(window.scrollY)
|
|
|
|
viewer.style.transform=`translateY(${window.scrollY * realScale}px)`
|
2022-11-07 11:52:54 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
function trackScrollCanto(){
|
|
|
|
console.log('cantoscrollT*realscale '+document.getElementById(displayId).scrollTop * realScale+' top: ' +document.getElementById(displayId).scrollTop )
|
|
|
|
viewer.style.transform=`translateY(${document.getElementById(displayId).scrollTop * realScale}px)`
|
2022-11-17 10:15:29 +01:00
|
|
|
|
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
function trackScrollViewer(toppos){
|
|
|
|
console.log('scrollMMView top*1/realScale: '+toppos*(1/realScale)+' top pos: '+toppos)
|
|
|
|
did=document.getElementById(displayId)
|
|
|
|
|
|
|
|
did.scrollTop=(toppos*(1/realScale))
|
|
|
|
|
|
|
|
|
2022-11-15 10:41:16 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
function hideMinimap(){
|
2022-11-11 22:11:22 +01:00
|
|
|
$('.canto').each(function() {
|
|
|
|
$(this).attr("style", 'display:none');
|
|
|
|
});
|
2022-12-06 11:25:04 +01:00
|
|
|
$( ".minimap__container" ).remove();
|
|
|
|
currentMinimap=''
|
2022-11-11 22:11:22 +01:00
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
// fa diventare draggable il minimapviewer
|
|
|
|
|
|
|
|
|
|
|
|
//end minimap management
|
2022-12-05 11:41:58 +01:00
|
|
|
//Cantica management functions
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
function showCantica(cantica){
|
2022-12-05 11:41:58 +01:00
|
|
|
var listaCanti = new Set()
|
2022-12-05 14:11:02 +01:00
|
|
|
var setVersi = new Set()
|
2022-12-06 11:25:04 +01:00
|
|
|
var listaVersi = []
|
|
|
|
var listaForme =[]
|
|
|
|
containerForme=formeterza
|
|
|
|
if(cantica=='Inferno')
|
|
|
|
containerForme=formeprima
|
|
|
|
if(cantica=='Purgatorio')
|
|
|
|
containerForme=formeseconda
|
|
|
|
for (cmpItem of containerForme){
|
|
|
|
formaItem=cmpItem[0].split("_")
|
|
|
|
listaCanti=createDivCanti(listaCanti, cantica, 'Canto '+formaItem[1])
|
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
var obj = new Object();
|
2022-12-06 11:25:04 +01:00
|
|
|
var forma=new Object()
|
|
|
|
setVersi=createDivVersi(setVersi, cantica, formaItem[3], 'Canto '+formaItem[1])
|
|
|
|
/*
|
|
|
|
obj.numverso = formaItem[3];
|
|
|
|
|
|
|
|
obj.canto = 'Canto '+formaItem[1];
|
|
|
|
obj.cantica = cantica;
|
|
|
|
listaVersi.push(obj)
|
|
|
|
*/
|
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
forma.numverso = formaItem[3];
|
2022-12-06 11:25:04 +01:00
|
|
|
forma.canto = 'Canto '+formaItem[1];
|
2022-12-05 11:41:58 +01:00
|
|
|
forma.pos = formaItem[2];
|
|
|
|
forma.form = formaItem[0];
|
|
|
|
forma.cantica = cantica;
|
2022-12-05 14:11:02 +01:00
|
|
|
createSpanForme(forma)
|
|
|
|
//listaForme.push(forma)
|
2022-12-05 11:41:58 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
//renderData(cantica, listaCanti, listaVersi, listaForme);
|
2022-12-05 11:41:58 +01:00
|
|
|
return
|
|
|
|
}
|
2022-12-06 15:48:49 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
function createSpanForme(element){
|
|
|
|
var spanoccorrenza=$('<span />')
|
|
|
|
var pos=parseInt(element.pos)
|
|
|
|
spanoccorrenza.attr('id', element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso+"_"+pos)
|
|
|
|
if (listarisultati.length>0 && listarisultati.includes(spanoccorrenza.attr('id')))
|
2022-12-05 14:11:02 +01:00
|
|
|
spanoccorrenza.attr('class', "f6 mark ")
|
|
|
|
spanoccorrenza.append(element.form.replaceAll("%20", " "))
|
2022-12-06 11:25:04 +01:00
|
|
|
elementoverso=$('#'+element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso)
|
2022-12-05 14:11:02 +01:00
|
|
|
spanoccorrenza.appendTo(elementoverso)
|
|
|
|
elementoverso.append(' ')
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
function createDivVersi(setVersi, cantica, num, canto){
|
|
|
|
if(setVersi.has(cantica+"_"+num+"_"+canto))
|
2022-12-05 14:11:02 +01:00
|
|
|
return setVersi
|
2022-12-06 11:25:04 +01:00
|
|
|
else{
|
2022-12-05 14:11:02 +01:00
|
|
|
var elementoverso = $('<p />')
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
elementoverso.append(num + ". ")
|
|
|
|
elementoverso.attr("style", "line-height: 0.5em")
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
elementoverso.attr('class', 'f6 text-secondary text-nowrap font-weight-lighter')
|
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
elementoverso.attr('id', cantica+"_"+ canto.replace(" ", "_")+"_"+num)
|
|
|
|
elementoverso.appendTo('#' + cantica +canto.replace(" ", "_"))
|
|
|
|
setVersi.add(cantica+"_"+num+"_"+canto)
|
2022-12-05 14:11:02 +01:00
|
|
|
return setVersi
|
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
function createDivCanti(orderedListaCanti, cantica, canto){
|
|
|
|
if (orderedListaCanti.has(canto)){
|
2022-12-05 14:11:02 +01:00
|
|
|
return orderedListaCanti
|
|
|
|
}
|
|
|
|
var divcanto = $('<div />')
|
|
|
|
var titolocanto = $('<h4 class="titolo-canto pb-2" />')
|
2022-12-06 11:25:04 +01:00
|
|
|
titolocanto.append(cantica+", "+canto)
|
2022-12-05 14:11:02 +01:00
|
|
|
divcanto.attr('class', 'canto')
|
|
|
|
divcanto.attr('style', 'display:none')
|
|
|
|
divcanto.attr('id', (cantica + canto).replace(" ", "_"))
|
|
|
|
titolocanto.appendTo(divcanto)
|
|
|
|
divcanto.appendTo(' .blog-main')
|
|
|
|
orderedListaCanti.add(canto)
|
|
|
|
return orderedListaCanti
|
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
function renderData(cantica, listaCanti, listaVersi, listaForme){
|
|
|
|
//var orderedListaCanti = Array.from(listaCanti)
|
|
|
|
//orderedListaCanti = orderedListaCanti.sort((a, b) => {
|
|
|
|
// return parseInt(a.split(" ")[1], 10)-parseInt(b.split(" ")[1], 10)
|
|
|
|
//});
|
|
|
|
//var orderedListaVersi = Array.from(listaVersi)
|
|
|
|
//orderedListaVersi = orderedListaVersi.sort((a, b) => {
|
|
|
|
// return parseInt(a.numverso, 10)-parseInt(b.numverso, 10)
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
/*
|
|
|
|
listaVersi = listaVersi.filter((value, index, self) =>
|
|
|
|
index === self.findIndex((t) => (
|
|
|
|
t.numverso === value.numverso && t.canto === value.canto && t.cantica===value.cantica
|
|
|
|
))
|
|
|
|
)*/
|
|
|
|
|
|
|
|
//var orderedListaForme = Array.from(listaForme)
|
|
|
|
//orderedListaForme = orderedListaForme.sort((a, b) => {
|
|
|
|
// return parseInt(a.pos, 10)-parseInt(b.pos, 10)
|
|
|
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
//var divListaCanti = $('<DIV id="Canti' + cantica + '" />')
|
|
|
|
/*
|
|
|
|
for (canto of orderedListaCanti) {
|
|
|
|
|
|
|
|
|
|
|
|
var divcanto = $('<div />')
|
|
|
|
var titolocanto = $('<h4 class="titolo-canto pb-2" />')
|
|
|
|
titolocanto.append(cantica+", "+canto)
|
|
|
|
divcanto.attr('class', 'canto')
|
|
|
|
divcanto.attr('style', 'display:none')
|
|
|
|
divcanto.attr('id', (cantica + canto).replace(" ", "_"))
|
|
|
|
titolocanto.appendTo(divcanto)
|
|
|
|
divcanto.appendTo(' .blog-main')
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
//divListaCanti.appendTo('#listacanti')
|
|
|
|
//divListaCanti.appendTo(ddmenus[cantica])
|
|
|
|
/*
|
|
|
|
for (verso of listaVersi) {
|
|
|
|
|
|
|
|
|
|
|
|
var elementoverso = $('<p />')
|
|
|
|
//vartestoverso=verso.numverso;
|
|
|
|
elementoverso.append(verso.numverso + ". ")
|
|
|
|
elementoverso.attr("style", "line-height: 0.5em")
|
|
|
|
|
|
|
|
elementoverso.attr('class', 'f6 text-secondary text-nowrap font-weight-lighter')
|
|
|
|
//elementoverso.attr('class', 'f6 font-weight-lighter nowrap')
|
|
|
|
elementoverso.attr('id', verso.cantica+"_"+ verso.canto.replace(" ", "_")+"_"+verso.numverso)
|
|
|
|
elementoverso.appendTo('#' + cantica + verso.canto.replace(" ", "_"))
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
listaForme.forEach((element) => {
|
|
|
|
var spanoccorrenza=$('<span />')
|
|
|
|
var pos=parseInt(element.pos)
|
|
|
|
spanoccorrenza.attr('id', element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso+"_"+pos)
|
|
|
|
if (listarisultati.length>0 && listarisultati.includes(spanoccorrenza.attr('id')))
|
|
|
|
spanoccorrenza.attr('class', "f6 mark ")
|
|
|
|
spanoccorrenza.append(element.form)
|
|
|
|
elementoverso=$('#'+element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso)
|
|
|
|
spanoccorrenza.appendTo(elementoverso)
|
|
|
|
elementoverso.append(' ')
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
// Search functions
|
|
|
|
|
|
|
|
async function executeQueryVersi(query) {
|
|
|
|
bindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
|
|
|
|
alert(query)
|
|
|
|
try {
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
var listaCanti = new Set()
|
|
|
|
|
|
|
|
listaVersi = new Set()
|
|
|
|
listaForme = new Set()
|
|
|
|
let cantica = 0;
|
|
|
|
bindingsStream.on('data', (binding) => {
|
|
|
|
//cantica
|
|
|
|
cantica = binding.get('Cantica').value;
|
|
|
|
//la lista dei canti
|
|
|
|
listaCanti.add(binding.get('Canto').value)
|
|
|
|
//la lista dei versi
|
|
|
|
var obj = new Object();
|
|
|
|
var forma=new Object()
|
|
|
|
obj.numverso = binding.get('NumeroVerso').value;
|
|
|
|
obj.verso = binding.get('Verso').value;
|
|
|
|
obj.canto = binding.get('Canto').value;
|
|
|
|
//obj.pos = binding.get('pos').value;
|
|
|
|
//obj.form = binding.get('textform').value;
|
|
|
|
obj.cantica = cantica;
|
|
|
|
listaVersi.add(obj)
|
|
|
|
forma.numverso = binding.get('NumeroVerso').value;
|
|
|
|
forma.canto = binding.get('Canto').value;
|
|
|
|
forma.pos = binding.get('pos').value;
|
|
|
|
forma.form = binding.get('textform').value;
|
|
|
|
forma.cantica = cantica;
|
|
|
|
|
|
|
|
listaForme.add(forma)
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
});
|
|
|
|
bindingsStream.on('end', () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var orderedListaCanti = Array.from(listaCanti)
|
|
|
|
orderedListaCanti = orderedListaCanti.sort((a, b) => {
|
|
|
|
return parseInt(a.split(" ")[1], 10)-parseInt(b.split(" ")[1], 10)
|
|
|
|
//if (parseInt(a.split(" ")[1], 10) < parseInt(b.split(" ")[1]), 10) {
|
|
|
|
// return -1;
|
|
|
|
//}
|
|
|
|
});
|
|
|
|
|
|
|
|
var orderedListaVersi = Array.from(listaVersi)
|
|
|
|
|
|
|
|
orderedListaVersi = orderedListaVersi.sort((a, b) => {
|
|
|
|
return parseInt(a.numverso, 10)-parseInt(b.numverso, 10)
|
|
|
|
//if (parseInt(a.numverso, 10) < parseInt(b.numverso, 10)) {
|
|
|
|
// console.log(parseInt(a.numverso, 10)+' '+parseInt(b.numverso, 10))
|
|
|
|
// return -1;
|
|
|
|
//}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
orderedListaVersi = orderedListaVersi.filter((value, index, self) =>
|
|
|
|
index === self.findIndex((t) => (
|
|
|
|
t.numverso === value.numverso && t.canto === value.canto && t.cantica===value.cantica
|
|
|
|
))
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var orderedListaForme = Array.from(listaForme)
|
|
|
|
orderedListaForme = orderedListaForme.sort((a, b) => {
|
|
|
|
return parseInt(a.pos, 10)-parseInt(b.pos, 10)
|
|
|
|
//if (parseInt(a.pos) < parseInt(b.pos)) {
|
|
|
|
// return -1;
|
|
|
|
//}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var divListaCanti = $('<DIV id="Canti' + cantica + '" />')
|
|
|
|
for (canto of orderedListaCanti) {
|
|
|
|
var licanto = $('<li class="navig-canto"/>')
|
|
|
|
licanto.attr('name', cantica + canto)
|
|
|
|
licanto.attr('href', "#")
|
|
|
|
licanto.attr("style", "line-height: 1.2em")
|
|
|
|
numcanto=canto.split(" ")[1]
|
|
|
|
licanto.append(numcanto)
|
|
|
|
|
|
|
|
//licanto.appendTo('#listacanti')
|
|
|
|
licanto.appendTo(divListaCanti)
|
|
|
|
var divcanto = $('<div />')
|
|
|
|
var titolocanto = $('<h1 class="f3 titolo-canto" />')
|
|
|
|
titolocanto.append(cantica+", "+canto)
|
|
|
|
divcanto.attr('class', 'canto')
|
|
|
|
divcanto.attr('style', 'display:none')
|
|
|
|
divcanto.attr('id', (cantica + canto).replace(" ", "_"))
|
|
|
|
titolocanto.appendTo(divcanto)
|
|
|
|
divcanto.appendTo(' .blog-main')
|
|
|
|
}
|
|
|
|
//divListaCanti.appendTo('#listacanti')
|
|
|
|
divListaCanti.appendTo(ddmenus[cantica])
|
|
|
|
for (verso of orderedListaVersi) {
|
|
|
|
|
|
|
|
|
|
|
|
var elementoverso = $('<p />')
|
|
|
|
vartestoverso=verso.numverso;
|
|
|
|
elementoverso.append(verso.numverso + ". ")
|
|
|
|
//elementoverso.append(verso.numverso + ". " + managePunctuation(verso.verso))
|
|
|
|
elementoverso.attr("style", "line-height: 0.5em")
|
|
|
|
elementoverso.attr('class', 'f6 font-weight-lighter nowrap')
|
|
|
|
elementoverso.attr('id', verso.cantica+"_"+ verso.canto.replace(" ", "_")+"_"+verso.numverso)
|
|
|
|
elementoverso.appendTo('#' + cantica + verso.canto.replace(" ", "_"))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
orderedListaForme.forEach((element) => {
|
|
|
|
var spanoccorrenza=$('<span />')
|
|
|
|
var pos=parseInt(element.pos)
|
|
|
|
spanoccorrenza.attr('id', element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso+"_"+pos)
|
|
|
|
if (listarisultati.length>0 && 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)
|
|
|
|
elementoverso.append(' ')
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.log(err.message);
|
|
|
|
$("#loader").hide();
|
|
|
|
};
|
|
|
|
};
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
//execute query
|
|
|
|
var listarisultati=[];
|
2022-11-11 22:11:22 +01:00
|
|
|
async function executeQuerySearch(query) {
|
|
|
|
seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
|
2022-12-06 15:48:49 +01:00
|
|
|
console.log(query)
|
2022-11-11 22:11:22 +01:00
|
|
|
alert(query)
|
|
|
|
try {
|
2022-11-18 11:13:18 +01:00
|
|
|
var result = new Set()
|
2022-12-06 11:25:04 +01:00
|
|
|
var resultsInCantica=[]
|
|
|
|
var resultsInCanto=[]
|
2022-11-11 22:11:22 +01:00
|
|
|
seachbBindingsStream.on('data', (binding) => {
|
|
|
|
//cantica
|
|
|
|
cantica = binding.get('Cantica').value;
|
2022-11-18 11:13:18 +01:00
|
|
|
resultsInCantica.push(cantica);
|
2022-11-11 22:11:22 +01:00
|
|
|
//canto
|
2022-12-06 11:25:04 +01:00
|
|
|
canto=binding.get('Canto').value;
|
|
|
|
resultsInCanto.push(cantica+canto)
|
2022-11-11 22:11:22 +01:00
|
|
|
//numero del verso
|
2022-12-06 11:25:04 +01:00
|
|
|
numverso=binding.get('NumeroVerso').value;
|
2022-11-11 22:26:10 +01:00
|
|
|
//posizione delframmento
|
2022-12-06 11:25:04 +01:00
|
|
|
pos=binding.get('pos').value;
|
|
|
|
result.add(cantica+"_"+canto.replace(" ", "_")+"_"+numverso+"_"+pos)
|
2022-11-11 22:11:22 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
seachbBindingsStream.on('end', () => {
|
2022-11-18 11:13:18 +01:00
|
|
|
listarisultati = Array.from(result)
|
2022-12-06 11:25:04 +01:00
|
|
|
cantiche=["Inferno", "Purgatorio", "Paradiso"]
|
|
|
|
|
2022-11-18 11:13:18 +01:00
|
|
|
//evidenzia risultati
|
2022-12-06 11:25:04 +01:00
|
|
|
for (ris of listarisultati){
|
|
|
|
idris='#'+ris
|
2022-12-05 11:41:58 +01:00
|
|
|
$(idris).attr('class', "f6 mark ")
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-12 19:45:14 +01:00
|
|
|
}
|
2022-11-18 11:13:18 +01:00
|
|
|
//aggiunge badge con totale risultati accanto alle cantiche
|
2022-12-06 11:25:04 +01:00
|
|
|
i=0
|
|
|
|
for(cantica of cantiche){
|
|
|
|
i+=1
|
2022-11-18 11:13:18 +01:00
|
|
|
let count = resultsInCantica.reduce((n, x) => n + (x === cantica), 0);
|
2022-12-06 11:25:04 +01:00
|
|
|
var spanbadgecantica=$('<span />');
|
2022-11-18 12:48:53 +01:00
|
|
|
spanbadgecantica.attr('class', 'badge badge-primary badge-pill ml-1');
|
2022-11-18 11:19:06 +01:00
|
|
|
spanbadgecantica.append(count)
|
2022-12-06 11:25:04 +01:00
|
|
|
spanbadgecantica.appendTo($('#cantica'+i))
|
2022-11-18 11:13:18 +01:00
|
|
|
}
|
|
|
|
//aggiunge badge con totale risultati accanto ai canti
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
for(cantica of cantiche){
|
|
|
|
for( k of Array(35).keys()){
|
|
|
|
if (k==0)
|
2022-11-18 11:13:18 +01:00
|
|
|
continue
|
2022-12-06 11:25:04 +01:00
|
|
|
let count = resultsInCanto.reduce((n, x) => n + (x === cantica+'Canto '+k), 0);
|
|
|
|
|
|
|
|
var spanbadge=$('<span />');
|
2022-11-18 12:48:53 +01:00
|
|
|
spanbadge.attr('class', cantobadgeclass);
|
|
|
|
spanbadge.append(count)
|
2022-11-18 11:13:18 +01:00
|
|
|
//$("[name='nameofobject']")
|
2022-12-06 11:25:04 +01:00
|
|
|
spanbadge.appendTo($('[name="'+cantica+'Canto '+k+'"]'))
|
2022-11-18 11:13:18 +01:00
|
|
|
//spanbadge.insertAfter($('[name="'+cantica+'Canto '+k+'"]'))
|
|
|
|
}
|
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
|
|
|
|
2022-11-18 11:13:18 +01:00
|
|
|
//aggiorna minimap
|
2022-12-06 11:25:04 +01:00
|
|
|
if (currentMinimap!=''){
|
|
|
|
|
2022-11-12 19:45:14 +01:00
|
|
|
showMinimap(currentMinimap)
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
|
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
});
|
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
catch (err) {
|
|
|
|
console.log(err.message);
|
|
|
|
$("#loader").hide();
|
2022-11-06 17:12:56 +01:00
|
|
|
};
|
|
|
|
};
|
2022-11-08 10:44:20 +01:00
|
|
|
|
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
});
|