See the route: open the valley on that dragon's most probable route
In-page links now keep their sub-path (#valley/blue) when switching tabs, and a link to a dragon opens it fresh on its most probable route (earlier detours cleared). Clicking the Valley tab itself keeps the current selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2eace69d7d
commit
790b7e6f5e
@@ -467,8 +467,14 @@
|
||||
if (parts[0] !== "valley") return;
|
||||
const c = parts[1] ? COLOURS.find((x) => x.toLowerCase() === parts[1].toLowerCase()) : null;
|
||||
const enc = parts[2] && c && S.ENCOUNTERS[c].includes(parts[2]) ? parts[2] : null;
|
||||
// plain "#valley" (e.g. the tab itself) keeps whatever the reader was looking at
|
||||
if (!c) { writeHash(); return; }
|
||||
if (!st.policy) { st.pendingHash = { c, enc }; return; }
|
||||
if (c !== st.colour || (enc && enc !== st.focus)) { st.colour = c; st.focus = enc; st.expanded = null; render(); }
|
||||
// a link to a dragon opens its most probable route, fresh: no earlier detours, nothing expanded
|
||||
st.colour = c; st.focus = enc; st.expanded = null; st.info = null;
|
||||
delete st.over[enc || ""];
|
||||
S.ENCOUNTERS[c].forEach((e) => delete st.over[e]);
|
||||
render();
|
||||
}
|
||||
|
||||
/* ---------- render ---------- */
|
||||
|
||||
+8
-1
@@ -60,7 +60,14 @@
|
||||
const a = e.target.closest('a[href^="#"]');
|
||||
if (!a) return;
|
||||
const id = a.getAttribute("href").slice(1);
|
||||
if (tabOf(id)) { e.preventDefault(); showTab(tabOf(id)); return; }
|
||||
if (tabOf(id)) {
|
||||
// keep sub-paths such as #valley/blue so the destination can open on that selection
|
||||
e.preventDefault();
|
||||
try { history.replaceState(null, "", "#" + id); } catch (err) { /* ignore */ }
|
||||
showTab(tabOf(id), false, true);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
return;
|
||||
}
|
||||
const target = document.getElementById(id);
|
||||
const panel = target && target.closest(".tabpanel");
|
||||
if (panel && panel.hidden) { e.preventDefault(); showTab(panel.id.replace("panel-", "")); target.scrollIntoView({ behavior: "smooth" }); }
|
||||
|
||||
Reference in New Issue
Block a user