+
Nastavení banneru
-
+
+
+
+
Správa rezervací vozidel
@@ -2769,6 +2815,125 @@ async function saveApp(event) {
}
}
+// Navigation functionality
+const sidebar = document.getElementById('sidebar');
+const sidebarToggle = document.getElementById('sidebarToggle');
+const sidebarOverlay = document.getElementById('sidebarOverlay');
+const mainContent = document.getElementById('mainContent');
+
+// Toggle sidebar on mobile
+function toggleSidebar() {
+ sidebar.classList.toggle('-translate-x-full');
+ sidebarOverlay.classList.toggle('hidden');
+ document.body.classList.toggle('overflow-hidden');
+}
+
+// Close sidebar when clicking outside on mobile
+function closeSidebar() {
+ if (!sidebar.classList.contains('-translate-x-full')) {
+ toggleSidebar();
+ }
+}
+
+// Navigation between sections
+function showSection(sectionId) {
+ // If no sectionId provided, try to get it from URL hash
+ if (!sectionId) {
+ const hash = window.location.hash.substring(1);
+ if (hash && ['dashboard', 'reservations', 'banner', 'apps'].includes(hash)) {
+ sectionId = hash;
+ } else {
+ sectionId = 'dashboard';
+ }
+ } else {
+ // Update URL hash without page jump
+ history.pushState(null, null, `#${sectionId}`);
+ }
+
+ // Hide all sections
+ document.querySelectorAll('.section-content').forEach(section => {
+ section.style.display = 'none';
+ });
+
+ // Show selected section
+ const section = document.getElementById(sectionId) || document.querySelector(`.section-content[data-section="${sectionId}"]`);
+ if (section) {
+ section.style.display = 'block';
+ // Smooth scroll to the top of the section
+ window.scrollTo({ top: 0, behavior: 'smooth' });
+ }
+
+ // Update active nav link
+ document.querySelectorAll('nav a').forEach(link => {
+ link.classList.remove('bg-gray-700', 'text-white');
+ link.classList.add('text-gray-300');
+ });
+
+ const activeLink = document.getElementById(`nav-${sectionId}`) || document.querySelector(`nav a[data-section="${sectionId}"]`);
+ if (activeLink) {
+ activeLink.classList.remove('text-gray-300');
+ activeLink.classList.add('bg-gray-700', 'text-white');
+ }
+
+ // Close sidebar on mobile after selection
+ if (window.innerWidth < 768) {
+ closeSidebar();
+ }
+}
+
+// Event listeners
+if (sidebarToggle) {
+ sidebarToggle.addEventListener('click', (e) => {
+ e.stopPropagation();
+ toggleSidebar();
+ });
+}
+
+if (sidebarOverlay) {
+ sidebarOverlay.addEventListener('click', closeSidebar);
+}
+
+document.addEventListener('DOMContentLoaded', function() {
+ // Handle back/forward navigation
+ window.addEventListener('popstate', function() {
+ const hash = window.location.hash.substring(1);
+ if (hash) {
+ showSection(hash);
+ } else {
+ showSection('dashboard');
+ }
+ });
+
+ // Show section based on URL hash or default to dashboard
+ const hash = window.location.hash.substring(1);
+ if (hash && ['dashboard', 'reservations', 'banner', 'apps'].includes(hash)) {
+ showSection(hash);
+ } else {
+ showSection('dashboard');
+ }
+
+ // Set up navigation links
+ document.querySelectorAll('nav a').forEach(link => {
+ link.addEventListener('click', (e) => {
+ e.preventDefault();
+ const sectionId = link.getAttribute('data-section');
+ showSection(sectionId);
+ });
+ });
+
+ // Handle window resize
+ function handleResize() {
+ if (window.innerWidth >= 768) {
+ sidebar.classList.remove('-translate-x-full');
+ sidebarOverlay.classList.add('hidden');
+ document.body.classList.remove('overflow-hidden');
+ }
+ }
+
+ window.addEventListener('resize', handleResize);
+ handleResize();
+});
+
// Logout functionality
document.getElementById('logoutBtn').addEventListener('click', function() {
localStorage.removeItem('token');