diff options
Diffstat (limited to 'src/components/ScheduleInteractive.astro')
| -rw-r--r-- | src/components/ScheduleInteractive.astro | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro index 58574ce..6bcbb1c 100644 --- a/src/components/ScheduleInteractive.astro +++ b/src/components/ScheduleInteractive.astro @@ -15,6 +15,10 @@ const COUNCIL_KEY = 'council'; const isCouncil = (e: { type: string; name: string }) => e.type === 'meeting' && e.name.includes('小平市議会'); + // 図書館のイベントは出典に図書館のページ(info.html?id=…)のリンクが入っている。 + const LIBRARY_KEY = 'library'; + const isLibrary = (e: { source?: string }) => + (e.source ?? '').includes('library.kodaira.ed.jp/viewer/info.html'); const WEEKDAYS = ['日', '月', '火', '水', '木', '金', '土']; const WEEKDAY_MAP = { 日: 0, 月: 1, 火: 2, 水: 3, 木: 4, 金: 5, 土: 6 }; @@ -150,6 +154,8 @@ const dateText = cells[0].textContent.trim(); const name = cells[1].textContent.trim(); const timeText = cells[2].textContent.trim(); + // 出典欄はリンク先URLで判定するため、HTML を保持する(textContent には href が入らない)。 + const source = cells[4] ? cells[4].innerHTML : ''; const rowId = `${type}-row-${i}`; row.id = rowId; @@ -186,6 +192,7 @@ categoryLabel, rowId, dateText, + source, }); }); } @@ -247,6 +254,7 @@ function matchesCategory(e) { if (activeCategory === 'all') return true; if (activeCategory === COUNCIL_KEY) return isCouncil(e); + if (activeCategory === LIBRARY_KEY) return isLibrary(e); // 「審議会等」は市議会を除く(市議会は別のボタンで絞り込む)。 if (activeCategory === MEETING_ICON) return e.type === 'meeting' && !isCouncil(e); return e.category === activeCategory; @@ -325,6 +333,11 @@ ).join('')} ${cells.join('')} </div> + <p class="schedule-cal-filter-note">${ + activeCategory === 'all' + ? '絞り込みなし(すべての予定を表示)' + : `絞り込み中:${filterLabel()}` + }</p> `; calendarEl.querySelectorAll('.schedule-cal-day[data-date]').forEach((btn) => { @@ -407,11 +420,20 @@ function categoryLabel(category) { if (category === COUNCIL_KEY) return '市議会'; + if (category === LIBRARY_KEY) return '図書館'; if (category === MEETING_ICON) return '審議会等'; const def = CATEGORY_DEFS.find((c) => c.icon === category); return def ? def.label : '交流・地域'; } + // 「🏛️ 市議会」「📖 図書館」のように、アイコン付きで現在の絞り込みを表す + function filterLabel() { + if (activeCategory === COUNCIL_KEY) return `${MEETING_ICON} 市議会`; + if (activeCategory === LIBRARY_KEY) return '📖 図書館'; + if (activeCategory === MEETING_ICON) return `${MEETING_ICON} 審議会等`; + return `${activeCategory} ${categoryLabel(activeCategory)}`; + } + function ensureStatus(container, type) { const id = `${type}-filter-status`; let status = document.getElementById(id); @@ -434,7 +456,7 @@ const filtered = activeCategory !== 'all'; status.classList.toggle('is-filtered', filtered); const text = filtered - ? `${tableLabel}:「${activeCategory === COUNCIL_KEY ? categoryLabel(activeCategory) : `${activeCategory} ${categoryLabel(activeCategory)}`}」で絞り込み中:${visible}件/全${total}件` + ? `${tableLabel}:「${filterLabel()}」で絞り込み中:${visible}件/全${total}件` : `${tableLabel}:全${total}件を表示しています(絞り込みなし)`; status.innerHTML = `<span class="schedule-table-status-text">${text}</span>`; if (filtered) { @@ -512,6 +534,12 @@ label: '審議会等', count: meetingEntries.length, }, + { + category: LIBRARY_KEY, + icon: '📖', + label: '図書館', + count: entries.filter(isLibrary).length, + }, ...CATEGORY_DEFS.map((c) => ({ category: c.icon, icon: c.icon, |
