rif in progress
This commit is contained in:
parent
abb74e65a0
commit
49fe4d93eb
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
import { getVersiConCitazioni, queryRiferimenti} from './dataMgr.js';
|
||||
import { getVersiConCitazioni, queryRiferimenti, getListaRis} from './dataMgr.js';
|
||||
import { getJsonQuery, emptyStructCard } from './script_5.0.js';
|
||||
import {resetGraphStr} from './syntgraph_5.0.js'
|
||||
|
||||
|
@ -1489,6 +1489,12 @@ $(document).ready(function() {
|
|||
//manageMM (cantoDisplayed)
|
||||
//var currPage = 0;
|
||||
//var latestPhraseId = "";
|
||||
var telive=getListaRis()
|
||||
for (var ve of telive) {
|
||||
let idve = ve
|
||||
$(ve).removeClass("font-weight-bold mark ")
|
||||
minim.contents().find(ve).removeClass("font-weight-bold mark ")
|
||||
}
|
||||
drawMinimap(cantoDisplayed, true)
|
||||
}
|
||||
|
||||
|
|
134
js/dataMgr.js
134
js/dataMgr.js
|
@ -4,10 +4,11 @@ import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0
|
|||
//import * as arrow from 'https://cdn.skypack.dev/apache-arrow@9'
|
||||
|
||||
|
||||
var rif_commentatori=[];
|
||||
var rif_autori=[];
|
||||
var rif_areetematiche=[];
|
||||
var rif_fonti=[];
|
||||
var rif_commentatori = [];
|
||||
var rif_autori = [];
|
||||
var rif_areetematiche = [];
|
||||
var rif_fonti = [];
|
||||
var listaidversi = []
|
||||
const cantobadgeclassBis = 'badge badge-outline-warning badge-pill'
|
||||
|
||||
const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
|
||||
|
@ -16,7 +17,7 @@ const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
|
|||
const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
|
||||
|
||||
const worker_url = URL.createObjectURL(
|
||||
new Blob([`importScripts("${bundle.mainWorker}");`], {type: 'text/javascript'})
|
||||
new Blob([`importScripts("${bundle.mainWorker}");`], { type: 'text/javascript' })
|
||||
);
|
||||
|
||||
// Instantiate the asynchronus version of DuckDB-wasm
|
||||
|
@ -26,7 +27,7 @@ const db = new duckdb.AsyncDuckDB(logger, worker);
|
|||
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
|
||||
URL.revokeObjectURL(worker_url);
|
||||
|
||||
console.log ('datamgr init done')
|
||||
console.log('datamgr init done')
|
||||
|
||||
|
||||
//await db.registerFileURL('remote.parquet', 'http://localhost:8000/js/data/riferimenti_3.parquet', DuckDBDataProtocol.HTTP, false);
|
||||
|
@ -42,19 +43,19 @@ await conn.query(`
|
|||
SELECT * FROM "https://lida.dantenetwork.it/js/data/riferimenti_3.parquet";
|
||||
`);
|
||||
|
||||
var table=await conn.query(`
|
||||
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']);
|
||||
rif_autori = result.map((x) => x['Aut']);
|
||||
//console.log(rif_autori)
|
||||
|
||||
|
||||
var table=await conn.query(`
|
||||
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']);
|
||||
rif_commentatori = result2.map((x) => x['Com']);
|
||||
|
||||
|
||||
|
||||
|
@ -66,52 +67,55 @@ rif_commentatori=result2.map((x) => x['Com']);
|
|||
//console.log(rif_commentatori)
|
||||
|
||||
|
||||
var table=await conn.query(`
|
||||
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']);
|
||||
rif_areetematiche = result3.map((x) => x['CA']);
|
||||
|
||||
|
||||
var table1=await conn.query(`
|
||||
var table1 = await conn.query(`
|
||||
select distinct TiFo from riferimenti;
|
||||
`);
|
||||
const result4 = table1.toArray().map((row) => row.toJSON());
|
||||
rif_fonti=result4.map((x) => x['TiFo']);
|
||||
rif_fonti = result4.map((x) => x['TiFo']);
|
||||
|
||||
//console.log(rif_fonti)
|
||||
await conn.close();
|
||||
|
||||
console.log('done')
|
||||
export function getListaRis(){
|
||||
return listaidversi;
|
||||
}
|
||||
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(`
|
||||
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,
|
||||
|
@ -122,76 +126,74 @@ export async function getVersiConCitazioni(canticapar = '', cantopar = '') {
|
|||
from riferimenti
|
||||
where Cantica='${canticapar}' and Canto='${cantopar}' order by verso;
|
||||
`);
|
||||
|
||||
|
||||
var result4 = table.toArray().map((row) => row.toJSON());
|
||||
|
||||
|
||||
|
||||
|
||||
await tconn.close();
|
||||
return result4
|
||||
|
||||
|
||||
}
|
||||
export async function queryRiferimenti(filtro, cid){
|
||||
if(filtro==null){
|
||||
export async function queryRiferimenti(filtro, cid) {
|
||||
if (filtro == null) {
|
||||
return
|
||||
}
|
||||
console.log(filtro)
|
||||
const tconn= await db.connect();
|
||||
var querytl='select Cantica, Canto, Verso from riferimenti'
|
||||
var queryfi=' where '
|
||||
if (filtro.Commentatore!=null && filtro.Commentatore.trim()!='all')
|
||||
queryfi+="Com='"+filtro.Commentatore.trim()+"'"
|
||||
const tconn = await db.connect();
|
||||
var querytl = 'select Cantica, Canto, Verso from riferimenti'
|
||||
var queryfi = ' where '
|
||||
if (filtro.Commentatore != null && filtro.Commentatore.trim() != 'all')
|
||||
queryfi += "Com='" + filtro.Commentatore.trim() + "'"
|
||||
else
|
||||
queryfi+="Com like '%'"
|
||||
if (filtro.Autore_Fonte!=null && filtro.Autore_Fonte.trim()!='all')
|
||||
queryfi+=" and Aut='"+filtro.Autore_Fonte.trim()+"'"
|
||||
|
||||
var rs= await tconn.query(querytl+queryfi)
|
||||
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||
|
||||
await tconn.close();
|
||||
var resxcantica= Object.groupBy(result4, ({ Cantica }) => Cantica);
|
||||
|
||||
queryfi += "Com like '%'"
|
||||
if (filtro.Autore_Fonte != null && filtro.Autore_Fonte.trim() != 'all')
|
||||
queryfi += " and Aut='" + filtro.Autore_Fonte.trim() + "'"
|
||||
|
||||
var numcid=cid.split('_')[1]
|
||||
for (var cantica in resxcantica){
|
||||
var rs = await tconn.query(querytl + queryfi)
|
||||
var result4 = rs.toArray().map((row) => row.toJSON());
|
||||
|
||||
await tconn.close();
|
||||
var resxcantica = Object.groupBy(result4, ({ Cantica }) => Cantica);
|
||||
|
||||
|
||||
var numcid = cid.split('_')[1]
|
||||
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 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'))
|
||||
console.log(spanbadgecantica)
|
||||
var tmp=resxcantica[cantica]
|
||||
var resxcanto= Object.groupBy(tmp, ({ Canto }) => Canto);
|
||||
for (var canto in resxcanto){
|
||||
var tmpv=resxcanto[canto]
|
||||
var tmp = resxcantica[cantica]
|
||||
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', '')
|
||||
if (canto.startsWith('0')) {
|
||||
canto = canto.replace('0', '')
|
||||
}
|
||||
spanbadge.appendTo($nctags.filter('[name="' + cantica + 'Canto ' + canto + '"]'))
|
||||
if (cid.includes(cantica) && numcid==canto){
|
||||
|
||||
|
||||
for (const tmpvi of tmpv){
|
||||
let myveid='#'+cantica+'_Canto_'+canto+'_'+tmpvi.Verso.split('-')[0]
|
||||
console.log(myveid)
|
||||
for (const tmpvi of tmpv) {
|
||||
let myveid = '#' + cantica + '_Canto_' + canto + '_' + tmpvi.Verso.split('-')[0]
|
||||
console.log(myveid)
|
||||
listaidversi.push(myveid)
|
||||
if (cid.includes(cantica) && numcid == canto)
|
||||
$(myveid).addClass("font-weight-bold mark ")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
drawMinimap(cid, true)
|
||||
|
||||
|
||||
}
|
||||
/*console.log(resxcantica)*/
|
||||
return resxcantica
|
||||
|
||||
return listaidversi
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue