feat: add help page and polish UI details

Add a searchable ? help page, hide HLTB retry after success, scroll the whole game modal with a capped addons block, and give the friend comparison more height.
This commit is contained in:
strsv committed 2026-11-07 05:43:24 +03:00
1 parent eb7ce10f82
commit 4428d86f91
4 files changed
+341 -8

No files matched your search

+51 -3
View File
@@ -1954,6 +1954,50 @@ function debounce(fn, ms) {
};
}
let helpLoaded = false;
async function loadHelp() {
if (helpLoaded) return;
const content = $("#helpContent");
try {
const response = await fetch("/static/help.html");
if (!response.ok) throw new Error(`HTTP ${response.status}`);
content.innerHTML = await response.text();
helpLoaded = true;
buildHelpToc();
} catch (err) {
content.innerHTML = `<p class="muted">Не удалось загрузить справку: ${esc(err.message)}</p>`;
}
}
function buildHelpToc() {
const toc = $("#helpToc");
const sections = [...document.querySelectorAll("#helpContent .help-section")];
toc.innerHTML = sections.map((section) => {
const title = section.querySelector("h2")?.textContent || section.id;
return `<a href="#${section.id}" data-target="${section.id}">${esc(title)}</a>`;
}).join("");
toc.querySelectorAll("a").forEach((link) => {
link.addEventListener("click", (event) => {
event.preventDefault();
const target = document.getElementById(link.dataset.target);
if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
});
});
}
$("#helpSearch").addEventListener("input", debounce(() => {
const query = $("#helpSearch").value.trim().toLowerCase();
document.querySelectorAll("#helpContent .help-section").forEach((section) => {
const match = !query || section.textContent.toLowerCase().includes(query);
section.classList.toggle("hidden", !match);
});
document.querySelectorAll("#helpToc a").forEach((link) => {
const target = document.getElementById(link.dataset.target);
link.classList.toggle("hidden", !!(target && target.classList.contains("hidden")));
});
}, 150));
function switchView(view) {
state.view = view;
document.documentElement.dataset.view = view;
@@ -1969,8 +2013,10 @@ function switchView(view) {
$("#hltbView").classList.toggle("hidden", view !== "hltb");
$("#friendsView").classList.toggle("hidden", view !== "friends");
$("#servicesView").classList.toggle("hidden", view !== "services");
$("#helpView").classList.toggle("hidden", view !== "help");
if (view === "hltb") loadHltb(true);
if (view === "friends") loadFriends();
if (view === "help") loadHelp();
try {
const url = new URL(location.href);
if (view === "library") {
@@ -2301,7 +2347,7 @@ async function pollJob(silent = false) {
clearTimeout(jobTimer);
jobTimer = setTimeout(pollJob, 1500);
} else if (st.finished_at) {
$(context.retry).hidden = !st.name;
$(context.retry).hidden = !(st.cancelled || st.exit_code !== 0);
$(context.bar).style.width = st.exit_code === 0 ? "100%" : "0%";
const text = st.cancelled ? "отменено"
: st.exit_code === 0 ? "готово" : `ошибка (код ${st.exit_code})`;
@@ -2472,8 +2518,8 @@ document.addEventListener("keydown", (e) => {
themeToggle.click();
} else if (e.key === "?") {
e.preventDefault();
toast("Клавиши: / поиск · f фильтры · g вид · t тема · Esc закрыть");
}
switchView("help");
}
});
/* ---------- boot ---------- */
@@ -2511,6 +2557,8 @@ if ("serviceWorker" in navigator) {
if (params.get("friend")) openFriendCompare(params.get("friend"));
} else if (params.get("view") === "services") {
switchView("services");
} else if (params.get("view") === "help") {
switchView("help");
}
await loadGames(true);
if (params.get("game")) openGame(params.get("game"));