Feat: persist active tab in URL hash across page refreshes
This commit is contained in:
parent
731e3137bd
commit
0cbfd34cb4
2 changed files with 21 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
services:
|
services:
|
||||||
pediatric-scribe:
|
pediatric-scribe:
|
||||||
image: danielonyejesi/pediatric-ai-scribe-v3:v1.2
|
image: danielonyejesi/pediatric-ai-scribe-v3:v1.3
|
||||||
ports:
|
ports:
|
||||||
- "3552:3000"
|
- "3552:3000"
|
||||||
env_file:
|
env_file:
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,31 @@
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
// --- TAB NAVIGATION ---
|
// --- TAB NAVIGATION ---
|
||||||
|
function activateTab(tabName) {
|
||||||
|
var btn = document.querySelector('.tab-btn[data-tab="' + tabName + '"]');
|
||||||
|
if (!btn || btn.classList.contains('hidden')) return false;
|
||||||
|
document.querySelectorAll('.tab-btn').forEach(function(b) { b.classList.remove('active'); });
|
||||||
|
document.querySelectorAll('.tab-content').forEach(function(c) { c.classList.remove('active'); });
|
||||||
|
btn.classList.add('active');
|
||||||
|
var tabEl = document.getElementById(tabName + '-tab');
|
||||||
|
if (tabEl) tabEl.classList.add('active');
|
||||||
|
window.location.hash = tabName;
|
||||||
|
document.dispatchEvent(new CustomEvent('tabChanged', { detail: { tab: tabName } }));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelectorAll('.tab-btn').forEach(function(btn) {
|
document.querySelectorAll('.tab-btn').forEach(function(btn) {
|
||||||
btn.addEventListener('click', function() {
|
btn.addEventListener('click', function() {
|
||||||
document.querySelectorAll('.tab-btn').forEach(function(b) { b.classList.remove('active'); });
|
activateTab(btn.getAttribute('data-tab'));
|
||||||
document.querySelectorAll('.tab-content').forEach(function(c) { c.classList.remove('active'); });
|
|
||||||
btn.classList.add('active');
|
|
||||||
var tabId = btn.getAttribute('data-tab') + '-tab';
|
|
||||||
var tabEl = document.getElementById(tabId);
|
|
||||||
if (tabEl) tabEl.classList.add('active');
|
|
||||||
document.dispatchEvent(new CustomEvent('tabChanged', { detail: { tab: btn.getAttribute('data-tab') } }));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Restore tab from URL hash on load
|
||||||
|
var hash = window.location.hash.replace('#', '');
|
||||||
|
if (!hash || !activateTab(hash)) {
|
||||||
|
activateTab('encounter'); // default
|
||||||
|
}
|
||||||
|
|
||||||
// --- MODEL SELECTOR ---
|
// --- MODEL SELECTOR ---
|
||||||
var modelSelect = document.getElementById('global-model-select');
|
var modelSelect = document.getElementById('global-model-select');
|
||||||
var costBadge = document.getElementById('model-cost-badge');
|
var costBadge = document.getElementById('model-cost-badge');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue