Skip to content

Commit f96eb18

Browse files
authored
Update index.html
1 parent ab5d86a commit f96eb18

1 file changed

Lines changed: 35 additions & 13 deletions

File tree

index.html

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@
545545

546546
<!-- Navigation -->
547547
<nav class="navbar">
548-
<a class="nav-link active" onclick="router('home')">Home</a>
549-
<a class="nav-link" onclick="router('staff')">Staff</a>
548+
<a class="nav-link active" href="#home">Home</a>
549+
<a class="nav-link" href="#staff">Staff</a>
550550
<a class="nav-link" href="https://discord.com/invite/userpfp-1129784704267210844" target="_blank">Discord</a>
551551
</nav>
552552

@@ -596,31 +596,48 @@ <h3 id="modalTitle" style="margin-top:0; font-size: 1.5rem; margin-bottom: 0.5re
596596
</div>
597597

598598
<script>
599-
// --- Router Logic ---
600-
function router(viewName) {
599+
// --- Redirection Logic ---
600+
// Instantly redirect if user is on /website/ path (legacy support)
601+
if (window.location.pathname.includes('/website')) {
602+
const newPath = window.location.pathname.replace('/website', '');
603+
window.location.replace(newPath + window.location.hash);
604+
}
605+
606+
// --- Routing Logic ---
607+
function handleRoute() {
608+
// Get hash or default to 'home'
609+
let viewName = window.location.hash.replace('#', '') || 'home';
610+
611+
// Valid routes check (optional, but good for safety)
612+
if (!['home', 'staff'].includes(viewName)) {
613+
viewName = 'home';
614+
}
615+
601616
// Update Nav
602617
document.querySelectorAll('.nav-link').forEach(link => {
603618
link.classList.remove('active');
604-
if(link.innerText.toLowerCase() === viewName) link.classList.add('active');
619+
if (link.getAttribute('href') === `#${viewName}`) link.classList.add('active');
605620
});
606621

607-
// Update View
622+
// Update View visibility
608623
document.querySelectorAll('.view-container').forEach(view => {
609624
view.classList.remove('active');
610625
});
611-
document.getElementById(`${viewName}-view`).classList.add('active');
626+
const activeView = document.getElementById(`${viewName}-view`);
627+
if (activeView) activeView.classList.add('active');
612628

613-
// Handle background visibility
629+
// Handle background & Lazy Loading
614630
const bgContainer = document.getElementById('pfp-bg-container');
615631
if (viewName === 'home') {
616-
bgContainer.style.display = 'block';
617-
// Lazy load PFPs if not loaded yet
632+
if (bgContainer) bgContainer.style.display = 'block';
618633
if (!window.pfpsLoaded) loadPfps();
619634
} else {
620-
bgContainer.style.display = 'none';
621-
// Lazy load Staff if not loaded yet
635+
if (bgContainer) bgContainer.style.display = 'none';
622636
if (!window.staffLoaded && viewName === 'staff') loadStaff();
623637
}
638+
639+
// Scroll to top
640+
window.scrollTo(0, 0);
624641
}
625642

626643
// --- Home Logic (PFP Columns & Mods) ---
@@ -900,12 +917,17 @@ <h3 id="modalTitle" style="margin-top:0; font-size: 1.5rem; margin-bottom: 0.5re
900917
// Initialize
901918
document.addEventListener('DOMContentLoaded', () => {
902919
initMods();
903-
router('home');
920+
921+
// Initial routing
922+
handleRoute();
904923

905924
// Close modal when clicking outside
906925
document.getElementById('infoModal').addEventListener('click', (e) => {
907926
if(e.target === document.getElementById('infoModal')) closeModal();
908927
});
928+
929+
// Listen for hash changes
930+
window.addEventListener('hashchange', handleRoute);
909931
});
910932

911933
</script>

0 commit comments

Comments
 (0)