diff --git a/js/cesareBrowse.js b/js/cesareBrowse.js index dc7912f..236996d 100644 --- a/js/cesareBrowse.js +++ b/js/cesareBrowse.js @@ -113,8 +113,9 @@ $(document).ready(function() { myquery =new sparqlGenerator().stringify(jsonQuery) executeQuerySearch(myquery) - if (currentMinimap!='') - showMinimap(currentMinimap) + + + }); @@ -140,6 +141,7 @@ $(document).ready(function() { tempstringa=tempstringa.replaceAll(" !", "!") tempstringa=tempstringa.replaceAll(" ?", "?") tempstringa=tempstringa.replaceAll(" ;", ";") + tempstringa=tempstringa.replaceAll("%20", " ") return tempstringa } @@ -148,7 +150,8 @@ $(document).ready(function() { for (verso of listarisultativersi){ idverso='#'+verso console.log(idverso) - $(idverso).attr('class', $(idverso).attr('class').replace(" dark-blue", "")) + //$(idverso).attr('class', $(idverso).attr('class').replace(" dark-blue", "")) + $(idverso).attr('class', 'f6 font-weight-lighter') } if (currentMinimap!='') showMinimap(currentMinimap) @@ -234,6 +237,7 @@ $(document).ready(function() { var listaCanti = new Set() listaVersi = new Set() + listaForme = new Set() let cantica = 0; bindingsStream.on('data', (binding) => { //cantica @@ -242,13 +246,20 @@ $(document).ready(function() { 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.from = binding.get('from').value; - obj.to = binding.get('to').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) }); @@ -268,6 +279,25 @@ $(document).ready(function() { if (parseInt(a.numverso) < parseInt(b.numverso)) { 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) => { + if (parseInt(a.pos) < parseInt(b.pos)) { + return -1; + } + }); var divListaCanti = $('
') @@ -297,15 +327,17 @@ $(document).ready(function() { var elementoverso = $('

') vartestoverso=verso.numverso; elementoverso.append(verso.numverso + ". ") - arrayVerso=managePunctuation(verso.verso).split(" "); + /*arrayVerso=managePunctuation(verso.verso).split(" "); for (wpos in arrayVerso){ var divoccorrenza=$('') var pos=parseInt(verso.from)+parseInt(wpos) divoccorrenza.attr('id', verso.cantica+"_"+ verso.canto.replace(" ", "_")+"_"+verso.numverso+"_"+pos) - divoccorrenza.append(arrayVerso[wpos]+" ") + divoccorrenza.append(arrayVerso[wpos]) + divoccorrenza.appendTo(elementoverso) - } + elementoverso.append(' ') + }*/ //elementoverso.append(verso.numverso + ". " + managePunctuation(verso.verso)) elementoverso.attr("style", "line-height: 0.5em") elementoverso.attr('class', 'f6 font-weight-lighter') @@ -313,6 +345,16 @@ $(document).ready(function() { elementoverso.appendTo('#' + cantica + verso.canto.replace(" ", "_")) } + + orderedListaForme.forEach((element) => { + var spanoccorrenza=$('') + var pos=parseInt(element.pos) + spanoccorrenza.attr('id', element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso+"_"+pos) + spanoccorrenza.append(managePunctuation(element.form)) + elementoverso=$('#'+element.cantica+"_"+ element.canto.replace(" ", "_")+"_"+element.numverso) + spanoccorrenza.appendTo(elementoverso) + elementoverso.append(' ') + }) @@ -327,7 +369,7 @@ $(document).ready(function() { //execute query async function executeQuerySearch(query) { seachbBindingsStream = await myEngine.queryBindings(query, { sources: [{ type: 'sparql', value: sparqlEndpoint },], }); - console.log(query) + //console.log(query) alert(query) try { var resultVersi = new Set() @@ -349,7 +391,13 @@ $(document).ready(function() { for (verso of listarisultativersi){ idverso='#'+verso console.log(idverso) - $(idverso).attr('class', $(idverso).attr('class')+" dark-blue") + $(idverso).attr('class', "f6 b dark-blue ") + + } + if (currentMinimap!=''){ + + showMinimap(currentMinimap) + } diff --git a/js/utils.js b/js/utils.js index 82e5347..4ce1f95 100644 --- a/js/utils.js +++ b/js/utils.js @@ -76,7 +76,7 @@ LIMIT 20 ` // Per restituire i versi di una cantica -var qVersiCantica=` +var qVersiCanticaold=` PREFIX ecrm: PREFIX orl: PREFIX ontolex: @@ -99,6 +99,36 @@ var qVersiCantica=` FILTER regex(?t_cantica,"Inferno","i") . }` +var qVersiCantica=` + PREFIX ecrm: + PREFIX orl: + PREFIX ontolex: + PREFIX olires: + PREFIX xsd: + PREFIX text: + PREFIx hdn: + + SELECT (?textver AS ?Verso) (?NumVerso AS ?NumeroVerso) (?t_canto AS ?Canto) (?t_cantica AS ?Cantica) + ?textform ?pos + WHERE { + ?ver ecrm:P190_Has_Symbolic_Content ?textver; + olires:hasNumber ?NumVerso; + olires:hasStructuralComponent ?fa. +# olires:OccursInRegion ?reg . + ?fa orl:occurrenceOf ?form. + ?fa olires:OccursInRegion ?regfo . + ?regfo olires:fragmentRegionFrom ?pos . + ?form ontolex:writtenRep ?textform. +# ?reg olires:fragmentRegionFrom ?from; +# olires:fragmentRegionTo ?to . + ?canto ecrm:P102_has_title ?t_canto; + olires:hasStructuralComponent ?ver. + ?cantica ecrm:P102_has_title ?t_cantica ; + olires:hasStructuralComponent ?canto. + FILTER regex(?t_cantica,"Inferno","i") . + }` + + var hdnquerygrammar = ` Expression = head:((_)?"("(_)?("AND "/"OR ") Filtro+ (_)?(")")?){return '{"'+head[3]+'": ['+head[4]+"]}"}//{ return head}.join("").replaceAll(", ,","").replaceAll("(,","(").replaceAll(",("," (")}