aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-07 12:29:10 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-07 12:29:10 +0900
commit5c56c4f74225ef9f8a5e992228cdab17eb029bea (patch)
treeb0a27be02e3fdc8b3d90ac9bc3fb7c13fb5cded7 /src
parent919976ee778a1898816dc0df21cd25d5e2cdaf87 (diff)
events: 行のアンカーIDを日付と名称から作るよう変更
行番号から作っていたため、予定を追加すると共有リンクが別の予定を 指していた。日付と名称のハッシュに変え、追加しても変わらないように した。
Diffstat (limited to 'src')
-rw-r--r--src/components/ScheduleInteractive.astro14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro
index 19a3f59..4c31d99 100644
--- a/src/components/ScheduleInteractive.astro
+++ b/src/components/ScheduleInteractive.astro
@@ -26,6 +26,16 @@
const escapeHtml = (s) =>
s.replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
+ // 行番号ではなく、日付と名称からアンカーIDを作る(予定を追加してもリンクが変わらないように)。
+ function stableId(input: string): string {
+ let hash = 2166136261;
+ for (let i = 0; i < input.length; i++) {
+ hash ^= input.charCodeAt(i);
+ hash = Math.imul(hash, 16777619);
+ }
+ return (hash >>> 0).toString(36);
+ }
+
function initSchedule() {
const calendarEl = document.getElementById('schedule-calendar');
const detailsEl = document.getElementById('schedule-day-details');
@@ -39,7 +49,7 @@
const entries = [];
function collect(table, type) {
- table.querySelectorAll('tbody tr').forEach((row, i) => {
+ table.querySelectorAll('tbody tr').forEach((row) => {
const cells = row.querySelectorAll('td');
if (cells.length < 3) return;
const dateText = cells[0].textContent.trim();
@@ -47,7 +57,7 @@
const timeText = cells[2].textContent.trim();
// 出典欄はリンク先URLで判定するため、HTML を保持する(textContent には href が入らない)。
const source = cells[4] ? cells[4].innerHTML : '';
- const rowId = `${type}-row-${i}`;
+ const rowId = `${type}-${stableId(`${dateText}|${name}`)}`;
row.id = rowId;
let category = MEETING_ICON;