159 lines
4.8 KiB
JavaScript
159 lines
4.8 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 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;
|
|
}
|
|
}));
|
|
|
|
const emptyInfo = `<div class="card card-body well well-sm m-1 mt-2 p-0" id="infoCard0">
|
|
<span class="p-3 text-muted bg-lida-vis small" style="opacity: 0.6;">
|
|
Nessuna struttura visualizzata</span></div>`;
|
|
const defText = document.createTextNode('Nessuna struttura visualizzata');
|
|
var iDiv = document.createElement('div')
|
|
iDiv.className="card card-body well well-sm m-1 mt-2 p-0"
|
|
iDiv.setAttribute("id","infoCard0")
|
|
var iSpan=document.createElement('span')
|
|
iSpan.setAttribute('class', "p-3 text-muted bg-lida-vis small")
|
|
iSpan.setAttribute('style', "opacity: 0.6;")
|
|
iSpan.appendChild(defText)
|
|
iDiv.appendChild(iSpan);
|
|
|
|
|
|
document.addEventListener("dblclick", function(e){
|
|
const target = e.target.closest("."+formaClass);
|
|
|
|
|
|
if(target){
|
|
|
|
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.getElementsByClassName(lsentid);
|
|
var sentence = document.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 (selectedVista!='frasi' && !listaPeriodiRisultato.includes(tmpsent))
|
|
sentence[i].style.removeProperty('color');
|
|
|
|
sentence[i].classList.remove('font-weight-normal');
|
|
|
|
}
|
|
//console.log('matches for clausole '+matches)
|
|
|
|
|
|
//$('#tab-list #vis0-tab').tab('show')
|
|
resetMinimap(tmpsent)
|
|
|
|
document.getElementById("displayinfo").appendChild(iDiv)
|
|
if (tmpsent==lsentid){
|
|
|
|
//showMinimap()
|
|
|
|
return
|
|
}
|
|
|
|
}
|
|
|
|
var main=runtime1.module(commarc, name => {
|
|
|
|
if (name === "sentenceStructArcs_new") {
|
|
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
|
|
|
|
console.log('here graph '+lisid+' '+lsentid)
|
|
main.redefine('width', 645);
|
|
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');
|
|
}
|
|
$('#tab-list #vis1-tab').tab('show')
|
|
updateMinimap(lsentid)
|
|
|
|
|
|
}
|
|
else
|
|
return
|
|
|
|
|
|
|
|
}
|
|
//showMinimap()
|
|
});
|
|
|
|
//manage clauses
|
|
|
|
function resetMinimap(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.remove('font-italic');
|
|
if (selectedVista!='frasi')
|
|
iframeSentence[i].style.removeProperty('color');
|
|
|
|
iframeSentence[i].classList.remove('font-weight-normal');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
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 (selectedVista!='frasi'){
|
|
var synttp=iframeSentence[i].className.split(" ")[1]
|
|
iframeSentence[i].style.color = colorssp(mapsynttypestopalette[synttp]);
|
|
}
|
|
}
|
|
|
|
}
|