aggiornata gestione minimap, redraw solo se si cambia canto

This commit is contained in:
cesare 2023-02-21 15:29:45 +01:00
parent 037c8145c1
commit a2cd157372
4 changed files with 85 additions and 37 deletions

View File

@ -23,6 +23,7 @@ $(document).ready(function() {
var shownSentenceList = new Set()
//var currentMinimap = ''
var listarisultati = [];
var listaPeriodiRisultato = [];
var resultSentences = new Set()
@ -111,7 +112,16 @@ function loadFrasi() {
$(this).css('color', colorssp(mapsynttypestopalette[stp]));
})
drawMinimap(cantoDisplayed)
let minim=$(" .minimap__content")
minim.contents().find(" .sentencetag").each(function(){
$(this).attr('style', 'display: d-flex;');
})
minim.contents().find(' .'+formaClass).each(function() {
stp=$(this).attr('class').split(" ")[1]
$(this).css('color', colorssp(mapsynttypestopalette[stp]));
})
//drawMinimap(cantoDisplayed)
}
function resetFrasi(){
@ -122,7 +132,14 @@ function resetFrasi(){
//console.log(colorssp(mapsynttypestopalette[stp]))
$(this).css('color', '');
})
drawMinimap(cantoDisplayed)
let minim=$(" .minimap__content")
minim.contents().find(" .sentencetag").each(function(){
$(this).css('display', 'none');
})
minim.contents().find(' .'+formaClass).each(function() {
$(this).css('color', '');
})
//drawMinimap(cantoDisplayed)
}
@ -444,6 +461,8 @@ $(" ."+formaClass).hover(function(idx, element) {
$('.canto').each(function() {
$(this).css("display", "none");
});
const cid=$(this).attr('name').replace(" ", "_");
cantoDisplayed = "#"+cid;
@ -627,21 +646,23 @@ $(" ."+formaClass).hover(function(idx, element) {
});
}
let minim=$(" .minimap__content")
for (forma of listarisultati) {
idforma = '#' + forma
$(idforma).removeClass("font-weight-bold mark ")
minim.contents().find(idforma).removeClass("font-weight-bold mark ")
}
$(".badge").remove();
$("#headingZero").css("display", "none");
$("#vistaFrasi").empty()
$("#vistaFrasi").css("display", "none");
//$("#vistaFrasi").empty()
//$("#vistaFrasi").css("display", "none");
listarisultati = []
listaPeriodiRisultato=[]
resultSentences=new Set()
$(cantoDisplayed).attr('style', 'display: d-flex;');
drawMinimap(cantoDisplayed)
//drawMinimap(cantoDisplayed)
}
var unitaRicerca='forma'
@ -698,24 +719,6 @@ $(" ."+formaClass).hover(function(idx, element) {
}
/*
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');
}
*/
function resetSentenceStructure(sentence) {
/*
@ -941,6 +944,7 @@ $(" ."+formaClass).hover(function(idx, element) {
});
seachbBindingsStream.on('end', () => {
var resSent=new Set()
let minim=$(" .minimap__content")
console.log('start rendering...')
listarisultati = Array.from(result)
var listaclausole=Array.from(resultClauses)
@ -996,11 +1000,15 @@ $(" ."+formaClass).hover(function(idx, element) {
if (listarisultati.length){
//evidenzia risultati
for (ris of listarisultati) {
idris = '#' + ris
$(idris).addClass("font-weight-bold mark ")
minim.contents().find(idris).addClass("font-weight-bold mark ")
}
}
@ -1021,7 +1029,7 @@ $(" ."+formaClass).hover(function(idx, element) {
//$('#cantica' + i).after(spanbadgecantica)
}
}
//aggiunge badge con totale risultati nel bottone lista canti
//aggiunge badge con totale risultati nel bottone lista risultati
if (totResultN>0){
$("#headingZero").attr('style', 'display: d-flex;')
var spanbadgelista = $('<span />');
@ -1052,13 +1060,15 @@ $(" ."+formaClass).hover(function(idx, element) {
}
}
}
console.log('badge end...')
console.log('badge end')
/*
//aggiorna minimap
if (currentMinimap != '') {
showMinimap()
}
*/
});
queryExecuted = true;
$(cantoDisplayed).attr('style', 'display: d-flex;');

View File

@ -36,9 +36,12 @@ document.addEventListener("dblclick", function(e){
sentence[i].classList.remove('font-weight-normal');
}
resetMinimap(tmpsent)
if (tmpsent==lsentid){
//getDimensionsDiv()
showMinimap()
//showMinimap()
return
}
@ -78,7 +81,8 @@ document.addEventListener("dblclick", function(e){
//collection[i].style.removeProperty('color');
}
showMinimap()
updateMinimap(lsentid)
}
else
@ -87,12 +91,44 @@ document.addEventListener("dblclick", function(e){
}
//showMinimap()
});
function getColor(cltype){
function resetMinimap(sentid){
var iframe = document.getElementsByClassName("minimap__content");
return (clausecolors(cltype))
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]);
}
}
}

View File

@ -243,7 +243,7 @@ var colorssp = d3.scaleQuantize()
"#D53E4F", "#9E0142", "#e377c2", "#7f7f7f", "#bcbd22"]);
const mapsynttypestopalette = {
"Ma": 0, "SubI": 1, "SubII": 3, "SubIII": 4, "Co": 5,
"Ma": 0, "SubI": 1, "SubII": 3, "SubIII": 4, "Co": 5, "Co0":2,
"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
@ -270,7 +270,7 @@ function getFormaContext(formaid, numversi=3) {
var cantica = 1;
var listaforme = formeprima;
var minpos = 0;
var limitv = Math.max((numversi-1),2)
var limitv = Math.max((numversi),3)
var maxpos = 0;
var offset=0;
@ -296,7 +296,7 @@ function getFormaContext(formaid, numversi=3) {
maxpos = listaforme.length - 1
var pos = 0
const startindex=Math.max(0, (offset-25))
const startindex=Math.max(0, (offset-10))
for (i=startindex; i<listaforme.length; i++){
var tmpos=listaforme[i].split('_')[2]

View File

@ -749,6 +749,8 @@ function _sentenceStructArcs(d3,DOM,width,margin,sentenceheight,lisid,data_frasi
const arcGroup = container
.attr ("id", "periodograph")
.attr("name", lisid)
.attr("width",null)
.attr("height",null)
.append("g")
.style('pointer-events', 'all')
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")