|
11 | 11 | const STAMPS = [ |
12 | 12 | { id: "first_open", group: "learn", kind: "auto", mark: "첫", name: "첫 걸음", how: "커리큘럼에서 자료 하나를 열어 보세요.", href: "/#curriculum" }, |
13 | 13 | { id: "post", group: "learn", kind: "auto", mark: "글", name: "연재 독자", how: "연재 글을 하나 읽어 보세요.", href: "/#posts" }, |
| 14 | + { id: "webbook", group: "learn", kind: "auto", mark: "책", name: "웹북 독자", how: "웹북 『Python으로 하는 인과추론』에서 한 장을 끝까지 읽어 보세요.", href: "/Causal-Inference-with-Python/" }, |
14 | 15 | { id: "builder", group: "learn", kind: "auto", mark: "B", name: "Builder 탐방", how: "Builder 세 명의 이력이나 페이지를 열어 보세요.", href: "/#contrib" }, |
15 | 16 | { id: "comment", group: "together", kind: "self", mark: "말", name: "레포에 한마디", how: "관심 있는 레포에 질문이나 응원을 남겨 보세요.", go: `${REPO}/discussions`, goLabel: "토론 게시판" }, |
16 | 17 | { id: "event_photo", group: "together", kind: "self", mark: "찰", name: "행사 사진 후기", how: "Data Forum 같은 팀 행사 사진과 한 줄 후기를 올려 보세요.", go: `${REPO}/discussions/new/choose`, goLabel: "후기 올리기" }, |
|
121 | 122 | if (toastEl && dlg && toastEl.parentNode !== dlg) dlg.appendChild(toastEl); |
122 | 123 | } |
123 | 124 | }); |
| 125 | + /* #passport (the web book links here) opens the passport */ |
| 126 | + function openFromHash() { |
| 127 | + if (location.hash !== "#passport") return; |
| 128 | + history.replaceState(history.state, "", location.pathname + location.search); |
| 129 | + passportDialog("link"); |
| 130 | + const dlg = document.getElementById("passport-dialog"); |
| 131 | + if (toastEl && dlg && toastEl.parentNode && toastEl.parentNode !== dlg) dlg.appendChild(toastEl); |
| 132 | + } |
| 133 | + window.addEventListener("hashchange", openFromHash); |
124 | 134 | document.addEventListener("DOMContentLoaded", () => { |
125 | 135 | paintCounts(); |
126 | 136 | /* a Builder page view counts toward the Builder stamp */ |
127 | 137 | const m = location.pathname.match(/^\/builders\/([^/]+)\.html$/); |
128 | 138 | if (m) window.hubSeen("builders", m[1], 3, "builder"); |
| 139 | + /* the web book (same origin) keeps finished chapters in cil-book-read: one is enough for the stamp */ |
| 140 | + try { |
| 141 | + const read = JSON.parse(localStorage.getItem("cil-book-read") || "{}"); |
| 142 | + if (read && typeof read === "object" && Object.keys(read).length) window.hubStamp("webbook"); |
| 143 | + } catch (e) { /* storage unavailable */ } |
| 144 | + openFromHash(); |
129 | 145 | }); |
130 | 146 | })(); |
0 commit comments