diff --git a/browseMgr_5.2.js b/browseMgr_5.2.js
deleted file mode 100644
index 8c43e16..0000000
--- a/browseMgr_5.2.js
+++ /dev/null
@@ -1,3274 +0,0 @@
-/**
- *
- */
-import { getVersiConCitazioni, queryRiferimenti, getListaRis, cleanListaRis, getRisultatiRiferimenti, getListaIdCommenti, queryRiferimentimul, versoCommentato } from './dataMgr_5.2.js';
-import { getJsonQuery, emptyStructCard, setCurrentPage, managePage, emptyNoteList } from './script_5.2.js';
-import { resetGraphStr } from './syntgraph_5.2.js'
-
-
-export var manageRisultatoCommmenti;
-export var showRiferimentiFrasi;
-export var resetResult;
-export var lsentid;
-export var lisid;
-export const formaClass = 'frm'
-export var vistaPeriodi = false
-var vistaDialoghi = false
-var vistaRiferimenti = true
-export var listaPeriodiRisultato;
-export var listaClausoleRisultato;
-export var numeroContesti;
-export var cantoDisplayed;
-export var showOffset = 30;
-export var graphTextReset;
-export var isSearchRiferimenti = false;
-export var showFrasi;
-export var listarisultati = [];
-
-const cantobadgeclass = 'badge badge-outline-warning badge-pill'
-const hdnNamespace = 'http://dantenetwork.it/data/commedia/'
-const syntitNamespace = 'https://dantenetwork.it/ontology/syntit/current/'
-
-
-
-$(document).ready(function() {
- //removeGraph = false;
- const dialogspeakers = {
- "Beatrice": "diaBeatrice",
- "Dante": "diaDante",
- "Virgilio": "diaVirgilio",
- "Cacciaguida": "diaCacciaguida",
- "san Bernardo": "diaSanBernardo"
- }
- const dialogaltri = 'diaAltri'
- const versiPerGruppo = 5;
- var listaClausoleRisultatoContesti = []
-
- var listaRisultatiCommenti = []
- graphTextReset = function() { manageResults() }
-
- const sparqlGenerator = sparqljs.Generator;
- const myEngine = new Comunica.QueryEngine();
-
- const sparqlEndpoint = "https://hdnlab1.isti.cnr.it/fuseki/commedia/query";
- //const sparqlEndpoint = "https://lida.dantenetwork.it/fuseki/commedia/query";
- var elencoRiferimenti;
-
- var shownSentenceList = new Set()
- var filterBottonAdded = false;
- var showingComments = false;
- listaPeriodiRisultato = [];
- listaClausoleRisultato = []
- /*var commentsArray = []
- var commentsJson = {}*/
- var commentsSQL = {}
- var resultcommentsSQL = {}
- /*var resultSentences = new Set()*/
- const cantiche = ["Inferno", "Purgatorio", "Paradiso"]
- var loadedCanti = new Set();
- const openSTag = "{"
- const closeSTag = "}"
-
- cantoDisplayed = "#InfernoCanto_1";
-
- var prevCantoDisplayed = "#InfernoCanto_1";
- var contextLength = 3;
-
- var idCitazione = "citazioneFrase";
-
- initCitazioni();
-
- resetResult = function() {
- //console.log('clean result')
- cleanSearchResult()
- //esprlogica = []
- }
-
- //hideMinimap();
- createAllDivCanti()
- //const start = performance.now();
- showCanto(formeprima, '1', '1')
- $("#InfernoCanto_1").attr('style', 'display: d-flex;')
- $("#printCantoCorrente").prop("disabled", false);
- loadedCanti.add("InfernoCanto_1")
- drawMinimap("#InfernoCanto_1", false)
- const minim = $(" .minimap__content")
-
-
- $('#opzioniVista :checkbox').change(function() {
- const changedOption = $(this)[0].id;
- switch (changedOption + "|" + this.checked) {
- case "visPeriodi|true":
- vistaPeriodi = true
- loadFrasi();
- break;
- case "visPeriodi|false":
- //$("#vistaFrasi").css("display", "none");
- resetFrasi()
- manageResults()
- vistaPeriodi = false
- break;
- case "visRiferimenti|true":
- vistaRiferimenti = true
- /*initCitazioni()
- $(cantoDisplayed).find(" .showcomments").each(function() {
- $(this).css("display", "inline-block");
- })
- //$(" .showcomments").css("display", "inline-block");
- minim.contents().find(" .showcomments").each(function() {
- $(this).css('display', 'inline-block');
- })*/
- setCitazioni(true)
- break;
- case "visRiferimenti|false":
- /*$(cantoDisplayed).find(" .showcomments").each(function() {
- $(this).css("display", "none");
- })
- //$(".showcomments").css("display", "none");
- minim.contents().find(" .showcomments").each(function() {
- $(this).css('display', 'none');
- })
- $('#displaynote').empty()
- $('#displaynote').append($(emptyNoteList))*/
- setCitazioni(false)
- vistaRiferimenti = false
- break;
- case "visDialoghi|true":
- loadDialoghi();
- vistaDialoghi = true
- break;
- case "visDialoghi|false":
- $("#vistaDialoghi").css("display", "none");
- vistaDialoghi = false
- resetDialoghi()
- break;
- case "visMetafore|true":
- //loadMetafore();
- break;
- case "visMetafore|false":
- $("#vistaMetafore").css("display", "none");
- }
- });
-
-
-
- $(" ." + formaClass).each(function(idx, element) {
- // We cycle through the elements using each() so that we can choose the element specifically that we wish to clean up afterward
- var ele = $(element);
- ele.tooltip({
- content: (function() { return formatTTContent(ele.attr('title'), ele.attr('class').split(' ')[1], ele.attr('class').split(' ')[0]); }),
- classes: { "ui-tooltip": 'Nik_dropdown-content' },
- close: function(event, ui) { $(".ui-helper-hidden-accessible").remove(); },
- create: function(ev, ui) { $(this).data("ui-tooltip").liveRegion.remove(); },
- hide: false,
- show: { delay: 800, duration: 0 }
-
- });
- });
-
-
-
- $(" ." + formaClass).dblclick(function() {
-
- var sentenceId = $(this).attr('class').split(' ')[0].replace('$', '')
- //console.log('dblclick ' + lisid)
- if (shownSentenceList.has(sentenceId)) {
- resetSentenceStructure(sentenceId)
- shownSentenceList.delete(sentenceId)
-
- }
- else {
- //showSentenceStructure (sentenceId)
- shownSentenceList.add(sentenceId)
-
-
- }
- });
-
-
- $(" ." + formaClass).hover(function(idx, element) {
-
- var sentenceId = $(this).attr('class').split(' ')[0].split('_')
- var tmplisid = sentenceId[0] + '_' + sentenceId[1] + '_' + sentenceId[3]
- lsentid = $(this).attr('class').split(' ')[0]
- lisid = tmplisid
- });
-
-
- /*
- * Espansione del contesto
- */
-
- jQuery(document).delegate(' .espandiFrase, .riduciFrase', 'click', function() {
- if ($(this).hasClass("disabled")) {
- return;
- };
- //var posizioniEspansione = []
- var cid = $(this).attr('id');
- var parcid = cid.split('_');
- var posVerso
- var reit = '#versiFrase' + parcid[4]
- var expcontextLength = $(reit + " > li").length
- if (cid.includes('_er_')) {
- expcontextLength = contextLength
- } else {
- posVerso = $(reit).attr('posVerso')
- if (posVerso == 1) { // caso inizio o fine canto
- expcontextLength += contextLength;
- }
- }
-
- //svuoto la lista di versi
- $(reit).empty()
- //genero la nuova lista di versi
- var versiContestoExp = getFormaContext(parseInt(parcid[3]), expcontextLength);
- var divVersoExp = ''
- var setVersicontestoExp = new Set()
- for (var forma of versiContestoExp) {
- if (!setVersicontestoExp.has(forma.verso)) {
- //divVersoExp = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
- divVersoExp = createDivVersoGenericLi(forma.cantica + 1, forma.verso, forma.canto)
- $(reit).append(divVersoExp)
- setVersicontestoExp.add(forma.verso)
- }
- createSpanFormeNew(forma.testo, forma.catg, 'e' + forma.posizione, forma.periodo, forma.funzperiodo, divVersoExp)
- //posizioniEspansione.push('e' + forma.posizione)
- }
-
- if (cid.includes('_er_')) {
- ///$("#"+cid).css("display", "none");
- $("#" + cid).removeClass("btn-outline-primary");
- $("#" + cid).addClass("btn-outline-secondary");
- $("#" + cid).addClass("disabled");
- }
- else {
- cid = cid.replace("ex", "er");
- ///$("#"+cid).attr('style', 'display: d-flex;');
- $("#" + cid).removeClass("btn-outline-secondary");
- $("#" + cid).removeClass("disabled");
- $("#" + cid).addClass("btn-outline-primary");
- }
-
-
- //evidenzio risultato
-
- for (var ris of listarisultati) {
- var idris = '#e' + ris
- $(idris).addClass("font-weight-bold mark ")
- }
-
- //gestisco risultati se unità di ricerca è periodo
- if (listaPeriodiRisultato.length) {
- for (var msid of listaPeriodiRisultato) {
- loadPeriodo(msid)
-
- }
- }
- //gestisce risultati se unità di ricerca è frase
- if (listaClausoleRisultato.length) {
- for (var clsid of listaClausoleRisultato) {
- let tmpid = clsid.split('-')
- loadClausola(tmpid[0], tmpid[1], tmpid[2], tmpid[3])
-
- }
- }
-
- //aggiungo listeners
-
- //addFormaListenersInRisultato(posizioniEspansione)
- addFormaListenersInCanto()
-
- //disegno minimap, onlyContent = true
- drawMinimap('#vistaFrasi', true)
- //manageMM('#vistaFrasi')
-
-
- })
-
-
-
- /*
- * Costruzione e visualizzazione del risultato in frasi.
- */
-
-
- //var prevstart = -1
- //var prevoffset = -1
- jQuery.manageResultList = function manageResultList(start, offset = showOffset) {
-
-
- //console.log('Paginazione...')
- //prevstart = start
- //prevoffset = offset
- if (cantoDisplayed != '#vistaFrasi') {
- prevCantoDisplayed = cantoDisplayed;
- $(cantoDisplayed).css("display", "none");
- //visualizzo
- $("#vistaFrasi").attr('style', 'display: d-flex;');
- cantoDisplayed = "#vistaFrasi";
- }
-
- //listarisultati.sort(function(a, b){return a - b});
- $("#vistaFrasi").empty();
- showFrasi(start, offset)
-
- if (vistaPeriodi) {
- loadFrasi();
- }
- if (vistaDialoghi) {
- loadDialoghi();
- }
- addFormaListenersInCanto()
- drawMinimap('#vistaFrasi', false)
-
- }
-
- function countResultContexts() {
- var numeroRisultati = 0;
- if (listarisultati.length) {
- var ultimaPosizione = -1;
- for (var risultato of listarisultati) {
-
- if (risultato <= ultimaPosizione) {
- continue;
- }
- numeroRisultati = numeroRisultati + 1;
-
- ultimaPosizione = getContextLastPosition(risultato, contextLength);
- }
- numeroContesti = numeroRisultati
- //console.log('num contesti ' + numeroContesti)
- return (numeroRisultati)
- }
-
-
- if (listaClausoleRisultato.length) {
- numeroContesti = listaClausoleRisultatoContesti.length
- return (listaClausoleRisultatoContesti.length)
-
- }
- numeroContesti = numeroRisultati
- return (numeroRisultati)
- }
-
- function getResInPage(startcont, endcont) {
- var res = [];
- var contaContesti = 0
- //console.log(listaClausoleRisultato)
- if (listarisultati.length) {
- var ultimaPosizione = -1;
- for (var risultato of listarisultati) {
- if (risultato <= ultimaPosizione) {
- continue;
- }
- contaContesti = contaContesti + 1;
- if (contaContesti >= startcont && contaContesti < endcont) {
- res.push(risultato)
- }
- if (contaContesti > endcont)
- break;
- ultimaPosizione = getContextLastPosition(risultato, contextLength);
- }
- //ordino la lista dei risultati
- res.sort(function(a, b) { return a - b });
- return (res)
- }
- if (listaClausoleRisultatoContesti.length && !listarisultati.length) {
- var lim = endcont
- if (listaClausoleRisultatoContesti.length <= endcont)
- lim = listaClausoleRisultatoContesti.length - 1
- for (let i = startcont; i <= lim; i++) {
- res.push(listaClausoleRisultatoContesti[i])
- }
- //res.sort(function(a, b) { puno = a[0].split('-')[3]; pdue = b[0].split('-')[3]; return parseInt(puno) - parseInt(pdue) });
- return (res)
- }
- return (res)
- }
-
- showFrasi = function(start, offset = showOffset, whereToDisplay = "#vistaFrasi") {
- var canto, numeroCantica;
- var divVerso;
- var elencoRisutati = $(whereToDisplay);
- //elencoRisutati.empty();
-
- var numeroRisultato = 0;
- var ultimaPosizione = 0;
- var numeroVersi;
- //const intsup = Math.min(start + offset, listarisultati.length)
- var t0 = performance.now();
- var resincontext = getResInPage(start, start + offset)
- var t1 = performance.now();
-
- for (let i = 0; i < resincontext.length; i++) {
- //risultato = listarisultati[i];
- var risultato = resincontext[i];
- numeroRisultato++;
-
- if (!risultato.toString().includes('-') && risultato <= parseInt(ultimaPosizione)) {
- continue;
- }
- var versiContesto = ''
- var ctxpivot = 0
- if (!Array.isArray(risultato)) {
- risultato = parseInt(risultato)
- versiContesto = getFormaContext(risultato, contextLength);
- ctxpivot = risultato
- }
- else {
- versiContesto = getFraseContext(risultato, contextLength);
- if (versiContesto.length) {
- var tmind = Math.floor(versiContesto.length / 2);
- ctxpivot = versiContesto[tmind]['posizione']
- }
- }
-
-
- var setVersicontesto = new Set()
- divVerso = ''
- numeroCantica = 0
- canto = 0
- //var titoloCanto = $('
')
- var versiIniziali = $('')
- var listaVersi = $('
')
-
- listaVersi.attr('id', "Frase" + numeroRisultato);
- versiIniziali.attr('id', "versiFrase" + numeroRisultato);
- numeroVersi = 0;
- for (var forma of versiContesto) {
- if (setVersicontesto.size == 0) {
- numeroCantica = forma.cantica
- canto = forma.canto
- }
- if (!setVersicontesto.has(forma.verso)) {
- //divVerso = createDivVersoLI(forma.cantica + 1, forma.verso, forma.canto)
- divVerso = createDivVersoGenericLi(forma.cantica + 1, forma.verso, forma.canto)
- versiIniziali.append(divVerso)
- listaVersi.append(versiIniziali)
- elencoRisutati.append(listaVersi)
- setVersicontesto.add(forma.verso)
- numeroVersi++;
- }
- createSpanFormeNew(forma.testo, forma.catg, 'e' + forma.posizione, forma.periodo, forma.funzperiodo, divVerso)
- }
- ultimaPosizione = forma.posizione;
-
- if (numeroVersi < contextLength + 1) {
- versiIniziali.attr('posVerso', 1); // inizio o fine canto
- } else {
- versiIniziali.attr('posVerso', 9999);
- }
-
- var comandi = $('')
- comandi.attr('id', "comandiFrase" + numeroRisultato)
- //comandi.attr('class', 'comandi col flex-nowrap d-inline justify-content-between pl-1 pb-2 ml-2 mb-2 border-bottom');
-
- var comandiGrp = $('')
- comandiGrp.attr('class', 'btn-group flex-nowrap d-inline pr-3 mt-1 mr-3 align-text-bottom');
- comandiGrp.attr('role', "group")
-
- var spanBadgeExpand = $('');
- var expandIcon = '';
- //spanBadgeExpand.attr('class', 'btn btn-sm btn-outline-primary espandiFrase px-1 pt-1 pb-0');
- var spanBadgeReduce = $('');
- var reduceIcon = '';
-
- //spanBadgeReduce.attr('class', 'btn btn-sm btn-outline-secondary riduciFrase px-1 pt-1 pb-0 ml-1 disabled');
-
- //spanBadgeExpand.attr('id', getCantica(numeroCantica) + "Canto_ex_" + canto + "_" + risultato + "_" + numeroRisultato);
- spanBadgeExpand.attr('id', getCantica(numeroCantica) + "Canto_ex_" + canto + "_" + ctxpivot + "_" + numeroRisultato);
- spanBadgeExpand.append(expandIcon);
-
- spanBadgeReduce.attr('id', getCantica(numeroCantica) + "Canto_er_" + canto + "_" + ctxpivot + "_" + numeroRisultato);
- spanBadgeReduce.append(reduceIcon)
-
- spanBadgeExpand.appendTo(comandiGrp);
- spanBadgeReduce.appendTo(comandiGrp);
-
- comandiGrp.appendTo(comandi);
-
-
- var citazioneDiv = $('')
- //citazioneDiv.attr('class', ' text-right flex-nowrap d-inline ml-3 px-3 py-0');
- var citazione = $('')
- citazione.append("[" + getCantica(numeroCantica) + ", Canto " + getRoman(canto) + "]")
- //citazione.attr('class', ' pl-3 citazioneFrase align-text-top');
- citazione.attr('name', getCantica(numeroCantica) + "Canto " + canto);
- citazione.attr('id', idCitazione + '_' + numeroRisultato + '_' + risultato);
- citazione.appendTo(citazioneDiv);
-
- citazioneDiv.appendTo(comandi);
-
- comandi.appendTo(elencoRisutati);
-
- }
- var t2 = performance.now()
-
- //console.log('res in context ' + (t1 - t0))
- //console.log('list creation ' + (t2 - t1))
- //evidenzio resultati
- var clausesinrs = []
- for (var ris of listarisultati) {
- let idris = '#e' + ris
- if ($(idris).attr('class') != null) {
- //console.log($(idris).attr('class').replace(' frm', ''))
- clausesinrs.push($(idris).attr('class').replace(' frm', ''))
- }
-
- $(idris).addClass("font-weight-bold mark ")
- }
-
- if (listarisultati.length == 0) {
- for (var ric of resincontext) {
- if (Array.isArray(ric)) {
- for (var ricel of ric) {
- var telric = ricel.split('-')[0] + ' ' + ricel.split('-')[1] + ' ' + ricel.split('-')[2] + ' ' + ricel.split('-')[3]
- clausesinrs.push(telric)
- }
- }
- }
- }
-
- var t3 = performance.now()
- //console.log('mar res ' + (t2 - t3))
- //evidenzio i periodi se unità di ricerca è impostato come periodo
- if (listaPeriodiRisultato.length) {
- for (var msid of clausesinrs) {
- loadPeriodo(msid.split(' ')[0])
-
- }
-
- /*for (var msid of listaPeriodiRisultato) {
- loadPeriodo(msid)
-
- }
-*/
- }
- var t4 = performance.now()
- //console.log('load per ' + (t3 - t4))
- //evidenzio le frasi se unità di ricerca è frase
- if (listaClausoleRisultato.length) {
- for (var clsid of clausesinrs) {
- let tmpid = clsid.split(' ')
- loadClausola(tmpid[0], tmpid[1], tmpid[2], tmpid[3])
- }
- /*for (var clsid of listaClausoleRisultato) {
- let tmpid = clsid.split('-')
- //loadFrase(tmpid[0], tmpid[1])
- loadClausola(tmpid[0], tmpid[1], tmpid[2], tmpid[3])
-
- }*/
- }
- var t5 = performance.now()
- console.log('load cla ' + (t4 - t5))
-
-
- }
-
- jQuery(document).delegate('.navig-canto, .citazioneFrase', 'click', function(e) {
- resetFrasi()
-
- //nasconde vista risultati
- $("#vistaFrasi").css("display", "none");
-
- //rimuove il grafo sintattico se c'è'
- resetGraphStr()
- emptyStructCard()
-
- $(".filterRiferimentiOn").css('display', 'none');
- $(".filterRiferimentiOff").css('display', 'none');
-
-
- $(cantoDisplayed).css("display", "none");
-
- const cid = $(this).attr('name').replace(" ", "_");
- var telive = getListaRis()
- cantoDisplayed = "#" + cid;
-
- if (!telive.length > 0 || !showingComments) {
- $('#displaynote').empty();
- $('#displaynote').append($(emptyNoteList))
- }
-
- showingComments = false;
-
- /*if (telive.length > 0) {
- initCitazioni()
- } else {
- if (vistaRiferimenti) {
- initCitazioni();
- }
- }*/
- var parcid = cid.split('_')
- var numeroCantica;
- var forma;
- if (parcid[0].includes('Inferno')) {
- forma = formeprima;
- numeroCantica = 1;
- }
- if (parcid[0].includes('Purgatorio')) {
- forma = formeseconda;
- numeroCantica = 2;
- }
- if (parcid[0].includes('Paradiso')) {
- forma = formeterza;
- numeroCantica = 3;
- }
-
- if (!(loadedCanti.has(cid))) {
- showCanto(forma, numeroCantica, parcid[1])
- $("#printCantoCorrente").prop("disabled", false);
- loadedCanti.add(cid)
- }
-
- setCitazioni(vistaRiferimenti)
-
- if (telive.length > 0) {
- initCitazioni()
- }
-
- for (var tel of telive) {
- var telId = tel.split("_");
- var commento = "#Commento_" + numeroCantica + "_" + telId[2] + "_" + telId[3];
- telId = "#" + telId[0] + telId[1] + "_" + telId[2];
- $(commento).addClass("risultato ")
- $(telId + " #" + tel.replace('|', '')).addClass("mark ")
- }
-
- $("#" + $(this).attr('name').replace(" ", "_")).attr('style', 'display: d-flex;')
-
-
- drawMinimap("#" + $(this).attr('name').replace(" ", "_"), false)
-
- //console.log("#" + $(this).attr('name').replace(" ", "_"))
- if (vistaPeriodi) {
- loadFrasi();
- }
- if (vistaDialoghi) {
- loadDialoghi();
- }
-
- addFormaListenersInCanto();
-
- //se si sta arrivando al canto da un link della lista risultati
- const callerid = $(this).attr('id');
- if (callerid != null && callerid.startsWith(idCitazione)) {
- const mypos = callerid.split('_')[2]
- //var latestPhraseId = callerid.split('_')[0].replace("citazione", "") + callerid.split('_')[1];
- $("#collapse" + parcid[0].replace("Canto", "")).collapse('show');
- document.getElementById(mypos).scrollIntoView({
- behavior: "smooth",
- });
-
- }
- manageResults()
-
-
- });
-
-
- //Query
-
- jQuery(document).delegate('#searchcomm, #searchcomm2', 'click', function(e) {
- e.preventDefault();
- manageQuery()
- });
-
-
- //Reset
-
- jQuery(document).delegate('#cleanresult', 'click', function(e) {
-
- cleanSearchResult()
- //esprlogica = []
- $('#queryText').val("")
-
- });
-
- //Utility functions
-
-
-
- function addFormaListenersInCanto(cantoCitazione = cantoDisplayed) {
- let idn = 0
- $(cantoCitazione).find(" ." + formaClass).each(function(idx, element) {
- idn = idn + 1
- var ele = $(element);
-
- $(element).tooltip({
- content: (function() { return formatTTContent(ele.attr('title'), ele.attr('class').split(' ')[1], ele.attr('class').split(' ')[0]); }),
- classes: { "ui-tooltip": 'Nik_dropdown-content' },
- //close: function(event, ui) { $(".ui-helper-hidden-accessible").remove(); },
- //create: function(ev, ui) { $(this).data("ui-tooltip").liveRegion.remove(); },
- hide: false,
- show: { delay: 800, duration: 0 }
-
- });
- $(element).hover(function(idx, element) {
-
- var sentenceId = $(this).attr('class').split(' ')[0].split('_')
- var tmplisid = sentenceId[0] + '_' + sentenceId[1] + '_' + sentenceId[3]
- lsentid = $(this).attr('class').split(' ')[0]
- lisid = tmplisid
-
- });
-
- });
-
-
- }
-
-
- function getRoman(numero) {
-
- var romani = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X",
- "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX",
- "XXI", "XXII", "XXIII", "XXIV", "XXV", "XXVI", "XXVII", "XXVIII", "XXIX", "XXX",
- "XXXI", "XXXII", "XXXIII", "XXXIV"];
- return (romani[numero - 1]);
-
- }
-
- /*function getNumCurrentCantica() {
-
- var mcanto = cantoDisplayed.replace("#", '')
- var cantica = ''
- if (mcanto.startsWith('Inf'))
- cantica = '1'
- if (mcanto.startsWith('Pur'))
- cantica = '2'
- if (mcanto.startsWith('Par'))
- cantica = '3'
-
- return (cantica + '_' + mcanto.split('_')[1])
- }*/
-
-
-
- function loadPeriodo(idperiodo) {
-
-
-
- if (!isPeriodoInCanto(idperiodo, cantoDisplayed) && !(cantoDisplayed.includes('#vistaFrasi'))) {
- return
- }
-
- $(cantoDisplayed).find(' .' + idperiodo).each(function() {
- var pstp = $(this).attr('class').split(" ")[1]
- if (pstp == 'sentencetag')
- $(this).attr('style', 'display: d-flex;');
- //$(this).css('color', colorssp(mapsynttypestopalette[pstp]));
- })
-
- minim.contents().find(' .' + idperiodo).each(function() {
- var mpstp = $(this).attr('class').split(" ")[1]
- if (mpstp == 'sentencetag')
- $(this).attr('style', 'display: d-flex;');
- })
- }
-
- function isPeriodoInCanto(idperiodo, canto) {
- var datiperiodo = idperiodo.split('_')
- var daticanto = canto.split('_')
- var canticaprd = datiperiodo[0]
- var cantoprd = datiperiodo[1]
- if (canticaprd == '1' && daticanto[0].includes('Inferno'))
- return (cantoprd == daticanto[1])
- if (canticaprd == '2' && daticanto[0].includes('Purgatorio'))
- return (cantoprd == daticanto[1])
- if (canticaprd == '3' && daticanto[0].includes('Paradiso'))
- return (cantoprd == daticanto[1])
- return false
- }
-
-
- function loadClausola(idperiodo, funzionefrase, fromn, ton) {
-
- if (!isPeriodoInCanto(idperiodo, cantoDisplayed) && !(cantoDisplayed.includes('#vistaFrasi')))
- return
-
-
- if (fromn == null || ton == null) {
- $(cantoDisplayed).find(' .' + idperiodo + '.' + funzionefrase).each(function() {
- var tpstp = $(this).attr('class').split(" ")[1]
- $(this).css('color', colorssp(mapsynttypestopalette[tpstp]));
-
-
- })
-
- minim.contents().find(' .' + idperiodo + '.' + funzionefrase).each(function() {
- var mtpstp = $(this).attr('class').split(" ")[1]
- $(this).css('color', colorssp(mapsynttypestopalette[mtpstp]));
- })
- }
- else {
- $(cantoDisplayed).find(' .' + idperiodo).each(function() {
- var vid = parseInt($(this).attr('id').replace('e', ''))
- if (vid >= parseInt(fromn)
- && vid <= parseInt(ton)) {
- var pstp = $(this).attr('class').split(" ")[1]
-
- if (pstp.trim() == funzionefrase)
- $(this).css('color', colorssp(mapsynttypestopalette[pstp]));
- }
-
- })
-
- minim.contents().find(' .' + idperiodo).each(function() {
- var vid = parseInt($(this).attr('id').replace('e', ''))
- if (vid >= parseInt(fromn)
- && vid <= parseInt(ton)) {
- var mpstp = $(this).attr('class').split(" ")[1]
- if (mpstp.trim() == funzionefrase)
- $(this).css('color', colorssp(mapsynttypestopalette[mpstp]));
- }
-
- })
- }
- }
-
-
- function loadDialoghi() {
- var aca = '3'
- if (cantoDisplayed.includes('Inferno'))
- aca = '1'
- if (cantoDisplayed.includes('Purgatorio'))
- aca = '2'
- for (const india in dialoghi) {
- //console.log(dialoghi[india]['Cnt'].replace('_so',''))
- var diaclass = dialoghi[india]['Cnt'].replace('_so', '')
- var authclass = dialoghi[india]['Cnt'];
- if (diaclass.split('_')[1] != cantoDisplayed.split('_')[1])
- continue;
- if (diaclass.split('_')[0] != aca)
- continue;
- var csscl = dialogaltri
- if (dialoghi[india]['Spna'] in dialogspeakers) {
- csscl = dialogspeakers[dialoghi[india]['Spna']]
- }
-
-
- $(cantoDisplayed).find(' .' + diaclass).each(function() {
- $(this).addClass(csscl)
-
- })
- $(cantoDisplayed).find(' .' + authclass).each(function() {
- //$(this).addClass(csscl)
- $(this).attr('style', 'display: d-flex;');
-
- })
- minim.contents().find(' .' + diaclass).each(function() {
- $(this).addClass(csscl)
-
- })
-
- }
- emphResults()
- }
-
- function setCitazioni(citeon) {
- if (citeon) {
- initCitazioni()
- $(cantoDisplayed).find(" .showcomments").each(function() {
- $(this).css("display", "inline-block");
- })
- minim.contents().find(" .showcomments").each(function() {
- $(this).css('display', 'inline-block');
- })
- }
- else {
- $(cantoDisplayed).find(" .showcomments").each(function() {
- $(this).css("display", "none");
- })
- minim.contents().find(" .showcomments").each(function() {
- $(this).css('display', 'none');
- })
- $('#displaynote').empty()
- $('#displaynote').append($(emptyNoteList))
- }
-
- }
-
- function loadFrasi() {
- var stp
- $(cantoDisplayed).find(' .sentencetag').each(function() {
- $(this).attr('style', 'display: d-flex;');
- })
- $(cantoDisplayed).find(' .' + formaClass).each(function() {
- stp = $(this).attr('class').split(" ")[1]
-
- $(this).css('color', colorssp(mapsynttypestopalette[stp]));
- })
- //let minim=$(" .minimap__content")
- minim.contents().find(" .sentencetag").each(function() {
- $(this).attr('style', 'display: d-flex;');
- })
- minim.contents().find(' .' + formaClass).each(function() {
- stp = $(this).attr('class').split(" ")[1]
-
- $(this).css('color', colorssp(mapsynttypestopalette[stp]));
- })
- }
- function resetDialoghi() {
-
- for (var mk in dialogspeakers) {
- //console.log (mk+' '+dialogspeakers[mk])
- $(cantoDisplayed).find(' .' + dialogspeakers[mk]).each(function() {
- $(this).removeClass(dialogspeakers[mk]);
- })
- minim.contents().find(' .' + dialogspeakers[mk]).each(function() {
- $(this).removeClass(dialogspeakers[mk]);
- })
- }
- $(cantoDisplayed).find(' .' + dialogaltri).each(function() {
- $(this).removeClass(dialogaltri);
- })
- minim.contents().find(' .' + dialogaltri).each(function() {
- $(this).removeClass(dialogaltri);
- })
- emphResults()
- }
-
- function resetFrasi() {
-
- $(cantoDisplayed).find(' .sentencetag').each(function() {
- $(this).css('display', 'none');
- })
-
-
- $(cantoDisplayed).find(' .' + formaClass).each(function() {
- //console.log(colorssp(mapsynttypestopalette[stp]))
- $(this).css('color', '');
- $(this).removeClass('font-weight-bold')
- })
-
- minim.contents().find(" .sentencetag").each(function() {
- $(this).css('display', 'none');
- })
- minim.contents().find(' .' + formaClass).each(function() {
- $(this).css('color', '');
- $(this).removeClass('font-weight-bold')
- })
-
-
- //cancello il grafo sintattico
- resetGraphStr()
- emptyStructCard()
- //emphResults()
- }
- //visualizzazione risultati
- function emphResults() {
-
- //evidenzio i periodi se unità di ricerca è impostato come periodo
- if (listaPeriodiRisultato.length) {
- for (var msid of listaPeriodiRisultato) {
- //if (isPeriodoInCanto(msid, cantoDisplayed))
- loadPeriodo(msid)
-
- }
-
- }
- //evidenzio le frasi se unità di ricerca è frase
- if (listaClausoleRisultato.length) {
- for (var clsid of listaClausoleRisultato) {
- if (isPeriodoInCanto(clsid, cantoDisplayed)) {
- let tmpid = clsid.split('-')
- //loadFrase(tmpid[0], tmpid[1])
- loadClausola(tmpid[0], tmpid[1], tmpid[2], tmpid[3])
- }
- }
- }
-
- }
- /*INIZIO GESTIONE CITAZIONI*/
-
- async function initCitazioni(cantoCitazione = cantoDisplayed) {
- //"#InfernoCanto_1"
- var idcantica = '1'
- var mcanto = cantoCitazione.replace("#", '')
- var cantica = ''
- if (mcanto.startsWith('Inf'))
- cantica = 'Inferno'
- if (mcanto.startsWith('Pur')) {
- cantica = 'Purgatorio'
- idcantica = '2'
- }
-
- if (mcanto.startsWith('Par')) {
- cantica = 'Paradiso'
- idcantica = '3'
- }
- var canto = mcanto.split('_')[1]
- var idCommento = "Commento_" + idcantica + "_" + canto + "_";
- var idverso = cantica + '_Canto_' + canto + '_'
- var idminimap = cantica + 'Canto_' + canto
- /*console.log(myid)*/
- if (canto.length == 1)
- canto = '0' + canto
- //commentsJson = getVersiConCitazioniJson(cantica, canto)
-
- /*
- */
- var mresult = await getVersiConCitazioni(cantica, canto)
-
-
- commentsSQL = Object.groupBy(mresult, ({ VersoCitazione }) => VersoCitazione);
-
- var tmpkeys = []
-
- for (const ke in commentsSQL) {
-
- var t = ke.split('-')[0].replace('|', '')
-
- if (tmpkeys.indexOf(t) == -1)
- tmpkeys.push(t)
- else
- continue
- var pio = $("#" + idCommento + t)
- if (pio.length)
- break;
-
- if (t == 'Proemio') {
- //console.log(idminimap + ' ' + t)
- var elcanto = $("#" + 'Titolo' + idminimap)
- if (canto.startsWith('0'))
- canto = canto.replace('0', '')
- createProemioSpan(idCommento + t, elcanto, commentsSQL[ke].length, cantica + '_Canto_' + canto + '_Proemio')
- continue
- }
-
- var elverso = $("#" + idverso + t)
-
- createCommentSpan(idCommento + t, elverso, commentsSQL[ke].length)
- }
-
- drawMinimap("#" + idminimap, false)
- //console.log (commentsSQL)
- }
-
-
-
- function removeHtmlTags(value) {
- var text = value;
- if (text != null) {
- text = text.replace(/<(.|\n)*?>/g, '');
- text = text.replace("«", "");
- text = text.replace("»", "");
- text = text.replace(/\ /g, ' ');
- text = text.replace(/[\r\n]+/gm, ' ');
- return text;
- }
- }
- var noteAdded;
-
- jQuery(document).delegate(' .showcomments', 'click', function() {
-
- var cid = $(this).attr('id');
- var filterOn = true;
- var risultato;
- var parcid = cid.split("_")
- var idsRisultato = getListaRis();
- var cantica;
- var idRisultato;
- switch (parcid[1]) {
- case "1": cantica = "Inferno";
- break;
- case "2": cantica = "Purgatorio";
- break;
- case "3": cantica = "Paradiso";
- }
-
-
- if (idsRisultato.length > 0) {
- risultato = true;
- } else {
- risultato = false;
- }
-
- idRisultato = cantica + "_Canto_" + parcid[2] + "_" + parcid[3] + "_sp";
- if (idsRisultato.includes(idRisultato)) {
- risultato = true;
- } else {
- risultato = false;
- }
- switch (parcid[0]) {
- case "Commento":
- case "CommentoRes":
-
- if (risultato) {
- $(".filterRiferimentiOn").css('display', 'none');
- $(".filterRiferimentiOff").css('display', 'inline-block');
- filterOn = true;
- } else {
- $(".filterRiferimentiOn").css('display', 'none');
- $(".filterRiferimentiOff").css('display', 'none');
- filterOn = false;
- }
- break;
- case "CommentoQuery":
- if (parcid[4] == "On") {
- $(".filterRiferimentiOn").css('display', 'none');
- $(".filterRiferimentiOff").css('display', 'inline-block');
- filterOn = true;
- } else {
- $(".filterRiferimentiOn").css('display', 'inline-block');
- $(".filterRiferimentiOff").css('display', 'none');
- filterOn = false;
- }
- break;
- }
-
-
- if (cantoDisplayed.includes('#vistaFrasi')) {
- commentsSQL = getCommentsInResult($(this).attr('id'), $(this).attr('class'))
- if (commentsSQL.length == 0)
- return
- }
-
- if (!cantoDisplayed.includes('#vistaFrasi') && !hasCommentsJson(cid)) {
- return
- }
-
- var commentArea = $('#displaynote');
- var idCommento = "CommentoQuery_" + parcid[1] + "_" + parcid[2] + "_" + parcid[3];
-
- $(".filterRiferimentiOn").attr("id", idCommento + "_On")
- $(".filterRiferimentiOff").attr("id", idCommento + "_Off")
-
- commentArea.empty()
- if ($('#noteCard0').length) {
- $("#noteCard0")[0].remove();
- }
- var id = parcid[3];
- var gruppoVersi;
- var versText = "";
- var allGrouplKeys = Object.keys(commentsSQL);
- var currentGroup;
-
- allGrouplKeys.sort().some(function(k) {
- if (k == id || k.startsWith(id + '-')) {
- gruppoVersi = k
- if (gruppoVersi.includes("-")) {
- versText = ", Versi " + gruppoVersi;
- } else {
- versText = ", Verso " + gruppoVersi;
- }
- currentGroup = createNoteGroup(cantica, getRoman(parcid[2]), versText, k, commentsSQL[k].length)
- noteAdded = false;
- commentsSQL[k].forEach(function(value, i) {
- currentGroup.append(createNoteEntry(value, k, i, filterOn, risultato))
- });
- commentArea.append(currentGroup);
-
- if (!noteAdded && filterOn) {
- currentGroup.css('display', 'none');
- }
- }
- $('#tab-list #vis0-tab').tab('show')
- $("#printRiferimentiCorrenti").prop("disabled", false);
- })
- })
-
- function getCommentsInResult(tmpcid, tmpclass) {
-
- var versicomments = []
- var myid = tmpcid.split('_')
- var tmpresu = getRisultatiRiferimenti()
-
- var resultComments = Object.groupBy(tmpresu, ({ Cantica }) => Cantica);
-
- var tcantica = 'Inferno'
- switch (myid[1]) {
- case "2": tcantica = "Purgatorio";
- break;
- case "3": tcantica = "Paradiso";
- }
-
- if (!tcantica in resultComments)
- return versicomments
- var tmpCanti = resultComments[tcantica]
- var cantiComments = Object.groupBy(tmpCanti, ({ Canto }) => Canto);
- if (myid[2].length == 1)
- myid[2] = '0' + myid[2]
-
- if (!myid[2] in cantiComments)
- return versicomments
- var tmpversi = cantiComments[myid[2]]
- var isin = false
- versicomments = Object.groupBy(tmpversi, ({ VersoCitazione }) => VersoCitazione);
- for (const [keyt, value] of Object.entries(versicomments)) {
- if (keyt == myid[3] || keyt.startsWith(myid[3] + '-')) {
- isin = true
- break
- }
- }
- if (!isin)
- versicomments = []
-
- return versicomments
-
- }
-
- function createNoteGroup(cantica, canto, versi, id, len) {
- var noteGroupCard = $('');
- var commentHeader = $('