Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 0 additions & 86 deletions .github/docs/nav-state.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/zensical.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Navigation behavior is injected centrally by Process-PSModule Build-Site.
[project]
site_name = "-{{ REPO_NAME }}-"
repo_name = "-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-"
repo_url = "https://github.com/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-"
extra_javascript = ["https://cdn.jsdelivr.net/gh/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}-@main/.github/docs/nav-state.js"]

[project.theme]
language = "en"
Expand Down
87 changes: 0 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,6 @@
display: none !important;
}
</style>
<!-- Navigation behavior update marker -->
<script>
(() => {
const storageKey = "zensical-nav-state-v1";
let lastSignature = "";

const getToggles = () =>
Array.from(document.querySelectorAll("input.md-nav__toggle.md-toggle[id]"));

const getPrimaryList = () =>
document.querySelector("nav.md-nav--primary > ul.md-nav__list");

const applyDefaultTopLevelState = (toggles) => {
const primaryList = getPrimaryList();
if (!primaryList) {
return;
}

const topLevelToggles = Array.from(
primaryList.querySelectorAll(":scope > li > input.md-nav__toggle.md-toggle[id]")
);
const topLevelIds = new Set(topLevelToggles.map((toggle) => toggle.id));

for (const toggle of toggles) {
toggle.checked = topLevelIds.has(toggle.id);
}
};

const restoreState = (toggles) => {
const raw = localStorage.getItem(storageKey);
if (!raw) {
applyDefaultTopLevelState(toggles);
return;
}

try {
const state = JSON.parse(raw);
for (const toggle of toggles) {
if (Object.prototype.hasOwnProperty.call(state, toggle.id)) {
toggle.checked = !!state[toggle.id];
}
}
} catch {
applyDefaultTopLevelState(toggles);
}
};

const persistState = (toggles) => {
const state = {};
for (const toggle of toggles) {
state[toggle.id] = !!toggle.checked;
}
localStorage.setItem(storageKey, JSON.stringify(state));
};

const initialize = () => {
const toggles = getToggles();
if (toggles.length === 0) {
return;
}

const signature = toggles.map((toggle) => toggle.id).join("|");
if (signature === lastSignature) {
return;
}

lastSignature = signature;
restoreState(toggles);
for (const toggle of toggles) {
if (toggle.dataset.navStateBound === "true") {
continue;
}

toggle.dataset.navStateBound = "true";
toggle.addEventListener("change", () => persistState(getToggles()));
}
};

if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initialize, { once: true });
} else {
initialize();
}

setInterval(initialize, 500);
})();
</script>

{{ DESCRIPTION }}

Expand Down