fix: clean up duplicate code and implement URL hash navigation

- Remove duplicate </style></head><body> tags
- Remove duplicate script tags and incomplete JavaScript
- Add URL hash handling (e.g., /admin#dashboard, /admin#properties)
- Add hashchange event listener for browser back/forward navigation
- Simplify navigation by updating hash instead of directly calling loadSection

Fixes issue where URL didn't change when navigating between admin sections.
This commit is contained in:
TenerifeProp Dev
2026-04-07 06:54:23 +01:00
parent b7f88b7c35
commit 072fc62cba

View File

@@ -1164,9 +1164,6 @@
}
</style>
</head>
<body>
</style>
</head>
<body>
<!-- ============ SIDEBAR ============ -->
<aside class="sidebar" id="sidebar">
@@ -1438,25 +1435,6 @@
<script src="https://cdn.jsdelivr.net/npm/moment@2.30.1/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lightpick@1.6.2/lightpick.min.js"></script>
<script>
// ============ SIDEBAR NAVIGATION ============
$(document).ready(function() {
// Navigation
$('.sidebar-link, .quick-action').on('click', function(e) {
e.preventDefault();
const section = $(this).data('section');
// Update sidebar active
$('.sidebar-link').removeClass('active');
$(`.sidebar-link[data-section="${section}"]`).addClass('active');
// Show section
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/datatables.net@1.13.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/datatables.net-bs5@1.13.8/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script>
// Dynamic section loader
const sections = {
@@ -1513,8 +1491,21 @@
}
$(document).ready(function() {
// Load dashboard on start
loadSection('dashboard');
// Handle browser back/forward navigation
function handleHashChange() {
const hash = window.location.hash.slice(1) || 'dashboard';
if (sections[hash]) {
$('.sidebar-link').removeClass('active');
$(`.sidebar-link[data-section="${hash}"]`).addClass('active');
loadSection(hash);
}
}
// Initial load based on URL hash
handleHashChange();
// Listen for hash changes (browser back/forward)
$(window).on('hashchange', handleHashChange);
// Sidebar navigation
$('.sidebar-link').on('click', function(e) {
@@ -1522,10 +1513,8 @@
const section = $(this).data('section');
if (!section) return;
$('.sidebar-link').removeClass('active');
$(this).addClass('active');
loadSection(section);
window.scrollTo(0, 0);
// Update URL hash
window.location.hash = section;
});
// Quick actions