From f2addc279aa0671c83fb300e6b294ebbfa4f8ef8 Mon Sep 17 00:00:00 2001 From: cesare Date: Wed, 15 Feb 2023 12:00:51 +0100 Subject: [PATCH] filtri contesto, in progress --- css/browsingldc.css | 8 +++++--- js/cesareBrowse.js | 31 ++++++++++++++++++++++++++++++- js/syntgraph.js | 43 +++++++++++-------------------------------- js/utils.js | 44 ++++++++++++++++++++++++++++++-------------- 4 files changed, 76 insertions(+), 50 deletions(-) diff --git a/css/browsingldc.css b/css/browsingldc.css index 0e07080..6993b4c 100644 --- a/css/browsingldc.css +++ b/css/browsingldc.css @@ -29,17 +29,19 @@ font-size: 12px; font-weight: normal; font-style: italic; - font-family: -apple-system, BlinkMacSystemFont, “Helvetica Neue”, + font-family: "Bracciolini", "Spectral", -apple-system, BlinkMacSystemFont, “Helvetica Neue”, “Segoe UI”, “Roboto”, “Oxygen”, “Ubuntu”, “Cantarell”, - “Fira Sans”, “Droid Sans”, - sans-serif; + “Fira Sans”, “Droid Sans”, sans-serif; } #displaycanto span:hover { color: red; } + .canto { + -webkit-user-select: none; + user-select: none; } diff --git a/js/cesareBrowse.js b/js/cesareBrowse.js index b041cf1..eb0b4ad 100644 --- a/js/cesareBrowse.js +++ b/js/cesareBrowse.js @@ -345,6 +345,9 @@ $(" ."+formaClass).hover(function(idx, element) { elencoVersi.appendTo(elencoRisutati); } + //add listeners + addFormListeners() + $("#vistaFrasi").attr('style', 'display: d-flex;'); }); @@ -429,6 +432,32 @@ $(" ."+formaClass).hover(function(idx, element) { //Utility functions + function addFormListeners(){ + + $(" ." + formaClass).each(function(idx, element) { + var ele = $(element); + ele.tooltip({ + content: (function() { return formatTTContent(ele.attr('title'), ele.attr('class').split(' ')[1]); }), + 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: false + + }); + ele.hover(function(idx, element) { + + sentenceId = $(this).attr('class').split(' ')[0].split('_') + var tmplisid = sentenceId[0] + '_' + sentenceId[1] + '_' + sentenceId[3] + lsentid = $(this).attr('class').split(' ')[0] + lisid = tmplisid + + }); + + }); + + } + function getCantica(numeroCantica){ switch (numeroCantica){ @@ -747,7 +776,7 @@ $(" ."+formaClass).hover(function(idx, element) { titolocanto.append(cantica + ", " + canto) divcanto.attr('class', 'canto') divcanto.css("display", "none") - //divcanto.attr('style', 'display:none') + divcanto.attr('id', (cantica + canto).replace(" ", "_")) titolocanto.appendTo(divcanto) divcanto.appendTo('#displaycanto') diff --git a/js/syntgraph.js b/js/syntgraph.js index dd99cf5..c7f75d2 100644 --- a/js/syntgraph.js +++ b/js/syntgraph.js @@ -4,32 +4,7 @@ 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://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/runtime.js"; -//import commarc from "https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/index.js"; -//const synttypes=["princ", "subord I","subord II","subord III","coord", "coord I", "coord II","subord IV","subord V","parent", -// "coord III", "pcoord", "coord 0", "subord VI", "coord IV", "coord V", "pcoord I","subord VII"] - -//var clausecolors=d3.scaleOrdinal(d3.schemeSet1).domain(synttypes) - -/*const maptypes={"Ma": "princ", "SubI": "subord I", "SubII": "subord II", "SubIII": "subord III", "Co": "coord", - "CoI": "coord I", "CoII": "coord II", "SubIV": "subord IV", "SubV": "subord V", "ParentethicalClause": "parent", - "CoIII": "coord III", "ParentheticalCo":"pcoord", "PseudoCo": "oord 0", "SubVI": "subord VI" , "CoIV": "coord IV", - "CoV": "coord V", "ParentheticalCoI": "pcoord I", "SubVII": "subord VII"} - */ -//const structpalette=d3.quantize(d3.interpolateHcl("#4d4193", "#60c96e"), 18) - -/*const maptypestopalette={"Ma": 0, "SubI": 1, "SubII": 3, "SubIII": 4, "Co": 5, - "CoI": 9, "CoII": 10, "SubIV": 5, "SubV": 6, "ParentethicalClause": 17, - "CoIII": 11, "ParentheticalCo":14, "PseudoCo": 16, "SubVI": 7 , "CoIV": 12, - "CoV": 13, "ParentheticalCoI": 15, "SubVII": 8} - -var colorssp = d3.scaleQuantize() - .domain([0,17]) - .range(["#3288bd", "#66c2a5", "#e41a1c", "#4daf4a", "#984ea3", "#d53e4f", "#f46d43", "#ABDDA4", - "#E6F598", "#FFFFBF", "#FEE08B", "#FDAE61", "#F46D43", - "#D53E4F", "#9E0142", "#e377c2", "#7f7f7f", "#bcbd22"]); -*/ const runtime1 = new Runtime(new Library(name => { console.log('name' +name) switch (name) { @@ -38,8 +13,6 @@ const runtime1 = new Runtime(new Library(name => { } })); - - document.addEventListener("dblclick", function(e){ const target = e.target.closest("."+formaClass); @@ -62,23 +35,28 @@ document.addEventListener("dblclick", function(e){ sentence[i].classList.remove('font-weight-normal'); } - getDimensionsDiv() - if (tmpsent==lsentid) + + if (tmpsent==lsentid){ + getDimensionsDiv() return + } + } var main=runtime1.module(commarc, name => { - if (name === "sentenceStructArcs") + if (name === "sentenceStructArcs") { return new Inspector(document.querySelector("#displayinfo")); + } }); - main.redefine('width', 648); - main.redefine('height', 500); + //main.redefine("links", d3.csv("https://hdnlab1.isti.cnr.it/d3search/node_modules/commarcdiag/files/parsint_mod_completo_pre_new_4.csv", d3.autoType)); if (lisid!=''){ + console.log('here graph '+lisid+' '+lsentid) + main.redefine('width', 540); main.redefine("lisid", lisid); var collection = document.getElementsByClassName(lsentid); for (let i = 0; i < collection.length; i++) { @@ -99,6 +77,7 @@ document.addEventListener("dblclick", function(e){ //collection[i].style.removeProperty('color'); } + getDimensionsDiv() } else return diff --git a/js/utils.js b/js/utils.js index 5310f2d..14f63cd 100644 --- a/js/utils.js +++ b/js/utils.js @@ -322,7 +322,7 @@ function getFormaContext(formaid) { contextitem['cantica'] = cantica; contextitem['posizione'] = tmpform[2]; contextitem['catg'] = tmpform[4]; - contextitem['periodo'] = cantica + '_' + tmpform[1] + '_' + tmpform[5]; + contextitem['periodo'] = cantica + '_' + tmpform[1] + '_s_' + tmpform[5]; contextitem['funzperiodo'] = tmpform[6]; context.push(contextitem); } @@ -332,7 +332,7 @@ function getFormaContext(formaid) { } //restituisce la query per ottenere tutti i versi di una cantica: NON USATA: RIMUOVERE - +/* function versiCantica(cantica) { var SparqlParser = sparqljs.Parser; var parser = new SparqlParser(); @@ -341,7 +341,7 @@ function versiCantica(cantica) { return (parsedqVersiCantica) } - +*/ // the basic initial query is parsed RIMUOVERE function gimmespq() { @@ -496,8 +496,10 @@ function buildSQ(stquery) { if (stquery['Clausola0']['opzioni_testo'] == 'prefisso') { strval = "^" + searchtext.trim(); } - //COMPLETARE con regexp - + + var filtroContesto=getFiltroContesto(JSON.parse(stquery['Clausola0']['contesto'])); + + parsedquery.where[0].expression.args[1].value = strval; if (stquery['Clausola0']['lemma_forma'] == 'lemma') parsedquery.where[0].expression.args[0].value = "lm"; @@ -510,6 +512,22 @@ function buildSQ(stquery) { return (parsedquery) +} + +//Filtro Contesto + +function getFiltroContesto(datiContesto){ + var cantica=0; + for (contestoCantica of datiContesto){ + cantica++; + for (const [index, element] of contestoCantica.entries()) { + if(element==1) + console.log('Cantica '+cantica+', Canto '+(parseInt(index)+1)); + } + } + + + } function buildStatementClause(clause, parsedquery, whereind, theplace) { @@ -629,8 +647,6 @@ function buildClause(clause, parsedquery, whereind) { - - if (clause['typeGramm0'] != null && clause['typeGramm0'] != "all") if (whereind > -1) //parsedquery.where[whereind].triples.push(JSON.parse(data21)[clause['typeGramm0']]); @@ -1188,13 +1204,13 @@ var syntgroup = ` { var funzione_clausola = { "princ": "hasClauseFunction:MainClause", - "subord i": "hasClauseFunction:SubordinateClause", - "subord ii": "", - "subord iii": "", - "subord iv": "", - "subord v": "", - "subord vi": "", - "subord vii": "", + "subord i": "hasClauseFunction:SubordinateClauseI", + "subord ii": "hasClauseFunction:SubordinateClauseII", + "subord iii": "hasClauseFunction:SubordinateClauseIII", + "subord iv": "hasClauseFunction:SubordinateClauseIV", + "subord v": "hasClauseFunction:SubordinateClauseV", + "subord vi": "hasClauseFunction:SubordinateClauseVI", + "subord vii": "hasClauseFunction:SubordinateClauseVII", "coord i": "hasClauseFunction:CoordinateClause", "coord ii": "", "coord iii": "",