2022-11-06 17:12:56 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2022-11-08 10:44:20 +01:00
|
|
|
$(document).ready(function() {
|
2022-12-13 09:30:15 +01:00
|
|
|
const categoriegrammaticali={"v":"Verbo", "s":"Sostantivo", "a":"Aggettivo", "p":"Pronome", "r":"Articolo", "b":"Avverbio","e":"Preposizione",
|
|
|
|
"c":"Congiunzione", "i":"Interiezione", "n":"Onomastica", "f":"Citazione", "l":"Locuzione",
|
|
|
|
"r-e":"Articolo, Preposizione", "b-v":"Avverbio, Verbo", "p-v":"Pronome, Verbo",
|
|
|
|
"b-p-v":"Avverbio, Pronome, Verbo", "b-p":"Avverbio, Pronome",
|
|
|
|
"e-p":"Preposizione, Pronome", "a-s":"Aggettivo, Sostantivo"}
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 17:39:52 +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-06 17:39:52 +01:00
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
var listaVersi = new Set()
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
var currentMinimap = ''
|
|
|
|
var listarisultati = [];
|
2022-12-09 10:45:43 +01:00
|
|
|
var minimapScrolling = false;
|
|
|
|
var displayId = 'displaycanto'
|
|
|
|
var minimapTopPos;
|
|
|
|
//used in minimap
|
|
|
|
//
|
|
|
|
let minimap = document.createElement('div');
|
|
|
|
let minimapSize = document.createElement('div');
|
|
|
|
let viewer = document.createElement('div');
|
|
|
|
let minimapContent = document.createElement('iframe');
|
|
|
|
let scale = 0.1;
|
|
|
|
let realScale;
|
|
|
|
let mappedElement = '';
|
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
hideMinimap();
|
2022-12-10 12:48:37 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
showCantica('Inferno')
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
$('#cantica2').css({ 'opacity': 0.40 });
|
|
|
|
$('#cantica3').css({ 'opacity': 0.40 });
|
2022-12-09 10:45:43 +01:00
|
|
|
//$("#CantiInferno").attr('style', 'display:block')
|
2022-12-06 17:39:52 +01:00
|
|
|
$("#InfernoCanto_1").attr('style', 'display:block')
|
2022-12-09 10:45:43 +01:00
|
|
|
drawMinimap("InfernoCanto_1")
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
showCantica('Purgatorio')
|
|
|
|
showCantica('Paradiso')
|
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-09 10:45:43 +01:00
|
|
|
// prima cantica
|
2022-11-06 17:12:56 +01:00
|
|
|
$('#cantica1').on('click', function() {
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-12 13:30:59 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
$('#cantica1').css({ 'opacity': 1 });
|
|
|
|
$('#cantica2').css({ 'opacity': 0.40 });
|
|
|
|
$('#cantica3').css({ 'opacity': 0.40 });
|
2022-11-07 11:52:54 +01:00
|
|
|
});
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-09 10:45:43 +01:00
|
|
|
// seconda cantica
|
2022-11-07 11:52:54 +01:00
|
|
|
$('#cantica2').on('click', function() {
|
2022-12-12 13:30:59 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
$('#cantica1').css({ 'opacity': 0.40 });
|
|
|
|
$('#cantica2').css({ 'opacity': 1 });
|
|
|
|
$('#cantica3').css({ 'opacity': 0.40 });
|
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-12-09 10:45:43 +01:00
|
|
|
// terza cantica
|
2022-11-07 11:52:54 +01:00
|
|
|
$('#cantica3').on('click', function() {
|
2022-12-12 13:30:59 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
$('#cantica1').css({ 'opacity': 0.40 });
|
|
|
|
$('#cantica2').css({ 'opacity': 0.40 });
|
|
|
|
$('#cantica3').css({ 'opacity': 1 });
|
|
|
|
});
|
|
|
|
var mmih = 0
|
|
|
|
var mmiw = 0
|
2022-12-09 10:45:43 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
$("#" + displayId).scroll(function() {
|
|
|
|
if (minimapScrolling) {
|
|
|
|
minimapScrolling = false
|
|
|
|
console.log('no scroll')
|
2022-11-07 11:52:54 +01:00
|
|
|
}
|
2022-11-08 10:44:20 +01:00
|
|
|
else {
|
2022-12-06 17:39:52 +01:00
|
|
|
console.log('yes scrolling')
|
|
|
|
console.log("viewer top pos before: " + $('#minimapviewer').offset().top)
|
|
|
|
trackScrollCanto()
|
|
|
|
console.log("viewer top pos after: " + $('#minimapviewer').offset().top)
|
2022-12-06 11:25:04 +01:00
|
|
|
}
|
2022-11-06 17:12:56 +01:00
|
|
|
});
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
|
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-12-06 17:39:52 +01:00
|
|
|
// Crea id per la div che contiene il canto
|
2022-11-08 10:44:20 +01:00
|
|
|
$("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display:block')
|
2022-12-06 17:39:52 +01:00
|
|
|
manageMiniMap(this);
|
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-12-06 17:39:52 +01:00
|
|
|
function manageMiniMap(divElem) {
|
|
|
|
mmiw = $("#" + displayId).innerWidth();
|
|
|
|
mmih = $("#" + displayId).innerHeight();
|
2022-12-09 10:45:43 +01:00
|
|
|
drawMinimap($(divElem).attr('name').replace(" ", "_"))
|
2022-12-06 17:39:52 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
//Query
|
2022-11-14 09:22:00 +01:00
|
|
|
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-12 13:30:59 +01:00
|
|
|
jQuery(document).delegate('#searchcomm, #searchcomm2', 'click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
manageQuery()
|
2022-12-06 17:39:52 +01:00
|
|
|
});
|
2022-12-12 13:30:59 +01:00
|
|
|
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
//Reset
|
2022-12-06 10:01:42 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
jQuery(document).delegate('#cleanresult', 'click', function(e) {
|
|
|
|
console.log('clean')
|
|
|
|
cleanSearchResult()
|
|
|
|
esprlogica = []
|
|
|
|
$('#queryText').val("")
|
|
|
|
|
|
|
|
});
|
2022-12-09 10:45:43 +01:00
|
|
|
|
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
//Utility functions
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-09 10:45:43 +01:00
|
|
|
function drawMinimap(name){
|
|
|
|
|
|
|
|
showMinimap(name)
|
|
|
|
currentMinimap = name;
|
|
|
|
|
|
|
|
//mmviewer diventa draggable
|
|
|
|
minimapTopPos = $('#minimapviewer').offset().top
|
|
|
|
console.log("top viewer init " + minimapTopPos)
|
|
|
|
|
|
|
|
$('#minimapviewer').draggable({
|
|
|
|
axis: "y",
|
|
|
|
containment: $('#displayminimap'),
|
|
|
|
scroll: false,
|
|
|
|
start: function(event, ui) { minimapScrolling = true; },
|
|
|
|
stop: function(event, ui) { minimapScrolling = false; },
|
|
|
|
drag: function(event, ui) {
|
|
|
|
|
|
|
|
minimapScrolling = true;
|
|
|
|
trackScrollViewer(ui.offset.top - minimapTopPos);
|
|
|
|
console.log(ui);
|
|
|
|
}
|
|
|
|
});
|
2022-12-06 11:25:04 +01:00
|
|
|
}
|
2022-12-12 13:30:59 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
function cleanSearchResult() {
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
for (verso of listarisultati) {
|
|
|
|
idverso = '#' + verso
|
2022-12-12 15:18:43 +01:00
|
|
|
$(idverso).attr('class', 'f6 text-secondary text-nowrap font-weight-lighter')
|
2022-12-06 17:39:52 +01:00
|
|
|
}
|
|
|
|
$(".badge").remove();
|
|
|
|
listarisultati = []
|
|
|
|
if (currentMinimap != '')
|
|
|
|
showMinimap(currentMinimap)
|
|
|
|
}
|
2022-12-12 13:30:59 +01:00
|
|
|
|
|
|
|
function manageQuery(){
|
|
|
|
cleanSearchResult()
|
|
|
|
esprlogica = []
|
|
|
|
jsonQuery=getJsonQuery()
|
|
|
|
console.log("got json query")
|
|
|
|
|
|
|
|
jsonQuery = buildSQ(jsonQuery)
|
|
|
|
|
|
|
|
myquery = new sparqlGenerator().stringify(jsonQuery)
|
|
|
|
console.log(myquery)
|
|
|
|
executeQuerySearch(myquery)
|
|
|
|
}
|
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
//minimap management
|
2022-12-09 10:45:43 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
function showMinimap(element) {
|
|
|
|
mmplace = document.getElementById('displayminimap')
|
2022-12-05 11:41:58 +01:00
|
|
|
minimap.className = 'minimap__container'
|
|
|
|
minimapSize.className = 'minimap__size'
|
|
|
|
viewer.className = 'minimap__viewer'
|
2022-12-06 17:39:52 +01:00
|
|
|
viewer.id = 'minimapviewer'
|
2022-12-05 11:41:58 +01:00
|
|
|
minimapContent.className = 'minimap__content'
|
2022-11-08 10:44:20 +01:00
|
|
|
minimap.append(minimapSize, viewer, minimapContent);
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
mmplace.appendChild(minimap)
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
let html = document.getElementById(element).outerHTML//innerHTML
|
2022-12-06 17:39:52 +01:00
|
|
|
if (html == null | html == '')
|
2022-12-05 11:41:58 +01:00
|
|
|
return;
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
let iFrameDoc = minimapContent.contentWindow.document;
|
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 17:39:52 +01:00
|
|
|
cssLinkb.rel = "stylesheet";
|
2022-11-17 16:37:08 +01:00
|
|
|
cssLinkb.type = "text/css";
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-11-18 14:55:06 +01:00
|
|
|
var cssLinkscroll = document.createElement("link");
|
|
|
|
cssLinkscroll.href = "./css/browsingldc.css";
|
2022-12-06 17:39:52 +01:00
|
|
|
cssLinkscroll.rel = "stylesheet";
|
2022-11-18 14:55:06 +01:00
|
|
|
cssLinkscroll.type = "text/css";
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-11-08 10:44:20 +01:00
|
|
|
iFrameDoc.open();
|
|
|
|
iFrameDoc.write(html);
|
|
|
|
iFrameDoc.close();
|
2022-12-06 17:39:52 +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 17:39:52 +01:00
|
|
|
mappedElement = element
|
|
|
|
|
2022-11-17 16:37:08 +01:00
|
|
|
getDimensionsDiv()
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
window.addEventListener('scroll', trackScroll)
|
2022-11-17 16:37:08 +01:00
|
|
|
window.addEventListener('resize', getDimensionsDiv)
|
|
|
|
}
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getInnerHeight(elm) {
|
|
|
|
var computed = getComputedStyle(elm),
|
|
|
|
padding = parseInt(computed.paddingTop) + parseInt(computed.paddingBottom);
|
|
|
|
|
|
|
|
return elm.clientHeight - padding
|
2022-12-06 10:01:42 +01:00
|
|
|
}
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
function getDimensionsDiv() {
|
|
|
|
cantoplace = document.getElementById(displayId)
|
|
|
|
elementplace = document.getElementById(mappedElement)
|
|
|
|
|
|
|
|
bodyWidth = elementplace.clientWidth;
|
|
|
|
bodyRatio = elementplace.clientHeight / bodyWidth;
|
|
|
|
|
|
|
|
let winRatio = getInnerHeight(cantoplace) / (cantoplace.clientWidth);
|
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
//minimap.style.width='15%';
|
2022-12-06 17:39:52 +01:00
|
|
|
minimap.style.width = '100%';
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
realScale = minimap.clientWidth / bodyWidth;
|
2022-12-06 11:25:04 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
minimapSize.style.paddingTop = `${bodyRatio * 100}%`
|
|
|
|
viewer.style.paddingTop = `${winRatio * 100}%`;
|
|
|
|
minimapContent.style.transform = `scale(${realScale})`;
|
|
|
|
minimapContent.style.width = `${(100 / realScale)}%`;
|
2022-12-10 12:48:37 +01:00
|
|
|
minimapContent.style.height = `${(100 / realScale)}%`;
|
2022-12-06 17:39:52 +01:00
|
|
|
//minimapContent.style.height=`100%`;
|
|
|
|
minimapContent.style.float = 'right';
|
2022-11-07 11:52:54 +01:00
|
|
|
}
|
2022-11-17 10:15:29 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
function trackScroll() {
|
|
|
|
//console.log(window.scrollY)
|
|
|
|
viewer.style.transform = `translateY(${window.scrollY * realScale}px)`
|
2022-11-17 10:15:29 +01:00
|
|
|
}
|
2022-12-06 17:39:52 +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-15 10:41:16 +01:00
|
|
|
}
|
2022-12-06 17:39:52 +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))
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideMinimap() {
|
2022-11-11 22:11:22 +01:00
|
|
|
$('.canto').each(function() {
|
|
|
|
$(this).attr("style", 'display:none');
|
|
|
|
});
|
2022-12-06 17:39:52 +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
|
|
|
|
2022-12-05 11:41:58 +01:00
|
|
|
//Cantica management functions
|
2022-12-06 17:39:52 +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-10 12:48:37 +01:00
|
|
|
$("#loader").show();
|
2022-12-09 10:45:43 +01:00
|
|
|
containerForme = formeprima
|
|
|
|
if (cantica == 'Paradiso')
|
|
|
|
containerForme = formeterza
|
2022-12-06 17:39:52 +01:00
|
|
|
if (cantica == 'Purgatorio')
|
|
|
|
containerForme = formeseconda
|
|
|
|
for (cmpItem of containerForme) {
|
2022-12-13 09:30:15 +01:00
|
|
|
formaItem = cmpItem.split("_")
|
2022-12-06 17:39:52 +01:00
|
|
|
listaCanti = createDivCanti(listaCanti, cantica, 'Canto ' + formaItem[1])
|
|
|
|
var forma = new Object()
|
|
|
|
setVersi = createDivVersi(setVersi, cantica, formaItem[3], 'Canto ' + formaItem[1])
|
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
forma.numverso = formaItem[3];
|
2022-12-06 17:39:52 +01:00
|
|
|
forma.canto = 'Canto ' + formaItem[1];
|
2022-12-05 11:41:58 +01:00
|
|
|
forma.pos = formaItem[2];
|
|
|
|
forma.form = formaItem[0];
|
2022-12-13 09:30:15 +01:00
|
|
|
forma.catgramm = formaItem[4];
|
2022-12-05 11:41:58 +01:00
|
|
|
forma.cantica = cantica;
|
2022-12-05 14:11:02 +01:00
|
|
|
createSpanForme(forma)
|
2022-12-05 11:41:58 +01:00
|
|
|
}
|
2022-12-10 12:48:37 +01:00
|
|
|
$("#loader").hide();
|
2022-12-05 11:41:58 +01:00
|
|
|
return
|
|
|
|
}
|
2022-12-06 15:48:49 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
function createSpanForme(element) {
|
|
|
|
var spanoccorrenza = $('<span />')
|
|
|
|
var pos = parseInt(element.pos)
|
|
|
|
spanoccorrenza.attr('id', element.cantica + "_" + element.canto.replace(" ", "_") + "_" + element.numverso + "_" + pos)
|
2022-12-13 09:30:15 +01:00
|
|
|
spanoccorrenza.attr('cg', element.catgramm)
|
2022-12-06 17:39:52 +01:00
|
|
|
if (listarisultati.length > 0 && listarisultati.includes(spanoccorrenza.attr('id')))
|
2022-12-12 15:18:43 +01:00
|
|
|
spanoccorrenza.attr('class', "font-weight-bold mark ")
|
2022-12-05 14:11:02 +01:00
|
|
|
spanoccorrenza.append(element.form.replaceAll("%20", " "))
|
2022-12-06 17:39:52 +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 17:39:52 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
}
|
2022-12-06 17:39:52 +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 17:39:52 +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 17:39:52 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
elementoverso.attr('class', 'f6 text-secondary text-nowrap font-weight-lighter')
|
|
|
|
|
2022-12-06 17:39:52 +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 17:39:52 +01:00
|
|
|
|
2022-12-05 14:11:02 +01:00
|
|
|
}
|
2022-12-06 17:39:52 +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 17:39:52 +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-12 13:30:59 +01:00
|
|
|
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
|
2022-12-06 11:25:04 +01:00
|
|
|
//execute query
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-11-11 22:11:22 +01:00
|
|
|
async function executeQuerySearch(query) {
|
2022-12-10 12:48:37 +01:00
|
|
|
$("#loader").show();
|
2022-11-11 22:11:22 +01:00
|
|
|
seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], });
|
2022-12-06 17:39:52 +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 17:39:52 +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-12-12 15:18:43 +01:00
|
|
|
|
2022-11-11 22:11:22 +01:00
|
|
|
//canto
|
2022-12-06 17:39:52 +01:00
|
|
|
canto = binding.get('Canto').value;
|
2022-12-12 15:18:43 +01:00
|
|
|
|
2022-11-11 22:11:22 +01:00
|
|
|
//numero del verso
|
2022-12-06 17:39:52 +01:00
|
|
|
numverso = binding.get('NumeroVerso').value;
|
2022-12-12 15:18:43 +01:00
|
|
|
//posizione del frammento
|
2022-12-06 17:39:52 +01:00
|
|
|
pos = binding.get('pos').value;
|
2022-12-12 15:18:43 +01:00
|
|
|
if (!result.has(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)){
|
|
|
|
result.add(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)
|
|
|
|
resultsInCantica.push(cantica);
|
|
|
|
resultsInCanto.push(cantica + canto)
|
|
|
|
}
|
|
|
|
|
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 17:39:52 +01:00
|
|
|
cantiche = ["Inferno", "Purgatorio", "Paradiso"]
|
|
|
|
|
2022-11-18 11:13:18 +01:00
|
|
|
//evidenzia risultati
|
2022-12-06 17:39:52 +01:00
|
|
|
for (ris of listarisultati) {
|
|
|
|
idris = '#' + ris
|
2022-12-12 15:18:43 +01:00
|
|
|
$(idris).attr('class', "font-weight-bold mark ")
|
2022-12-06 17:39:52 +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 17:39:52 +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-12 13:30:59 +01:00
|
|
|
if (count>0){
|
|
|
|
var spanbadgecantica = $('<span />');
|
|
|
|
spanbadgecantica.attr('class', 'badge badge-primary badge-pill ml-1');
|
|
|
|
spanbadgecantica.append(count)
|
|
|
|
spanbadgecantica.appendTo($('#cantica' + i))
|
|
|
|
}
|
2022-11-18 11:13:18 +01:00
|
|
|
}
|
|
|
|
//aggiunge badge con totale risultati accanto ai canti
|
2022-12-06 17:39:52 +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 17:39:52 +01:00
|
|
|
let count = resultsInCanto.reduce((n, x) => n + (x === cantica + 'Canto ' + k), 0);
|
2022-12-12 13:30:59 +01:00
|
|
|
if (count>0){
|
|
|
|
var spanbadge = $('<span />');
|
|
|
|
spanbadge.attr('class', cantobadgeclass);
|
|
|
|
spanbadge.append(count)
|
|
|
|
//$("[name='nameofobject']")
|
|
|
|
spanbadge.appendTo($('[name="' + cantica + 'Canto ' + k + '"]'))
|
|
|
|
//spanbadge.insertAfter($('[name="'+cantica+'Canto '+k+'"]'))
|
|
|
|
}
|
2022-11-18 11:13:18 +01:00
|
|
|
}
|
|
|
|
}
|
2022-12-06 17:39:52 +01:00
|
|
|
|
|
|
|
|
2022-11-18 11:13:18 +01:00
|
|
|
//aggiorna minimap
|
2022-12-06 17:39:52 +01:00
|
|
|
if (currentMinimap != '') {
|
|
|
|
|
2022-11-12 19:45:14 +01:00
|
|
|
showMinimap(currentMinimap)
|
2022-12-06 17:39:52 +01:00
|
|
|
|
2022-11-06 17:12:56 +01:00
|
|
|
}
|
2022-12-10 12:48:37 +01:00
|
|
|
$("#loader").hide();
|
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);
|
2022-12-10 12:48:37 +01:00
|
|
|
//$("#loader").hide();
|
2022-11-06 17:12:56 +01:00
|
|
|
};
|
2022-12-10 12:48:37 +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
|
|
|
});
|