|
|
|
diff --git a/webui/src/main/resources/application/functions.js b/webui/src/main/resources/application/functions.js
index 681386e3..034f5664 100644
--- a/webui/src/main/resources/application/functions.js
+++ b/webui/src/main/resources/application/functions.js
@@ -215,7 +215,6 @@ function findAncestor(element, selector) {
function applyToAllSvg() {
- console.log("Applying SvgPanZoom to all SVG elements");
document.querySelectorAll('svg').forEach(svg => {
if (!svg.dataset.svgPanZoomInitialized) {
new SvgPanZoom().init(svg);
diff --git a/webui/src/main/resources/application/main.js b/webui/src/main/resources/application/main.js
index f36373c6..9a60a0f0 100644
--- a/webui/src/main/resources/application/main.js
+++ b/webui/src/main/resources/application/main.js
@@ -4,9 +4,10 @@ let singleInput = false;
let stickyInput = false;
let loadImages = "true";
let showMenubar = true;
+let messageDiv;
function onWebSocketText(event) {
- console.log('WebSocket message:', event);
+ console.debug('WebSocket message:', event);
const messagesDiv = document.getElementById('messages');
if (!messagesDiv) return;
const firstCommaIndex = event.data.indexOf(',');
@@ -14,14 +15,8 @@ function onWebSocketText(event) {
const messageId = event.data.substring(0, firstCommaIndex);
const messageVersion = event.data.substring(firstCommaIndex + 1, secondCommaIndex);
const messageContent = event.data.substring(secondCommaIndex + 1);
- // if (messageVersion <= (messageVersions[messageId] || 0)) {
- // console.log("Ignoring message with id " + messageId + " and version " + messageVersion);
- // return;
- // } else {
messageVersions[messageId] = messageVersion;
messageMap[messageId] = messageContent;
- // }
- // Cleanup: remove temporary event listeners
const messageDivs = document.querySelectorAll('[id="' + messageId + '"]');
messageDivs.forEach((messageDiv) => {
@@ -88,11 +83,6 @@ function onWebSocketText(event) {
} catch (e) {
console.log("Error updating tabs: " + e);
}
-
- /* If appPostMessage is defined, call it */
- if (typeof appPostMessage !== 'undefined') {
- appPostMessage(event.data);
- }
}
document.addEventListener('DOMContentLoaded', () => {
@@ -104,6 +94,33 @@ document.addEventListener('DOMContentLoaded', () => {
applyToAllSvg();
}, 5000); // Adjust the interval as needed
+ // Restore the selected tabs from localStorage before adding event listeners
+ document.querySelectorAll('.tabs-container').forEach(tabsContainer => {
+ const savedTab = localStorage.getItem(`selectedTab_${tabsContainer.id}`);
+ if (savedTab) {
+ const savedButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${savedTab}"]`);
+ if (savedButton) {
+ savedButton.classList.add('active');
+ const forTab = savedButton.getAttribute('data-for-tab');
+ const selectedContent = tabsContainer.querySelector(`.tab-content[data-tab="${forTab}"]`);
+ if (selectedContent) {
+ selectedContent.classList.add('active');
+ selectedContent.style.display = 'block';
+ }
+ console.log(`Restored saved tab: ${savedTab}`);
+ }
+ }
+ });
+ document.querySelectorAll('.tabs-container').forEach(tabsContainer => {
+ const savedTab = localStorage.getItem(`selectedTab_${tabsContainer.id}`);
+ if (savedTab) {
+ const savedButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${savedTab}"]`);
+ if (savedButton) {
+ savedButton.click();
+ console.log(`Restored saved tab: ${savedTab}`);
+ }
+ }
+ });
const historyElement = document.getElementById('history');
if (historyElement) historyElement.addEventListener('click', () => showModal('sessions'));
@@ -318,4 +335,16 @@ document.addEventListener('DOMContentLoaded', () => {
});
updateTabs();
+
+ // Restore the selected tabs from localStorage
+ document.querySelectorAll('.tabs-container').forEach(tabsContainer => {
+ const savedTab = localStorage.getItem(`selectedTab_${tabsContainer.id}`);
+ if (savedTab) {
+ const savedButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${savedTab}"]`);
+ if (savedButton) {
+ savedButton.click();
+ console.log(`Restored saved tab: ${savedTab}`);
+ }
+ }
+ });
});
\ No newline at end of file
diff --git a/webui/src/main/resources/application/tabs.js b/webui/src/main/resources/application/tabs.js
index e8bc462a..b3c7d079 100644
--- a/webui/src/main/resources/application/tabs.js
+++ b/webui/src/main/resources/application/tabs.js
@@ -1,38 +1,54 @@
function updateTabs() {
document.querySelectorAll('.tab-button').forEach(button => {
- button.addEventListener('click', (event) => { // Ensure the event is passed as a parameter
+ // console.log(`Adding click event listener to tab button: ${button.getAttribute('data-for-tab')}`);
+ button.addEventListener('click', (event) => {
+ // console.log(`Tab button clicked: ${button.getAttribute('data-for-tab')}`);
event.stopPropagation();
const forTab = button.getAttribute('data-for-tab');
+ const tabsContainerId = button.closest('.tabs-container').id;
+ // console.log(`Tabs container ID: ${tabsContainerId}`);
+ // console.log(`Saving selected tab to localStorage: selectedTab_${tabsContainerId} = ${forTab}`);
+ localStorage.setItem(`selectedTab_${tabsContainerId}`, forTab);
let tabsParent = button.closest('.tabs-container');
tabsParent.querySelectorAll('.tab-button').forEach(tabButton => {
if (tabButton.closest('.tabs-container') === tabsParent) tabButton.classList.remove('active');
});
button.classList.add('active');
+ // console.log(`Active tab set to: ${forTab}`);
let selectedContent = null;
tabsParent.querySelectorAll('.tab-content').forEach(content => {
if (content.closest('.tabs-container') === tabsParent) {
if (content.getAttribute('data-tab') === forTab) {
content.classList.add('active');
content.style.display = 'block'; // Ensure the content is displayed
+ // console.log(`Content displayed for tab: ${forTab}`);
selectedContent = content;
} else {
content.classList.remove('active');
content.style.display = 'none'; // Ensure the content is hidden
+ // console.log(`Content hidden for tab: ${content.getAttribute('data-tab')}`);
}
}
});
if (selectedContent !== null) updateNestedTabs(selectedContent);
});
+ // Check if the current button should be activated based on localStorage
+ const savedTab = localStorage.getItem(`selectedTab_${button.closest('.tabs-container').id}`);
+ if (button.getAttribute('data-for-tab') === savedTab) {
+ button.dispatchEvent(new Event('click'));
+ }
});
}
function updateNestedTabs(element) {
element.querySelectorAll('.tabs-container').forEach(tabsContainer => {
try {
+ // console.log(`Updating nested tabs for container: ${tabsContainer.id}`);
let hasActiveButton = false;
tabsContainer.querySelectorAll('.tab-button').forEach(nestedButton => {
if (nestedButton.classList.contains('active')) {
hasActiveButton = true;
+ // console.log(`Found active nested button: ${nestedButton.getAttribute('data-for-tab')}`);
}
});
if (!hasActiveButton) {
@@ -43,24 +59,43 @@ function updateNestedTabs(element) {
const activeButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${activeTab}"]`);
if (activeButton !== null) {
activeButton.classList.add('active');
+ // console.log(`Set active nested button: ${activeTab}`);
}
} else {
/* Add 'active' to the class list of the first button */
const firstButton = tabsContainer.querySelector('.tab-button');
if (firstButton !== null) {
firstButton.classList.add('active');
+ // console.log(`Set first nested button as active: ${firstButton.getAttribute('data-for-tab')}`);
}
}
}
+ const savedTab = localStorage.getItem(`selectedTab_${tabsContainer.id}`);
+ // console.log(`Retrieved saved tab from localStorage: selectedTab_${tabsContainer.id} = ${savedTab}`);
+ if (savedTab) {
+ const savedButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${savedTab}"]`);
+ if (savedButton) {
+ savedButton.classList.add('active');
+ const forTab = savedButton.getAttribute('data-for-tab');
+ const selectedContent = tabsContainer.querySelector(`.tab-content[data-tab="${forTab}"]`);
+ if (selectedContent) {
+ selectedContent.classList.add('active');
+ selectedContent.style.display = 'block';
+ }
+ // console.log(`Restored saved tab: ${savedTab}`);
+ }
+ }
} catch (e) {
- console.log("Error updating tabs: " + e);
+ // console.log("Error updating tabs: " + e);
}
});
}
document.addEventListener('DOMContentLoaded', () => {
+ // console.log('Document loaded. Initializing tabs...');
updateTabs();
updateNestedTabs(document);
+
});
window.updateTabs = updateTabs; // Expose updateTabs to the global scope
\ No newline at end of file
diff --git a/webui/src/main/resources/welcome/functions.js b/webui/src/main/resources/welcome/functions.js
index 14cf4dfe..69028783 100644
--- a/webui/src/main/resources/welcome/functions.js
+++ b/webui/src/main/resources/welcome/functions.js
@@ -191,7 +191,6 @@ function findAncestor(element, selector) {
function applyToAllSvg() {
- console.log("Applying SvgPanZoom to all SVG elements");
document.querySelectorAll('svg').forEach(svg => {
if (!svg.dataset.svgPanZoomInitialized) {
new SvgPanZoom().init(svg);
diff --git a/webui/src/main/resources/welcome/tabs.js b/webui/src/main/resources/welcome/tabs.js
index e8bc462a..b3c7d079 100644
--- a/webui/src/main/resources/welcome/tabs.js
+++ b/webui/src/main/resources/welcome/tabs.js
@@ -1,38 +1,54 @@
function updateTabs() {
document.querySelectorAll('.tab-button').forEach(button => {
- button.addEventListener('click', (event) => { // Ensure the event is passed as a parameter
+ // console.log(`Adding click event listener to tab button: ${button.getAttribute('data-for-tab')}`);
+ button.addEventListener('click', (event) => {
+ // console.log(`Tab button clicked: ${button.getAttribute('data-for-tab')}`);
event.stopPropagation();
const forTab = button.getAttribute('data-for-tab');
+ const tabsContainerId = button.closest('.tabs-container').id;
+ // console.log(`Tabs container ID: ${tabsContainerId}`);
+ // console.log(`Saving selected tab to localStorage: selectedTab_${tabsContainerId} = ${forTab}`);
+ localStorage.setItem(`selectedTab_${tabsContainerId}`, forTab);
let tabsParent = button.closest('.tabs-container');
tabsParent.querySelectorAll('.tab-button').forEach(tabButton => {
if (tabButton.closest('.tabs-container') === tabsParent) tabButton.classList.remove('active');
});
button.classList.add('active');
+ // console.log(`Active tab set to: ${forTab}`);
let selectedContent = null;
tabsParent.querySelectorAll('.tab-content').forEach(content => {
if (content.closest('.tabs-container') === tabsParent) {
if (content.getAttribute('data-tab') === forTab) {
content.classList.add('active');
content.style.display = 'block'; // Ensure the content is displayed
+ // console.log(`Content displayed for tab: ${forTab}`);
selectedContent = content;
} else {
content.classList.remove('active');
content.style.display = 'none'; // Ensure the content is hidden
+ // console.log(`Content hidden for tab: ${content.getAttribute('data-tab')}`);
}
}
});
if (selectedContent !== null) updateNestedTabs(selectedContent);
});
+ // Check if the current button should be activated based on localStorage
+ const savedTab = localStorage.getItem(`selectedTab_${button.closest('.tabs-container').id}`);
+ if (button.getAttribute('data-for-tab') === savedTab) {
+ button.dispatchEvent(new Event('click'));
+ }
});
}
function updateNestedTabs(element) {
element.querySelectorAll('.tabs-container').forEach(tabsContainer => {
try {
+ // console.log(`Updating nested tabs for container: ${tabsContainer.id}`);
let hasActiveButton = false;
tabsContainer.querySelectorAll('.tab-button').forEach(nestedButton => {
if (nestedButton.classList.contains('active')) {
hasActiveButton = true;
+ // console.log(`Found active nested button: ${nestedButton.getAttribute('data-for-tab')}`);
}
});
if (!hasActiveButton) {
@@ -43,24 +59,43 @@ function updateNestedTabs(element) {
const activeButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${activeTab}"]`);
if (activeButton !== null) {
activeButton.classList.add('active');
+ // console.log(`Set active nested button: ${activeTab}`);
}
} else {
/* Add 'active' to the class list of the first button */
const firstButton = tabsContainer.querySelector('.tab-button');
if (firstButton !== null) {
firstButton.classList.add('active');
+ // console.log(`Set first nested button as active: ${firstButton.getAttribute('data-for-tab')}`);
}
}
}
+ const savedTab = localStorage.getItem(`selectedTab_${tabsContainer.id}`);
+ // console.log(`Retrieved saved tab from localStorage: selectedTab_${tabsContainer.id} = ${savedTab}`);
+ if (savedTab) {
+ const savedButton = tabsContainer.querySelector(`.tab-button[data-for-tab="${savedTab}"]`);
+ if (savedButton) {
+ savedButton.classList.add('active');
+ const forTab = savedButton.getAttribute('data-for-tab');
+ const selectedContent = tabsContainer.querySelector(`.tab-content[data-tab="${forTab}"]`);
+ if (selectedContent) {
+ selectedContent.classList.add('active');
+ selectedContent.style.display = 'block';
+ }
+ // console.log(`Restored saved tab: ${savedTab}`);
+ }
+ }
} catch (e) {
- console.log("Error updating tabs: " + e);
+ // console.log("Error updating tabs: " + e);
}
});
}
document.addEventListener('DOMContentLoaded', () => {
+ // console.log('Document loaded. Initializing tabs...');
updateTabs();
updateNestedTabs(document);
+
});
window.updateTabs = updateTabs; // Expose updateTabs to the global scope
\ No newline at end of file