This commit is contained in:
1 parent
b65c8c39fe
commit
b2ab347129
18 files changed
+166
-25
No files matched your search
+12
-1
@@ -15,7 +15,8 @@ const LAYOUT_KEY = "sb.layout";
|
||||
function defaultFilters() {
|
||||
return {
|
||||
status: "", genres: [], tags: [], installed: false, unplayed: false, favorite: false,
|
||||
minHours: "", maxHours: "", minYear: "", maxYear: "", minReview: "", maxReview: "",
|
||||
duration: "", minHours: "", maxHours: "", minYear: "", maxYear: "",
|
||||
minReview: "", maxReview: "",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -220,6 +221,11 @@ function fmtHours(h) {
|
||||
return `${h >= 100 ? Math.round(h) : h.toFixed(1).replace(".0", "")} ч`;
|
||||
}
|
||||
|
||||
function fmtDuration(h) {
|
||||
if (!h) return "";
|
||||
return `≈${h >= 10 ? Math.round(h) : h.toFixed(1).replace(".0", "")} ч`;
|
||||
}
|
||||
|
||||
function initials(name) {
|
||||
return name.split(/\s+/).slice(0, 2).map((w) => w[0] || "").join("").toUpperCase();
|
||||
}
|
||||
@@ -241,6 +247,7 @@ function cardHtml(g, mode = "library") {
|
||||
const meta = [
|
||||
g.year ? esc(g.year) : null,
|
||||
mode === "library" ? fmtHours(g.hours) : null,
|
||||
g.duration ? `<span title="оценка по тегам">${fmtDuration(g.duration)}</span>` : null,
|
||||
g.rating ? `${g.rating}/10` : null,
|
||||
].filter(Boolean).map((x) => `<span>${x}</span>`).join('<span class="dot"></span>');
|
||||
const desc = g.description
|
||||
@@ -477,6 +484,7 @@ function syncFilterControls() {
|
||||
$("#search").value = state.q;
|
||||
$("#sort").value = state.sort;
|
||||
$("#fStatus").value = state.filters.status;
|
||||
$("#fDuration").value = state.filters.duration;
|
||||
$("#fInstalled").checked = !!state.filters.installed;
|
||||
$("#fUnplayed").checked = !!state.filters.unplayed;
|
||||
$("#fFavorite").checked = !!state.filters.favorite;
|
||||
@@ -568,6 +576,7 @@ function filterParams() {
|
||||
if (state.filters.installed) p.set("installed", "1");
|
||||
if (state.filters.unplayed) p.set("unplayed", "1");
|
||||
if (state.filters.favorite) p.set("favorite", "1");
|
||||
if (state.filters.duration) p.set("duration", state.filters.duration);
|
||||
[
|
||||
["minHours", "min_hours"], ["maxHours", "max_hours"],
|
||||
["minYear", "min_year"], ["maxYear", "max_year"],
|
||||
@@ -748,6 +757,7 @@ function renderModal(g) {
|
||||
const meta = [
|
||||
g.year ? `<span><b>${esc(g.year)}</b></span>` : "",
|
||||
g.review != null ? `<span><b>${g.review}%</b> отзывов</span>` : "",
|
||||
g.duration ? `<span title="оценка по тегам"><b>${fmtDuration(g.duration)}</b></span>` : "",
|
||||
g.metacritic != null ? `<span>MC <b>${g.metacritic}</b></span>` : "",
|
||||
g.hours ? `<span><b>${fmtHours(g.hours)}</b></span>` : "",
|
||||
g.installed ? `<span class="muted">установлена${g.size_gb ? " · " + g.size_gb + " ГБ" : ""}</span>` : "",
|
||||
@@ -885,6 +895,7 @@ $("#sort").addEventListener("change", (e) => {
|
||||
});
|
||||
|
||||
$("#fStatus").addEventListener("change", (e) => { state.filters.status = e.target.value; loadGames(true); });
|
||||
$("#fDuration").addEventListener("change", (e) => { state.filters.duration = e.target.value; loadGames(true); });
|
||||
let rangeTimer = null;
|
||||
document.querySelectorAll("[data-filter]").forEach((input) => {
|
||||
input.addEventListener("input", (e) => {
|
||||
|
||||
Reference in new issue
Block a user