Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import { initLearning, renderLearningTab } from './learning.js';
let currentTab = "dashboard";
let jargonSimplified = false;

// Tab Routing Registry
const tabHandlers = {
"dashboard": renderGoals,
"simulator": updateSimulator,
"passport": renderPassportTab,
"learning": renderLearningTab
};

/**
* Handles tab switching logic
* @param {string} tabId
Expand Down Expand Up @@ -39,15 +47,8 @@ function switchTab(tabId) {
});

// Module specific updates when switching
if (tabId === "dashboard") {
renderGoals();
} else if (tabId === "simulator") {
// Re-render simulator to draw SVG chart with correct width
updateSimulator();
} else if (tabId === "passport") {
renderPassportTab();
} else if (tabId === "learning") {
renderLearningTab();
if (tabHandlers[tabId]) {
tabHandlers[tabId]();
}

// Re-apply jargon translation state to newly rendered elements
Expand All @@ -73,14 +74,8 @@ document.addEventListener('DOMContentLoaded', () => {
jargonSimplified = simplified;

// Refresh the active tab elements to translate them
if (currentTab === "dashboard") {
renderGoals();
} else if (currentTab === "simulator") {
updateSimulator();
} else if (currentTab === "passport") {
renderPassportTab();
} else if (currentTab === "learning") {
renderLearningTab();
if (tabHandlers[currentTab]) {
tabHandlers[currentTab]();
}
});

Expand Down
Loading