diff --git a/src/frontend/static/app.js b/src/frontend/static/app.js index ad2bbd5..28cf9b0 100644 --- a/src/frontend/static/app.js +++ b/src/frontend/static/app.js @@ -436,6 +436,28 @@ function saveRoomsFilter() { localStorage.setItem(ROOMS_FILTER_KEY, JSON.stringify(roomsState.filter)); } +/** «Четверг» -> «четвергам» (для фразы «по четвергам и пятницам»). */ +function weekdayPlural(day) { + if (day.endsWith("ье")) return day.slice(0, -2) + "ьям"; // воскресенье + if (day.endsWith("а")) return day + "м"; // пятница, среда + return day + "ам"; // четверг, вторник +} + +function daysPhrase(days) { + const forms = days.map(weekdayPlural); + if (forms.length === 1) return `по ${forms[0]}`; + return `по ${forms.slice(0, -1).join(", ")} и ${forms[forms.length - 1]}`; +} + +/** Описание из таблицы, если оно не сводится к номеру и дням (иначе не показываем). */ +function roomInfoText(room) { + const info = (room.info || "").trim(); + if (!info) return ""; + let rest = info.replace(/\d+/g, ""); + (room.available_days || []).forEach((day) => { rest = rest.split(day).join(""); }); + return rest.replace(/[\s;,.]+/g, "") ? info : ""; +} + /** Русское склонение существительного при числе. */ function pluralRu(count, one, few, many) { const mod10 = count % 10; @@ -659,11 +681,13 @@ function updateRoomsSummary() { if (roomsState.mode !== "free") { const restricted = all.filter((r) => !roomAvailableOn(r)).length; if (restricted) { - notes.push(`${pluralRu(restricted, "аудитория отмечена", "аудитории отмечены", "аудиторий отмечено")} как доступные только по отдельным дням`); + notes.push(`с ограничением по дням: ${restricted}`); } } if (hint) { - hint.textContent = notes.join(". "); + hint.textContent = notes + .map((text) => text.charAt(0).toUpperCase() + text.slice(1)) + .join(". "); hint.classList.toggle("hidden", !notes.length); } } @@ -701,14 +725,13 @@ function roomsCardHead(room) { const head = document.createElement("div"); head.className = "day-head"; const attrs = roomAttrsText(room); - const restricted = room.available_days && !roomAvailableOn(room); + const info = roomInfoText(room); head.innerHTML = `