mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-26 07:51:34 +00:00
feat(dashboard): change pages without reloading the dashboard
nav.js (loaded on every signed-in page) follows links and GET forms to other dashboard pages by fetching the page and swapping in its <main>, title, page styles and page scripts; the sidebar, top bar and live WebSocket stay. History entries, back/forward (with scroll positions, also kept for a reload), deep links, #hash filters and breadcrumbs keep working. What the old page set up is taken down first: its document/window listeners, setInterval timers, Live watchers and topics, DataTables, dialogs and what it appended to <body>. Page scripts run again in order; DOMContentLoaded/load handlers they add run once they have all run. A thin bar shows while loading; a failed fetch shows an inline error with Try again / Open it normally. Falls back to a normal load for anything that isn't a signed-in dashboard page, when the account or permissions changed, and for pages with module scripts or an import map (World 3D, property view and 3D, UGC server) or data-nav="reload", and when leaving those. Unsaved-change prompts (beforeunload) are asked before swapping. Check: click around the sidebar and into accounts/characters: no white flash, the footer's live indicator stays "live", back/forward return to the same scroll position, breadcrumbs follow the path (Accounts > an account > a character). Activity Log links with #search= still filter. System Log's server picker works. Leaving Settings with a change asks first. World 3D and a property's 3D view still load (normally). Pages that poll (Server Health, Instance Load) stop polling once left (browser network tab). Test: NavRulesJs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,10 @@
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
|
||||
<link href="https://cdn.datatables.net/v/bs5/jq-3.7.0/dt-2.3.7/b-3.2.6/fh-4.0.6/sc-2.4.3/datatables.min.css" rel="stylesheet" integrity="sha384-XMNDGLb5fN9IqhIrVXOAtGKcz4KCr+JSHXGZ1TDXQPDukbEAfmLPjHdCXhgK93fv" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="/css/dashboard.css">
|
||||
{# A page's own styles: nav.js swaps what is between these two when it changes pages without a reload #}
|
||||
<meta name="page-head-start">
|
||||
{% block css %}{% endblock %}
|
||||
<meta name="page-head-end">
|
||||
</head>
|
||||
<body data-username="{{ username }}" data-gm-level="{{ gmLevel }}" data-account-id="{{ accountId }}" data-prefs="{{ prefs }}" data-labels="{{ labelsJson }}" data-can="{% for key, allowed in can %}{% if allowed %}{{ key }} {% endif %}{% endfor %}">
|
||||
{% if username and username != "" %}
|
||||
@@ -37,7 +40,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</header>
|
||||
<main class="flex-grow-1 p-2 p-sm-3 p-lg-4">
|
||||
<main class="flex-grow-1 p-2 p-sm-3 p-lg-4" tabindex="-1">
|
||||
{% else if exists("public_page") %}
|
||||
{# Pages open to visitors who aren't signed in (public_page: {name, status, showcase}) show their normal content under a small top bar #}
|
||||
<div class="d-flex flex-column min-vh-100">
|
||||
@@ -67,8 +70,12 @@
|
||||
<script src="/js/dashboard.js"></script>
|
||||
<script src="/js/decide.js"></script>
|
||||
<script src="/js/ai-suggest.js"></script>
|
||||
<script src="/js/nav.js"></script>
|
||||
{% endif %}
|
||||
|
||||
{# The page's own scripts: nav.js runs these again when it swaps a page in #}
|
||||
<div id="page-scripts" hidden>
|
||||
{% block scripts %}{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user