Spaces:
Paused
Paused
Create static/js/app.js
Browse files- static/js/app.js +34 -0
static/js/app.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// static/js/app.js
|
| 2 |
+
|
| 3 |
+
function switchView(viewId, element) {
|
| 4 |
+
// Hide all views
|
| 5 |
+
document.querySelectorAll('.view-container').forEach(v => {
|
| 6 |
+
v.classList.remove('active');
|
| 7 |
+
// Small delay to allow CSS transitions if we add them later
|
| 8 |
+
v.style.display = 'none';
|
| 9 |
+
});
|
| 10 |
+
|
| 11 |
+
// Show the target view
|
| 12 |
+
const target = document.getElementById(viewId);
|
| 13 |
+
if(target) {
|
| 14 |
+
target.style.display = 'flex';
|
| 15 |
+
// Trigger reflow
|
| 16 |
+
void target.offsetWidth;
|
| 17 |
+
target.classList.add('active');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// Update Sidebar highlighting
|
| 21 |
+
document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
|
| 22 |
+
if(element) element.classList.add('active');
|
| 23 |
+
|
| 24 |
+
// Auto-close sidebar on mobile after clicking
|
| 25 |
+
if(window.innerWidth <= 768) {
|
| 26 |
+
document.getElementById('sidebar').classList.remove('open');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// Auto-focus specific inputs based on view
|
| 30 |
+
if(viewId === 'terminal-view') {
|
| 31 |
+
const termInput = document.getElementById('terminal-input');
|
| 32 |
+
if(termInput) termInput.focus();
|
| 33 |
+
}
|
| 34 |
+
}
|