Aggiunta stampa (da completare) e riportate tutte le modifiche della 5.1
This commit is contained in:
parent
5d015f00c5
commit
352457dc4e
|
@ -417,7 +417,9 @@ a[target="_blank"]::after {
|
||||||
border-color: rgb(68, 41, 48) !important;
|
border-color: rgb(68, 41, 48) !important;
|
||||||
background-color: rgb(68, 41, 48) !important;
|
background-color: rgb(68, 41, 48) !important;
|
||||||
}
|
}
|
||||||
|
.custom-checkbox .custom-control-input:disabled:checked~.custom-control-label::before {
|
||||||
|
opacity: 0.4 !important;
|
||||||
|
}
|
||||||
.custom-control-input:active~.custom-control-label::before {
|
.custom-control-input:active~.custom-control-label::before {
|
||||||
background-color: rgba(65, 93, 67, 0.5) !important;
|
background-color: rgba(65, 93, 67, 0.5) !important;
|
||||||
border-color: rgba(65, 93, 67, 0.5) !important;
|
border-color: rgba(65, 93, 67, 0.5) !important;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,630 @@
|
||||||
|
import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/+esm';
|
||||||
|
|
||||||
|
|
||||||
|
//import * as arrow from 'https://cdn.skypack.dev/apache-arrow@9'
|
||||||
|
|
||||||
|
|
||||||
|
var rif_commentatori = [];
|
||||||
|
var rif_autori = [];
|
||||||
|
var rif_areetematiche = [];
|
||||||
|
var rif_fonti = [];
|
||||||
|
var listaidversi = []
|
||||||
|
var listaversicommentati=[]
|
||||||
|
var listaidcommenti = []
|
||||||
|
var listarisriferimenti = []
|
||||||
|
var listariferimentirisultato=[]
|
||||||
|
var processedrif=new Set()
|
||||||
|
|
||||||
|
const cantobadgeclassBis = 'badge badge-outline-warning badge-pill'
|
||||||
|
|
||||||
|
const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
|
||||||
|
|
||||||
|
// Select a bundle based on browser checks
|
||||||
|
const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
|
||||||
|
|
||||||
|
const worker_url = URL.createObjectURL(
|
||||||
|
new Blob([`importScripts("${bundle.mainWorker}");`], { type: 'text/javascript' })
|
||||||
|
);
|
||||||
|
|
||||||
|
// Instantiate the asynchronus version of DuckDB-wasm
|
||||||
|
const worker = new Worker(worker_url);
|
||||||
|
const logger = new duckdb.ConsoleLogger();
|
||||||
|
const db = new duckdb.AsyncDuckDB(logger, worker);
|
||||||
|
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
|
||||||
|
URL.revokeObjectURL(worker_url);
|
||||||
|
|
||||||
|
console.log('datamgr init done')
|
||||||
|
|
||||||
|
|
||||||
|
//await db.registerFileURL('remote.parquet', 'http://localhost:8000/js/data/riferimenti_3.parquet', DuckDBDataProtocol.HTTP, false);
|
||||||
|
|
||||||
|
/*const res = await fetch('http://localhost:8000/js/data/riferimenti_3.parquet');
|
||||||
|
|
||||||
|
await db.registerFileBuffer('buffer.parquet', new Uint8Array(await res.arrayBuffer()));*/
|
||||||
|
|
||||||
|
const conn = await db.connect();
|
||||||
|
//CREATE TABLE commedia AS
|
||||||
|
// SELECT * FROM "https://lida.dantenetwork.it/js/data/com.parquet";
|
||||||
|
await conn.query(`
|
||||||
|
CREATE TABLE riferimenti AS
|
||||||
|
SELECT * FROM "https://lida.dantenetwork.it/js/data/riferimenti_7.parquet";
|
||||||
|
|
||||||
|
`);
|
||||||
|
|
||||||
|
var table = await conn.query(`
|
||||||
|
select distinct Aut from riferimenti order by Aut COLLATE NOCASE;
|
||||||
|
`);
|
||||||
|
const result = table.toArray().map((row) => row.toJSON());
|
||||||
|
rif_autori = result.map((x) => x['Aut']);
|
||||||
|
//console.log(rif_autori)
|
||||||
|
|
||||||
|
|
||||||
|
var table = await conn.query(`
|
||||||
|
select distinct Com from riferimenti;
|
||||||
|
`);
|
||||||
|
const result2 = table.toArray().map((row) => row.toJSON());
|
||||||
|
rif_commentatori = result2.map((x) => x['Com']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var table = await conn.query(`
|
||||||
|
select distinct CA from riferimenti order by CA;
|
||||||
|
`);
|
||||||
|
const result3 = table.toArray().map((row) => row.toJSON());
|
||||||
|
|
||||||
|
rif_areetematiche = result3.map((x) => x['CA']);
|
||||||
|
|
||||||
|
|
||||||
|
var table1 = await conn.query(`
|
||||||
|
select distinct TiFo from riferimenti order by TiFo COLLATE NOCASE;
|
||||||
|
`);
|
||||||
|
const result4 = table1.toArray().map((row) => row.toJSON());
|
||||||
|
//console.log(result4)
|
||||||
|
rif_fonti = result4.map((x) => x['TiFo']);
|
||||||
|
|
||||||
|
var querytl = 'select IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti order by n1, n2, n3'
|
||||||
|
var tablerif = await conn.query(querytl);
|
||||||
|
const result5 = tablerif.toArray().map((row) => row.toJSON());
|
||||||
|
var allreferences = Object.groupBy(result5, ({ Cantica }) => Cantica);
|
||||||
|
for (var cantica in allreferences) {
|
||||||
|
var tmp = allreferences[cantica]
|
||||||
|
for (var el of tmp) {
|
||||||
|
var tmpc = el.Canto
|
||||||
|
if (tmpc.startsWith('0'))
|
||||||
|
tmpc = tmpc.replace('0', '')
|
||||||
|
|
||||||
|
let ordveid = el.Cantica + '_Canto_' + tmpc + '_' + el.Verso.split('-')[0] + '_sp'
|
||||||
|
listaversicommentati.push(ordveid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listaversicommentati=[...new Set(listaversicommentati)]
|
||||||
|
|
||||||
|
/*var tableP = await conn.query(`
|
||||||
|
select * from commedia limit 10;
|
||||||
|
`);
|
||||||
|
const result5 = tableP.toArray().map((row) => row.toJSON());
|
||||||
|
console.log(result5)*/
|
||||||
|
|
||||||
|
await conn.close();
|
||||||
|
|
||||||
|
console.log('done')
|
||||||
|
|
||||||
|
opzioniRiferimenti()
|
||||||
|
|
||||||
|
|
||||||
|
export function versoCommentato(rif) {
|
||||||
|
if (listaversicommentati.includes(rif)){
|
||||||
|
var pars=rif.split('_')
|
||||||
|
var tc=pars[2]
|
||||||
|
if (tc.length==1)
|
||||||
|
tc='0'+tc
|
||||||
|
if(! processedrif.has(rif)){
|
||||||
|
getCitazioniInVerso(pars[0], tc, pars[3])
|
||||||
|
processedrif.add(rif)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRisultatiRiferimenti() {
|
||||||
|
listariferimentirisultato=[... new Set(listariferimentirisultato)]
|
||||||
|
return listariferimentirisultato;
|
||||||
|
}
|
||||||
|
export function getListaRis() {
|
||||||
|
return listaidversi;
|
||||||
|
}
|
||||||
|
export function getListaIdCommenti() {
|
||||||
|
return listaidcommenti;
|
||||||
|
}
|
||||||
|
export function cleanListaRis() {
|
||||||
|
listaidversi = [];
|
||||||
|
listaidcommenti = [];
|
||||||
|
listarisriferimenti = [];
|
||||||
|
listariferimentirisultato=[]
|
||||||
|
processedrif=new Set()
|
||||||
|
}
|
||||||
|
export function getFontiS() {
|
||||||
|
|
||||||
|
return rif_fonti
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAreeTematicheS() {
|
||||||
|
|
||||||
|
return rif_areetematiche
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAutoriFontiCitazioniS() {
|
||||||
|
|
||||||
|
return rif_autori
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCommentatoriS() {
|
||||||
|
|
||||||
|
return rif_commentatori
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getVersiConCitazioni(canticapar = '', cantopar = '') {
|
||||||
|
|
||||||
|
//let citcantiche = ['Inferno', 'Purgatorio', 'Paradiso']
|
||||||
|
if (canticapar == '') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const tconn = await db.connect();
|
||||||
|
var table = await tconn.query(`
|
||||||
|
select Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione,
|
||||||
|
F as FonteCitazione, LF as LuogoFonteCitazione, NF as NotaFonteCitazione,
|
||||||
|
TF as TestoFonteCitazione, UF as URLFonteCitazione, NaRi as NaturaRiferimento,
|
||||||
|
RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto,
|
||||||
|
Aut as NomeAutoreCitazione, TiFo as TitoloFonteCitazione, Verso as VersoCitazione, CA as AreaTematica,
|
||||||
|
TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie,
|
||||||
|
CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, n1, n2, n3
|
||||||
|
from riferimenti
|
||||||
|
where Cantica='${canticapar}' and Canto='${cantopar}' order by n1, n2, n3;
|
||||||
|
`);
|
||||||
|
|
||||||
|
var result4 = table.toArray().map((row) => row.toJSON());
|
||||||
|
|
||||||
|
|
||||||
|
await tconn.close();
|
||||||
|
return result4
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getCitazioniInVerso(canticapar = '', cantopar = '', versopar='') {
|
||||||
|
|
||||||
|
//let citcantiche = ['Inferno', 'Purgatorio', 'Paradiso']
|
||||||
|
if (canticapar == '') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const tconn = await db.connect();
|
||||||
|
var table = await tconn.query(`
|
||||||
|
select Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione,
|
||||||
|
F as FonteCitazione, LF as LuogoFonteCitazione, NF as NotaFonteCitazione,
|
||||||
|
TF as TestoFonteCitazione, UF as URLFonteCitazione, NaRi as NaturaRiferimento,
|
||||||
|
RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto,
|
||||||
|
Aut as NomeAutoreCitazione, TiFo as TitoloFonteCitazione, Verso as VersoCitazione, CA as AreaTematica,
|
||||||
|
TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie,
|
||||||
|
CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, Cantica, Canto, n1, n2, n3
|
||||||
|
from riferimenti
|
||||||
|
where Cantica='${canticapar}' and Canto='${cantopar}' and (Verso='${versopar}' or Verso like '%${versopar}-%') order by n1, n2, n3;
|
||||||
|
`);
|
||||||
|
|
||||||
|
var resultvc = table.toArray().map((row) => row.toJSON());
|
||||||
|
|
||||||
|
await tconn.close();
|
||||||
|
listariferimentirisultato=listariferimentirisultato.concat(resultvc)
|
||||||
|
//console.log('CONCAT '+canticapar+', '+ cantopar+', '+versopar+', length:' +listariferimentirisultato.length)
|
||||||
|
//return resultvc
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getWhere(filtro) {
|
||||||
|
if (filtro == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var queryfi = ''
|
||||||
|
console.log(filtro)
|
||||||
|
var contenuti_riferimento = {
|
||||||
|
'personaggio': " and CPER !='' and CPER !='no'",
|
||||||
|
'episodio': " and CEP !='' and CEP !='no'",
|
||||||
|
'motivo': " and CMO !='' and CMO !='no'",
|
||||||
|
'immagine': " and CIM !='' and CIM !='no'",
|
||||||
|
'teoria': " and CTE !='' and CTE !='no'",
|
||||||
|
'stilema': " and CST !='' and CST !='no'",
|
||||||
|
'topografia': " and CTO !='' and CTO !='no'"
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmpfiltro = ''
|
||||||
|
|
||||||
|
queryfi = ' '
|
||||||
|
if (filtro.Commentatore != null && filtro.Commentatore.trim() != 'all') {
|
||||||
|
tmpfiltro = filtro.Commentatore.trim()
|
||||||
|
tmpfiltro = tmpfiltro.replace("\'", "_")
|
||||||
|
queryfi += "Com like'" + tmpfiltro + "'"
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
queryfi += "Com like '%'"
|
||||||
|
if (filtro.Autore_Fonte != null && filtro.Autore_Fonte.trim() != 'all') {
|
||||||
|
|
||||||
|
tmpfiltro = filtro.Autore_Fonte
|
||||||
|
tmpfiltro = tmpfiltro.replace("\'", "_")
|
||||||
|
//console.log(tmpfiltro)
|
||||||
|
queryfi += " and Aut like '" + tmpfiltro.trim() + "'"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filtro.Fonte != null && filtro.Fonte.trim() != 'all')
|
||||||
|
queryfi += " and TiFo='" + filtro.Fonte.trim() + "'"
|
||||||
|
|
||||||
|
if (filtro.Area_Tematica != null && filtro.Area_Tematica.trim() != 'all')
|
||||||
|
queryfi += " and CA='" + filtro.Area_Tematica.trim() + "'"
|
||||||
|
|
||||||
|
if (filtro.Tipo_Riferimento != null && filtro.Tipo_Riferimento.trim() != 'all')
|
||||||
|
queryfi += " and NaRi='" + filtro.Tipo_Riferimento.trim().toUpperCase() + "'"
|
||||||
|
if (filtro.Contenuto_Riferimento != null && filtro.Contenuto_Riferimento != 'all')
|
||||||
|
queryfi += contenuti_riferimento[filtro.Contenuto_Riferimento.trim()]
|
||||||
|
|
||||||
|
if (filtro.Rapporto_Testo_Fonte != null && filtro.Rapporto_Testo_Fonte != 'all')
|
||||||
|
queryfi += " and UPPER(RSO)=UPPER('" + filtro.Rapporto_Testo_Fonte.trim() + "')"
|
||||||
|
|
||||||
|
if (filtro.Testo_Fonte != null && filtro.Testo_Fonte.trim() != '')
|
||||||
|
queryfi += " and TF like '%" + filtro.Testo_Fonte.trim() + "%'"
|
||||||
|
|
||||||
|
if (filtro.Testo_Nota != null && filtro.Testo_Nota.trim() != '')
|
||||||
|
queryfi += " and Ann like '%" + filtro.Testo_Nota.trim() + "%'"
|
||||||
|
if (filtro.contesto != null) {
|
||||||
|
var marray = JSON.parse(filtro.contesto);
|
||||||
|
var infiltro = false
|
||||||
|
var oplog = ' and ('
|
||||||
|
var tfi = filtroContesto(marray[0], 'Inferno', oplog)
|
||||||
|
queryfi += tfi
|
||||||
|
if (tfi.trim() != ''){
|
||||||
|
infiltro = true
|
||||||
|
oplog = ' or '
|
||||||
|
}
|
||||||
|
tfi = ''
|
||||||
|
tfi = filtroContesto(marray[1], 'Purgatorio', oplog)
|
||||||
|
if (tfi != '') {
|
||||||
|
infiltro = true
|
||||||
|
queryfi += tfi
|
||||||
|
oplog = ' or '
|
||||||
|
}
|
||||||
|
tfi = ''
|
||||||
|
tfi = filtroContesto(marray[2], 'Paradiso', oplog)
|
||||||
|
if (tfi != '') {
|
||||||
|
infiltro = true
|
||||||
|
queryfi += tfi
|
||||||
|
}
|
||||||
|
if (infiltro)
|
||||||
|
queryfi += ")"
|
||||||
|
}
|
||||||
|
return (queryfi)
|
||||||
|
}
|
||||||
|
var tmpc = ''
|
||||||
|
function getWherePart(iclause, query, cls) {
|
||||||
|
console.log(cls)
|
||||||
|
for (var filt in iclause) {
|
||||||
|
if ('TERM' in iclause[filt]) {
|
||||||
|
var rifterm = iclause[filt]['TERM']
|
||||||
|
console.log(getWhere(query[rifterm]))
|
||||||
|
/*tmpc += '('+getWhere(query[rifterm])*/
|
||||||
|
console.log(parseInt(filt) + 1)
|
||||||
|
if (parseInt(filt) == 0) {
|
||||||
|
tmpc += '(' + getWhere(query[rifterm])
|
||||||
|
tmpc += ') '
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
tmpc += cls + ' (' + getWhere(query[rifterm])
|
||||||
|
tmpc += ') '
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var myop = Object.keys(iclause[filt])[0];
|
||||||
|
if (parseInt(filt) > 0)
|
||||||
|
tmpc += ' ' + cls
|
||||||
|
getWherePart(iclause[filt][myop], query, myop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//tmpc+=')'
|
||||||
|
return tmpc
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function queryRiferimentimul(query, cid) {
|
||||||
|
var wherecl = ' where '
|
||||||
|
var parser = peg.generate(hdnriferquerygrammar);
|
||||||
|
var test = query['EsprLogicaRif'].join(" ");
|
||||||
|
test = test.replaceAll("( ", "(")
|
||||||
|
test = test.replaceAll(" )", ")")
|
||||||
|
var rifclauses = parser.parse(test);
|
||||||
|
var jsonclauses = JSON.parse(rifclauses)
|
||||||
|
tmpc = ''
|
||||||
|
for (var cls in jsonclauses) {
|
||||||
|
wherecl += '(' + getWherePart(jsonclauses[cls], query, cls) + ')'
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log(wherecl)
|
||||||
|
const tconn = await db.connect();
|
||||||
|
|
||||||
|
var querytl = 'select DISTINCT IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti'
|
||||||
|
var rs = await tconn.query(querytl + wherecl + ' order by n1, n2, n3')
|
||||||
|
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||||
|
|
||||||
|
await tconn.close();
|
||||||
|
var resxcantica = Object.groupBy(result4, ({ Cantica }) => Cantica);
|
||||||
|
console.log(resxcantica)
|
||||||
|
return showResult(resxcantica, cid)
|
||||||
|
}
|
||||||
|
|
||||||
|
function showResult(resxcantica, cid) {
|
||||||
|
/*var resKeys = Object.keys(resxcantica);
|
||||||
|
var tuttiVersiPurgatorio = []
|
||||||
|
var tuttiVersiParadiso = []*/
|
||||||
|
listaidversi = []
|
||||||
|
var numcid = cid.split('_')[1]
|
||||||
|
/*if (resKeys.includes("Inferno")) {
|
||||||
|
sortRiferimenti(resxcantica.Inferno, listaidversi)
|
||||||
|
}
|
||||||
|
if (resKeys.includes("Purgatorio")) {
|
||||||
|
sortRiferimenti(resxcantica.Purgatorio, tuttiVersiPurgatorio)
|
||||||
|
listaidversi = listaidversi.concat(tuttiVersiPurgatorio)
|
||||||
|
}
|
||||||
|
if (resKeys.includes("Paradiso")) {
|
||||||
|
sortRiferimenti(resxcantica.Paradiso, tuttiVersiParadiso)
|
||||||
|
listaidversi = listaidversi.concat(tuttiVersiParadiso)
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
for (var cantica in resxcantica) {
|
||||||
|
var $nctags = $(' .navig-canto')
|
||||||
|
|
||||||
|
//console.log(resxcantica[cantica].length)
|
||||||
|
var i = 1;
|
||||||
|
if (cantica == 'Purgatorio')
|
||||||
|
i = 2
|
||||||
|
if (cantica == 'Paradiso')
|
||||||
|
i = 3
|
||||||
|
var spanbadgecantica = $('<span />');
|
||||||
|
spanbadgecantica.attr('class', 'badge badge-warning badge-pill mx-2');
|
||||||
|
spanbadgecantica.append(resxcantica[cantica].length)
|
||||||
|
spanbadgecantica.appendTo($('#cantica' + i + '-badge'))
|
||||||
|
|
||||||
|
var tmp = resxcantica[cantica]
|
||||||
|
for (var el of tmp) {
|
||||||
|
var tmpc = el.Canto
|
||||||
|
if (tmpc.startsWith('0')) {
|
||||||
|
tmpc = tmpc.replace('0', '')
|
||||||
|
}
|
||||||
|
|
||||||
|
let ordveid = el.Cantica + '_Canto_' + tmpc + '_' + el.Verso.split('-')[0] + '_sp'
|
||||||
|
listaidversi.push(ordveid)
|
||||||
|
}
|
||||||
|
|
||||||
|
var resxcanto = Object.groupBy(tmp, ({ Canto }) => Canto);
|
||||||
|
for (var canto in resxcanto) {
|
||||||
|
var tmpv = resxcanto[canto]
|
||||||
|
var spanbadge = $('<span />');
|
||||||
|
spanbadge.attr('class', cantobadgeclassBis);
|
||||||
|
spanbadge.append(resxcanto[canto].length)
|
||||||
|
if (canto.startsWith('0')) {
|
||||||
|
canto = canto.replace('0', '')
|
||||||
|
}
|
||||||
|
spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]'))
|
||||||
|
for (const tmpvi of tmpv) {
|
||||||
|
let myveid = cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0].replace('|', '') + '_sp'
|
||||||
|
//listaidversi.push(myveid)
|
||||||
|
listaidcommenti.push(tmpvi.IdRiferimento) //Nico
|
||||||
|
if (cid.includes(cantica) && numcid == canto)
|
||||||
|
$('#' + myveid).addClass("mark ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawMinimap(cid, true)
|
||||||
|
}
|
||||||
|
/*console.log(resxcantica)*/
|
||||||
|
return listaidversi
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function queryRiferimenti(filtro, cid) {
|
||||||
|
if (filtro == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log(filtro)
|
||||||
|
var contenuti_riferimento = {
|
||||||
|
'personaggio': " and CPER !='' and CPER !='no'",
|
||||||
|
'episodio': " and CEP !='' and CEP !='no'",
|
||||||
|
'motivo': " and CMO !='' and CMO !='no'",
|
||||||
|
'immagine': " and CIM !='' and CIM !='no'",
|
||||||
|
'teoria': " and CTE !='' and CTE !='no'",
|
||||||
|
'stilema': " and CST !='' and CST !='no'",
|
||||||
|
'topografia': " and CTO !='' and CTO !='no'"
|
||||||
|
}
|
||||||
|
const tconn = await db.connect();
|
||||||
|
var tmpfiltro = ''
|
||||||
|
var querytlcompl = `SELECT Ann as Annotazione, Com as Commentario, FrN as frammentoNota, AC as AutoreCitazione,
|
||||||
|
F as FonteCitazione, LF as LuogoFonteCitazione, NF as NotaFonteCitazione,
|
||||||
|
TF as TestoFonteCitazione, UF as URLFonteCitazione, NaRi as NaturaRiferimento,
|
||||||
|
RCC as RapportoCommentoCommentatoreText, RSO as RapportoSoggettoOggetto,
|
||||||
|
Aut as NomeAutoreCitazione, TiFo as TitoloFonteCitazione, Verso as VersoCitazione, CA as AreaTematica,
|
||||||
|
TiCi as TipoCitazione, CEP as CitEpisodi, CIM as CitImmagini, CTE as CitTeorie,
|
||||||
|
CMO as CitMotivi, CST as CitStilemi, CTO as CitTopografie, CPER as CitPersonaggi, IdRiferimento, n1, n2, n3,
|
||||||
|
Cantica, Canto, Verso FROM riferimenti`
|
||||||
|
var querytl = 'select DISTINCT IdRiferimento, Cantica, Canto, Verso, n1, n2, n3 from riferimenti'
|
||||||
|
var queryfi = ' where '
|
||||||
|
if (filtro.Commentatore != null && filtro.Commentatore.trim() != 'all') {
|
||||||
|
tmpfiltro = filtro.Commentatore.trim()
|
||||||
|
tmpfiltro = tmpfiltro.replace("\'", "_")
|
||||||
|
queryfi += "Com like'" + tmpfiltro + "'"
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
queryfi += "Com like '%'"
|
||||||
|
if (filtro.Autore_Fonte != null && filtro.Autore_Fonte.trim() != 'all') {
|
||||||
|
|
||||||
|
tmpfiltro = filtro.Autore_Fonte
|
||||||
|
tmpfiltro = tmpfiltro.replace("\'", "_")
|
||||||
|
//console.log(tmpfiltro)
|
||||||
|
queryfi += " and Aut like '" + tmpfiltro.trim() + "'"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filtro.Fonte != null && filtro.Fonte.trim() != 'all')
|
||||||
|
queryfi += " and TiFo='" + filtro.Fonte.trim() + "'"
|
||||||
|
|
||||||
|
if (filtro.Area_Tematica != null && filtro.Area_Tematica.trim() != 'all')
|
||||||
|
queryfi += " and CA='" + filtro.Area_Tematica.trim() + "'"
|
||||||
|
|
||||||
|
if (filtro.Tipo_Riferimento != null && filtro.Tipo_Riferimento.trim() != 'all')
|
||||||
|
queryfi += " and NaRi='" + filtro.Tipo_Riferimento.trim().toUpperCase() + "'"
|
||||||
|
if (filtro.Contenuto_Riferimento != null && filtro.Contenuto_Riferimento != 'all')
|
||||||
|
queryfi += contenuti_riferimento[filtro.Contenuto_Riferimento.trim()]
|
||||||
|
|
||||||
|
if (filtro.Rapporto_Testo_Fonte != null && filtro.Rapporto_Testo_Fonte != 'all')
|
||||||
|
queryfi += " and UPPER(RSO)=UPPER('" + filtro.Rapporto_Testo_Fonte.trim() + "')"
|
||||||
|
|
||||||
|
if (filtro.Testo_Fonte != null && filtro.Testo_Fonte.trim() != '')
|
||||||
|
queryfi += " and TF like '%" + filtro.Testo_Fonte.trim() + "%'"
|
||||||
|
|
||||||
|
if (filtro.Testo_Nota != null && filtro.Testo_Nota.trim() != '')
|
||||||
|
queryfi += " and Ann like '%" + filtro.Testo_Nota.trim() + "%'"
|
||||||
|
if (filtro.contesto != null) {
|
||||||
|
var marray = JSON.parse(filtro.contesto);
|
||||||
|
var infiltro = false
|
||||||
|
var oplog = ' and ('
|
||||||
|
var tfi = filtroContesto(marray[0], 'Inferno', oplog)
|
||||||
|
queryfi += tfi
|
||||||
|
if (tfi.trim() != ''){
|
||||||
|
infiltro = true
|
||||||
|
oplog = ' or '
|
||||||
|
}
|
||||||
|
|
||||||
|
tfi = ''
|
||||||
|
tfi = filtroContesto(marray[1], 'Purgatorio', oplog)
|
||||||
|
if (tfi != '') {
|
||||||
|
infiltro = true
|
||||||
|
queryfi += tfi
|
||||||
|
oplog = ' or '
|
||||||
|
}
|
||||||
|
tfi = ''
|
||||||
|
tfi = filtroContesto(marray[2], 'Paradiso', oplog)
|
||||||
|
if (tfi != '') {
|
||||||
|
infiltro = true
|
||||||
|
queryfi += tfi
|
||||||
|
}
|
||||||
|
if (infiltro)
|
||||||
|
queryfi += ")"
|
||||||
|
}
|
||||||
|
|
||||||
|
var rs = await tconn.query(querytl + queryfi + ' order by n1, n2, n3;')
|
||||||
|
|
||||||
|
//var rs = await tconn.query(querytlcompl + queryfi+ ' order by n1, n2, n3;')
|
||||||
|
listarisriferimenti = rs.toArray().map((row) => row.toJSON());
|
||||||
|
|
||||||
|
await tconn.close();
|
||||||
|
var resxcantica = Object.groupBy(listarisriferimenti, ({ Cantica }) => Cantica);
|
||||||
|
return (showResult(resxcantica, cid))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*function sortRiferimenti(canticaArray,arrayValues){
|
||||||
|
var versi = []
|
||||||
|
var cantica;
|
||||||
|
var canto;
|
||||||
|
for (var j = 0; j < canticaArray.length; j++) {
|
||||||
|
versi = canticaArray[j].Verso.split("-")
|
||||||
|
cantica = canticaArray[j].Cantica
|
||||||
|
canto = canticaArray[j].Canto
|
||||||
|
if (canto.startsWith('0')) {
|
||||||
|
canto = canto.replace('0', '')
|
||||||
|
}
|
||||||
|
arrayValues.push(cantica + '_Canto_' + canto + '_' + versi[0])
|
||||||
|
}
|
||||||
|
arrayValues.sort(function(a, b) {
|
||||||
|
var versoA = a.split('_')
|
||||||
|
var versoB = b.split('_')
|
||||||
|
var cantoA = Number(versoA[2]);
|
||||||
|
var cantoB = Number(versoB[2])
|
||||||
|
versoA = versoA[3];
|
||||||
|
versoB = versoB[3];
|
||||||
|
if (cantoA == cantoB){
|
||||||
|
return (versoA - versoB)
|
||||||
|
}else{
|
||||||
|
return (cantoA - cantoB)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}*/
|
||||||
|
|
||||||
|
function opzioniRiferimenti() {
|
||||||
|
$.each(rif_commentatori, function(i, p) {
|
||||||
|
if (!!p && p.length > 2) {
|
||||||
|
$('#CommentatorexR1Rx').append($('<option></option>')
|
||||||
|
.val(p).html(p));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$.each(rif_fonti, function(i, p) {
|
||||||
|
if (!!p && p.length > 2) {
|
||||||
|
$('#FontexR1Rx').append($('<option></option>')
|
||||||
|
.val(p).html(p));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$.each(rif_autori, function(i, p) {
|
||||||
|
if (!!p && p.length > 2) {
|
||||||
|
$('#Autore_FontexR1Rx').append($('<option></option>')
|
||||||
|
.val(p).html(p));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$.each(rif_areetematiche, function(i, p) {
|
||||||
|
if (!!p && p.length > 2) {
|
||||||
|
$('#Area_TematicaxR1Rx').append($('<option></option>')
|
||||||
|
.val(p).html(p));
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
function filtroContesto(marray, cantica, op) {
|
||||||
|
var filtrost = ''
|
||||||
|
if (marray.every((val, i, arr) => val === 1)) {
|
||||||
|
return op + " Cantica='" + cantica + "'"
|
||||||
|
}
|
||||||
|
if (marray.some((val, i, arr) => val === 1)) {
|
||||||
|
var tearr = marray.reduce(function(tearr, n, i) { if (n === 1) tearr.push(i); return tearr; }, []);
|
||||||
|
for (const ic in tearr) {
|
||||||
|
var canto = (tearr[ic] + 1).toString()
|
||||||
|
if ((tearr[ic] + 1) < 10)
|
||||||
|
canto = '0' + canto
|
||||||
|
if (ic == 0)
|
||||||
|
filtrost += op + " (Cantica='" + cantica + "' and (Canto='" + canto + "'"
|
||||||
|
else
|
||||||
|
filtrost += " or Canto='" + canto + "'"
|
||||||
|
|
||||||
|
}
|
||||||
|
if (tearr.length)
|
||||||
|
filtrost += "))"
|
||||||
|
console.log(filtrost)
|
||||||
|
}
|
||||||
|
return filtrost
|
||||||
|
}
|
||||||
|
|
||||||
|
//Contesto per lista risultati
|
||||||
|
|
||||||
|
export async function getFormaCntxtLastPosition(formaid, numversi = 3) {
|
||||||
|
/*const tconn = await db.connect();
|
||||||
|
var querycnt = "select * from commedia where index>=((select index from commedia where Position='" + formaid + "')-25) order by index limit 50"
|
||||||
|
console.log(" " + formaid)
|
||||||
|
var rs = await tconn.query(querycnt)
|
||||||
|
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||||
|
|
||||||
|
|
||||||
|
console.log(result4.at(-1)['Position'])
|
||||||
|
console.log('-----------------------------------------')
|
||||||
|
|
||||||
|
|
||||||
|
await tconn.close();
|
||||||
|
return (result4.at(-1)['Position'])*/
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,150 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*import {Runtime, Library, Inspector} from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/runtime.js";
|
||||||
|
import commarc from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/index.js";*/
|
||||||
|
import {Runtime, Library, Inspector} from "https://lida.dantenetwork.it/node_modules/commarcdiag/runtime.js";
|
||||||
|
import commarc from "https://lida.dantenetwork.it/node_modules/commarcdiag/index.js";
|
||||||
|
import {formaClass, lisid, lsentid, vistaPeriodi, listaPeriodiRisultato, listaClausoleRisultato, cantoDisplayed, graphTextReset} from "./browseMgr_5.2.js"
|
||||||
|
import { fillStructCard, emptyStructCard } from "./script_5.2.js";
|
||||||
|
|
||||||
|
const iframe = document.getElementsByClassName("minimap__content");
|
||||||
|
const runtime1 = new Runtime(new Library(name => {
|
||||||
|
console.log('name' +name)
|
||||||
|
switch (name) {
|
||||||
|
case "d3@^5.8": return d3;
|
||||||
|
case "d3@^6.0": return d3;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
document.addEventListener("dblclick", function(e){
|
||||||
|
const target = e.target.closest("."+formaClass);
|
||||||
|
|
||||||
|
if(target){
|
||||||
|
|
||||||
|
|
||||||
|
if(resetGraphStr())
|
||||||
|
return
|
||||||
|
|
||||||
|
var hcontainer="#structCard0"
|
||||||
|
|
||||||
|
var main=runtime1.module(commarc, name => {
|
||||||
|
|
||||||
|
//if (name === "sentenceStructArcs_new") {
|
||||||
|
if (name === "sentenceArcsStructs_new") {
|
||||||
|
const structel = document.querySelector(cantoDisplayed).getElementsByClassName(lsentid);
|
||||||
|
//console.log(structel[0].parentNode.getAttribute('value'))
|
||||||
|
var stid=lsentid.split('_')
|
||||||
|
var structid=stid[0]+'_'+stid[1]+'_'+structel[0].parentNode.parentNode.getAttribute('value')
|
||||||
|
console.log(structid)
|
||||||
|
fillStructCard(structid);
|
||||||
|
return new Inspector(document.querySelector(hcontainer));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if (lisid!=''){
|
||||||
|
//var mywidth=document.getElementById('displaycanto').offsetWidth
|
||||||
|
|
||||||
|
//console.log('here graph '+lisid+' '+lsentid)
|
||||||
|
|
||||||
|
|
||||||
|
main.redefine('width', 625);
|
||||||
|
main.redefine("lisid", lisid);
|
||||||
|
const structel = document.querySelector(cantoDisplayed).getElementsByClassName(lsentid);
|
||||||
|
var stid=lsentid.split('_')
|
||||||
|
var structid=stid[0]+'_'+stid[1]+'_'+structel[0].parentNode.parentNode.getAttribute('value')
|
||||||
|
|
||||||
|
fillStructCard(structid)
|
||||||
|
|
||||||
|
var collection = document.getElementsByClassName(lsentid);
|
||||||
|
for (let i = 0; i < collection.length; i++) {
|
||||||
|
//collection[i].classList.add('font-weight-normal');
|
||||||
|
collection[i].classList.add('font-italic');
|
||||||
|
if (!vistaPeriodi){
|
||||||
|
var synttp=collection[i].className.split(" ")[1]
|
||||||
|
collection[i].style.color = colorssp(mapsynttypestopalette[synttp]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//collection[i].style.removeProperty('color');
|
||||||
|
}
|
||||||
|
$('#tab-list #vis1-tab').tab('show')
|
||||||
|
updateMinimap(lsentid)
|
||||||
|
$("#printPeriodoCorrente").prop("disabled", false);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function updateMinimap(sentid){
|
||||||
|
//var iframe = document.getElementsByClassName("minimap__content");
|
||||||
|
|
||||||
|
var iframeDocument = iframe[0].contentDocument || iframe[0].contentWindow.document;
|
||||||
|
if (!iframeDocument) {
|
||||||
|
throw "iframe couldn't be found in DOM.";
|
||||||
|
}
|
||||||
|
var iframeSentence = iframeDocument.getElementsByClassName(sentid);
|
||||||
|
for (let i = 0; i < iframeSentence.length; i++) {
|
||||||
|
iframeSentence[i].classList.add('font-italic');
|
||||||
|
|
||||||
|
if (!vistaPeriodi){
|
||||||
|
var synttp=iframeSentence[i].className.split(" ")[1]
|
||||||
|
iframeSentence[i].style.color = colorssp(mapsynttypestopalette[synttp]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resetGraphStr(){
|
||||||
|
|
||||||
|
var periodograph = document.getElementById("periodograph");
|
||||||
|
if (periodograph != null) {
|
||||||
|
let showngr = document.getElementById("periodograph").getAttribute('name').split("_")
|
||||||
|
var tmpsent = showngr[0] + "_" + showngr[1] + "_s_" + showngr[2]
|
||||||
|
periodograph.parentNode.removeChild(periodograph);
|
||||||
|
|
||||||
|
var sentence=document.querySelector(cantoDisplayed).getElementsByClassName(tmpsent);
|
||||||
|
|
||||||
|
for (let i = 0; i < sentence.length; i++) {
|
||||||
|
//var matches = listaClausoleRisultato.filter(s => s.includes(sentence[i].classList[0]));
|
||||||
|
sentence[i].classList.remove('font-italic');
|
||||||
|
if (!vistaPeriodi)
|
||||||
|
sentence[i].style.removeProperty('color');
|
||||||
|
|
||||||
|
sentence[i].classList.remove('font-weight-normal');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//reset Minimap
|
||||||
|
var iframeDocument = myiframe[0].contentDocument || myiframe[0].contentWindow.document;
|
||||||
|
if (!iframeDocument) {
|
||||||
|
throw "iframe couldn't be found in DOM.";
|
||||||
|
}
|
||||||
|
var iframeSentence = iframeDocument.getElementsByClassName(tmpsent);
|
||||||
|
for (let i = 0; i < iframeSentence.length; i++) {
|
||||||
|
iframeSentence[i].classList.remove('font-italic');
|
||||||
|
if (!vistaPeriodi)
|
||||||
|
iframeSentence[i].style.removeProperty('color');
|
||||||
|
|
||||||
|
iframeSentence[i].classList.remove('font-weight-normal');
|
||||||
|
}
|
||||||
|
//EMPTY CARD
|
||||||
|
emptyStructCard()
|
||||||
|
//visualizzazione risultati query
|
||||||
|
graphTextReset()
|
||||||
|
if (tmpsent == lsentid) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue