|
284 | 284 | : t.key === "stars" ? topStarsHTML() : `<p class="spark-empty">${esc(t.empty || "")}</p>`} |
285 | 285 | </li>`; |
286 | 286 | }).join(""); |
| 287 | + const ev = box.querySelector('.tile[data-key="events"]'); |
| 288 | + if (ev) ev.insertAdjacentHTML("beforeend", `<a class="tile-link" href="#events" aria-label="행사 보기"></a>`); |
287 | 289 | box.querySelectorAll(".tile").forEach((el, i) => { |
288 | 290 | const t = growthTiles[i]; |
289 | 291 | if (t.series.length > 1) drawSpark(el, t); |
|
711 | 713 | }).join(""); |
712 | 714 | } |
713 | 715 |
|
| 716 | + /* the legend doubles as a filter: pick a track to keep only its line */ |
714 | 717 | function renderLegend() { |
715 | | - $("#line-legend").innerHTML = state.lineList.map((l) => `<li data-line="${l.id}"><span class="num" aria-hidden="true"></span>${esc(l.name)}</li>`).join("") + |
| 718 | + const count = (id) => [...state.repos.values()].filter((r) => (r.lines || []).includes(id)).length; |
| 719 | + $("#line-legend").innerHTML = state.lineList.map((l) => `<li data-line="${l.id}"><button type="button" class="ll" data-focus-line="${l.id}" aria-pressed="false" title="${esc(l.description || "")}"><span class="num" aria-hidden="true"></span>${esc(l.name)}<span class="ll-n">${count(l.id)}</span></button></li>`).join("") + |
716 | 720 | `<li><svg width="28" height="6" aria-hidden="true"><path d="M2 3H26" stroke="var(--l-main)" stroke-width="3" stroke-dasharray="5 6" stroke-linecap="round"/></svg>도서·강의 (유료)</li>`; |
| 721 | + if (!$("#line-desc")) $("#line-legend").insertAdjacentHTML("afterend", `<p class="line-desc" id="line-desc" aria-live="polite"></p>`); |
| 722 | + } |
| 723 | + function focusLine(id) { |
| 724 | + const root = $("#metro"), on = id && state.focusLine !== id ? id : null; |
| 725 | + state.focusLine = on; |
| 726 | + root.classList.toggle("focusing", !!on); |
| 727 | + root.querySelectorAll(".track, .badge").forEach((el) => el.classList.toggle("faded", !!on && el.dataset.line !== on)); |
| 728 | + root.querySelectorAll(".st").forEach((el) => el.classList.toggle("faded", !!on && !(el.dataset.lines || "").split(" ").includes(on))); |
| 729 | + document.querySelectorAll("[data-focus-line]").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.focusLine === on))); |
| 730 | + document.querySelectorAll(".vline").forEach((v) => v.classList.toggle("faded", !!on && v.dataset.line !== on)); |
| 731 | + const l = on && state.lines.get(on); |
| 732 | + $("#line-desc").innerHTML = l ? `<b>${esc(l.name)}</b>: ${esc(l.description || l.tagline || "")} <button type="button" class="link-btn" data-focus-line="${on}">전체 노선 보기</button>` : ""; |
| 733 | + if (on) track("select_track", { track: on }); |
717 | 734 | } |
718 | 735 |
|
719 | 736 | /* ---------- tabs ---------- */ |
|
811 | 828 | } |
812 | 829 | } |
813 | 830 |
|
| 831 | + const daysTo = (iso) => Math.ceil((Date.parse(`${iso}T00:00:00+09:00`) - Date.now()) / DAY); |
| 832 | + function renderNextEvent() { |
| 833 | + const el = $("#next-event"), next = state.events.find((e) => e.upcoming && e.date); |
| 834 | + if (!el || !next) return; |
| 835 | + const d = daysTo(next.date); |
| 836 | + if (d < 0) return; |
| 837 | + el.hidden = false; |
| 838 | + el.innerHTML = `<span class="ne-k">다음 행사</span><span class="ne-d">${d === 0 ? "오늘" : `D-${d}`}</span><span class="ne-t"><b>${dot(next.date)} · ${esc(next.name)}</b><span>${next.link ? "참가 신청을 받고 있습니다" : "신청 링크는 곧 열립니다"} · 지난 ${state.events.filter((e) => !e.upcoming).length}회에 ${fmt(state.events.reduce((s, e) => s + (e.participants || 0), 0))}명이 함께했습니다</span></span><span class="ne-go" aria-hidden="true">›</span>`; |
| 839 | + } |
814 | 840 | /* the next Data Forum gets the space; past ones are one line each */ |
815 | 841 | function renderEvents() { |
816 | 842 | const list = [...state.events].sort((a, b) => b.order - a.order); |
817 | 843 | const next = list.find((e) => e.upcoming), past = list.filter((e) => !e.upcoming); |
818 | 844 | const when = (e) => (e.date ? dot(e.date) : `${e.year}년`); |
819 | 845 | const total = past.reduce((s, e) => s + (e.participants || 0), 0); |
| 846 | + const maxP = Math.max(1, ...past.map((e) => e.participants || 0)); |
| 847 | + const dd = next && next.date ? daysTo(next.date) : null; |
820 | 848 | const nextHTML = next ? `<li class="event next"> |
821 | | - <span class="soon-tag">다음 행사</span> |
| 849 | + <span class="soon-tag">다음 행사${dd != null && dd >= 0 ? ` · ${dd === 0 ? "오늘" : `D-${dd}`}` : ""}</span> |
822 | 850 | <span class="ord">${next.order}회</span> |
823 | 851 | <h3>${next.link ? `<a href="${esc(next.link)}" target="_blank" rel="noopener">${esc(next.name)}</a>` : esc(next.name)}</h3> |
824 | 852 | <span class="when">${when(next)}</span> |
| 853 | + <p class="ev-about">현업과 학계가 만나 인과추론과 실험, 데이터 의사결정을 이야기하는 자리입니다. 지난 ${past.length}회에 ${fmt(total)}명이 함께했습니다.</p> |
825 | 854 | ${next.link ? `<a class="btn sm" href="${esc(next.link)}" target="_blank" rel="noopener">참가 신청하기</a>` : `<span class="ppl">신청 링크는 곧 열립니다.</span>`} |
826 | 855 | </li>` : ""; |
827 | 856 | const pastHTML = past.map((e) => `<li class="event past"> |
828 | 857 | <span class="ord">${e.order}회</span> |
829 | 858 | <span class="ev-name">${e.link ? `<a href="${esc(e.link)}" target="_blank" rel="noopener">${esc(e.name)}</a>` : esc(e.name)}<span class="when">${when(e)}</span></span> |
830 | | - <span class="ev-n">${e.participants ? `<b>${fmt(e.participants)}</b>명` : ""}</span> |
| 859 | + <span class="ev-n">${e.participants ? `<span class="ev-num"><b>${fmt(e.participants)}</b>명</span><i class="ev-bar" aria-hidden="true"><i style="width:${Math.round((e.participants / maxP) * 100)}%"></i></i>` : ""}</span> |
831 | 860 | </li>`).join(""); |
832 | 861 | $("#event-list").innerHTML = nextHTML + (past.length ? `<li class="event-past"><p class="ev-sum">지난 Data Forum ${past.length}회 · 참가 ${fmt(total)}명</p><ol>${pastHTML}</ol></li>` : ""); |
833 | 862 | } |
|
842 | 871 | } |
843 | 872 |
|
844 | 873 | function stationGroup(parent, id, r, cls) { |
845 | | - const g = svg("g", { class: "st" + cls, "data-line": primaryLine(r), "data-st": id, tabindex: 0, role: "button", "aria-label": `${r.title} 열기` }, parent); |
| 874 | + const g = svg("g", { class: "st" + cls, "data-line": primaryLine(r), "data-lines": (r.lines || []).join(" "), "data-st": id, tabindex: 0, role: "button", "aria-label": `${r.title} 열기` }, parent); |
846 | 875 | g.addEventListener("click", () => openStation(id, "map")); |
847 | 876 | g.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); openStation(id, "map"); } }); |
848 | 877 | return g; |
|
1374 | 1403 | if (nl) { closeStation(); gotoLevel(nl.dataset.nextLevel); return; } |
1375 | 1404 | const ext = e.target.closest("a[data-post][target=_blank]"); |
1376 | 1405 | if (ext) stamp("post"); |
| 1406 | + const fl = e.target.closest("[data-focus-line]"); |
| 1407 | + if (fl) { focusLine(fl.dataset.focusLine); return; } |
| 1408 | + const tg = e.target.closest("[data-tab-go]"); |
| 1409 | + if (tg) { selectTab(tg.dataset.tabGo); $("#tab-map").scrollIntoView({ behavior: reduceMotion ? "auto" : "smooth", block: "start" }); track("open_map", { source: "tab_note" }); return; } |
1377 | 1410 | const stepBtn = e.target.closest("[data-step]"); |
1378 | 1411 | if (stepBtn) { |
1379 | 1412 | state.level = stepBtn.dataset.step; |
|
1457 | 1490 | const setHeader = () => { if (header) document.documentElement.style.setProperty("--header-h", `${header.offsetHeight}px`); }; |
1458 | 1491 | setHeader(); window.addEventListener("resize", setHeader); |
1459 | 1492 | renderLegend(); renderMap(); wireTabs(); |
1460 | | - renderFeatured(); renderPartner(); renderEvents(); renderStages(); renderArticles(); renderDaily(); watchMapScroll(); |
| 1493 | + renderFeatured(); renderPartner(); renderEvents(); renderNextEvent(); renderStages(); renderArticles(); renderDaily(); watchMapScroll(); |
1461 | 1494 | /* sections fill in after the data loads, so jump again once they have their height */ |
1462 | 1495 | if (/^#(contrib|events|reading|join)$/.test(location.hash)) requestAnimationFrame(() => { const el = $(location.hash); if (el) el.scrollIntoView(); }); |
1463 | 1496 | openFromHash(); |
|
0 commit comments