carica i canto in maniera differenziata. visualizza il canto selezionato
relativo alla cantica selezionata
This commit is contained in:
parent
3f89ee28ca
commit
03fa724606
|
@ -1,17 +1,19 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
var resetResult;
|
||||
var resetResult;
|
||||
|
||||
$(document).ready(function() {
|
||||
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",
|
||||
"e-r":"Preposizione, Articolo", "v-b":"Verbo, Avverbio", "v-p":"Verbo, Pronome",
|
||||
"v-p-b":"Verbo, Pronome, Avverbio", "p-b":"Pronome, Avverbio",
|
||||
"p-e":"Pronome, Preposizione", "s-a":"Sostantivo, Aggettivo",}
|
||||
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",
|
||||
"e-r": "Preposizione, Articolo", "v-b": "Verbo, Avverbio", "v-p": "Verbo, Pronome",
|
||||
"v-p-b": "Verbo, Pronome, Avverbio", "p-b": "Pronome, Avverbio",
|
||||
"p-e": "Pronome, Preposizione", "s-a": "Sostantivo, Aggettivo",
|
||||
}
|
||||
|
||||
const cantobadgeclass = 'badge badge-outline-info badge-pill'
|
||||
|
||||
|
@ -37,7 +39,12 @@ $(document).ready(function() {
|
|||
let realScale;
|
||||
let mappedElement = '';
|
||||
|
||||
resetResult=function(){
|
||||
var purgatorioSelected = "PurgatorioCanto_1";
|
||||
var paradisoSelected = "ParadisoCanto_1";
|
||||
var infernoSelected = "InfernoCanto_1";
|
||||
|
||||
|
||||
resetResult = function() {
|
||||
//console.log('clean result')
|
||||
cleanSearchResult()
|
||||
esprlogica = []
|
||||
|
@ -46,28 +53,71 @@ $(document).ready(function() {
|
|||
hideMinimap();
|
||||
createAllDivCanti()
|
||||
const start = performance.now();
|
||||
|
||||
showCantica('Inferno')
|
||||
showCantica('Purgatorio')
|
||||
showCantica('Paradiso')
|
||||
var purgatorioLoaded = false;
|
||||
var paradisoLoaded = false;
|
||||
|
||||
$("#InfernoCanto_1").attr('style', 'display:block')
|
||||
drawMinimap("InfernoCanto_1")
|
||||
const end = performance.now();
|
||||
console.log(`Load cantiche time: ${end - start} ms`);
|
||||
|
||||
jQuery(document).delegate('#cantica2', 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!purgatorioLoaded){
|
||||
showCantica('Purgatorio')
|
||||
purgatorioLoaded = true;
|
||||
}
|
||||
|
||||
$('.canto').each(function() {
|
||||
$(this).attr("style", 'display:none');
|
||||
});
|
||||
$("#"+purgatorioSelected).attr('style', 'display:block')
|
||||
manageMiniMap("#"+purgatorioSelected);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
jQuery(document).delegate('#cantica3', 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!paradisoLoaded){
|
||||
showCantica('Paradiso')
|
||||
paradisoLoaded = true;
|
||||
}
|
||||
|
||||
$('.canto').each(function() {
|
||||
$(this).attr("style", 'display:none');
|
||||
});
|
||||
$("#"+paradisoSelected).attr('style', 'display:block')
|
||||
manageMiniMap("#"+paradisoSelected);
|
||||
|
||||
return true;
|
||||
});
|
||||
jQuery(document).delegate('#cantica1', 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('.canto').each(function() {
|
||||
$(this).attr("style", 'display:none');
|
||||
});
|
||||
$("#"+infernoSelected).attr('style', 'display:block')
|
||||
manageMiniMap("#"+infernoSelected);
|
||||
return true;
|
||||
});
|
||||
$("[data-cg]").hover(function() {
|
||||
var details=getHoverContent($(this).data("cg"))
|
||||
var details = getHoverContent($(this).data("cg"))
|
||||
var index = details.indexOf(",");
|
||||
var categoria = "";
|
||||
if (index != -1){
|
||||
categoria = details.substring(0,index);
|
||||
details = details.substring(index+1);
|
||||
}else{
|
||||
if (index != -1) {
|
||||
categoria = details.substring(0, index);
|
||||
details = details.substring(index + 1);
|
||||
} else {
|
||||
categoria = details;
|
||||
details = "";
|
||||
}
|
||||
$(this).popover({title: categoria, content: details, trigger: "click"});
|
||||
$(this).popover({ title: categoria, content: details, trigger: "click" });
|
||||
});
|
||||
|
||||
var mmih = 0
|
||||
|
@ -101,6 +151,15 @@ $(document).ready(function() {
|
|||
function manageMiniMap(divElem) {
|
||||
mmiw = $("#" + displayId).innerWidth();
|
||||
mmih = $("#" + displayId).innerHeight();
|
||||
var selectedCanto = ($(divElem).attr('name').replace(" ", "_"));
|
||||
if (selectedCanto.startsWith("Inferno")){
|
||||
infernoSelected = selectedCanto;
|
||||
}else
|
||||
if(selectedCanto.startsWith("Paradiso")){
|
||||
paradisoSelected = selectedCanto;
|
||||
}else{
|
||||
purgatorioSelected = selectedCanto;
|
||||
}
|
||||
drawMinimap($(divElem).attr('name').replace(" ", "_"))
|
||||
}
|
||||
|
||||
|
@ -124,36 +183,36 @@ $(document).ready(function() {
|
|||
|
||||
//Utility functions
|
||||
|
||||
function getHoverContent(categ){
|
||||
function getHoverContent(categ) {
|
||||
//console.log('Categoria '+categ)
|
||||
if(categ.includes('-')){
|
||||
categs=categ.split('-')
|
||||
mycat=[]
|
||||
for (cat of categs){
|
||||
if (categ.includes('-')) {
|
||||
categs = categ.split('-')
|
||||
mycat = []
|
||||
for (cat of categs) {
|
||||
mycat.push(cat[0])
|
||||
}
|
||||
console.log(mycat.join('-'))
|
||||
return categoriegrammaticali[mycat.join('-')]
|
||||
}
|
||||
if (categ[0]=='v'){
|
||||
if (categ[0] == 'v') {
|
||||
return parserVerbi.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if(categ[0]=='s'){
|
||||
if (categ[0] == 's') {
|
||||
return parserSostantivi.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if(categ[0]=='e'){
|
||||
if (categ[0] == 'e') {
|
||||
return parserPreposizioni.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if(categ[0]=='b'){
|
||||
if (categ[0] == 'b') {
|
||||
return parserAvverbi.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if(categ[0]=='p'){
|
||||
if (categ[0] == 'p') {
|
||||
return parserPronomi.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if(categ[0]=='a'){
|
||||
if (categ[0] == 'a') {
|
||||
return parserAggettivi.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if(categ[0]=='r'){
|
||||
if (categ[0] == 'r') {
|
||||
return parserArticolo.parse(categ).split(',').filter(prop => prop.length > 0).join()
|
||||
}
|
||||
if (categ[0] == 'f') {
|
||||
|
@ -169,7 +228,7 @@ $(document).ready(function() {
|
|||
return categoriegrammaticali[categ[0]]
|
||||
}
|
||||
|
||||
function drawMinimap(name){
|
||||
function drawMinimap(name) {
|
||||
|
||||
showMinimap(name)
|
||||
currentMinimap = name;
|
||||
|
@ -205,12 +264,12 @@ $(document).ready(function() {
|
|||
showMinimap(currentMinimap)
|
||||
}
|
||||
|
||||
function manageQuery(){
|
||||
function manageQuery() {
|
||||
cleanSearchResult()
|
||||
esprlogica = []
|
||||
jsonQuery=getJsonQuery()
|
||||
jsonQuery = getJsonQuery()
|
||||
console.log("got json query")
|
||||
if(jsonQuery['QueryAvanzata']==0 && jsonQuery['Clausola0']['queryText']==''){
|
||||
if (jsonQuery['QueryAvanzata'] == 0 && jsonQuery['Clausola0']['queryText'] == '') {
|
||||
alert('Digitare una stringa da cercare')
|
||||
return
|
||||
}
|
||||
|
@ -333,18 +392,18 @@ $(document).ready(function() {
|
|||
if (cantica == 'Purgatorio')
|
||||
containerForme = formeseconda
|
||||
const endlc = performance.now();
|
||||
console.log(`Load `+cantica+` time: ${endlc - start} ms`);
|
||||
console.log(`Load ` + cantica + ` time: ${endlc - start} ms`);
|
||||
var elverso, formaItem
|
||||
for (var cmpItem of containerForme) {
|
||||
|
||||
formaItem = cmpItem.split("_")
|
||||
|
||||
//createDivVerso(cantica, num, canto, forma, catgram, pos)
|
||||
if (! setVersi.has(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])){
|
||||
elverso=createDivVerso(cantica, formaItem[3], 'Canto_' + formaItem[1], formaItem[0], formaItem[4], formaItem[2])
|
||||
setVersi.add(cantica+ "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])
|
||||
if (!setVersi.has(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])) {
|
||||
elverso = createDivVerso(cantica, formaItem[3], 'Canto_' + formaItem[1], formaItem[0], formaItem[4], formaItem[2])
|
||||
setVersi.add(cantica + "_" + formaItem[3] + "_" + 'Canto_' + formaItem[1])
|
||||
}
|
||||
else{
|
||||
else {
|
||||
//setVersi = createDivVersi(setVersi, cantica, formaItem[3], 'Canto_' + formaItem[1])
|
||||
createSpanFormeNew(cantica, 'Canto_' + formaItem[1], formaItem[3], formaItem[0], formaItem[4], formaItem[2], elverso)
|
||||
}
|
||||
|
@ -382,11 +441,11 @@ $(document).ready(function() {
|
|||
function createSpanFormeNew(cantica, canto, numverso, forma, catgramm, pos, elementoverso) {
|
||||
var spanoccorrenza = $('<span />')
|
||||
//var pos = parseInt(pos)
|
||||
spanoccorrenza.attr('id', cantica + "_" + canto+ "_" + numverso + "_" + pos)
|
||||
spanoccorrenza.attr('id', cantica + "_" + canto + "_" + numverso + "_" + pos)
|
||||
spanoccorrenza.attr('data-cg', catgramm)
|
||||
//if (listarisultati.length > 0 && listarisultati.includes(spanoccorrenza.attr('id')))
|
||||
// spanoccorrenza.attr('class', "font-weight-bold mark ")
|
||||
spanoccorrenza.append(forma+" ")
|
||||
spanoccorrenza.append(forma + " ")
|
||||
//elementoverso = $('#' + cantica + "_" + canto + "_" + numverso)
|
||||
spanoccorrenza.appendTo(elementoverso)
|
||||
//elementoverso.append(' ')
|
||||
|
@ -424,17 +483,17 @@ $(document).ready(function() {
|
|||
|
||||
var spanoccorrenza = $('<span />')
|
||||
//var pos = parseInt(pos)
|
||||
spanoccorrenza.attr('id', cantica + "_" + canto+ "_" + num + "_" + pos)
|
||||
spanoccorrenza.attr('id', cantica + "_" + canto + "_" + num + "_" + pos)
|
||||
spanoccorrenza.attr('data-cg', catgram)
|
||||
|
||||
spanoccorrenza.append(forma+" ")
|
||||
spanoccorrenza.append(forma + " ")
|
||||
spanoccorrenza.appendTo(elementoverso)
|
||||
|
||||
elementoverso.appendTo('#' + cantica + canto)
|
||||
return elementoverso
|
||||
|
||||
}
|
||||
/*
|
||||
/*
|
||||
function createDivCanti(orderedListaCanti, cantica, canto) {
|
||||
if (orderedListaCanti.has(canto)) {
|
||||
return orderedListaCanti
|
||||
|
@ -453,13 +512,13 @@ $(document).ready(function() {
|
|||
*/
|
||||
|
||||
function createAllDivCanti() {
|
||||
cantiche=["Inferno", "Purgatorio","Paradiso"]
|
||||
for (cantica of cantiche){
|
||||
for (var i=1; i<35; i++){
|
||||
if(i==34 && cantica!=="Inferno"){
|
||||
cantiche = ["Inferno", "Purgatorio", "Paradiso"]
|
||||
for (cantica of cantiche) {
|
||||
for (var i = 1; i < 35; i++) {
|
||||
if (i == 34 && cantica !== "Inferno") {
|
||||
continue
|
||||
}
|
||||
canto= "Canto "+i
|
||||
canto = "Canto " + i
|
||||
var divcanto = $('<div />')
|
||||
var titolocanto = $('<h4 class="titolo-canto pb-2" />')
|
||||
titolocanto.append(cantica + ", " + canto)
|
||||
|
@ -495,7 +554,7 @@ $(document).ready(function() {
|
|||
numverso = binding.get('NumeroVerso').value;
|
||||
//posizione del frammento
|
||||
pos = binding.get('pos').value;
|
||||
if (!result.has(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)){
|
||||
if (!result.has(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)) {
|
||||
result.add(cantica + "_" + canto.replace(" ", "_") + "_" + numverso + "_" + pos)
|
||||
resultsInCantica.push(cantica);
|
||||
resultsInCanto.push(cantica + canto)
|
||||
|
@ -518,7 +577,7 @@ $(document).ready(function() {
|
|||
for (cantica of cantiche) {
|
||||
i += 1
|
||||
let count = resultsInCantica.reduce((n, x) => n + (x === cantica), 0);
|
||||
if (count>0){
|
||||
if (count > 0) {
|
||||
var spanbadgecantica = $('<span />');
|
||||
spanbadgecantica.attr('class', 'badge badge-primary badge-pill ml-1');
|
||||
spanbadgecantica.append(count)
|
||||
|
@ -532,7 +591,7 @@ $(document).ready(function() {
|
|||
if (k == 0)
|
||||
continue
|
||||
let count = resultsInCanto.reduce((n, x) => n + (x === cantica + 'Canto ' + k), 0);
|
||||
if (count>0){
|
||||
if (count > 0) {
|
||||
var spanbadge = $('<span />');
|
||||
spanbadge.attr('class', cantobadgeclass);
|
||||
spanbadge.append(count)
|
||||
|
@ -560,11 +619,11 @@ $(document).ready(function() {
|
|||
|
||||
};
|
||||
|
||||
/*
|
||||
* REGOLE DI PARSING PER VISUALIZZAZIONE PROPRIETÀ
|
||||
*/
|
||||
/*
|
||||
* REGOLE DI PARSING PER VISUALIZZAZIONE PROPRIETÀ
|
||||
*/
|
||||
|
||||
var categoriegrammaticaliGrammar=`Expression = head:(Filtro){return 'Verbo,'+head.join()}
|
||||
var categoriegrammaticaliGrammar = `Expression = head:(Filtro){return 'Verbo,'+head.join()}
|
||||
Filtro= fhead:("v") tail:( transitivita? diatesi? impersonalita*
|
||||
coniugazione? modotempo?
|
||||
persona? funzione* declinazione?
|
||||
|
@ -641,7 +700,7 @@ _ "whitespace"= " "*
|
|||
|
||||
`
|
||||
|
||||
var categoriaGrammaticaleSostantivo = `
|
||||
var categoriaGrammaticaleSostantivo = `
|
||||
Expression = head:(Filtro){return 'Sostantivo,'+head.join()}
|
||||
Filtro= fhead:("s") tail:( genereforma? declinazionesostantivo? generelemma?
|
||||
numersingolareplurale? locuzione?){return tail}
|
||||
|
@ -667,7 +726,7 @@ _ "whitespace"= " "*
|
|||
|
||||
`
|
||||
|
||||
var categoriaGrammaticalePreposizione = `
|
||||
var categoriaGrammaticalePreposizione = `
|
||||
Expression = head:(Filtro){return 'Preposizione,'+head.join()}
|
||||
Filtro= fhead:("e") tail:( tipo1? tipo2? sintassi? complemento1? complemento2?){return tail}
|
||||
|
||||
|
@ -749,7 +808,7 @@ complemento2=
|
|||
"k14" {return(" Di Rapporto")}
|
||||
|
||||
`
|
||||
var avverbio = `Expression = head:(Filtro){return 'Avverbio,'+head.join()}
|
||||
var avverbio = `Expression = head:(Filtro){return 'Avverbio,'+head.join()}
|
||||
Filtro= fhead:("b") tail:( locuzione? tipo?){return tail}
|
||||
|
||||
locuzione = "lz" {return(' Avverbio in Locuzione Separato')}/
|
||||
|
@ -772,7 +831,7 @@ _ "whitespace"= " "*
|
|||
|
||||
`
|
||||
|
||||
var pronome = `Expression = head:(Filtro){return 'Pronome,'+head.join()}
|
||||
var pronome = `Expression = head:(Filtro){return 'Pronome,'+head.join()}
|
||||
Filtro= fhead:("p") tail:( tipo_pronome? classe_pronome? genere_pronome?
|
||||
numero_pronome? forma_pronome? funzione_pronome? tiporiflessivi?){return tail}
|
||||
|
||||
|
@ -822,7 +881,7 @@ Integer "integer"
|
|||
_ "whitespace"= " "*
|
||||
|
||||
`
|
||||
var categoriaGrammaticaleAggettivo = `
|
||||
var categoriaGrammaticaleAggettivo = `
|
||||
Expression = head:(Filtro){return 'Aggettivo,'+head.join()}
|
||||
Filtro= fhead:("a") tail:( tipo_aggettivo classe_aggettivo? genere_aggettivo?
|
||||
numero_aggettivo? grado_aggettivo? tipo_complemento? tipo_frase?
|
||||
|
@ -905,7 +964,7 @@ Integer "integer"
|
|||
_ "whitespace"= " "*
|
||||
|
||||
`
|
||||
var categoriaGrammaticaleArticolo = `
|
||||
var categoriaGrammaticaleArticolo = `
|
||||
|
||||
Expression = head:(Filtro){return 'Articolo,'+head.join()}
|
||||
Filtro= fhead:("r") tail:( tipo? genere? numero?){return tail}
|
||||
|
@ -930,7 +989,7 @@ _ "whitespace"= " "*
|
|||
|
||||
|
||||
`
|
||||
var citazione = `
|
||||
var citazione = `
|
||||
Expression = head:(Filtro){return 'Citazione,'+head.join()}
|
||||
Filtro= fhead:("f") tail:( fake? tipo?){return tail}
|
||||
|
||||
|
@ -948,7 +1007,7 @@ Integer "integer"
|
|||
_ "whitespace"= " "*
|
||||
|
||||
`
|
||||
var onomastica = `Expression = head:(Filtro){return 'Onomastica,'+head.join()}
|
||||
var onomastica = `Expression = head:(Filtro){return 'Onomastica,'+head.join()}
|
||||
Filtro= fhead:("n") tail:( proprio tipo?){return tail}
|
||||
|
||||
tipo="x" {return(' Separato')}/
|
||||
|
@ -960,7 +1019,7 @@ Integer "integer"
|
|||
|
||||
_ "whitespace"= " "*
|
||||
`
|
||||
var congiunzione =`
|
||||
var congiunzione = `
|
||||
Expression = head:(Filtro){return 'Congiunzione,'+head.join()}
|
||||
Filtro= fhead:("c") tail:( tipo? cordinativasubordinativa? tipocoordinativa?
|
||||
tiposubordinativa* complementodue?){return tail}
|
||||
|
@ -1004,17 +1063,17 @@ Integer "integer"
|
|||
|
||||
_ "whitespace"= " "*
|
||||
`
|
||||
//parser per categorie
|
||||
var parserVerbi = peg.generate(categoriegrammaticaliGrammar);
|
||||
var parserSostantivi = peg.generate(categoriaGrammaticaleSostantivo);
|
||||
var parserPreposizioni = peg.generate(categoriaGrammaticalePreposizione);
|
||||
var parserAvverbi = peg.generate(avverbio);
|
||||
var parserPronomi = peg.generate(pronome);
|
||||
var parserAggettivi = peg.generate(categoriaGrammaticaleAggettivo);
|
||||
var parserArticolo = peg.generate(categoriaGrammaticaleArticolo);
|
||||
var parserCitazione = peg.generate(citazione);
|
||||
var parserOnomastica = peg.generate(onomastica);
|
||||
var parserCongiunzione = peg.generate(congiunzione);
|
||||
//parser per categorie
|
||||
var parserVerbi = peg.generate(categoriegrammaticaliGrammar);
|
||||
var parserSostantivi = peg.generate(categoriaGrammaticaleSostantivo);
|
||||
var parserPreposizioni = peg.generate(categoriaGrammaticalePreposizione);
|
||||
var parserAvverbi = peg.generate(avverbio);
|
||||
var parserPronomi = peg.generate(pronome);
|
||||
var parserAggettivi = peg.generate(categoriaGrammaticaleAggettivo);
|
||||
var parserArticolo = peg.generate(categoriaGrammaticaleArticolo);
|
||||
var parserCitazione = peg.generate(citazione);
|
||||
var parserOnomastica = peg.generate(onomastica);
|
||||
var parserCongiunzione = peg.generate(congiunzione);
|
||||
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue