LiDa_Search/js/syntgraph.js

99 lines
2.7 KiB
JavaScript

/**
*
*/
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 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){
var periodograph=document.getElementById("periodograph");
if (periodograph!=null){
console.log('val '+document.getElementById("periodograph").getAttribute('name'))
let showngr=document.getElementById("periodograph").getAttribute('name').split("_")
var tmpsent=showngr[0]+"_"+showngr[1]+"_s_"+showngr[2]
periodograph.parentNode.removeChild(periodograph);
//var sentence = document.getElementsByClassName(lsentid);
var sentence = document.getElementsByClassName(tmpsent);
for (let i = 0; i < sentence.length; i++) {
sentence[i].classList.remove('font-italic');
if (selectedVista!='frasi')
sentence[i].style.removeProperty('color');
sentence[i].classList.remove('font-weight-normal');
}
if (tmpsent==lsentid){
//getDimensionsDiv()
showMinimap()
return
}
}
var main=runtime1.module(commarc, name => {
if (name === "sentenceStructArcs") {
return new Inspector(document.querySelector("#displayinfo"));
}
});
//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!=''){
var mywidth=document.getElementById('displaycanto').offsetWidth
let svgwidth=Math.min((mywidth-65), 800)
console.log('here graph '+lisid+' '+lsentid)
main.redefine('width', 605);
main.redefine("lisid", lisid);
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');
//collection[i].classList.add('text-info');
//console.log(collection[i].className)
//console.log(maptypes[synttp]+' '+maptypestopalette[synttp]+', '+colorssp(maptypestopalette[synttp]))
//collection[i].style.background = colorssp(maptypestopalette[synttp]);
if (selectedVista!='frasi'){
var synttp=collection[i].className.split(" ")[1]
collection[i].style.color = colorssp(mapsynttypestopalette[synttp]);
}
//collection[i].style.removeProperty('color');
}
showMinimap()
}
else
return
}
});
function getColor(cltype){
return (clausecolors(cltype))
}