From 82ad4ee82fc817b55ff961dd93ba33c7d905b80f Mon Sep 17 00:00:00 2001
From: cesare <cesare@bigeh>
Date: Mon, 24 Mar 2025 17:43:20 +0100
Subject: [PATCH] bug fixing

---
 js/browseMgr_5.1.js | 58 ++++++++++++++++++++++++++++++++++++---------
 js/browseMgr_5.2.js | 57 ++++++++++++++++++++++++++++++++++----------
 2 files changed, 91 insertions(+), 24 deletions(-)

diff --git a/js/browseMgr_5.1.js b/js/browseMgr_5.1.js
index b95ede3..ef53146 100644
--- a/js/browseMgr_5.1.js
+++ b/js/browseMgr_5.1.js
@@ -101,25 +101,25 @@ $(document).ready(function() {
 				loadFrasi();
 				break;
 			case "visPeriodi|false":
-				$("#vistaFrasi").css("display", "none");
+				//$("#vistaFrasi").css("display", "none");
 				resetFrasi()
 				manageResults()
 				vistaPeriodi = false
 				break;
 			case "visRiferimenti|true":
 				vistaRiferimenti = true
-				initCitazioni()
+				/*initCitazioni()
 				$(cantoDisplayed).find(" .showcomments").each(function() {
 					$(this).css("display", "inline-block");
 				})
 				//$(" .showcomments").css("display", "inline-block");
 				minim.contents().find(" .showcomments").each(function() {
 					$(this).css('display', 'inline-block');
-				})
-
+				})*/
+				setCitazioni(true)
 				break;
 			case "visRiferimenti|false":
-				$(cantoDisplayed).find(" .showcomments").each(function() {
+				/*$(cantoDisplayed).find(" .showcomments").each(function() {
 					$(this).css("display", "none");
 				})
 				//$(".showcomments").css("display", "none");
@@ -127,7 +127,8 @@ $(document).ready(function() {
 					$(this).css('display', 'none');
 				})
 				$('#displaynote').empty()
-				$('#displaynote').append($(emptyNoteList))
+				$('#displaynote').append($(emptyNoteList))*/
+				setCitazioni(false)
 				vistaRiferimenti = false
 				break;
 			case "visDialoghi|true":
@@ -149,7 +150,7 @@ $(document).ready(function() {
 
 
 	$("#visAiuto").click(function(){
-			window.open("./manuale/manualeGui.html","_blank");
+			window.open("./Manuale/manualeGUI.html","_blank");
 	})
 		
 		
@@ -592,13 +593,13 @@ $(document).ready(function() {
 
 		showingComments = false;
 
-		if (telive.length > 0) {
+		/*if (telive.length > 0) {
 			initCitazioni()
 		} else {
 			if (vistaRiferimenti) {
 				initCitazioni();
 			}
-		}
+		}*/
 		var parcid = cid.split('_')
 		var numeroCantica;
 		var forma;
@@ -619,7 +620,14 @@ $(document).ready(function() {
 			showCanto(forma, numeroCantica, parcid[1])
 			loadedCanti.add(cid)
 		}
-
+		
+		setCitazioni(vistaRiferimenti)
+		
+		if (telive.length > 0) {
+			initCitazioni()
+		}
+		
+		
 
 		for (var tel of telive) {
 			var telId = tel.split("_");
@@ -637,11 +645,17 @@ $(document).ready(function() {
 		//console.log("#" + $(this).attr('name').replace(" ", "_"))
 		if (vistaPeriodi) {
 			loadFrasi();
+		}else{
+			resetFrasi()
 		}
+		
 		if (vistaDialoghi) {
 			loadDialoghi();
+		}else{
+			resetDialoghi()
 		}
-
+		
+		
 		addFormaListenersInCanto();
 
 		//se si sta arrivando al canto da un link della lista risultati 
@@ -859,6 +873,28 @@ $(document).ready(function() {
 		}
 		emphResults()
 	}
+	function setCitazioni(citeon){
+		if (citeon){
+			initCitazioni()
+			$(cantoDisplayed).find(" .showcomments").each(function() {
+				$(this).css("display", "inline-block");
+			})
+			minim.contents().find(" .showcomments").each(function() {
+				$(this).css('display', 'inline-block');
+			})
+		}
+		else{
+			$(cantoDisplayed).find(" .showcomments").each(function() {
+				$(this).css("display", "none");
+			})
+			minim.contents().find(" .showcomments").each(function() {
+				$(this).css('display', 'none');
+			})
+			$('#displaynote').empty()
+			$('#displaynote').append($(emptyNoteList))
+		}
+		
+	}
 	function loadFrasi() {
 		var stp
 		$(cantoDisplayed).find(' .sentencetag').each(function() {
diff --git a/js/browseMgr_5.2.js b/js/browseMgr_5.2.js
index f1d4072..eed50d2 100644
--- a/js/browseMgr_5.2.js
+++ b/js/browseMgr_5.2.js
@@ -101,25 +101,25 @@ $(document).ready(function() {
 				loadFrasi();
 				break;
 			case "visPeriodi|false":
-				$("#vistaFrasi").css("display", "none");
+				//$("#vistaFrasi").css("display", "none");
 				resetFrasi()
 				manageResults()
 				vistaPeriodi = false
 				break;
 			case "visRiferimenti|true":
 				vistaRiferimenti = true
-				initCitazioni()
+				/*initCitazioni()
 				$(cantoDisplayed).find(" .showcomments").each(function() {
 					$(this).css("display", "inline-block");
 				})
 				//$(" .showcomments").css("display", "inline-block");
 				minim.contents().find(" .showcomments").each(function() {
 					$(this).css('display', 'inline-block');
-				})
-
+				})*/
+				setCitazioni(true)
 				break;
 			case "visRiferimenti|false":
-				$(cantoDisplayed).find(" .showcomments").each(function() {
+				/*$(cantoDisplayed).find(" .showcomments").each(function() {
 					$(this).css("display", "none");
 				})
 				//$(".showcomments").css("display", "none");
@@ -127,7 +127,8 @@ $(document).ready(function() {
 					$(this).css('display', 'none');
 				})
 				$('#displaynote').empty()
-				$('#displaynote').append($(emptyNoteList))
+				$('#displaynote').append($(emptyNoteList))*/
+				setCitazioni(false)
 				vistaRiferimenti = false
 				break;
 			case "visDialoghi|true":
@@ -306,6 +307,7 @@ $(document).ready(function() {
 		}
 
 		//listarisultati.sort(function(a, b){return a - b});
+		$("#vistaFrasi").empty();
 		showFrasi(start, offset)
 
 		if (vistaPeriodi) {
@@ -386,7 +388,7 @@ $(document).ready(function() {
 		var canto, numeroCantica;
 		var divVerso;
 		var elencoRisutati = $(whereToDisplay);
-		elencoRisutati.empty();
+		//elencoRisutati.empty();
 
 		var numeroRisultato = 0;
 		var ultimaPosizione = 0;
@@ -588,13 +590,13 @@ $(document).ready(function() {
 
 		showingComments = false;
 
-		if (telive.length > 0) {
+		/*if (telive.length > 0) {
 			initCitazioni()
 		} else {
 			if (vistaRiferimenti) {
 				initCitazioni();
 			}
-		}
+		}*/
 		var parcid = cid.split('_')
 		var numeroCantica;
 		var forma;
@@ -616,6 +618,11 @@ $(document).ready(function() {
 			loadedCanti.add(cid)
 		}
 
+		setCitazioni(vistaRiferimenti)
+
+		if (telive.length > 0) {
+			initCitazioni()
+		}
 
 		for (var tel of telive) {
 			var telId = tel.split("_");
@@ -855,6 +862,30 @@ $(document).ready(function() {
 		}
 		emphResults()
 	}
+
+	function setCitazioni(citeon) {
+		if (citeon) {
+			initCitazioni()
+			$(cantoDisplayed).find(" .showcomments").each(function() {
+				$(this).css("display", "inline-block");
+			})
+			minim.contents().find(" .showcomments").each(function() {
+				$(this).css('display', 'inline-block');
+			})
+		}
+		else {
+			$(cantoDisplayed).find(" .showcomments").each(function() {
+				$(this).css("display", "none");
+			})
+			minim.contents().find(" .showcomments").each(function() {
+				$(this).css('display', 'none');
+			})
+			$('#displaynote').empty()
+			$('#displaynote').append($(emptyNoteList))
+		}
+
+	}
+
 	function loadFrasi() {
 		var stp
 		$(cantoDisplayed).find(' .sentencetag').each(function() {
@@ -1900,7 +1931,7 @@ $(document).ready(function() {
 		$("#displaynote").empty();
 		$('#displaynote').append($(emptyNoteList));
 
- 		$(".filterRiferimentiOn").css('display', 'none');
+		$(".filterRiferimentiOn").css('display', 'none');
 		$(".filterRiferimentiOff").css('display', 'none');
 
 		if (cantoDisplayed != '#vistaFrasi') {
@@ -2089,9 +2120,9 @@ $(document).ready(function() {
 		var ultimaFormaCanto;
 		let numeroPeriodo = 1;
 		showingComments = false;
-		let startindex=800*(parseInt(canto)-1)
-		let reformecantica=formecantica.slice(startindex)
-		
+		let startindex = 800 * (parseInt(canto) - 1)
+		let reformecantica = formecantica.slice(startindex)
+
 		//formecantica.map(function(item) {
 		reformecantica.map(function(item) {
 			formaItem = item.split("_");